index.vue 13 KB

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