多租户商城-商户小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

587 lines
13 KiB

2 years ago
2 years ago
2 years ago
2 years ago
  1. <!--
  2. * @FileDescription:商品评价和问答
  3. * @Author: kahu
  4. * @Date: 2022/11/7
  5. * @LastEditors: kahu
  6. * @LastEditTime: 2022/11/7
  7. -->
  8. <template>
  9. <div class="content">
  10. <view class="evaQaTab flex-items flex-sp-around">
  11. <view
  12. :class="{active: activeTab === 1}"
  13. class="evaBtn"
  14. @click="activeTab = 1"
  15. >
  16. <view class="tabTit">{{$t('page.goodsevaluation')}}{{ commentList.length }}</view>
  17. </view>
  18. <view
  19. :class="{active: activeTab === 2}"
  20. class="qaBtn"
  21. @click="activeTab = 2"
  22. >
  23. <view class="tabTit">{{$t('client.commodityqa')}}{{ problemsTotal }}</view>
  24. </view>
  25. </view>
  26. <!-- 评价 -->
  27. <view class="borRig-line-20"></view>
  28. <view
  29. class="evaluate-box flex-start flex-column"
  30. v-show="activeTab === 1"
  31. >
  32. <view
  33. class="evaluateTag-box"
  34. v-if="commentList.length>0"
  35. >
  36. <view class="evaluateTag-text">
  37. {{$t('common.all')}}({{ commentList.length }})
  38. </view>
  39. </view>
  40. <view
  41. class="evaluate-contentbox mar-top-30"
  42. v-for="(commentItem, commentIndex) in commentList.slice(0,2)"
  43. :key="commentIndex"
  44. >
  45. <view class="evaluate-content flex-items flex-row flex-sp-between">
  46. <view class="flex-items">
  47. <image
  48. class="user-headSmallImg"
  49. :src="commentItem.headImage"
  50. ></image>
  51. <label class="fs28 mar-left-20">{{ commentItem.name }}</label>
  52. </view>
  53. <label class="font-color-999 fs22">{{ commentItem.createTime }}</label>
  54. </view>
  55. <view class="evaluateDes-box">
  56. <label class="evaluateDes">{{ commentItem.comment }}</label>
  57. </view>
  58. <view
  59. class="item-image-box"
  60. v-if="commentItem.image"
  61. >
  62. <view
  63. v-for="(imgItem, imgIndex) in (commentItem.image.split(',')||[])"
  64. :key="imgIndex"
  65. >
  66. <image
  67. @click="handlePreviewImage(commentList[commentIndex].images,imgIndex)"
  68. class="img-item"
  69. :src="imgItem"
  70. ></image>
  71. </view>
  72. </view>
  73. <view class="item-line"></view>
  74. <view
  75. class="item-like-box"
  76. v-if="commentItem.addComment !== ''"
  77. >
  78. <view class="addEvaluate">
  79. <view>追加评价{{ commentItem.addComment }}</view>
  80. <view
  81. class="item-image-box"
  82. v-if="commentItem.addImages"
  83. >
  84. <view
  85. v-for="(itemAddImg, imgIndex) in commentItem.addImages"
  86. :key="imgIndex"
  87. >
  88. <image
  89. @click="handlePreviewImage(commentList[commentIndex].addImages,imgIndex)"
  90. class="img-item"
  91. :src="itemAddImg"
  92. >
  93. </image>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. <view class="like-box">
  99. <image
  100. class="like-img"
  101. @click="handlePraise(commentItem,0)"
  102. src="https://ceres.zkthink.com/static/images/praiseActiveIcon.png"
  103. v-if="commentItem.ifLike === 1"
  104. ></image>
  105. <image
  106. class="like-img"
  107. @click="handlePraise(commentItem,1)"
  108. src="https://ceres.zkthink.com/static/images/praiseIcon.png"
  109. v-else
  110. ></image>
  111. <view class="like-num">{{ commentItem.likes }}</view>
  112. </view>
  113. </view>
  114. <view
  115. class="moreBox"
  116. v-if="commentList.length>0"
  117. @click="handleJumpToComments"
  118. >
  119. <label class="fs24">查看全部</label>
  120. <image
  121. class="evaluateAllArrow-icon mar-left-10"
  122. src="https://ceres.zkthink.com/static/img/user/arrow.png"
  123. ></image>
  124. </view>
  125. </view>
  126. <!-- 问答 -->
  127. <view class="borRig-line-20"></view>
  128. <view
  129. class="questions"
  130. v-show="activeTab === 2"
  131. >
  132. <view class="questionInfo flex-items flex-row flex-sp-between">
  133. <view class="infoTit">宝贝好不好问问已买过的人</view>
  134. <view
  135. class="putQuestion"
  136. @click="handleJumpToQuestion"
  137. >去提问
  138. </view>
  139. </view>
  140. <view class="listBox">
  141. <QuestionsAndAnswersList
  142. :product-info="productInfo"
  143. :problems-list="problemsList"
  144. />
  145. <view
  146. class="moreBox"
  147. v-if="problemsList.length>0"
  148. @click="handleJumpAllAnswer"
  149. >
  150. <label class="fs24">查看全部</label>
  151. <image
  152. class="evaluateAllArrow-icon mar-left-10"
  153. src="https://ceres.zkthink.com/static/img/user/arrow.png"
  154. ></image>
  155. </view>
  156. </view>
  157. </view>
  158. </div>
  159. </template>
  160. <script>
  161. const NET = require('../../../utils/request')
  162. const API = require('../../../config/api')
  163. import lodash from 'lodash'
  164. import QuestionsAndAnswersList from "./QuestionsAndAnswersList";
  165. export default {
  166. name: "GoodEvaluateAndQuestion",
  167. components: {QuestionsAndAnswersList},
  168. data() {
  169. return {
  170. // 当前选中的tab
  171. activeTab: 1, // 1评价 2问答
  172. problemsList: [], // 问题列表
  173. problemsTotal:0 //问题总数
  174. }
  175. },
  176. props: {
  177. commentList: {
  178. type: Array,
  179. default: () => []
  180. },
  181. productInfo: {
  182. type: Object,
  183. default: () => ({})
  184. }
  185. },
  186. mounted() {
  187. this.handleGetProblemList()
  188. },
  189. methods: {
  190. /**
  191. * 获取问答数据
  192. * @return {Promise<void>}
  193. */
  194. async handleGetProblemList() {
  195. if(!this.productInfo.productId){
  196. return
  197. }
  198. const res = await NET.request(API.getProblems, {
  199. productId: this.productInfo.productId,
  200. page: 1,
  201. pageSize: 2
  202. }, 'GET')
  203. this.problemsList = res.data.list
  204. this.problemsTotal = res.data.total
  205. },
  206. /**
  207. * 放大查看照片
  208. * @param dataList 所有照片
  209. * @param currentIndex 选中索引
  210. */
  211. handlePreviewImage(dataList, currentIndex) {
  212. uni.previewImage({
  213. current: dataList[currentIndex],
  214. urls: dataList
  215. })
  216. },
  217. /**
  218. * 点赞
  219. * @param commentItem 当前评论项
  220. * @param action 0取消1点赞
  221. */
  222. handlePraise: lodash.debounce(async function (commentItem, actionType) {
  223. uni.showLoading({
  224. mask: true,
  225. title: '提交中...',
  226. })
  227. try {
  228. await NET.request(API.LikeOrUnLikeComment, {
  229. commentId: commentItem.commentId,
  230. ifLike: actionType
  231. }, 'POST')
  232. if (commentItem.ifLike === 1) {
  233. commentItem.ifLike = 0
  234. commentItem.likes--
  235. } else {
  236. commentItem.ifLike = 1
  237. commentItem.likes++
  238. }
  239. } finally {
  240. uni.hideLoading()
  241. }
  242. }, 500),
  243. /**
  244. * 跳转到全部评论
  245. */
  246. handleJumpToComments() {
  247. this.$jump('/pages_category_page1/goodsModule/evaluateList?commentList=' + JSON.stringify(this.commentList))
  248. },
  249. /**
  250. * 跳转到提问
  251. */
  252. handleJumpToQuestion() {
  253. const paramObj = Object.assign({}, this.productInfo, {
  254. questionNumber: this.problemsList.length,
  255. images: this.productInfo.images[0],
  256. })
  257. this.$jump('/pages_category_page1/goodsModule/putQuestions', paramObj)
  258. },
  259. /**
  260. * 跳转到该商品下所有问答
  261. */
  262. handleJumpAllAnswer() {
  263. const paramObj = Object.assign({}, this.productInfo, {
  264. images: this.productInfo.images[0]
  265. })
  266. this.$jump('/pages_category_page1/goodsModule/answerList', paramObj)
  267. }
  268. }
  269. }
  270. </script>
  271. <style
  272. lang="scss"
  273. scoped
  274. >
  275. .evaQaTab {
  276. height: 82rpx;
  277. line-height: 82rpx;
  278. border-bottom: #F3F4F5 solid 2rpx;
  279. font-size: 30rpx;
  280. color: #CCCCCC;
  281. .evaBtn {
  282. width: 50%;
  283. position: relative;
  284. text-align: center;
  285. &:before {
  286. content: '';
  287. width: 2rpx;
  288. height: 30rpx;
  289. background: #CCCCCC;
  290. display: block;
  291. position: absolute;
  292. right: 0;
  293. top: 20rpx;
  294. }
  295. }
  296. .qaBtn {
  297. width: 50%;
  298. text-align: center;
  299. }
  300. .tabTit {
  301. display: inline-block;
  302. height: 82rpx;
  303. line-height: 82rpx;
  304. }
  305. .active {
  306. color: #333333;
  307. .tabTit {
  308. border-bottom: 4rpx solid #444444;
  309. }
  310. }
  311. }
  312. .questions {
  313. .questionInfo {
  314. padding: 0 30upx;
  315. min-height: 150upx;
  316. .infoTit {
  317. font-size: 28upx;
  318. }
  319. .putQuestion {
  320. width: 140upx;
  321. height: 60upx;
  322. background: #333333;
  323. line-height: 60upx;
  324. font-size: 24upx;
  325. color: #FFEBC4;
  326. padding-left: 20rpx;
  327. position: relative;
  328. &:before {
  329. content: '';
  330. width: 60rpx;
  331. height: 60rpx;
  332. background: url("https://ceres.zkthink.com/static/images/arrow.png") no-repeat center center;
  333. background-size: contain;
  334. display: block;
  335. position: absolute;
  336. right: 0;
  337. }
  338. }
  339. }
  340. .listBox {
  341. padding: 0 30upx;
  342. border-bottom: 20upx solid #EEEEEE;
  343. .itemBox {
  344. padding-bottom: 30upx;
  345. border-bottom: 1upx solid #EEEEEE;
  346. margin-bottom: 30upx;
  347. &:last-child {
  348. border-bottom: none;
  349. }
  350. .itemAsk {
  351. display: flex;
  352. align-items: center;
  353. margin-bottom: 42upx;
  354. i {
  355. font-style: normal;
  356. width: 38upx;
  357. height: 38upx;
  358. line-height: 38upx;
  359. background: #C5AA7B;
  360. display: block;
  361. margin-right: 30upx;
  362. font-size: 24upx;
  363. color: #FFFFFF;
  364. text-align: center;
  365. }
  366. span {
  367. font-size: 28upx;
  368. color: #333333;
  369. }
  370. }
  371. .answer {
  372. display: flex;
  373. justify-content: space-between;
  374. align-items: center;
  375. margin-bottom: 30upx;
  376. .answerBox {
  377. display: flex;
  378. align-items: center;
  379. i {
  380. font-style: normal;
  381. width: 38upx;
  382. height: 38upx;
  383. line-height: 38upx;
  384. background: #C5AA7B;
  385. display: block;
  386. text-align: center;
  387. margin-right: 30upx;
  388. font-size: 24rpx;
  389. color: #FFFFFF;
  390. }
  391. span {
  392. font-size: 26upx;
  393. color: #666666;
  394. }
  395. }
  396. .answerBtn {
  397. width: 130upx;
  398. height: 50upx;
  399. line-height: 50upx;
  400. border: #333333 2rpx solid;
  401. text-align: center;
  402. color: #333;
  403. font-size: 24upx;
  404. }
  405. }
  406. .seeAll {
  407. margin-left: 68upx;
  408. font-size: 28upx;
  409. color: #C5AA7B;
  410. }
  411. }
  412. }
  413. }
  414. .evaluate-box {
  415. background-color: #FFFFFF;
  416. margin-top: 20upx;
  417. .evaluate {
  418. width: 690upx;
  419. padding: 20upx 0;
  420. border-bottom: 1upx solid #EDEDED;
  421. }
  422. .evaluateTitle-box {
  423. width: 690upx;
  424. border-bottom: 1upx solid #EDEDED;
  425. padding-bottom: 20upx;
  426. }
  427. .evaluateAllArrow-icon {
  428. width: 18upx;
  429. height: 24upx;
  430. }
  431. .evaluateTag-box {
  432. margin-top: 10upx;
  433. margin-left: 10upx;
  434. padding-bottom: 10upx;
  435. display: flex;
  436. flex-wrap: wrap;
  437. .evaluateTag-text {
  438. background-color: #F4F4F4;
  439. border-radius: 6upx;
  440. padding: 16upx 14upx;
  441. color: #656565;
  442. margin-left: 20upx;
  443. margin-top: 20upx;
  444. }
  445. }
  446. .evaluate-contentbox {
  447. display: flex;
  448. justify-content: center;
  449. flex-direction: column;
  450. margin-left: 30upx;
  451. // border-bottom: 1upx solid #EDEDED;
  452. padding-bottom: 50upx;
  453. .evaluate-content {
  454. width: 670upx;
  455. display: flex;
  456. justify-content: space-between;
  457. .user-headSmallImg {
  458. width: 46upx;
  459. height: 46upx;
  460. border-radius: 50%;
  461. }
  462. }
  463. .evaluateDes-box {
  464. width: 670upx;
  465. margin-top: 30upx;
  466. .evaluateDes {
  467. width: 670upx;
  468. }
  469. }
  470. .addEvaluate {
  471. padding-top: 30upx;
  472. }
  473. }
  474. }
  475. .item-image-box {
  476. width: 700upx;
  477. display: flex;
  478. flex-direction: row;
  479. flex-wrap: wrap;
  480. .img-item {
  481. width: 223upx;
  482. height: 223upx;
  483. border-radius: 10upx;
  484. margin-right: 10upx;
  485. margin-top: 10upx;
  486. }
  487. }
  488. .item-line {
  489. width: 690upx;
  490. height: 1px;
  491. background: rgba(238, 238, 238, 1);
  492. margin-top: 20upx;
  493. }
  494. .item-like-box {
  495. display: flex;
  496. flex-direction: row;
  497. width: 690upx;
  498. align-items: center;
  499. justify-content: space-between;
  500. }
  501. .like-box {
  502. display: flex;
  503. flex-direction: row;
  504. padding-top: 30upx;
  505. align-items: center;
  506. justify-content: flex-end;
  507. margin-right: 50upx;
  508. .like-img {
  509. width: 48upx;
  510. height: 48upx;
  511. }
  512. .like-num {
  513. font-size: 28upx;
  514. font-weight: 500;
  515. color: rgba(51, 51, 51, 1);
  516. margin-left: 30upx;
  517. }
  518. }
  519. .moreBox {
  520. width: 170rpx;
  521. height: 54rpx;
  522. line-height: 54rpx;
  523. margin: 0 auto 50rpx auto;
  524. border: 2rpx solid #C5AA7B;
  525. color: #C5AA7B;
  526. display: flex;
  527. align-items: center;
  528. justify-content: center;
  529. image {
  530. width: 10rpx;
  531. height: 20rpx;
  532. }
  533. }
  534. </style>