index.vue 16 KB

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