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

421 lines
13 KiB

2 years ago
2 years ago
  1. <template>
  2. <view class="container">
  3. <!-- 骨架屏 -->
  4. <Skeleton
  5. el-color="#f1f3f4"
  6. bg-color="#fff"
  7. :loading="loading"
  8. :animation="true"
  9. ></Skeleton>
  10. <global-loading />
  11. <view class="u-skeleton">
  12. <!-- 我的评论 -->
  13. <view class="evaluateTitle-box flex-row-plus flex-sp-around u-skeleton-fillet">
  14. <view class="allEvaluate"
  15. :class="{'evaluateTitle-on' : evaluateTitleFlag == 1}"
  16. @click="evaluateTitleClick(1)"
  17. >全部评价({{ myCommentList.total || 0}})</view>
  18. <view class="centerLine">|</view>
  19. <view
  20. :class="{'evaluateTitle-on' : evaluateTitleFlag == 2}"
  21. @click="evaluateTitleClick(2)"
  22. >有图({{ myCommentList.imageTotal || 0}})</view>
  23. </view>
  24. <view v-if="evaluateTitleFlag == 1" class="mar-top-20">
  25. <template>
  26. <view
  27. class="evaluate-contentbox u-skeleton-fillet"
  28. v-for="(item, index) in commentVOList"
  29. :key="index"
  30. @click="commentDetails(index)"
  31. >
  32. <view class="evaluate-content flex-items flex-row flex-sp-between ">
  33. <view class="flex-items">
  34. <image class="user-headSmallImg u-skeleton-circle" v-if="item.headImage" :src="item.headImage"></image>
  35. <image class="user-headSmallImg u-skeleton-circle" src="https://ceres.zkthink.com/static/images/storeLogo.png" v-else></image>
  36. <view class="skuValue u-skeleton-fillet">
  37. <label class="fs28" v-if="item.name">{{item.name}}</label>
  38. <label class="fs28" v-else>匿名</label>
  39. <view class="fs22 font-color-999 mar-top-10">
  40. {{item.value}}
  41. </view>
  42. </view>
  43. </view>
  44. <view class="addCommentsBut" v-if="item.addComment == ''" @click.stop="addCommentsClick(index)">追加评价</view>
  45. </view>
  46. <view class="fs26 pad-topbot-20 u-skeleton-fillet" style="margin-top: 10rpx">{{item.comment}}</view>
  47. <view class="evaluateImg-box" v-if="item.image">
  48. <view v-for="(cItem, index) in commentImgData(item.image)" :key="index">
  49. <image class="evaluate-Img" :src="cItem"></image>
  50. </view>
  51. </view>
  52. <view class="addComments-box flex-column-plus" v-if="item.addComment">
  53. <label class="font-color-C5AA7B mar-top-30">用户追评</label>
  54. <label class="mar-top-20">{{item.addComment}}</label>
  55. <view class="evaluateImg-box mar-top-20" v-if="item.addImage">
  56. <view v-for="(dItem, index) in commentImgData(item.addImage)" :key="index">
  57. <image class="evaluate-Img" :src="dItem"></image>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="goodsDes-box u-skeleton-fillet flex-column-plus mar-top-30">
  62. <view class="flex-row-plus" @click.stop="goGoodsDetails(item.shopId,item.productId,item.skuId)">
  63. <image class="goodsDes-img default-img"
  64. onerror="this.src='url(https://ceres.zkthink.com/static/root/default.png) no-repeat center';this.οnerrοr=null"
  65. :src="item.productImage"></image>
  66. <view class="goodsDesText-box">
  67. <label class="fs26 goodsDes-text">{{item.productName}}</label>
  68. <view class="mar-top-70">
  69. <label>¥ {{item.productPrice}}</label>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <view class="flex-items flex-row mar-top-30 flex-sp-between">
  75. <view class="font-color-999 fs22">{{item.createTime}}</view>
  76. <view class="praise-box flex-items flex-row">
  77. <image class="praise-icon" @click.stop="zanTap(index,item.commentId,0)" src="https://ceres.zkthink.com/static/images/praiseActiveIcon.png"
  78. v-if="item.ifLike"></image>
  79. <image class="praise-icon" @click.stop="zanTap(index,item.commentId,1)" src="https://ceres.zkthink.com/static/images/addPraiseIcon.png"
  80. v-else></image>
  81. <label class="mar-left-10">{{item.likes}}</label>
  82. </view>
  83. </view>
  84. </view>
  85. </template>
  86. <view v-if="evaluateEmpty" class="emptyOrder-box flex-items-plus flex-column">
  87. <image class="emptyOrder-img" src="https://ceres.zkthink.com/static/img/bgnull.png"></image>
  88. <label class="font-color-999 fs26 mar-top-30">你还没有评论哦</label>
  89. </view>
  90. </view>
  91. <view v-if="evaluateTitleFlag == 2" class="mar-top-20">
  92. <template>
  93. <view
  94. class="evaluate-contentbox"
  95. v-for="(item, index) in commentVOList"
  96. :key="index"
  97. >
  98. <view class="evaluate-content flex-column" @click="commentDetails(index)" >
  99. <view class="flex-items">
  100. <image class="user-headSmallImg" v-if="item.headImage" :src="item.headImage"></image>
  101. <image class="user-headSmallImg" src="https://ceres.zkthink.com/static/images/storeLogo.png" v-else></image>
  102. <label class="fs28 mar-left-20" v-if="item.name">{{item.name}}</label>
  103. <label class="fs28 mar-left-20" v-else>匿名</label>
  104. </view>
  105. <view class="fs22 font-color-999 mar-top-10">
  106. {{item.value}}
  107. </view>
  108. <view class="fs26 pad-topbot-20">{{item.comment}}</view>
  109. <view class="evaluateImg-box" v-if="item.image">
  110. <view v-for="(cItem, index) in commentImgData(item.image)" :key="index">
  111. <image class="evaluate-Img" :src="cItem"></image>
  112. </view>
  113. </view>
  114. <view class="addComments-box flex-column-plus" v-if="item.addComment">
  115. <label class="font-color-C5AA7B mar-top-30">用户追评</label>
  116. <label class="mar-top-20">{{item.addComment}}</label>
  117. <view class="evaluateImg-box mar-top-20" v-if="item.addImage">
  118. <view v-for="(dItem, index) in commentImgData(item.addImage)" :key="index">
  119. <image class="evaluate-Img" :src="dItem"></image>
  120. </view>
  121. </view>
  122. </view>
  123. <view class="flex-items flex-row mar-top-30 flex-sp-between">
  124. <view class="font-color-999 fs22">{{item.createTime}}</view>
  125. <view class="praise-box flex-items flex-row">
  126. <image class="praise-icon" @click.stop="zanTap(index,item.commentId,0)" src="https://ceres.zkthink.com/static/images/praiseActiveIcon.png"
  127. v-if="item.ifLike"></image>
  128. <image class="praise-icon" @click.stop="zanTap(index,item.commentId,1)" src="https://ceres.zkthink.com/static/images/praiseIcon.png"
  129. v-else></image>
  130. <label class="mar-left-10">{{item.likes}}</label>
  131. </view>
  132. </view>
  133. </view>
  134. </view>
  135. </template>
  136. <view v-if="evaluateEmpty" class="emptyOrder-box flex-items-plus flex-column">
  137. <image class="emptyOrder-img" src="https://ceres.zkthink.com/static/img/bgnull.png"></image>
  138. <label class="font-color-999 fs26 mar-top-30">你还没有评论哦</label>
  139. </view>
  140. </view>
  141. </view>
  142. </view>
  143. </template>
  144. <script>
  145. import Skeleton from "../../components/Skeleton";
  146. const NET = require('../../utils/request')
  147. const API = require('../../config/api')
  148. export default {
  149. components: {Skeleton},
  150. data() {
  151. return {
  152. loading:true,
  153. evaluateTitleFlag: 1,
  154. myCommentList: [],
  155. commentVOList: [],
  156. state:"",
  157. page:1,//当前页
  158. pageSize:20,//每页记录数
  159. loadingType:0,
  160. topLeft: 0,
  161. evaluateEmpty: false
  162. }
  163. },
  164. onShow(){
  165. this.commentVOList = [{
  166. isLoading:true,
  167. name:'',
  168. comment:''
  169. },{
  170. isLoading:true,
  171. name:'',
  172. comment:''
  173. },{
  174. isLoading:true,
  175. name:'',
  176. comment:''
  177. },{
  178. isLoading:true,
  179. name:'',
  180. comment:''
  181. },{
  182. isLoading:true,
  183. name:'',
  184. comment:''
  185. }]
  186. this.getMyCommentList()
  187. },
  188. // onLoad() {
  189. // this.getMyCommentList()
  190. // },
  191. onReachBottom(){
  192. if(this.loadingType == 1){
  193. uni.stopPullDownRefresh()
  194. }else{
  195. this.page = this.page+1
  196. this.getMyCommentList()
  197. }
  198. },
  199. onBackPress(e) {
  200. if (e.from === 'navigateBack') {
  201. return false;
  202. }
  203. this.back();
  204. return true;
  205. },
  206. methods: {
  207. goGoodsDetails(shopId,productId,skuId){
  208. uni.navigateTo({
  209. url:'goodsDetails?shopId='+shopId+'&productId='+productId+'&skuId='+skuId
  210. })
  211. },
  212. back(){
  213. uni.switchTab({
  214. url:'../../pages/tabbar/user/index'
  215. });
  216. },
  217. commentImgData(imgData) {
  218. let imgDataResult = []
  219. imgDataResult = imgData.split(",");
  220. return imgDataResult
  221. },
  222. evaluateTitleClick(type) {
  223. this.evaluateEmpty = false
  224. if(type == 1){
  225. this.state = ''
  226. }else{
  227. this.state = "1"
  228. }
  229. this.page = 1
  230. this.commentVOList = []
  231. this.evaluateTitleFlag = type
  232. this.getMyCommentList()
  233. },
  234. //我的评价列表
  235. getMyCommentList() {
  236. this.$showLoading()
  237. this.loading = true
  238. NET.request(API.MyCommentList, {
  239. page: this.page,
  240. pageSize: this.pageSize,
  241. state: this.state
  242. }, 'GET').then(res => {
  243. uni.hideLoading()
  244. if(res.data.page.list.length == 0){
  245. this.loadingType = 1
  246. this.page = this.page
  247. }
  248. this.myCommentList = res.data
  249. this.commentVOList = this.commentVOList.concat(res.data.page.list)
  250. this.commentVOList = this.commentVOList.filter(item=>!item.isLoading)
  251. if (this.commentVOList.length === 0) {
  252. this.evaluateEmpty = true
  253. }
  254. }).catch(res => {
  255. uni.hideLoading()
  256. uni.showToast({
  257. title: res.data.message,
  258. duration: 2000,
  259. icon: 'none'
  260. });
  261. }).finally(()=>{
  262. this.loading = false
  263. this.$hideLoading()
  264. })
  265. },
  266. //点赞
  267. zanTap(index, likeId, actionType) {
  268. this.$showLoading()
  269. NET.request(API.LikeOrUnLikeComment, {
  270. commentId: likeId,
  271. ifLike: actionType
  272. }, 'POST').then(res => {
  273. this.commentVOList[index].ifLike = !this.commentVOList[index].ifLike
  274. this.commentVOList[index].likes = this.commentVOList[index].ifLike ? this.commentVOList[index].likes + 1 : this.commentVOList[index].likes - 1
  275. // this.commentVOList = []
  276. // this.page = 1
  277. // this.getMyCommentList()
  278. }).catch(res => {
  279. this.$hideLoading()
  280. // uni.hideLoading()
  281. })
  282. },
  283. commentDetails(id) {
  284. uni.setStorageSync('commentVOList', this.commentVOList[id]);
  285. uni.navigateTo({
  286. url: 'evaluateDetails'
  287. })
  288. },
  289. //追加评论
  290. addCommentsClick(id) {
  291. uni.setStorageSync('addCommentVOList', this.commentVOList[id]);
  292. uni.navigateTo({
  293. url: 'addEvaluate?type=2'
  294. })
  295. }
  296. }
  297. }
  298. </script>
  299. <style lang="scss" scoped>
  300. page {
  301. background-color: #FFFFFF;
  302. }
  303. .container {
  304. .emptyOrder-box {
  305. margin-top: 70upx;
  306. .emptyOrder-img {
  307. margin-top: 45%;
  308. width: 113upx;
  309. height: 98upx;
  310. }
  311. }
  312. .evaluateTitle-box {
  313. color: #CCCCCC;
  314. margin-top: 26upx;
  315. border-bottom: 2rpx solid #F3F4F5;
  316. .evaluateTitle-on {
  317. padding-bottom: 20upx;
  318. border-bottom: 4upx solid #C5AA7B;
  319. color: #333333;
  320. }
  321. }
  322. .evaluate-contentbox {
  323. display: flex;
  324. justify-content: center;
  325. flex-direction: column;
  326. padding: 30upx 30upx;
  327. margin: 10rpx 10rpx;
  328. background-color: #FFFFFF;
  329. border-bottom: 2rpx solid #F3F4F5;
  330. .evaluate-content {
  331. width: 670upx;
  332. display: flex;
  333. justify-content: space-between;
  334. .user-headSmallImg {
  335. width: 46upx;
  336. height: 46upx;
  337. border-radius: 50%;
  338. }
  339. .skuValue {
  340. text-align: left;
  341. padding-left: 30rpx;
  342. }
  343. }
  344. .evaluateImg-box {
  345. display: flex;
  346. flex-direction: row;
  347. flex-wrap: wrap;
  348. margin-left: -9upx;
  349. .evaluate-Img {
  350. width: 224upx;
  351. height: 224upx;
  352. border-radius: 10upx;
  353. margin-left: 9upx;
  354. margin-top: 9upx;
  355. }
  356. }
  357. .goodsDes-box {
  358. background-color: #F7F7F7;
  359. padding: 20upx 44upx 20upx 20upx;
  360. .goodsDes-img {
  361. width: 180upx;
  362. height: 180upx;
  363. border-radius: 10upx;
  364. }
  365. .goodsDesText-box {
  366. width: 416upx;
  367. margin-left: 30upx;
  368. }
  369. .praise-box {
  370. .praise-icon {
  371. width: 50upx;
  372. height: 50upx;
  373. }
  374. }
  375. }
  376. .addComments-box {
  377. border-top: 1upx solid #EEEEEE;
  378. margin-top: 35upx;
  379. }
  380. }
  381. }
  382. .praise-icon {
  383. width: 50upx;
  384. height: 50upx;
  385. }
  386. .addCommentsBut {
  387. width: 140upx;
  388. height: 58upx;
  389. background: #333333;
  390. font-size: 26upx;
  391. line-height: 58upx;
  392. text-align: center;
  393. color: #C5AA7B;
  394. }
  395. .addCommentsBut1 {
  396. width: 140upx;
  397. height: 58upx;
  398. font-size: 26upx;
  399. background: #333333;
  400. line-height: 58upx;
  401. text-align: center;
  402. }
  403. </style>