多租户商城-商户小程序端
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.

597 lines
13 KiB

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