userEvaluate.vue 12 KB

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