index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. <!-- 我的订单 -->
  2. <template>
  3. <view class="order">
  4. <view class="tabs">
  5. <u-tabs :list="tabLists" lineWidth="40" lineHeight="8" :lineColor="`url(${lineBg}) 100% 100%`" :activeStyle="{
  6. color: '#0D121A',
  7. fontSize: '32rpx',
  8. fontWeight: 'bold',
  9. transform: 'scale(1.05)'
  10. }" :inactiveStyle="{
  11. color: '#9EA3B1',
  12. fontSize: '28rpx',
  13. transform: 'scale(1)'
  14. }" itemStyle="padding-left: 18px; padding-right: 18px; height: 56px;" @click="tabsChange">
  15. </u-tabs>
  16. </view>
  17. <view class="content">
  18. <mescroll-body height="100%" class="custom-height" ref="mescrollRef" @init="mescrollInit" @down="downCallback"
  19. :up="upOption" @up="upCallback">
  20. <view class="order-list" v-if="arrList && arrList.length">
  21. <view class="tab-content" v-for="(item, index) in arrList" :key="index">
  22. <view class="order-top flex-start">
  23. <text class="name">{{ item.packageName }}({{ item.quantity }})</text>
  24. <text v-if="item.paymentStatus==='CANCELLED'" class="status cancel">{{
  25. item.paymentStatus | orderStatus
  26. }}
  27. </text>
  28. <text v-else-if="item.paymentStatus==='REFUNDED'" class="status cancel">
  29. {{ item.paymentStatus | orderStatus }}
  30. </text>
  31. <text v-else class="status color">{{ item.paymentStatus | orderStatus }}</text>
  32. </view>
  33. <view class="order-middle flex-between-no-center">
  34. <view class="order-middle-left">
  35. <view class="fs28 mt-4 fw400" v-for="(content, contentIndex) in item.packageContents"
  36. :key="contentIndex">{{ content }}
  37. </view>
  38. </view>
  39. <view class="order-middle-right flex-start" v-if="item.paymentStatus==='WAIT_PAYMENT'">
  40. <view class="right-label fs24">应付款</view>
  41. <view class="fs28 fw ml-6"> ¥{{ item.totalAmount }}</view>
  42. </view>
  43. <view class="order-middle-right" v-if="item.paymentStatus==='SHOOTING'">
  44. <view class="progress-bar">
  45. <view class="progress" :style="{ width: (item.completedQuantity/item.quantity)*100+ '%' }">{{item.completedQuantity/item.quantity*100}}%</view>
  46. </view>
  47. <!-- <view class="progress-container">{{item.completedQuantity}}/{{item.quantity}}</view>-->
  48. </view>
  49. <view class="order-middle-right cancel flex-start" v-if="item.paymentStatus==='REFUNDED'">
  50. <view class="right-label fs24 ">已退款</view>
  51. <view class="fs28 fw ml-6"> ¥{{ item.totalAmount }}</view>
  52. </view>
  53. </view>
  54. <view v-if="item.paymentStatus==='WAIT_PAYMENT'" class="order-bottom flex-between">
  55. <view class="order-bottom-left">
  56. </view>
  57. <view class="order-bottom-right flex">
  58. <view class="btn btn1 p2" @click="cancelOrder(item.orderId)">取消</view>
  59. <view class="btn btn2 p1" @click="submitOrder(item)">支付</view>
  60. <!-- <view class="btn3">寄样</view> -->
  61. </view>
  62. </view>
  63. <view v-else class="order-bottom flex-between">
  64. <view class="flex-start">
  65. <view class="fs24">实付款</view>
  66. <view class="fs28 fw ml-6"> ¥{{ item.totalAmount }}</view>
  67. </view>
  68. <view class="order-bottom-right flex">
  69. <view class="btn btn1 p2" v-if="item.paymentStatus==='WAIT_PAYMENT'" @click="cancelOrder(item.orderId)">
  70. 取消
  71. </view>
  72. <view class="btn btn1 p2" v-if="item.paymentStatus==='WAIT_SEND'" @click="cancelOrder(item.orderId)">
  73. 取消
  74. </view>
  75. <view class="btn btn1 p2" v-if="item.paymentStatus==='WAIT_ORDER'" @click="cancelOrder(item.orderId)">
  76. 取消
  77. </view>
  78. <view v-if="item.paymentStatus==='WAIT_SEND'" class="btn btn1 p2 ml-6">寄样</view>
  79. <view class="btn btn1 p2" v-if="item.paymentStatus==='SHOOTING'" @click="cancelOrder(item.orderId)">申请售后
  80. </view>
  81. <view class="btn btn1 p2" v-if="item.paymentStatus==='DELIVERED'"
  82. @click="aftermarketOrder(item.orderId)">申请售后
  83. </view>
  84. <view class="btn btn1 p2" v-if="item.paymentStatus==='WAIT_CHECK'"
  85. @click="aftermarketOrder(item.orderId)">申请售后
  86. </view>
  87. <view class="btn btn1 p2" v-if="item.paymentStatus==='AFTER_SALE'"
  88. @click="cancelAftermarketOrder(item.orderId)">撤回申请
  89. </view>
  90. <view class="btn btn1 p2 ml-6" v-if="item.paymentStatus==='WAIT_CHECK'"
  91. @click="checkOrder(item.orderId)">确认验收
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. <no-data :statusType="2" tipsText="暂无记录" v-if="!isInit && !arrList.length"></no-data>
  98. </mescroll-body>
  99. </view>
  100. </view>
  101. </template>
  102. <script>
  103. import MescrollMixin from "@/plugins/mescroll/components/mescroll-uni/mescroll-mixins.js";
  104. import MescrollBody from '@/plugins/mescroll/components/mescroll-uni/mescroll-uni.vue';
  105. import {
  106. aftermarketOrder,
  107. cancelAftermarketOrder,
  108. checkOrder,
  109. cancelOrder,
  110. getOrderListPage,
  111. updateOrder
  112. } from "../../apis/order";
  113. import {submitOrder} from "../../apis";
  114. export default {
  115. mixins: [MescrollMixin],
  116. components: {
  117. MescrollBody
  118. },
  119. data() {
  120. return {
  121. page: 1,
  122. limit: 10,
  123. lineBg: 'https://ovp-shop.oss-cn-hangzhou.aliyuncs.com/static/9dshop/ic_line.png',
  124. timeImg: 'https://ovp-shop.oss-cn-hangzhou.aliyuncs.com/static/9dshop/ic_time.png',
  125. arrList: [],
  126. isInit: false,
  127. paymentStatus: 'WAIT_PAYMENT',
  128. tabLists: [{name: '待付款', value: 'WAIT_PAYMENT'},
  129. {name: '待接单', value: 'WAIT_ORDER'},
  130. {name: '待寄样', value: 'WAIT_SEND'},
  131. {name: '拍摄中', value: 'SHOOTING'},
  132. {name: '待验收', value: 'WAIT_CHECK'},
  133. {name: '已交付', value: 'DELIVERED'},
  134. {name: '售后中', value: 'AFTER_SALE'},
  135. {name: '已取消', value: 'CANCELLED'},
  136. {name: '已退款', value: 'REFUNDED'}]
  137. };
  138. },
  139. computed: {},
  140. watch: {},
  141. onLoad() {
  142. this.getOrderListPage()
  143. },
  144. filters: {
  145. orderStatus(value) {
  146. const orderStatusList =
  147. [{name: '待付款', value: 'WAIT_PAYMENT'},
  148. {name: '待接单', value: 'WAIT_ORDER'},
  149. {name: '待寄样', value: 'WAIT_SEND'},
  150. {name: '拍摄中', value: 'SHOOTING'},
  151. {name: '待验收', value: 'WAIT_CHECK'},
  152. {name: '已交付', value: 'DELIVERED'},
  153. {name: '售后中', value: 'AFTER_SALE'},
  154. {name: '已取消', value: 'CANCELLED'},
  155. {name: '已退款', value: 'REFUNDED'}
  156. ]
  157. const orderItem = orderStatusList.find(item => item.value === value)
  158. return orderItem ? orderItem.name : ''
  159. }
  160. },
  161. methods: {
  162. submitOrder(params) {
  163. submitOrder({
  164. ...params
  165. }).then((res) => {
  166. // 检查是否在微信浏览器中
  167. if (typeof WeixinJSBridge === 'undefined') {
  168. if (document.addEventListener) {
  169. document.addEventListener('WeixinJSBridgeReady', () => {
  170. this.invokePayment(res);
  171. }, false);
  172. } else if (document.attachEvent) {
  173. document.attachEvent('WeixinJSBridgeReady', () => {
  174. this.invokePayment(res);
  175. });
  176. document.attachEvent('onWeixinJSBridgeReady', () => {
  177. this.invokePayment(res);
  178. });
  179. }
  180. } else {
  181. this.invokePayment(res);
  182. }
  183. })
  184. },
  185. invokePayment(rePayInfo) {
  186. WeixinJSBridge.invoke(
  187. 'getBrandWCPayRequest',
  188. {
  189. appId: rePayInfo.appid,
  190. timeStamp: rePayInfo.timeStamp,
  191. nonceStr: rePayInfo.nonceStr,
  192. package: rePayInfo.packages,
  193. signType: rePayInfo.signType,
  194. paySign: rePayInfo.sign
  195. },
  196. (res) => {
  197. if (res.err_msg === 'get_brand_wcpay_request:ok') {
  198. uni.navigateTo({
  199. url: '/pages/order/success?orderId=' + rePayInfo.orderId
  200. })
  201. } else if (res.err_msg === 'get_brand_wcpay_request:cancel') {
  202. uni.showToast({
  203. title: '用户取消了支付'
  204. })
  205. } else {
  206. console.error('支付失败', res.err_msg);
  207. // 处理支付失败的逻辑
  208. }
  209. }
  210. );
  211. },
  212. tabsChange(item) {
  213. this.paymentStatus = item.value
  214. this.page = 1
  215. setTimeout(() => {
  216. this.getOrderListPage()
  217. }, 200)
  218. },
  219. getOrderListPage() {
  220. getOrderListPage({
  221. paymentStatus: this.paymentStatus,
  222. page: 1,
  223. limit: 10,
  224. }).then(res => {
  225. this.arrList = res.list
  226. })
  227. },
  228. cancelOrder(orderId) {
  229. const that = this
  230. uni.showModal({
  231. title: '提示',
  232. content: '你确定要取消订单吗?',
  233. success: function (res) {
  234. if (res.confirm) {
  235. cancelOrder({
  236. orderId: Number(orderId)
  237. }).then(() => {
  238. that.arrList.splice(that.arrList.findIndex(item => item.orderId === orderId), 1)
  239. })
  240. } else if (res.cancel) {
  241. console.log('用户点击取消');
  242. }
  243. }
  244. });
  245. },
  246. updateOrder(orderId) {
  247. const that = this
  248. uni.showModal({
  249. title: '提示',
  250. content: '你确定要取消订单吗?',
  251. success: function (res) {
  252. if (res.confirm) {
  253. updateOrder({
  254. orderId: Number(orderId),
  255. }).then(() => {
  256. that.arrList.splice(that.arrList.findIndex(item => item.orderId === orderId), 1)
  257. })
  258. } else if (res.cancel) {
  259. console.log('用户点击取消');
  260. }
  261. }
  262. });
  263. },
  264. checkOrder(orderId) {
  265. const that = this
  266. uni.showModal({
  267. title: '提示',
  268. content: '你确定要验收该订单吗?',
  269. success: function (res) {
  270. if (res.confirm) {
  271. checkOrder({
  272. orderId: Number(orderId),
  273. }).then(() => {
  274. that.arrList.splice(that.arrList.findIndex(item => item.orderId === orderId), 1)
  275. })
  276. } else if (res.cancel) {
  277. console.log('用户点击取消');
  278. }
  279. }
  280. });
  281. },
  282. aftermarketOrder(orderId) {
  283. const that = this
  284. uni.showModal({
  285. title: '提示',
  286. content: '你确定要申请售后吗?',
  287. success: function (res) {
  288. if (res.confirm) {
  289. aftermarketOrder({
  290. orderId: Number(orderId)
  291. }).then(() => {
  292. that.arrList.splice(that.arrList.findIndex(item => item.orderId === orderId), 1)
  293. })
  294. } else if (res.cancel) {
  295. console.log('用户点击取消');
  296. }
  297. }
  298. });
  299. },
  300. cancelAftermarketOrder(orderId) {
  301. const that = this
  302. uni.showModal({
  303. title: '提示',
  304. content: '你确定要撤销售后吗?',
  305. success: function (res) {
  306. if (res.confirm) {
  307. cancelAftermarketOrder({
  308. orderId: Number(orderId)
  309. }).then(() => {
  310. that.arrList.splice(that.arrList.findIndex(item => item.orderId === orderId), 1)
  311. })
  312. } else if (res.cancel) {
  313. console.log('用户点击取消');
  314. }
  315. }
  316. });
  317. },
  318. },
  319. created() {
  320. },
  321. }
  322. </script>
  323. <style lang='scss' scoped>
  324. .order {
  325. height: 100vh;
  326. background-color: #EDEFF5;
  327. display: flex;
  328. flex-direction: column;
  329. .tabs {
  330. background-color: #FFF;
  331. padding: 0 28rpx 12rpx;
  332. }
  333. .content {
  334. flex: 1;
  335. overflow: hidden;
  336. }
  337. .order-list {
  338. padding: 24rpx;
  339. .tab-content {
  340. padding: 40rpx 36rpx;
  341. width: 100%;
  342. // height: 296rpx;
  343. background: #FFFFFF;
  344. border-radius: 24rpx;
  345. margin-bottom: 18rpx;
  346. .order-top {
  347. display: flex;
  348. justify-content: space-between;
  349. align-items: center;
  350. .name {
  351. font-weight: bold;
  352. font-size: 32rpx;
  353. color: #0D121A;
  354. }
  355. .status {
  356. font-size: 28rpx;
  357. color: #FF7441;
  358. }
  359. .status2 {
  360. font-size: 28rpx;
  361. color: #0D121A;
  362. }
  363. .status3 {
  364. font-size: 28rpx;
  365. color: #9EA3B1;
  366. }
  367. }
  368. .order-middle {
  369. margin-top: 32rpx;
  370. color: #0D121A;
  371. .order-middle-left {
  372. font-weight: 400;
  373. font-size: 28rpx;
  374. color: #9EA3B1;
  375. }
  376. .order-middle-right {
  377. }
  378. }
  379. .order-bottom {
  380. margin-top: 16rpx;
  381. .order-bottom-left {
  382. .time-img {
  383. margin-right: 8rpx;
  384. width: 48rpx;
  385. height: 48rpx;
  386. }
  387. .time {
  388. color: #FF7441;
  389. font-size: 24rpx;
  390. }
  391. }
  392. .order-bottom-right {
  393. .p1 {
  394. padding: 18rpx 44rpx;
  395. }
  396. .p2 {
  397. padding: 16rpx 42rpx;
  398. }
  399. .btn {
  400. font-weight: 500;
  401. font-size: 28rpx;
  402. display: flex;
  403. justify-content: center;
  404. align-items: center;
  405. border-radius: 36rpx;
  406. }
  407. .btn1 {
  408. color: #0D121A;
  409. border: 3rpx solid #E2E4EB;
  410. }
  411. .btn2 {
  412. margin-left: 16rpx;
  413. background: #FF7441;
  414. color: #FFF;
  415. }
  416. }
  417. }
  418. }
  419. }
  420. }
  421. .progress-bar {
  422. width: 260rpx;
  423. background-color: #e0e0e0;
  424. border-radius: 9999px;
  425. overflow: hidden;
  426. }
  427. .progress {
  428. height: 30rpx;
  429. background-color: #FF7441;
  430. width: 0%;
  431. text-align: center;
  432. line-height: 30rrpx;
  433. color: white;
  434. font-size: 20rpx;
  435. border-radius: 9999px;
  436. transition: width 0.5s ease;
  437. }
  438. .progress-container {
  439. width: 40rpx; /* 可按需调整宽度 */
  440. height: 20rpx; /* 可按需调整高度 */
  441. background-color: #f26522; /* 橙色,类似图中颜色,可按需调整 */
  442. border-radius: 20px; /* 圆角,让边角变圆润 */
  443. display: flex;
  444. justify-content: center;
  445. align-items: center;
  446. font-size: 20rpx; /* 文字大小,可按需调整 */
  447. color: white; /* 文字颜色 */
  448. font-weight: bold; /* 文字加粗 */
  449. }
  450. .cancel {
  451. color: #9EA3B1 !important;
  452. }
  453. </style>