myEvaluate.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <template>
  2. <view>
  3. <view class="wrap">
  4. <view class="u-tabs-box">
  5. <u-tabs :list="list" :is-scroll="false" inactive-color="#333" :current="current" class="utabs" :active-color="$lightColor" @change="changeTab"></u-tabs>
  6. </view>
  7. <swiper class="swiper-box" :current="current" @change="changeSwiper" duration="500">
  8. <swiper-item v-for="(item, listIndex) in list" :key="listIndex">
  9. <scroll-view scroll-y style="height: 100%" @scrolltolower="renderData(listIndex)">
  10. <u-empty text="尚无需要评价的商品" mode="list" v-if="orderList.length == 0"></u-empty>
  11. <view class="seller-view" v-for="(order, index) in orderList" :key="index">
  12. <!-- 店铺名称 -->
  13. <view class="box-title">
  14. <view class="title_seller_name">
  15. {{ order.storeName }}
  16. </view>
  17. </view>
  18. <view v-for="(sku, _index) in order.orderItems" :key="_index">
  19. <view class="goods-item-view">
  20. <view>
  21. <u-image border-radius="6rpx" width="132rpx" height="132rpx" class="goods_img" :src="sku.image" alt />
  22. </view>
  23. <view class="goods-info">
  24. <view class="goods-title u-line-2">{{ sku.name }}</view>
  25. <view class="text title">{{ gradeList[order.grade] || '' }}</view>
  26. </view>
  27. </view>
  28. <view class="btn-view u-row-between" v-if="current != 0">
  29. <view class="description">
  30. <view class="text title">
  31. <u-read-more ref="uReadMore" :color="$lightColor" text-indent="0">
  32. <rich-text :nodes="'评论内容:' + order.content || ''"></rich-text>
  33. </u-read-more>
  34. </view>
  35. <view class="goods-imgs-view" v-if="order.image">
  36. <view class="img-view" v-if="order.image" v-for="(img, imgIndex) in order.image.split(',')" :key="imgIndex">
  37. <u-image v-if="order.image" @click.native="
  38. preview(order.image.split(','), imgIndex)
  39. " width="160rpx" height="160rpx" :src="img"></u-image>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="again-btn" @click="onDetail(order)" v-if="current == 1">
  45. <u-tag text="评价详情" shape="circle" mode="plain" type="error" />
  46. </view>
  47. <view v-if="current == 0 && sku.commentStatus == 'UNFINISHED'">
  48. <view class="evaluate">
  49. <view @click="talkCommont(order)">
  50. <u-tag text="发表评价" shape="circle" mode="plain" type="error" />
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <uni-load-more :status="params.loadStatus"></uni-load-more>
  57. </scroll-view>
  58. </swiper-item>
  59. </swiper>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. import { getOrderList } from "@/api/order.js";
  65. import { getComments } from "@/api/members.js";
  66. export default {
  67. data() {
  68. return {
  69. list: [ //顶部tab
  70. {
  71. name: "待评价",
  72. },
  73. {
  74. name: "已评价",
  75. },
  76. ],
  77. gradeList: { //评论表
  78. GOOD: "好评",
  79. MODERATE: "中评",
  80. WORSE: "差评",
  81. haveImage: "有图",
  82. },
  83. current: 0, //当前tabIndex
  84. orderList: [], //商品集合
  85. params: {
  86. pageNumber: 1,
  87. pageSize: 10,
  88. loadStatus: "more",
  89. },
  90. };
  91. },
  92. onShow() {
  93. this.orderList = [];
  94. this.params.pageNumber = 1;
  95. this.current == 0 ? this.loadData() : this.loadComments();
  96. },
  97. watch: {
  98. /**
  99. * 切换current
  100. * 更改页面并重新加载数据
  101. */
  102. current(val) {
  103. this.params.pageNumber = 1;
  104. this.params.loadStatus = "more";
  105. this.orderList = [];
  106. //重新读取数据
  107. if (val == 0) {
  108. this.loadData();
  109. }
  110. if (val == 1) {
  111. this.orderList = [];
  112. this.loadComments();
  113. }
  114. },
  115. },
  116. methods: {
  117. /**
  118. * 判断当前店铺是否有可评价的商品
  119. */
  120. commentStatus(val) {
  121. if (this.current == 1) {
  122. return true;
  123. } else {
  124. let show;
  125. val.orderItems &&
  126. val.orderItems.forEach((item) => {
  127. if (item.commentStatus == "UNFINISHED") {
  128. show = true;
  129. } else {
  130. show = false;
  131. }
  132. });
  133. return show;
  134. }
  135. },
  136. /**
  137. * 点击图片放大或保存
  138. */
  139. preview(urls, index) {
  140. uni.previewImage({
  141. current: index,
  142. urls: urls,
  143. longPressActions: {
  144. itemList: ["保存图片"],
  145. success: function (data) {},
  146. fail: function (err) {},
  147. },
  148. });
  149. },
  150. /**
  151. * 点击tab触发
  152. */
  153. changeTab(index) {
  154. this.current = index;
  155. },
  156. /**
  157. * 点击swiper
  158. */
  159. changeSwiper(e) {
  160. this.current = e.target.current;
  161. },
  162. /**
  163. * 获取订单数据
  164. */
  165. loadData() {
  166. uni.showLoading({
  167. title: "加载中",
  168. });
  169. getOrderList(this.params).then((res) => {
  170. uni.hideLoading();
  171. const orderList = res.data.result.records;
  172. if (orderList.length < 10) {
  173. this.params.loadStatus = "noMore";
  174. }
  175. if (orderList.length > 0) {
  176. this.orderList = this.orderList.concat(orderList);
  177. this.params.pageNumber += 1;
  178. }
  179. });
  180. },
  181. /**
  182. * 发表评价
  183. */
  184. talkCommont(order) {
  185. uni.navigateTo({
  186. url: `./releaseEvaluate?sn=${order.sn}&order=${encodeURIComponent(
  187. JSON.stringify(order)
  188. )}`,
  189. });
  190. },
  191. /**
  192. * 加载已评价数据
  193. */
  194. loadComments() {
  195. uni.showLoading({
  196. title: "加载中",
  197. });
  198. getComments(this.params).then((res) => {
  199. uni.hideLoading();
  200. let orderList = res.data.result.records;
  201. if (orderList.length < 10) {
  202. this.params.loadStatus = "noMore";
  203. }
  204. orderList.forEach((item) => {
  205. item.orderItems = [
  206. {
  207. image: item.goodsImage,
  208. name: item.goodsName,
  209. goodsId: item.goodsId,
  210. skuId: item.skuId,
  211. },
  212. ];
  213. });
  214. this.orderList = this.orderList.concat(orderList);
  215. this.params.pageNumber += 1;
  216. });
  217. },
  218. /**
  219. * 滑到底部加载数据
  220. */
  221. renderData(index) {
  222. if (this.params.loadStatus == "noMore") return;
  223. if (index == 0) {
  224. this.loadData();
  225. }
  226. if (index == 1) {
  227. this.params.audit_status = "PASS_AUDIT";
  228. this.params.comments_type = "INITIAL";
  229. this.params.comment_status = "WAIT_CHASE";
  230. this.loadComments();
  231. }
  232. },
  233. /**
  234. * 评价详情
  235. */
  236. onDetail(comment) {
  237. uni.navigateTo({
  238. url:
  239. "./evaluateDetail?comment=" +
  240. encodeURIComponent(JSON.stringify(comment)),
  241. });
  242. },
  243. },
  244. };
  245. </script>
  246. <style lang="scss" scoped>
  247. page {
  248. height: 100%;
  249. }
  250. .wrap {
  251. background: #f6f6f6;
  252. height: calc(100vh - var(--window-top));
  253. width: 100%;
  254. }
  255. .goods-imgs-view {
  256. margin: 20rpx 0;
  257. display: flex;
  258. flex-direction: row;
  259. flex-wrap: wrap;
  260. align-items: center;
  261. .img-view {
  262. margin-right: 15rpx;
  263. }
  264. }
  265. .u-tabs-box {
  266. position: relative;
  267. z-index: 10;
  268. }
  269. .box-content {
  270. margin: 20rpx 0;
  271. }
  272. .title_seller_name {
  273. font-weight: 700;
  274. font-size: 28rpx;
  275. color: #333;
  276. padding-left: 0 !important;
  277. }
  278. .box-title {
  279. height: 90rpx;
  280. line-height: 90rpx;
  281. }
  282. .swiper-box {
  283. height: calc(100% - 88rpx);
  284. }
  285. .goods-specs {
  286. margin-bottom: 10rpx;
  287. color: #cccccc;
  288. font-size: 24rpx;
  289. }
  290. .goods-price {
  291. margin-bottom: 10rpx;
  292. color: #999999;
  293. font-size: 24rpx;
  294. }
  295. .goods-item-view {
  296. display: flex;
  297. margin-bottom: 20rpx;
  298. .goods-info {
  299. padding-left: 30rpx;
  300. .goods-title {
  301. color: $u-main-color;
  302. margin-bottom: 10rpx;
  303. }
  304. }
  305. .goods-num {
  306. margin: 0rpx 10rpx;
  307. display: flex;
  308. flex-direction: column;
  309. align-items: flex-end;
  310. justify-content: space-between;
  311. margin-bottom: 10rpx;
  312. .u-num {
  313. color: $aider-light-color;
  314. font-size: 33rpx;
  315. }
  316. }
  317. }
  318. .again-btn {
  319. margin: 0rpx 10rpx;
  320. display: flex;
  321. flex-direction: column;
  322. align-items: flex-end;
  323. margin-bottom: 10rpx;
  324. }
  325. .seller-view {
  326. background-color: #fff;
  327. margin: 20rpx 0px;
  328. padding: 0px 20rpx 20rpx 20rpx;
  329. border-radius: 20rpx;
  330. .seller-info {
  331. height: 70rpx;
  332. .seller-name {
  333. font-size: 33rpx;
  334. font-weight: 600;
  335. }
  336. .order-sn {
  337. color: #909399;
  338. }
  339. }
  340. .btn-view {
  341. min-height: 70rpx;
  342. margin: 5rpx 5rpx;
  343. display: flex;
  344. flex-direction: row;
  345. .description {
  346. size: 25rpx;
  347. color: #999999;
  348. .text {
  349. margin: 20rpx 0rpx;
  350. }
  351. .title {
  352. color: #5f5d5f;
  353. }
  354. }
  355. }
  356. .evaluate {
  357. padding: 20rpx 0;
  358. display: flex;
  359. justify-content: flex-end;
  360. }
  361. }
  362. </style>