index.vue 5.9 KB

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