GoodEvaluateAndQuestion.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <template>
  2. <div class="good-evaluate-and-question-container">
  3. <view class="evaQaTab flex-items flex-sp-around">
  4. <view :class="{ active: activeTab === 1 }" class="evaBtn" @click="activeTab = 1">
  5. <view class="tabTit">宝贝评价({{ goodsDetail.comments.length }})</view>
  6. </view>
  7. <view :class="{ active: activeTab === 2 }" class="qaBtn" @click="activeTab = 2">
  8. <view class="tabTit">商品问答({{ problemsTotal }})</view>
  9. </view>
  10. </view>
  11. <!-- 评价 -->
  12. <view class="borRig-line-20"></view>
  13. <view v-show="activeTab === 1" class="evaluate-box flex-start flex-column">
  14. <view v-if="goodsDetail.comments.length > 0" class="evaluateTag-box">
  15. <view class="evaluateTag-text">
  16. 全部({{ goodsDetail.comments.length }})
  17. </view>
  18. </view>
  19. <view
  20. v-for="(commentItem, commentIndex) in goodsDetail.comments.slice(0, 2)" :key="commentIndex"
  21. class="evaluate-contentbox mar-top-30"
  22. >
  23. <view class="evaluate-content flex-items flex-row flex-sp-between">
  24. <view class="flex-items">
  25. <image class="user-headSmallImg" :src="common.seamingImgUrl(commentItem.headImage)"></image>
  26. <label class="fs28 mar-left-20">{{ commentItem.name }}</label>
  27. </view>
  28. <label class="font-color-999 fs22">{{ commentItem.createTime }}</label>
  29. </view>
  30. <view class="evaluateDes-box">
  31. <label class="evaluateDes">{{ commentItem.comment }}</label>
  32. </view>
  33. <view v-if="commentItem.image" class="item-image-box">
  34. <view v-for="(imgItem, imgIndex) in (commentItem.image.split(',') || [])" :key="imgIndex">
  35. <image
  36. class="img-item" :src="common.seamingImgUrl(imgItem)"
  37. @click="handlePreviewImage(goodsDetail.comments[commentIndex].images, imgIndex)"
  38. >
  39. </image>
  40. </view>
  41. </view>
  42. <view class="item-line"></view>
  43. <view v-if="commentItem.addComment !== ''" class="item-like-box">
  44. <view class="addEvaluate">
  45. <view>追加评价:{{ commentItem.addComment }}</view>
  46. <view v-if="commentItem.addImages" class="item-image-box">
  47. <view v-for="(itemAddImg, imgIndex) in commentItem.addImages" :key="imgIndex">
  48. <image
  49. class="img-item" :src="common.seamingImgUrl(itemAddImg)"
  50. @click="handlePreviewImage(goodsDetail.comments[commentIndex].addImages, imgIndex)"
  51. >
  52. </image>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="like-box">
  58. <tui-icon
  59. v-if="commentItem.ifLike === 1" :size="24" color="#c5aa7b" name="agree"
  60. @click="handlePraise(commentItem, 0)"
  61. ></tui-icon>
  62. <tui-icon v-else :size="24" color="#cccccc" name="agree" @click="handlePraise(commentItem, 1)"></tui-icon>
  63. <view class="like-num">{{ commentItem.likes }}</view>
  64. </view>
  65. </view>
  66. <view
  67. v-if="goodsDetail.comments.length > 0" class="moreBox"
  68. @click="go(`/another-tf/another-serve/evaluateList/index?shopId=${goodsDetail.shopId}&productId=${goodsDetail.productId}&skuId=${goodsDetail.skuId}`)"
  69. >
  70. <label class="fs24">查看全部</label>
  71. <tui-icon :size="24" color="#baa174" name="arrowright" margin="0 0 0 10upx"></tui-icon>
  72. </view>
  73. </view>
  74. <!-- 问答 -->
  75. <view class="borRig-line-20"></view>
  76. <view v-show="activeTab === 2" class="questions">
  77. <view class="questionInfo flex-items flex-row flex-sp-between">
  78. <view class="infoTit">宝贝好不好,问问已买过的人</view>
  79. <view
  80. class="putQuestion"
  81. @click="go(`/another-tf/another-serve/putQuestions/index?shopId=${goodsDetail.shopId}&productId=${goodsDetail.productId}&skuId=${goodsDetail.skuId}&questionNumber=${problemsList.length}`)"
  82. >
  83. <text>去提问</text>
  84. <tui-icon :size="30" color="#d9c9a8" name="arrowright"></tui-icon>
  85. </view>
  86. </view>
  87. <view class="listBox">
  88. <QuestionsAndAnswersList :product-info="goodsDetail" :problems-list="problemsList" />
  89. <view
  90. v-if="problemsList.length > 0" class="moreBox"
  91. @click="go(`/another-tf/another-serve/answerList/index?shopId=${goodsDetail.shopId}&productId=${goodsDetail.productId}&skuId=${goodsDetail.skuId}`)"
  92. >
  93. <label class="fs24">查看全部</label>
  94. <tui-icon :size="24" color="#baa174" name="arrowright" margin="0 0 0 10upx"></tui-icon>
  95. </view>
  96. </view>
  97. </view>
  98. </div>
  99. </template>
  100. <script>
  101. import lodash from 'lodash-es'
  102. import QuestionsAndAnswersList from './QuestionsAndAnswersList'
  103. import { getProblemsSeckillApi, updateLikeOrUnLikeCommentApi } from '../../../../api/anotherTFInterface'
  104. export default {
  105. name: 'GoodEvaluateAndQuestion',
  106. components: { QuestionsAndAnswersList },
  107. props: {
  108. goodsDetail: {
  109. type: Object,
  110. default: () => ({})
  111. }
  112. },
  113. data() {
  114. return {
  115. // 当前选中的tab
  116. activeTab: 1, // 1评价 2问答
  117. problemsList: [], // 问题列表
  118. problemsTotal: 0 // 问题总数
  119. }
  120. },
  121. mounted() {
  122. this.handleGetProblemList()
  123. },
  124. methods: {
  125. /**
  126. * 获取问答数据
  127. * @return {Promise<void>}
  128. */
  129. async handleGetProblemList() {
  130. if (!this.goodsDetail.productId) {
  131. return
  132. }
  133. const res = await getProblemsSeckillApi({
  134. productId: this.goodsDetail.productId,
  135. page: 1,
  136. pageSize: 2
  137. })
  138. this.problemsList = res.data.list
  139. this.problemsTotal = res.data.total
  140. },
  141. /**
  142. * 放大查看照片
  143. * @param dataList 所有照片
  144. * @param currentIndex 选中索引
  145. */
  146. handlePreviewImage(dataList, currentIndex) {
  147. uni.previewImage({
  148. current: dataList[currentIndex],
  149. urls: dataList
  150. })
  151. },
  152. /**
  153. * 点赞
  154. * @param commentItem 当前评论项
  155. * @param action 0取消1点赞
  156. */
  157. handlePraise: lodash.debounce(async function (commentItem, actionType) {
  158. uni.showLoading({
  159. mask: true,
  160. title: '提交中...'
  161. })
  162. try {
  163. await updateLikeOrUnLikeCommentApi({
  164. commentId: commentItem.commentId,
  165. ifLike: actionType
  166. })
  167. if (commentItem.ifLike === 1) {
  168. commentItem.ifLike = 0
  169. commentItem.likes--
  170. } else {
  171. commentItem.ifLike = 1
  172. commentItem.likes++
  173. }
  174. } finally {
  175. uni.hideLoading()
  176. }
  177. }, 500)
  178. }
  179. }
  180. </script>
  181. <style lang="less" scoped>
  182. .good-evaluate-and-question-container {
  183. background-color: #ffffff;
  184. .evaQaTab {
  185. height: 82rpx;
  186. line-height: 82rpx;
  187. border-bottom: #F3F4F5 solid 2rpx;
  188. font-size: 30rpx;
  189. color: #CCCCCC;
  190. .evaBtn {
  191. width: 50%;
  192. position: relative;
  193. text-align: center;
  194. &:before {
  195. content: '';
  196. width: 2rpx;
  197. height: 30rpx;
  198. background: #CCCCCC;
  199. display: block;
  200. position: absolute;
  201. right: 0;
  202. top: 20rpx;
  203. }
  204. }
  205. .qaBtn {
  206. width: 50%;
  207. text-align: center;
  208. }
  209. .tabTit {
  210. display: inline-block;
  211. height: 82rpx;
  212. line-height: 82rpx;
  213. }
  214. .active {
  215. color: #333333;
  216. .tabTit {
  217. border-bottom: 4rpx solid #444444;
  218. }
  219. }
  220. }
  221. .questions {
  222. .questionInfo {
  223. padding: 0 30upx;
  224. min-height: 150upx;
  225. .infoTit {
  226. font-size: 28upx;
  227. }
  228. .putQuestion {
  229. display: flex;
  230. align-items: center;
  231. justify-content: space-between;
  232. width: 140upx;
  233. height: 60upx;
  234. background: #333333;
  235. line-height: 60upx;
  236. font-size: 24upx;
  237. color: #FFEBC4;
  238. padding-left: 20rpx;
  239. position: relative;
  240. }
  241. }
  242. .listBox {
  243. padding: 0 30upx;
  244. border-bottom: 20upx solid #EEEEEE;
  245. }
  246. }
  247. .evaluate-box {
  248. background-color: #FFFFFF;
  249. margin-top: 20upx;
  250. .evaluateTag-box {
  251. margin-top: 10upx;
  252. margin-left: 10upx;
  253. padding-bottom: 10upx;
  254. display: flex;
  255. flex-wrap: wrap;
  256. .evaluateTag-text {
  257. background-color: #F4F4F4;
  258. border-radius: 6upx;
  259. padding: 16upx 14upx;
  260. color: #656565;
  261. margin-left: 20upx;
  262. margin-top: 20upx;
  263. }
  264. }
  265. .evaluate-contentbox {
  266. display: flex;
  267. justify-content: center;
  268. flex-direction: column;
  269. margin-left: 30upx;
  270. // border-bottom: 1upx solid #EDEDED;
  271. padding-bottom: 50upx;
  272. .evaluate-content {
  273. width: 670upx;
  274. display: flex;
  275. justify-content: space-between;
  276. .user-headSmallImg {
  277. width: 46upx;
  278. height: 46upx;
  279. border-radius: 50%;
  280. }
  281. }
  282. .evaluateDes-box {
  283. width: 670upx;
  284. margin-top: 30upx;
  285. .evaluateDes {
  286. width: 670upx;
  287. }
  288. }
  289. .addEvaluate {
  290. padding-top: 30upx;
  291. }
  292. }
  293. }
  294. .item-image-box {
  295. width: 700upx;
  296. display: flex;
  297. flex-direction: row;
  298. flex-wrap: wrap;
  299. .img-item {
  300. width: 223upx;
  301. height: 223upx;
  302. border-radius: 10upx;
  303. margin-right: 10upx;
  304. margin-top: 10upx;
  305. }
  306. }
  307. .item-line {
  308. width: 690upx;
  309. height: 1px;
  310. background: rgba(238, 238, 238, 1);
  311. margin-top: 20upx;
  312. }
  313. .item-like-box {
  314. display: flex;
  315. flex-direction: row;
  316. width: 690upx;
  317. align-items: center;
  318. justify-content: space-between;
  319. }
  320. .like-box {
  321. display: flex;
  322. flex-direction: row;
  323. padding-top: 30upx;
  324. align-items: center;
  325. justify-content: flex-end;
  326. margin-right: 50upx;
  327. .like-num {
  328. font-size: 28upx;
  329. font-weight: 500;
  330. color: rgba(51, 51, 51, 1);
  331. margin-left: 30upx;
  332. }
  333. }
  334. .moreBox {
  335. width: 170rpx;
  336. height: 54rpx;
  337. line-height: 54rpx;
  338. margin: 0 auto 50rpx auto;
  339. border: 2rpx solid #C5AA7B;
  340. color: #C5AA7B;
  341. display: flex;
  342. align-items: center;
  343. justify-content: center;
  344. image {
  345. width: 10rpx;
  346. height: 20rpx;
  347. }
  348. }
  349. }
  350. </style>