index.vue 17 KB

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