index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  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. </view>
  45. <view class="flex">
  46. <view>
  47. <image class=" mar-l-20 img" :src="item.images" mode="aspectFit"></image>
  48. </view>
  49. <view class="mar-l-20 mar-r-20">
  50. <view class="font32 pad-b-10 ">
  51. {{item.productName}}
  52. </view>
  53. <view class="pad-t-10 font-gray font26"
  54. v-if="item.productCount && item.productCount > 1">
  55. 共{{item.productCount}}件商品
  56. </view>
  57. <view class="pad-t-20 font-gray">
  58. 规格: {{item.skuName}}
  59. </view>
  60. </view>
  61. </view>
  62. <text class="flex-end font-red font28 font-bold mar-r-10">
  63. 实付款 ¥{{item.paymentPrice}}
  64. </text>
  65. </view>
  66. <view>
  67. <view v-if="item.isAfter===0||item.isAfter===0">
  68. <!-- 待付款状态 -->
  69. <view v-if="item.status === 1" class="flex-items flex-end">
  70. <view class=" mar-t-20 mar-r-10">
  71. <view class="buyBtn" @click="payOrder(item)">
  72. 去付款
  73. </view>
  74. </view>
  75. <view class=" mar-t-20 mar-r-10">
  76. <view class="cancelBtn" @click="cancelOrder(item)">
  77. 取消订单
  78. </view>
  79. </view>
  80. </view>
  81. <!-- 待发货状态 -->
  82. <view v-if="item.status === 2" class="flex-items flex-end">
  83. <view class=" mar-t-20 mar-r-10" v-if="item.status === 2">
  84. <view class="buyBtn" @click="onceOrder(item)">
  85. 再来一单
  86. </view>
  87. </view>
  88. </view>
  89. <!-- 待收货状态 -->
  90. <view v-if="item.status === 3" class="flex-items flex-end">
  91. <view class=" mar-t-20 mar-r-10">
  92. <view class="cancelBtn" @click="logistics(item)">
  93. 查看物流
  94. </view>
  95. </view>
  96. <view class=" mar-t-20 mar-r-10">
  97. <view class="buyBtn" @click="confirmReceiptDialog(item)">
  98. 确认收货
  99. </view>
  100. </view>
  101. </view>
  102. <!-- 已完成状态 -->
  103. <view v-if="item.status === 4" class="flex-items flex-end">
  104. <view class=" mar-t-20 mar-r-10">
  105. <view class="cancelBtn" @click="goScore(item)" v-if="item.isEvaluate==0">
  106. 评价
  107. </view>
  108. </view>
  109. <view class=" mar-t-20 mar-r-10">
  110. <view class="buyBtn" @click="onceOrder(item)">
  111. 再来一单
  112. </view>
  113. </view>
  114. </view>
  115. </view>
  116. <!-- 售后中状态 -->
  117. <view class=" flex-items flex-end mar-t-20 mar-r-10" v-if="item.isAfter === 1">
  118. <view class="cancelBtn" @click="checkAfterSaleStatus(item)">
  119. 售后进度
  120. </view>
  121. </view>
  122. <!-- 售后完成状态 -->
  123. <view class=" flex-items flex-end mar-t-20 mar-r-10" v-if="item.isAfter === 2">
  124. <view class="cancelBtn" @click="checkAfterSaleStatus(item)">
  125. 售后详情
  126. </view>
  127. </view>
  128. </view>
  129. </view>
  130. </view>
  131. </view>
  132. <view v-else>
  133. <view class="flex-items-plus">
  134. <image src="@/static/images/empty.png" class="empty "></image>
  135. </view>
  136. <view class="font28 font-gray flex-items-plus">
  137. 数据为空
  138. </view>
  139. </view>
  140. <u-toast ref="uToast"></u-toast>
  141. <uni-popup ref="dialog" type="dialog">
  142. <uni-popup-dialog type="warn" cancelText="取消" confirmText="确认" title="提示" content="确认收货?"
  143. @confirm="confirmReceipt()"></uni-popup-dialog>
  144. </uni-popup>
  145. </view>
  146. </template>
  147. <script>
  148. import CustomToast from '@/uni_modules/custom-components/components/custom-toast/custom-toast.vue';
  149. import {
  150. getOrderList,
  151. confirmReceipt,
  152. cancelOrder
  153. } from '@/config/api.js';
  154. export default {
  155. components: {
  156. CustomToast
  157. },
  158. data() {
  159. return {
  160. current: 0,
  161. searchKey: "",
  162. tabList: [{
  163. name: '全部'
  164. },
  165. {
  166. name: '待付款'
  167. },
  168. {
  169. name: '待发货'
  170. },
  171. {
  172. name: '待收货'
  173. },
  174. {
  175. name: '已完成'
  176. },
  177. {
  178. name: '待评价'
  179. }
  180. ],
  181. orderList: [],
  182. isFirstLoad: true,
  183. params: {
  184. current: 1,
  185. size: 10,
  186. status: "",
  187. isAfter: "",
  188. isEvaluate: "",
  189. type: "",
  190. orderCode: ""
  191. },
  192. form: {},
  193. };
  194. },
  195. onLoad(op) {
  196. if (op.serachKey) {
  197. this.params.orderCode = op.serachKey;
  198. }
  199. console.log(op);
  200. if (op.status && op.status != 0) {
  201. this.params.status = op.status;
  202. this.current = op.status;
  203. }
  204. if (op.isAfter) {
  205. this.params.isAfter = op.isAfter;
  206. this.current = 5;
  207. }
  208. if (op.isEvaluate) {
  209. this.params.isEvaluate = op.isEvaluate;
  210. this.current = 6;
  211. }
  212. this.getList();
  213. setTimeout(() => {
  214. this.isFirstLoad = false;
  215. }, 1000)
  216. },
  217. onPullDownRefresh() {
  218. this.reset()
  219. uni.stopPullDownRefresh();
  220. },
  221. onShow() {
  222. console.log(this.isFirstLoad, "11")
  223. if (!this.isFirstLoad) {
  224. this.getList();
  225. }
  226. },
  227. methods: {
  228. goScore(item) {
  229. this.isFirstLoad = false
  230. this.$route('/packageOrder/pages/score/index?orderId=' + item.id)
  231. },
  232. reset() {
  233. this.orderList = [];
  234. this.params.current = 1;
  235. this.getList();
  236. },
  237. after(item) {
  238. this.$route('/packageOrder/pages/after-sale/index?id=' + item.id);
  239. },
  240. logistics(item) {
  241. this.$route('/packageOrder/pages/logistics/index?expressCode=' + item.expressCode);
  242. },
  243. onceOrder(item) {
  244. this.$route('/packageShop/pages/detail/index?skuId=' + item.skuId + '&id=' + item.productId);
  245. },
  246. goSearch() {
  247. this.$route('/packageShop/pages/search/index?type=2');
  248. },
  249. goDetail(item) {
  250. this.$route('/packageOrder/pages/detail/index?id=' + item.id);
  251. },
  252. tabClick(item) {
  253. console.log(item);
  254. if (item.index == 5) {
  255. this.params.isEvaluate = 0;
  256. this.params.isAfter = ""
  257. this.params.status = ""
  258. } else {
  259. this.params.status = item.index;
  260. this.params.isAfter = ""
  261. this.params.isEvaluate = ""
  262. }
  263. this.getList();
  264. },
  265. getList() {
  266. getOrderList(this.params).then((res) => {
  267. this.orderList = res.data.records;
  268. });
  269. },
  270. payOrder(item) {
  271. this.$route('/packageOrder/pages/payment/index?orderId=' + item.id);
  272. },
  273. async cancelOrder(item) {
  274. try {
  275. // 确认对话框
  276. const result = await new Promise((resolve) => {
  277. uni.showModal({
  278. title: '提示',
  279. content: '确定要取消订单:' + item.orderCode + ' 吗?',
  280. confirmText: '确定',
  281. cancelText: '取消',
  282. success: (res) => {
  283. resolve(res.confirm);
  284. }
  285. });
  286. });
  287. if (!result) {
  288. return;
  289. }
  290. // 调用取消订单接口
  291. const response = await cancelOrder({
  292. id: item.id
  293. });
  294. if (response.code === 200) {
  295. this.showToast('取消订单成功');
  296. // 重新获取订单列表
  297. this.reset();
  298. } else {
  299. this.showToast(response.msg || '取消订单失败');
  300. }
  301. } catch (e) {
  302. console.error('取消订单失败:', e);
  303. this.showToast('取消订单失败');
  304. }
  305. },
  306. confirmReceiptDialog(item) {
  307. this.$refs.dialog.open()
  308. this.form = item
  309. },
  310. showToast(text) {
  311. this.$refs.uToast.show({
  312. type: 'success',
  313. message: text
  314. })
  315. },
  316. confirmReceipt() {
  317. confirmReceipt(this.form).then((res) => {
  318. if (res.code == 200) {
  319. this.$refs.dialog.close()
  320. this.showToast('操作成功')
  321. this.reset()
  322. }
  323. })
  324. },
  325. checkAfterSaleStatus(item) {
  326. this.$route('/packageOrder/pages/after-sale/index?orderId=' + item.id);
  327. }
  328. }
  329. };
  330. </script>
  331. <style lang="scss">
  332. .bg {
  333. min-height: 100vh;
  334. padding-bottom: 20rpx;
  335. }
  336. .info-region {
  337. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  338. border-radius: 15rpx;
  339. width: 720rpx;
  340. height: auto;
  341. padding: 15rpx;
  342. background-color: white;
  343. margin-top: 10rpx;
  344. margin-bottom: 20rpx;
  345. margin-left: 15rpx;
  346. }
  347. .img {
  348. border-radius: 20rpx;
  349. width: 200rpx;
  350. height: 200rpx;
  351. }
  352. .daifahuo {
  353. color: #ffffff;
  354. background-color: #e2c696;
  355. padding: 4rpx 10rpx 4rpx 10rpx;
  356. border-radius: 20rpx;
  357. }
  358. .fukuan {
  359. color: #ffffff;
  360. background-color: #e29c6d;
  361. padding: 4rpx 10rpx 4rpx 10rpx;
  362. border-radius: 20rpx;
  363. }
  364. .shouhuo {
  365. color: #ffffff;
  366. background-color: #e2d972;
  367. padding: 4rpx 10rpx 4rpx 10rpx;
  368. border-radius: 20rpx;
  369. }
  370. .wancheng {
  371. color: #ffffff;
  372. background-color: #83e25a;
  373. padding: 4rpx 10rpx 4rpx 10rpx;
  374. border-radius: 20rpx;
  375. }
  376. .pingjia {
  377. color: #ffffff;
  378. background-color: #e0e2d9;
  379. padding: 4rpx 10rpx 4rpx 10rpx;
  380. border-radius: 20rpx;
  381. }
  382. .shouhou {
  383. color: #ffffff;
  384. background-color: #e23e3e;
  385. padding: 4rpx 10rpx 4rpx 10rpx;
  386. border-radius: 20rpx;
  387. }
  388. .buyBtn {
  389. font-size: 30rpx;
  390. width: 160rpx;
  391. height: 50rpx;
  392. text-align: center;
  393. line-height: 50rpx;
  394. border-radius: 36rpx;
  395. color: #fff;
  396. background: #E2A28A;
  397. }
  398. .cancelBtn {
  399. font-size: 30rpx;
  400. width: 160rpx;
  401. height: 50rpx;
  402. text-align: center;
  403. line-height: 50rpx;
  404. border-radius: 36rpx;
  405. color: #666666;
  406. background: #f5f5f5;
  407. }
  408. .empty {
  409. width: 400rpx;
  410. height: 400rpx;
  411. margin-top: 200rpx;
  412. }
  413. .nav-back {
  414. position: fixed;
  415. left: 30rpx;
  416. top: calc(var(--status-bar-height) + 20rpx);
  417. z-index: 100;
  418. .back-btn {
  419. width: 80rpx;
  420. height: 80rpx;
  421. background: rgba(255, 255, 255, 0.8);
  422. border: 1rpx solid rgba(0, 0, 0, 0.1);
  423. border-radius: 50%;
  424. display: flex;
  425. align-items: center;
  426. justify-content: center;
  427. transition: all 0.3s ease;
  428. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  429. &:active {
  430. transform: scale(0.95);
  431. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.15);
  432. }
  433. }
  434. .back-icon {
  435. font-family: "iconfont";
  436. font-size: 36rpx;
  437. color: #333;
  438. }
  439. }
  440. </style>