list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <view class="bg">
  3. <u-sticky>
  4. <view class="pad-t-10 ">
  5. <view class="flex-items bg-white pad-16" @tap="goSearch">
  6. <uni-icons type="search" color="#a8a8a8" size="28"></uni-icons>
  7. <view v-if="params.orderCode" class="font28">
  8. {{params.orderCode}}
  9. </view>
  10. <view class="font-gray font28" v-else>
  11. 请输入订单号或商品名称
  12. </view>
  13. </view>
  14. </view>
  15. <view class="bg-white">
  16. <u-tabs :current="current" lineWidth="30" :list="tabList" @click="tabClick"></u-tabs>
  17. </view>
  18. </u-sticky>
  19. <view v-if="orderList.length>0">
  20. <view v-for="(item,index) in orderList" :key="index">
  21. <view class="info-region">
  22. <view @tap="goDetail(item)">
  23. <view class="flex-items flex-sp-between mar-b-20 mar-lr-12">
  24. <view>
  25. 订单号:{{item.orderCode}}
  26. </view>
  27. <view v-if="item.isAfter==0||item.isAfter==3">
  28. <text class="fukuan" v-if="item.status==1">
  29. 待付款
  30. </text>
  31. <text class="daifahuo" v-if="item.status==2">
  32. 待发货
  33. </text>
  34. <text class="shouhuo" v-if="item.status==3">
  35. 待收货
  36. </text>
  37. <text class="pingjia mar-r-10" v-if="item.status==4&&item.isEvaluate==0">
  38. 待评价
  39. </text>
  40. <text class="wancheng" v-if="item.status==4">
  41. 已完成
  42. </text>
  43. </view>
  44. <text class="shouhou" v-if="item.isAfter==1">
  45. 售后中
  46. </text>
  47. <text class="pingjia" v-if="item.isAfter==2">
  48. 售后完成
  49. </text>
  50. </view>
  51. <view class="flex">
  52. <view>
  53. <image class=" mar-l-20 img" :src="item.images" mode="aspectFit"></image>
  54. </view>
  55. <view class="mar-l-20 mar-r-20">
  56. <view class="font32 pad-b-10 ">
  57. {{item.productName}}
  58. </view>
  59. <view class="pad-t-20 font-gray">
  60. 规格: {{item.skuName}}
  61. </view>
  62. </view>
  63. </view>
  64. <text class="flex-end font-red font28 font-bold mar-r-10">
  65. 实付款 ¥{{item.paymentPrice}}
  66. </text>
  67. </view>
  68. <view>
  69. <view v-if="item.isAfter===0||item.isAfter===0">
  70. <!-- 待付款状态 -->
  71. <view v-if="item.status === 1" class="flex-items flex-end">
  72. <view class=" mar-t-20 mar-r-10">
  73. <view class="buyBtn" @click="payOrder(item)">
  74. 去付款
  75. </view>
  76. </view>
  77. <view class=" mar-t-20 mar-r-10">
  78. <view class="cancelBtn" @click="cancelOrder(item)">
  79. 取消订单
  80. </view>
  81. </view>
  82. </view>
  83. <!-- 待发货状态 -->
  84. <view v-if="item.status === 2" class="flex-items flex-end">
  85. <view class=" mar-t-20 mar-r-10">
  86. <view class="cancelBtn" @click="after(item)">
  87. 申请售后
  88. </view>
  89. </view>
  90. <view class=" mar-t-20 mar-r-10" v-if="item.status === 2">
  91. <view class="buyBtn" @click="onceOrder(item)">
  92. 再来一单
  93. </view>
  94. </view>
  95. </view>
  96. <!-- 待收货状态 -->
  97. <view v-if="item.status === 3" class="flex-items flex-end">
  98. <view class=" mar-t-20 mar-r-10">
  99. <view class="cancelBtn" @click="logistics(item)">
  100. 查看物流
  101. </view>
  102. </view>
  103. <view class=" mar-t-20 mar-r-10">
  104. <view class="cancelBtn" @click="after(item)">
  105. 申请售后
  106. </view>
  107. </view>
  108. <view class=" mar-t-20 mar-r-10">
  109. <view class="buyBtn" @click="confirmReceiptDialog(item)">
  110. 确认收货
  111. </view>
  112. </view>
  113. </view>
  114. <!-- 已完成状态 -->
  115. <view v-if="item.status === 4" class="flex-items flex-end">
  116. <view class=" mar-t-20 mar-r-10">
  117. <view class="cancelBtn" @click="goScore(item)" v-if="item.isEvaluate==0">
  118. 评价
  119. </view>
  120. </view>
  121. <view class=" mar-t-20 mar-r-10">
  122. <view class="cancelBtn" @click="after(item)">
  123. 申请售后
  124. </view>
  125. </view>
  126. <view class=" mar-t-20 mar-r-10">
  127. <view class="buyBtn" @click="onceOrder(item)">
  128. 再来一单
  129. </view>
  130. </view>
  131. </view>
  132. </view>
  133. <!-- 售后中状态 -->
  134. <view class=" flex-items flex-end mar-t-20 mar-r-10" v-if="item.isAfter === 1">
  135. <view class="cancelBtn" @click="checkAfterSaleStatus(item)">
  136. 售后进度
  137. </view>
  138. </view>
  139. <!-- 售后完成状态 -->
  140. <view class=" flex-items flex-end mar-t-20 mar-r-10" v-if="item.isAfter === 2">
  141. <view class="cancelBtn" @click="checkAfterSaleStatus(item)">
  142. 售后详情
  143. </view>
  144. </view>
  145. </view>
  146. </view>
  147. </view>
  148. </view>
  149. <view v-else>
  150. <view class="flex-items-plus">
  151. <image src="../../static/images/empty.png" class="empty "></image>
  152. </view>
  153. <view class="font28 font-gray flex-items-plus">
  154. 数据为空
  155. </view>
  156. </view>
  157. <CustomToast ref="customToast" />
  158. <uni-popup ref="dialog" type="dialog">
  159. <uni-popup-dialog type="warn" cancelText="取消" confirmText="确认" title="提示" content="确认收货?"
  160. @confirm="confirmReceipt()"></uni-popup-dialog>
  161. </uni-popup>
  162. </view>
  163. </template>
  164. <script>
  165. import CustomToast from '../../components/CustomToast.vue';
  166. import {
  167. getOrderList,
  168. confirmReceipt
  169. } from '../../config/api.js';
  170. export default {
  171. components: {
  172. CustomToast,
  173. },
  174. data() {
  175. return {
  176. current: 0,
  177. searchKey: "",
  178. tabList: [{
  179. name: '全部'
  180. },
  181. {
  182. name: '待付款'
  183. },
  184. {
  185. name: '待发货'
  186. },
  187. {
  188. name: '待收货'
  189. },
  190. {
  191. name: '已完成'
  192. },
  193. {
  194. name: '售后'
  195. },
  196. {
  197. name: '待评价'
  198. }
  199. ],
  200. orderList: [],
  201. isFirstLoad: true, // 新增标志位,用于判断是否是首次加载
  202. params: {
  203. current: 1,
  204. size: 10,
  205. status: "",
  206. isAfter: "",
  207. isEvaluate: "",
  208. type: "",
  209. orderCode: ""
  210. },
  211. form: {},
  212. };
  213. },
  214. onLoad(op) {
  215. if (op.serachKey) {
  216. this.params.orderCode = op.serachKey;
  217. }
  218. console.log(op);
  219. if (op.status && op.status != 0) {
  220. this.params.status = op.status;
  221. this.current = op.status;
  222. }
  223. if (op.isAfter) {
  224. this.params.isAfter = op.isAfter;
  225. this.current = 5;
  226. }
  227. if (op.isEvaluate) {
  228. this.params.isEvaluate = op.isEvaluate;
  229. this.current = 6;
  230. }
  231. this.getList();
  232. setTimeout(() => {
  233. this.isFirstLoad = false; // 首次加载完成,将标志位设为 false
  234. }, 1000)
  235. },
  236. onPullDownRefresh() {
  237. this.reset()
  238. uni.stopPullDownRefresh();
  239. },
  240. onShow() {
  241. if (!this.isFirstLoad) {
  242. // 如果不是首次加载,再调用 getList 方法
  243. this.getList();
  244. }
  245. },
  246. methods: {
  247. goScore(item) {
  248. this.$route('/pages/order/score?orderId=' + item.id)
  249. },
  250. reset() {
  251. this.orderList = [];
  252. this.params.current = 1;
  253. this.getList();
  254. },
  255. after(item) {
  256. this.$route('/pages/order/after?id=' + item.id);
  257. },
  258. logistics(item) {
  259. this.$route('/pages/order/logistics?expressCode=' + item.expressCode);
  260. },
  261. onceOrder(item) {
  262. console.log(item, "item");
  263. this.$route('/packageShop/pages/detail/index?skuId=' + item.skuId + '&id=' + item.productId);
  264. },
  265. goSearch() {
  266. this.$route('/pages/order/search?type=2');
  267. },
  268. goDetail(item) {
  269. this.$route('/pages/order/detail?id=' + item.id);
  270. },
  271. tabClick(item) {
  272. console.log(item);
  273. if (item.index == 6) {
  274. this.params.isEvaluate = 0;
  275. this.params.isAfter = ""
  276. this.params.status = ""
  277. } else if (item.index == 5) {
  278. this.params.isAfter = 1
  279. this.params.status = ""
  280. this.params.isEvaluate = ""
  281. } else {
  282. this.params.status = item.index;
  283. this.params.isAfter = ""
  284. this.params.isEvaluate = ""
  285. }
  286. this.getList();
  287. },
  288. // 订单列表
  289. getList() {
  290. getOrderList(this.params).then((res) => {
  291. this.orderList = res.data.records;
  292. });
  293. },
  294. payOrder(item) {
  295. // 跳转到支付页面
  296. this.$route('/pages/order/payment?orderId=' + item.id);
  297. },
  298. cancelOrder(item) {
  299. // 实现取消订单逻辑
  300. console.log('取消订单,订单号:', item.orderCode);
  301. },
  302. confirmReceiptDialog(item) {
  303. this.$refs.dialog.open()
  304. this.form = item
  305. },
  306. confirmReceipt() {
  307. confirmReceipt(this.form).then((res) => {
  308. if (res.code == 200) {
  309. this.$refs.dialog.close()
  310. this.$refs.customToast.showToast('操作成功');
  311. this.reset()
  312. }
  313. })
  314. },
  315. checkAfterSaleStatus(item) {
  316. // 实现查看售后进度逻辑
  317. this.$route('/pages/order/after-progress?orderId=' + item.id);
  318. }
  319. }
  320. };
  321. </script>
  322. <style lang="scss">
  323. .bg {
  324. min-height: 100vh;
  325. padding-bottom: 20rpx;
  326. // background: linear-gradient(135deg, #f8ffee 0%, #fffff6 100%);
  327. }
  328. .info-region {
  329. /* 阴影效果 */
  330. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  331. border-radius: 15rpx;
  332. width: 720rpx;
  333. height: auto;
  334. padding: 15rpx;
  335. background-color: white;
  336. margin-top: 10rpx;
  337. margin-bottom: 20rpx;
  338. margin-left: 15rpx;
  339. }
  340. .img {
  341. border-radius: 20rpx;
  342. width: 200rpx;
  343. height: 200rpx;
  344. }
  345. .daifahuo {
  346. color: #ffffff;
  347. background-color: #e2c696;
  348. padding: 4rpx 10rpx 4rpx 10rpx;
  349. border-radius: 20rpx;
  350. }
  351. .fukuan {
  352. color: #ffffff;
  353. background-color: #e29c6d;
  354. padding: 4rpx 10rpx 4rpx 10rpx;
  355. border-radius: 20rpx;
  356. }
  357. .shouhuo {
  358. color: #ffffff;
  359. background-color: #e2d972;
  360. padding: 4rpx 10rpx 4rpx 10rpx;
  361. border-radius: 20rpx;
  362. }
  363. .wancheng {
  364. color: #ffffff;
  365. background-color: #83e25a;
  366. padding: 4rpx 10rpx 4rpx 10rpx;
  367. border-radius: 20rpx;
  368. }
  369. .pingjia {
  370. color: #ffffff;
  371. background-color: #e0e2d9;
  372. padding: 4rpx 10rpx 4rpx 10rpx;
  373. border-radius: 20rpx;
  374. }
  375. .shouhou {
  376. color: #ffffff;
  377. background-color: #e23e3e;
  378. padding: 4rpx 10rpx 4rpx 10rpx;
  379. border-radius: 20rpx;
  380. }
  381. .buyBtn {
  382. font-size: 30rpx;
  383. width: 160rpx;
  384. height: 50rpx;
  385. text-align: center;
  386. line-height: 50rpx;
  387. border-radius: 36rpx;
  388. color: #fff;
  389. background: #E2A28A;
  390. }
  391. .cancelBtn {
  392. font-size: 30rpx;
  393. width: 160rpx;
  394. height: 50rpx;
  395. text-align: center;
  396. line-height: 50rpx;
  397. border-radius: 36rpx;
  398. color: #6a6a6a;
  399. background: #e2e2e2;
  400. }
  401. .custom-easyinput {
  402. border: none;
  403. /* 取消边框 */
  404. outline: none;
  405. /* 取消聚焦时的轮廓线 */
  406. }
  407. </style>