index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. <template>
  2. <page title="商城订单" ref="pageRef" nav-color="transparent" custom-class="paddingB30">
  3. <tabbar
  4. :data="tabbarData"
  5. :initial="initial"
  6. @change="onChange"
  7. custom-class="paddingX14 marginB7"
  8. />
  9. <view v-if="tableData && tableData.length > 0">
  10. <view v-for="item in tableData" :key="item.tradeNo" class="cell">
  11. <view class="filter" />
  12. <view class="top">
  13. <view class="flex-align-between">
  14. <view class="flex-align">
  15. <view class="font2 color-2">下单时间:{{ item.createTime }}</view>
  16. <view v-if="item.type == 2" class="presell">预售订单</view>
  17. </view>
  18. <view class="color-theme font2">
  19. <text v-if="item.status === 0">待支付</text>
  20. <text v-if="item.status === 99">已完成</text>
  21. <text v-else-if="item.status === 1">待发货</text>
  22. <text v-else-if="item.status === 2">待收货</text>
  23. <text v-else-if="item.status === 10">已取消</text>
  24. <text v-else-if="item.status === 11">超时取消</text>
  25. <text v-else-if="item.status === 12">系统取消</text>
  26. </view>
  27. </view>
  28. <view
  29. v-if="item.status === 0 && !(item.type == 2 && item.paidAmount > 0)"
  30. class="color-2 font2 paddingT5"
  31. >
  32. {{ item.paymentTimeoutTime }}将自动取消该订单,如有优惠券,将自动退回
  33. </view>
  34. </view>
  35. <view class="middle flex-align flex1" @click="showDetail(item)">
  36. <image :src="item.itemList[0].cover" mode="aspectFit" class="img" />
  37. <view class="self-stretch flex-column-between marginL12 flex1" style="width: 0">
  38. <view class="color-1 bold line-ellipsis font4">
  39. {{ item.itemList[0].name }}
  40. </view>
  41. <view class="flex-align-between">
  42. <view class="flex-align">
  43. <view class="color-1 bold font4">
  44. ¥{{ item.itemList[0].price }}
  45. </view>
  46. <view
  47. v-if="
  48. item.status === 0 && item.type == 2 && item.paidAmount > 0
  49. "
  50. class="deposit"
  51. >
  52. 定金:¥{{ item.depositAmount }}
  53. </view>
  54. </view>
  55. <view class="color-1 font2">X{{ item.itemList[0].quantity }}</view>
  56. </view>
  57. <view class="color-theme font2" v-if="item.couponAmount">
  58. 使用优惠券-{{ item.couponAmount }}
  59. </view>
  60. <view v-if="item.status === 0" class="flex-align">
  61. <view class="color-3 font1 flex-align">
  62. <view>总价:</view>
  63. <view>
  64. <text class="font1">¥</text>
  65. <text class="font6 bold">{{ item.totalAmount }}</text>
  66. </view>
  67. </view>
  68. <view class="color-theme font1 flex-align paddingL12">
  69. <view
  70. v-if="
  71. item.type === 1 || (item.type === 2 && item.restFlag === 1)
  72. "
  73. >
  74. 需付款:
  75. </view>
  76. <view v-if="item.type === 2 && !item.restFlag">需付定金:</view>
  77. <view>
  78. <text class="font1">¥</text>
  79. <text
  80. v-if="
  81. item.type === 1 ||
  82. (item.type === 2 && item.restFlag === 1)
  83. "
  84. class="font6 bold"
  85. >
  86. {{ item.paymentAmount - item.paidAmount }}
  87. </text>
  88. <text
  89. v-if="item.type === 2 && !item.restFlag"
  90. class="font6 bold"
  91. >
  92. {{ item.depositAmount }}
  93. </text>
  94. </view>
  95. </view>
  96. </view>
  97. <view v-else class="color-theme flex-align">
  98. <view class="color-3 font1 flex-align">
  99. <view>总价:</view>
  100. <view>
  101. <text class="font1">¥</text>
  102. <text class="font6 bold">{{ item.totalAmount }}</text>
  103. </view>
  104. </view>
  105. <view class="color-theme font1 flex-align paddingL12">
  106. <text class="font2">实付款:</text>
  107. <text class="font8 bold">¥{{ item.paidAmount }}</text>
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. <view class="paddingY12 flex-align">
  113. <view class="font2 line-ellipsis flex1" style="width: 0">
  114. 订单号:{{ item.tradeNo }}
  115. </view>
  116. <button
  117. class="btn-clear copy flex-shrink0"
  118. @click.stop="$common.copy(item.tradeNo)"
  119. >
  120. 复制
  121. </button>
  122. </view>
  123. <view class="paddingB12 flex-align-end">
  124. <view v-if="item.status === 0" class="paddingL18 flex-shrink0">
  125. <button class="cm-plain-btn btn" @click.stop="realPay(item)">付款</button>
  126. </view>
  127. <view v-if="item.status === 1" class="paddingL10 flex-shrink0">
  128. <button class="cm-plain-btn btn info" @click.stop="showAddress(item)">
  129. 修改地址
  130. </button>
  131. </view>
  132. <button
  133. v-if="item.status === 2"
  134. class="btn"
  135. style="padding: 0 10rpx; margin: 0 10rpx"
  136. @click.stop="receive(item)"
  137. >
  138. 确认收货
  139. </button>
  140. <button
  141. v-if="[2, 99].includes(item.status)"
  142. class="btn"
  143. style="padding: 0 10rpx; margin: 0 10rpx"
  144. @click.stop="showExpress(item)"
  145. >
  146. 物流信息
  147. </button>
  148. </view>
  149. </view>
  150. </view>
  151. <empty v-if="isEmpty" :top="200" light />
  152. </page>
  153. </template>
  154. <script>
  155. import { LEVEL_MAP } from '@/utils/config'
  156. import tabbar from '@/components/tabbar'
  157. import empty from '@/components/empty'
  158. import pageMixin from './../../mixin/page'
  159. import loginMixin from '@/mixin/login'
  160. import { baseEncode } from '../../utils/utils'
  161. export default {
  162. mixins: [pageMixin, loginMixin],
  163. components: { tabbar, empty },
  164. data() {
  165. return {
  166. LEVEL_MAP,
  167. initial: 0,
  168. tabbarData: [
  169. {
  170. label: '全部',
  171. value: 'all'
  172. },
  173. {
  174. label: '待支付',
  175. value: 'to_pay'
  176. },
  177. {
  178. label: '待补款',
  179. value: 'to_payLeft'
  180. },
  181. {
  182. label: '待发货',
  183. value: 'to_delivery'
  184. },
  185. {
  186. label: '待收货',
  187. value: 'to_receive'
  188. },
  189. {
  190. label: '已完成',
  191. value: 'complete'
  192. },
  193. {
  194. label: '未完成',
  195. value: 'uncomplete'
  196. }
  197. ],
  198. index: 0
  199. }
  200. },
  201. computed: {
  202. itemWidth() {
  203. let width = this.$store.state.systemInfo.screenWidth
  204. width = (width - 28 - 30 - 16) / 5
  205. let height = (91 / 60) * width
  206. return { width, height }
  207. },
  208. payInfo() {
  209. return this.$store.state.payInfo
  210. }
  211. },
  212. watch: {
  213. payInfo(val) {
  214. if (val && val.payResult == 'SUCCESS') {
  215. this.paySuccess(val)
  216. } else if (val && val.payResult !== 'SUCCESS') {
  217. }
  218. }
  219. },
  220. onLoad(options) {
  221. this.initial = options.active || 0
  222. this.index = this.initial
  223. if (this.$store.state.hide == 1) {
  224. this.$service.user.getHide()
  225. }
  226. },
  227. mounted() {
  228. setTimeout(() => {
  229. this.refresh(true)
  230. }, 100)
  231. },
  232. onPullDownRefresh() {
  233. this.refresh()
  234. },
  235. onReachBottom() {
  236. this.loadMore()
  237. },
  238. methods: {
  239. init() {
  240. this.refresh()
  241. },
  242. async loadData(loading) {
  243. const item = this.tabbarData[this.index]
  244. const res = await this.$service.mall.orders(
  245. this.pageNum,
  246. this.pageSize,
  247. item.value,
  248. loading
  249. )
  250. return res
  251. },
  252. onChange(index) {
  253. this.index = index
  254. this.refresh(true)
  255. },
  256. showDetail(item) {
  257. this.$router.push('order_product_detail', { tradeNo: item.tradeNo })
  258. },
  259. showExpress(item) {
  260. this.$router.push('packages', { type: 1, tradeNo: item.deliveryTradeNo })
  261. },
  262. async realPay(item) {
  263. const res = await this.$service.mall.orderPay(item.tradeNo, 'ALIPAY_APP')
  264. if (res) {
  265. if (res.paySuccess) {
  266. this.refresh()
  267. if (this.$store.state.hide == 1) {
  268. this.$service.user.getHide()
  269. }
  270. return
  271. }
  272. let self = this
  273. // 支付宝支付
  274. uni.requestPayment({
  275. provider: 'alipay',
  276. orderInfo: res.payInfo,
  277. success: function (res) {
  278. self.close()
  279. if (self.$store.state.hide == 1) {
  280. self.$service.user.getHide()
  281. }
  282. self.$router.push('order_product')
  283. },
  284. fail: function (err) {
  285. console.log('fail:' + JSON.stringify(err));
  286. }
  287. });
  288. return
  289. }
  290. },
  291. // wechatPay(data) {
  292. // let payInfo = data.payInfo
  293. // wx.requestPayment({
  294. // timeStamp: payInfo.timeStamp,
  295. // nonceStr: payInfo.nonceStr,
  296. // package: payInfo.packageValue,
  297. // signType: payInfo.signType,
  298. // paySign: payInfo.paySign,
  299. // success: (res) => {
  300. // this.close()
  301. // if (this.$store.state.hide == 1) {
  302. // this.$service.user.getHide()
  303. // }
  304. // this.$router.push('order_product')
  305. // },
  306. // fail: (res) => {}
  307. // })
  308. // },
  309. wechatPay(data) {
  310. let payInfo = data.payInfo
  311. wx.requestPayment({
  312. timeStamp: payInfo.timeStamp,
  313. nonceStr: payInfo.nonceStr,
  314. package: payInfo.packageValue,
  315. signType: payInfo.signType,
  316. paySign: payInfo.paySign,
  317. success: (res) => {
  318. this.close()
  319. if (this.$store.state.hide == 1) {
  320. this.$service.user.getHide()
  321. }
  322. this.$router.push('order_product')
  323. },
  324. fail: (res) => {}
  325. })
  326. },
  327. thirdPay(data) {
  328. let self = this
  329. let redirectUrl = data.redirectUrl
  330. let requestId = data.requestId
  331. const base64Url = encodeURIComponent(baseEncode(redirectUrl))
  332. wx.openEmbeddedMiniProgram({
  333. path: 'pages/pay/order', // 启动目标页面
  334. appId: 'wx0448557563ffc600', // 启动的小程序
  335. envVersion: 'release', // develop | trial | release
  336. verify: 'binding',
  337. extraData: {
  338. title: '订单付款', // 导航Title
  339. tip: `待支付订单付款`, // 支付提示内容
  340. requestId: requestId, // 本次请求ID
  341. action: 'epPay', // 支付模式
  342. payUrl: base64Url // 支付地址, 需要进行Base64转换
  343. },
  344. success: (res) => {
  345. console.info('启动成功', res)
  346. },
  347. fail: (err) => {
  348. console.info('启动失败', err)
  349. }
  350. })
  351. },
  352. paySuccess(payInfo) {
  353. this.close()
  354. this.$store.state.payInfo = null
  355. if (this.$store.state.hide == 1) {
  356. this.$service.user.getHide()
  357. }
  358. this.$router.push('order_product')
  359. },
  360. showAddress(item) {
  361. this.$router.push('address', { type: 0, tradeNo: item.tradeNo })
  362. },
  363. receive(item) {
  364. this.$message.confirm('确认收货吗?', async () => {
  365. const res = await this.$service.mall.receive(item.tradeNo)
  366. res && this.refresh()
  367. })
  368. }
  369. }
  370. }
  371. </script>
  372. <style lang="scss" scoped>
  373. .cell {
  374. background: #fff;
  375. border-radius: 16rpx;
  376. margin: 20rpx 14px;
  377. position: relative;
  378. padding: 0 15px;
  379. .filter {
  380. position: absolute;
  381. left: 0;
  382. top: 0;
  383. bottom: 0;
  384. right: 0;
  385. z-index: -1;
  386. border-radius: 16rpx;
  387. backdrop-filter: blur(20rpx);
  388. }
  389. .top {
  390. padding: 20rpx 0;
  391. border-bottom: 2rpx solid #eee;
  392. .presell {
  393. background: $color-theme;
  394. width: 128rpx;
  395. height: 44rpx;
  396. line-height: 44rpx;
  397. border-radius: 22rpx;
  398. font-size: 24rpx;
  399. color: #fff;
  400. margin-left: 16rpx;
  401. text-align: center;
  402. }
  403. }
  404. .middle {
  405. padding: 24rpx 0;
  406. border-bottom: 2rpx solid #eee;
  407. .img {
  408. width: 180rpx;
  409. height: 180rpx;
  410. border-radius: 8rpx;
  411. }
  412. .deposit {
  413. background: $color-theme;
  414. height: 40rpx;
  415. line-height: 40rpx;
  416. border-radius: 20rpx;
  417. font-size: 22rpx;
  418. color: #fff;
  419. padding: 0 16rpx;
  420. margin-left: 16rpx;
  421. }
  422. }
  423. .copy {
  424. padding: 0 6rpx;
  425. height: 32rpx;
  426. line-height: 32rpx;
  427. border-radius: 8rpx;
  428. text-align: center;
  429. color: #000;
  430. font-size: 24rpx;
  431. background: #fec433;
  432. }
  433. .btn {
  434. height: 48rpx;
  435. line-height: 48rpx;
  436. text-align: center;
  437. padding: 0 20rpx;
  438. color: #000;
  439. font-size: 24rpx;
  440. background: #fec433;
  441. border-radius: 24rpx;
  442. border: none;
  443. box-shadow: none;
  444. &::after {
  445. display: none !important;
  446. }
  447. }
  448. }
  449. </style>