userEvaluate.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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. this.$switchTab('/pages/tabbar/user/index')
  209. },
  210. commentImgData(imgData) {
  211. let imgDataResult = []
  212. imgDataResult = imgData.split(',')
  213. return imgDataResult
  214. },
  215. evaluateTitleClick(type) {
  216. this.evaluateEmpty = false
  217. if (type == 1) {
  218. this.state = ''
  219. } else {
  220. this.state = '1'
  221. }
  222. this.page = 1
  223. this.commentVOList = []
  224. this.evaluateTitleFlag = type
  225. this.getMyCommentList()
  226. },
  227. // 我的评价列表
  228. getMyCommentList() {
  229. this.$showLoading()
  230. this.loading = true
  231. NET.request(API.MyCommentList, {
  232. page: this.page,
  233. pageSize: this.pageSize,
  234. state: this.state
  235. }, 'GET').then((res) => {
  236. uni.hideLoading()
  237. if (res.data.page.list.length == 0) {
  238. this.loadingType = 1
  239. this.page = this.page
  240. }
  241. this.myCommentList = res.data
  242. this.commentVOList = this.commentVOList.concat(res.data.page.list)
  243. this.commentVOList = this.commentVOList.filter((item) => !item.isLoading)
  244. if (this.commentVOList.length === 0) {
  245. this.evaluateEmpty = true
  246. }
  247. })
  248. .catch((res) => {
  249. uni.hideLoading()
  250. uni.showToast({
  251. title: res.data.message,
  252. duration: 2000,
  253. icon: 'none'
  254. })
  255. })
  256. .finally(() => {
  257. this.loading = false
  258. this.$hideLoading()
  259. })
  260. },
  261. // 点赞
  262. zanTap(index, likeId, actionType) {
  263. this.$showLoading()
  264. NET.request(API.LikeOrUnLikeComment, {
  265. commentId: likeId,
  266. ifLike: actionType
  267. }, 'POST').then((res) => {
  268. this.commentVOList[index].ifLike = !this.commentVOList[index].ifLike
  269. this.commentVOList[index].likes = this.commentVOList[index].ifLike ? this.commentVOList[index].likes + 1 : this.commentVOList[index].likes - 1
  270. // this.commentVOList = []
  271. // this.page = 1
  272. // this.getMyCommentList()
  273. })
  274. .catch((res) => {
  275. this.$hideLoading()
  276. // uni.hideLoading()
  277. })
  278. },
  279. commentDetails(id) {
  280. uni.setStorageSync('commentVOList', this.commentVOList[id])
  281. uni.navigateTo({
  282. url: 'evaluateDetails'
  283. })
  284. },
  285. // 追加评论
  286. addCommentsClick(id) {
  287. uni.setStorageSync('addCommentVOList', this.commentVOList[id])
  288. uni.navigateTo({
  289. url: 'addEvaluate?type=2'
  290. })
  291. }
  292. }
  293. }
  294. </script>
  295. <style lang="scss" scoped>
  296. page {
  297. background-color: #FFFFFF;
  298. }
  299. .container {
  300. .emptyOrder-box {
  301. margin-top: 70upx;
  302. .emptyOrder-img {
  303. margin-top: 45%;
  304. width: 113upx;
  305. height: 98upx;
  306. }
  307. }
  308. .evaluateTitle-box {
  309. color: #CCCCCC;
  310. margin-top: 26upx;
  311. border-bottom: 2rpx solid #F3F4F5;
  312. .evaluateTitle-on {
  313. padding-bottom: 20upx;
  314. border-bottom: 4upx solid #C5AA7B;
  315. color: #333333;
  316. }
  317. }
  318. .evaluate-contentbox {
  319. display: flex;
  320. justify-content: center;
  321. flex-direction: column;
  322. padding: 30upx 30upx;
  323. margin: 10rpx 10rpx;
  324. background-color: #FFFFFF;
  325. border-bottom: 2rpx solid #F3F4F5;
  326. .evaluate-content {
  327. width: 670upx;
  328. display: flex;
  329. justify-content: space-between;
  330. .user-headSmallImg {
  331. width: 46upx;
  332. height: 46upx;
  333. border-radius: 50%;
  334. }
  335. .skuValue {
  336. text-align: left;
  337. padding-left: 30rpx;
  338. }
  339. }
  340. .evaluateImg-box {
  341. display: flex;
  342. flex-direction: row;
  343. flex-wrap: wrap;
  344. margin-left: -9upx;
  345. .evaluate-Img {
  346. width: 224upx;
  347. height: 224upx;
  348. border-radius: 10upx;
  349. margin-left: 9upx;
  350. margin-top: 9upx;
  351. }
  352. }
  353. .goodsDes-box {
  354. background-color: #F7F7F7;
  355. padding: 20upx 44upx 20upx 20upx;
  356. .goodsDes-img {
  357. width: 180upx;
  358. height: 180upx;
  359. border-radius: 10upx;
  360. }
  361. .goodsDesText-box {
  362. width: 416upx;
  363. margin-left: 30upx;
  364. }
  365. .praise-box {
  366. .praise-icon {
  367. width: 50upx;
  368. height: 50upx;
  369. }
  370. }
  371. }
  372. .addComments-box {
  373. border-top: 1upx solid #EEEEEE;
  374. margin-top: 35upx;
  375. }
  376. }
  377. }
  378. .praise-icon {
  379. width: 50upx;
  380. height: 50upx;
  381. }
  382. .addCommentsBut {
  383. width: 140upx;
  384. height: 58upx;
  385. background: #333333;
  386. font-size: 26upx;
  387. line-height: 58upx;
  388. text-align: center;
  389. color: #C5AA7B;
  390. }
  391. .addCommentsBut1 {
  392. width: 140upx;
  393. height: 58upx;
  394. font-size: 26upx;
  395. background: #333333;
  396. line-height: 58upx;
  397. text-align: center;
  398. }
  399. </style>