qADetail.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <view v-if="ifShow" class="qaBox">
  3. <view class="qaTopInfo">
  4. <view class="qaTopInfoBox" @click="goGoodsDetails">
  5. <image :src="detailList.image"></image>
  6. <view class="qaInfoText">
  7. <h3>{{ detailList.productName }}</h3>
  8. <span>共{{ detailList.count }}个问题</span>
  9. </view>
  10. </view>
  11. <view class="qaTitBox">
  12. <view class="qaTit">
  13. <i>问</i>
  14. <h3>{{ detailList.problem }}</h3>
  15. </view>
  16. <view class="qaTitTime">
  17. <img :src="detailList.headImage" />
  18. <span class="qaName">{{ detailList.name }}</span>
  19. <span class="qaTimeInfo">{{ detailList.createTime }}</span>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="answerListBox">
  24. <view class="answerNum">共{{ answerslength }}条回答</view>
  25. <view v-for="item in detailList.answers" :key="item.answerId" class="answerList">
  26. <view class="answerItem">
  27. <view class="itemTit">
  28. <view class="itemAvatarBox">
  29. <img :src="item.headImage" alt="">
  30. <span class="answerName">{{ item.name }}</span>
  31. </view>
  32. <view class="answerTime">{{ item.createTime }}</view>
  33. </view>
  34. <view class="answerInfo">{{ item.answer }}</view>
  35. </view>
  36. </view>
  37. </view>
  38. <view v-if="detailList.ifExhibition == 1" class="pad-bot-100"></view>
  39. <view
  40. v-if="detailList.ifExhibition == 1" class="answerBtn"
  41. :style="{ 'padding-bottom': (isIphone == true ? 50 : 0) + 'rpx' }"
  42. >
  43. <view class="uni-form-item uni-column answerBtnBox">
  44. <input v-model="answerText" class="uni-input" maxlength="200" focus placeholder="被邀请的用户才能回答" />
  45. <view class="answerButton" @click="answer">
  46. 回答
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. const NET = require('../../utils/request')
  54. const API = require('../../config/api')
  55. import QuestionsAndAnswersList from './components/QuestionsAndAnswersList'
  56. export default {
  57. name: 'QADetail',
  58. components: { QuestionsAndAnswersList },
  59. data() {
  60. return {
  61. detailList: {}, // 商品问答详情
  62. productId: '',
  63. images: '',
  64. productName: '',
  65. problemsData: {},
  66. answerText: '',
  67. answerslength: 0,
  68. num: 0,
  69. isIphone: false,
  70. ifShow: false
  71. }
  72. },
  73. onLoad(options) {
  74. this.isIphone = getApp().globalData.isIphone
  75. this.problemsData = this.$getJumpParam(options)
  76. this.getProblems()
  77. },
  78. methods: {
  79. goGoodsDetails() {
  80. const shopId = this.detailList.shopId
  81. const productId = this.detailList.productId
  82. const skuId = this.detailList.skuId
  83. uni.navigateTo({
  84. url: 'goodsDetails?shopId=' + shopId + '&productId=' + productId + '&skuId=' + skuId
  85. })
  86. },
  87. // 商品问答数据
  88. getProblems() {
  89. NET.request(API.getProblemDetail, {
  90. problemId: this.problemsData.problemId,
  91. productId: this.problemsData.productId
  92. }, 'GET').then((res) => {
  93. this.detailList = res.data
  94. this.ifShow = true
  95. this.answerslength = this.detailList.answers.length
  96. uni.removeStorageSync('seeAllFnData')
  97. })
  98. .catch((res) => {
  99. uni.showToast({
  100. title: '失败',
  101. icon: 'none'
  102. })
  103. })
  104. },
  105. // 回答
  106. answer() {
  107. NET.request(API.addAnswer, {
  108. productId: this.problemsData.productId,
  109. answer: this.answerText,
  110. problemId: this.problemsData.problemId
  111. }, 'POST').then((res) => {
  112. this.getProblems()
  113. this.answerText = ''
  114. uni.showToast({
  115. title: '回答成功',
  116. icon: 'success'
  117. })
  118. })
  119. .catch((res) => {
  120. uni.showToast({
  121. title: '失败',
  122. icon: 'none'
  123. })
  124. })
  125. }
  126. }
  127. }
  128. </script>
  129. <style
  130. lang="scss"
  131. scoped
  132. >
  133. .qaBox {
  134. padding: 0 30upx;
  135. .qaTopInfo {
  136. margin-top: 20upx;
  137. .qaTopInfoBox {
  138. border-radius: 10upx;
  139. display: flex;
  140. align-items: center;
  141. padding: 15upx 20upx;
  142. margin-bottom: 55upx;
  143. image {
  144. border: 2px solid #E4E5E6;
  145. width: 120upx;
  146. height: 120upx;
  147. margin-right: 20upx;
  148. }
  149. .qaInfoText {
  150. h3 {
  151. font-size: 30upx;
  152. font-weight: 500;
  153. color: #333333;
  154. margin-bottom: 20rpx;
  155. }
  156. span {
  157. font-size: 24upx;
  158. color: #999999;
  159. }
  160. }
  161. }
  162. .qaTitBox {
  163. padding-bottom: 30upx;
  164. border-bottom: 1upx solid #EEEEEE;
  165. .qaTit {
  166. display: flex;
  167. align-items: center;
  168. margin-bottom: 35upx;
  169. i {
  170. width: 38upx;
  171. height: 38upx;
  172. background: #C83732;
  173. font-style: normal;
  174. text-align: center;
  175. color: #FFFFFF;
  176. font-size: 20upx;
  177. margin-right: 30upx;
  178. }
  179. h3 {
  180. font-size: 28upx;
  181. font-weight: 500;
  182. color: #333333;
  183. }
  184. }
  185. .qaTitTime {
  186. display: flex;
  187. align-items: center;
  188. img {
  189. width: 44upx;
  190. height: 44upx;
  191. margin-right: 20upx;
  192. }
  193. .qaName {
  194. font-size: 28upx;
  195. color: #666666;
  196. margin-right: 35upx;
  197. }
  198. .qaTimeInfo {
  199. color: #CCCCCC;
  200. font-size: 22upx;
  201. }
  202. }
  203. }
  204. }
  205. .answerListBox {
  206. .answerNum {
  207. font-size: 24upx;
  208. color: #CCCCCC;
  209. margin-bottom: 40upx;
  210. margin-top: 30upx;
  211. }
  212. .answerList {
  213. padding-bottom: 50upx;
  214. .answerItem {
  215. margin-bottom: 10upx;
  216. .itemTit {
  217. display: flex;
  218. align-items: center;
  219. justify-content: space-between;
  220. .itemAvatarBox {
  221. display: flex;
  222. img {
  223. width: 46upx;
  224. height: 46upx;
  225. margin-right: 20upx;
  226. }
  227. .answerName {
  228. font-size: 26upx;
  229. color: #333333;
  230. font-weight: bold;
  231. }
  232. }
  233. .answerTime {
  234. color: #CCCCCC;
  235. font-size: 20upx;
  236. }
  237. }
  238. .answerInfo {
  239. color: #333333;
  240. font-size: 28upx;
  241. margin-top: 20upx;
  242. font-weight: 400;
  243. }
  244. }
  245. }
  246. }
  247. .answerBtn {
  248. position: fixed;
  249. width: 100%;
  250. bottom: 0;
  251. left: 0;
  252. .answerBtnBox {
  253. display: flex;
  254. align-items: center;
  255. justify-content: space-between;
  256. width: 100%;
  257. padding: 30upx;
  258. background: #FFFFFF;
  259. input {
  260. margin-right: 30upx;
  261. width: 530upx;
  262. background: #F1F1F1;
  263. min-height: 84upx;
  264. padding-left: 30upx;
  265. font-size: 28upx;
  266. color: #999999;
  267. }
  268. .input-placeholder {
  269. font-size: 24upx;
  270. color: #999999;
  271. }
  272. .answerButton {
  273. width: 152upx;
  274. height: 84upx;
  275. background: #333333;
  276. text-align: center;
  277. line-height: 84upx;
  278. font-size: 30upx;
  279. color: #FFEBC4;
  280. }
  281. }
  282. }
  283. }
  284. </style>