order-details.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. <template>
  2. <view class="container details clearfix" :style="{ paddingBottom: isIphoneX ? 130 + 68 + 'rpx' : '130rpx' }">
  3. <!-- 自定义返回 -->
  4. <header-back
  5. :systeminfo="systeminfo"
  6. :navbar-data="nvabarData"
  7. :headerBtnPosi="headerBtnPosi"
  8. :isShare="isOrderShare"
  9. ></header-back>
  10. <tui-skeleton
  11. v-if="!skeletonShow"
  12. backgroundColor="#fafafa"
  13. borderRadius="10rpx"
  14. :isLoading="true"
  15. :loadingType="5"
  16. ></tui-skeleton>
  17. <view v-else class="container-details" :style="{ paddingTop: navbarHeight + 'px' }">
  18. <!-- 地址选择 -->
  19. <order-address ref="orderAddress" v-if="skeletonShow" :addressData="addressData"></order-address>
  20. <!-- 商品 -->
  21. <goods-list
  22. ref="goods"
  23. v-if="skeletonShow"
  24. :shopOrderData="shopOrderData"
  25. :information="information"
  26. ></goods-list>
  27. <!-- 订单信息 -->
  28. <order-information ref="information" v-if="skeletonShow" :information="information"></order-information>
  29. <!-- 发票信息 -->
  30. <invoice-tent ref="invoice" v-if="skeletonShow" :orderInvoice="orderInvoice"></invoice-tent>
  31. <!-- 支付记录 -->
  32. <payment-record
  33. ref="payment"
  34. v-if="skeletonShow"
  35. :discernReceiptList="discernReceiptList"
  36. :receiptAmount="receiptAmount"
  37. ></payment-record>
  38. <!-- 退款记录 -->
  39. <refund-record
  40. ref="refund"
  41. v-if="skeletonShow"
  42. :returnedPurchaseList="returnedPurchaseList"
  43. :returnedPurchaseFee="returnedPurchaseFee"
  44. ></refund-record>
  45. <!-- 底部button -->
  46. <order-button
  47. ref="orderButton"
  48. v-if="skeletonShow"
  49. :status="btnStatus"
  50. :shareCode="shareCode"
  51. :order="orderInfo"
  52. @buttonConfirm="handButtonConfirm"
  53. >
  54. </order-button>
  55. <!-- 支付凭证记录 -->
  56. <voucher-record
  57. ref="voucher"
  58. v-if="skeletonShow"
  59. :list="voucherList"
  60. />
  61. </view>
  62. <!-- 分享弹窗 -->
  63. <share-alert :orderId="orderId" v-if="isShareModal" @btnConfirm="onShareAppMessage"> </share-alert>
  64. <!-- 提示弹窗 -->
  65. <tui-modal
  66. :show="modal"
  67. @click="handleClick"
  68. :content="contentModalText"
  69. :button="modalButton"
  70. color="#333"
  71. :size="32"
  72. shape="circle"
  73. :maskClosable="false"
  74. >
  75. </tui-modal>
  76. </view>
  77. </template>
  78. <script>
  79. import headerBack from '@/components/cm-module/headerNavbar/header-back' //自定义导航
  80. import orderAddress from './components/details/orderAddress' //地址信息
  81. import goodsList from './components/details/goodsList' //商品列表
  82. import invoiceTent from './components/details/invoiceTent' //发票信息
  83. import orderInformation from './components/details/orderInformation' //订单信息
  84. import paymentRecord from './components/details/paymentRecord' //支付记录
  85. import refundRecord from './components/details/refundRecord' //退款记录
  86. import voucherRecord from './components/details/voucherRecord' //支付凭证记录
  87. import orderButton from './components/details/orderButton' //底部按钮
  88. import shareAlert from '@/components/cm-module/modelAlert/shareAlert.vue' //分享弹窗
  89. export default {
  90. components: {
  91. headerBack,
  92. orderInformation,
  93. orderAddress,
  94. invoiceTent,
  95. goodsList,
  96. paymentRecord,
  97. refundRecord,
  98. voucherRecord,
  99. orderButton,
  100. shareAlert
  101. },
  102. data() {
  103. return {
  104. skeletonShow: false,
  105. headerBtnPosi: this.setHeaderBtnPosi(), //获取设备顶部胶囊高度
  106. systeminfo: this.setSysteminfo(), //获取设备信息
  107. isIphoneX: this.$store.state.isIphoneX,
  108. CustomBar: this.CustomBar, // 顶部导航栏高度
  109. navbarHeight: '',
  110. nvabarData: {
  111. //顶部自定义导航
  112. showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示
  113. title: '订单详情' // 导航栏 中间的标题
  114. },
  115. state: 0,
  116. userId: '',
  117. orderId: '',
  118. shareCode: '', //分享码
  119. shareType: '', //分享登录页过来记录的状态
  120. cellPhone: '', //客服电话
  121. payStatus: 0,
  122. btnStatus: 0, //按钮组件状态
  123. onlinePayFlag: '',
  124. isOrderShare: false,
  125. isShareModal: false,
  126. modelType: 0,
  127. orderInfo: {},
  128. alertOrderInfo: {},
  129. addressData: {}, //地址信息初始化
  130. information: {}, //订单信息初始化
  131. shopOrderData: {}, //商品信息初始化
  132. orderInvoice: {}, //发票信息初始化
  133. returnedPurchaseList: {}, //退款信息初始化
  134. discernReceiptList: {}, //支付信息初始化
  135. voucherList: [], //支付凭证
  136. receiptAmount: 0, //支付金额
  137. returnedPurchaseFee: 0, //退款金额
  138. handleModelEven: 0,
  139. modal: false,
  140. contentModalText: '订单查询失败,请稍候重试~', //操作文字提示语句
  141. modalButton: [
  142. {
  143. text: '取消',
  144. type: 'gray',
  145. plain: true //是否空心
  146. },
  147. {
  148. text: '确定',
  149. customStyle: {
  150. color: '#fff',
  151. bgColor: '#F3B574'
  152. },
  153. plain: false
  154. }
  155. ]
  156. }
  157. },
  158. onLoad(option) {
  159. console.log(option)
  160. this.shareType = option.type
  161. this.orderId = option.orderId
  162. if (this.shareType === 'share') {
  163. this.state = 0
  164. this.isOrderShare = true
  165. } else if (option.type === 'confim' || option.type === 'search') {
  166. this.state = 0
  167. } else {
  168. this.state = option.state
  169. }
  170. this.getHeaderTopHeight()
  171. this.initOrderDetaileData()
  172. },
  173. filters: {
  174. TextFormat(status) {
  175. //处理金额
  176. let HtmlText,
  177. typeTextObject = {
  178. 0: '待确认',
  179. 4: '交易完成',
  180. 5: '订单完成',
  181. 6: '已关闭',
  182. 7: '交易全退',
  183. 77: '交易全退',
  184. 11: '待付款待发货',
  185. 12: '待付款部分发货',
  186. 13: '待付款已发货',
  187. 21: '部分付款待发货',
  188. 22: '部分付款部分发货',
  189. 23: '部分付款已发货',
  190. 31: '已付款待发货',
  191. 32: '已付款部分发货',
  192. 33: '已付款已发货',
  193. 111: '待付款待发货'
  194. }
  195. Object.keys(typeTextObject).forEach(key => {
  196. if (key == status) {
  197. HtmlText = typeTextObject[key]
  198. }
  199. })
  200. return HtmlText
  201. }
  202. },
  203. methods: {
  204. // 获取订单详情
  205. async initOrderDetaileData() {
  206. try {
  207. const userInfo = await this.$api.getStorage()
  208. this.userId = userInfo.userId ? userInfo.userId : 0
  209. const res = await this.OrderService.QueryOrderDetails({ orderId: this.orderId, userId: this.userId })
  210. const data = res.data
  211. this.skeletonShow = true
  212. this.orderInfo = data.order
  213. this.shareCode = data.shareCode
  214. this.addressData = data.userInfo
  215. this.information = data.order
  216. this.btnStatus = data.order.status
  217. this.payStatus = data.order.payStatus
  218. this.payableAmount = data.order.payableAmount
  219. this.shopOrderData = data.shopOrderList
  220. this.orderInvoice = data.orderInvoice
  221. this.onlinePayFlag = data.order.onlinePayFlag
  222. this.returnedPurchaseList = data.returnedPurchaseList
  223. this.discernReceiptList = data.discernReceiptList
  224. this.voucherList = data.voucher
  225. this.receiptAmount = data.order.receiptAmount
  226. this.returnedPurchaseFee = data.order.returnedPurchaseFee
  227. } catch (error) {
  228. //TODO handle the exception
  229. this.$util.msg(error.msg, 2000)
  230. }
  231. },
  232. handButtonConfirm(data) {
  233. //监听点击时间的按钮类型并执行...
  234. this.handShowAlert(data)
  235. },
  236. handShowAlert(data) {
  237. //判断点击的按钮类型并执行...
  238. switch (data.type) {
  239. case 'cancel':
  240. //取消订单
  241. this.modal = true
  242. this.contentModalText = '确认取消该订单吗?'
  243. this.handleModelEven = 1
  244. break
  245. case 'query':
  246. this.$api.navigateTo('/pages/user/order/order-logistics?orderId=' + this.orderId)
  247. break
  248. case 'upload':
  249. this.$api.navigateTo('/pages/user/order/order-addpay?orderId=' + this.orderId)
  250. break
  251. case 'confirm':
  252. //确认收货
  253. this.modal = true
  254. this.contentModalText = '确认收货吗?'
  255. this.handleModelEven = 2
  256. break
  257. case 'pay':
  258. this.getOrderPaymentValidation(data)
  259. break
  260. }
  261. },
  262. getOrderPaymentValidation(data) {
  263. //监听根据付款状态做操作
  264. this.OrderService.OrderPaymentValidation({ orderId: data.orderId })
  265. .then(response => {
  266. let data = response.data
  267. if (data.onlinePayFlag == 1) {
  268. // 只能线下
  269. this.$api.navigateTo(`/pages/user/pay/card-under?orderId=${data.orderId}`)
  270. } else {
  271. this.$api.navigateTo(`/pages/user/order/order-pay-list?orderId=${data.orderId}`)
  272. }
  273. })
  274. .catch(error => {
  275. this.$util.msg(error.msg, 2000)
  276. })
  277. },
  278. handleClick(e) {
  279. //确认操作
  280. if (e.index == 1) {
  281. switch (this.handleModelEven) {
  282. case 1: //取消订单
  283. this.cancelOrder()
  284. break
  285. case 2: //确认收货
  286. this.confirmReceipt()
  287. break
  288. }
  289. }
  290. this.modal = false
  291. },
  292. async confirmReceipt() {
  293. //确认收货
  294. try {
  295. const res = await this.OrderService.ConfirmReceipt({ orderId: this.orderId })
  296. this.$util.msg(res.msg, 2000, true, 'success')
  297. setTimeout(() => {
  298. this.initOrderDetaileData()
  299. }, 2000)
  300. } catch (error) {
  301. this.$util.msg(error.msg, 2000)
  302. }
  303. },
  304. async cancelOrder() {
  305. //取消订单
  306. try {
  307. const res = await this.OrderService.CancelOrder({ orderId: this.orderId, userIdentity: 0 })
  308. this.$util.msg(res.msg, 2000, true, 'success')
  309. setTimeout(() => {
  310. this.initOrderDetaileData()
  311. }, 2000)
  312. } catch (error) {
  313. this.$util.msg(error.msg, 2000)
  314. }
  315. },
  316. onShareAppMessage(res) {
  317. //分享转发
  318. this.isShareModal = false
  319. if (res.from === 'button') {
  320. // 来自页面内转发按钮
  321. }
  322. return {
  323. title: '您有新的分享订单,快来查看吧~',
  324. path: `/pages/user/order/order-sharelogin?orderId=${this.orderId}&userId=${this.userId}`,
  325. imageUrl: 'https://static.caimei365.com/app/mini-mcare/icon/icon_shareOrder@2x.png'
  326. }
  327. },
  328. getHeaderTopHeight() {
  329. let statusBarHeight = this.systeminfo.statusBarHeight // 状态栏高度
  330. let headerPosi = this.headerBtnPosi
  331. let btnPosi = {
  332. // 胶囊实际位置,坐标信息不是左上角原点
  333. height: headerPosi.height,
  334. width: headerPosi.width,
  335. // 胶囊top - 状态栏高度
  336. top: headerPosi.top - statusBarHeight,
  337. // 胶囊bottom - 胶囊height - 状态栏height (现胶囊bottom 为距离导航栏底部的长度)
  338. bottom: headerPosi.bottom - headerPosi.height - statusBarHeight,
  339. // 屏幕宽度 - 胶囊right
  340. right: this.systeminfo.screenWidth - headerPosi.right
  341. }
  342. this.navbarHeight = headerPosi.bottom + btnPosi.bottom // 原胶囊bottom + 现胶囊bottom
  343. },
  344. setHeaderBtnPosi() {
  345. // 获得胶囊按钮位置信息
  346. let headerBtnPosi = uni.getMenuButtonBoundingClientRect()
  347. return headerBtnPosi
  348. },
  349. setSysteminfo() {
  350. let systeminfo
  351. uni.getSystemInfo({
  352. // 获取设备信息
  353. success: res => {
  354. systeminfo = res
  355. }
  356. })
  357. return systeminfo
  358. }
  359. },
  360. onShow() {}
  361. }
  362. </script>
  363. <style lang="scss">
  364. page {
  365. height: auto;
  366. background: #f7f7f7;
  367. }
  368. .details {
  369. padding-bottom: 130rpx;
  370. }
  371. .return-instructions {
  372. font-size: 26rpx;
  373. color: #f3b574;
  374. line-height: 42rpx;
  375. padding: 32rpx 50rpx;
  376. background-color: #fffaf8;
  377. text-align: justify;
  378. }
  379. .btn-hover {
  380. background: #ffffff;
  381. }
  382. .animation {
  383. /* transition: transform 0.3s ease;*/
  384. transition-property: transform;
  385. transition-duration: 0.3s;
  386. transition-timing-function: ease;
  387. }
  388. .invoice-balance {
  389. width: 702rpx;
  390. height: auto;
  391. padding: 0 24rpx;
  392. background: #ffffff;
  393. float: left;
  394. margin-top: 24rpx;
  395. margin-bottom: 24rpx;
  396. .balabce-t {
  397. width: 100%;
  398. height: 86rpx;
  399. line-height: 86rpx;
  400. font-size: $font-size-28;
  401. color: $text-color;
  402. float: left;
  403. .balabce-t-le {
  404. float: left;
  405. font-weight: bold;
  406. }
  407. .balabce-t-ri {
  408. float: right;
  409. display: flex;
  410. align-items: center;
  411. .money {
  412. display: flex;
  413. float: left;
  414. }
  415. .checkbox-box {
  416. display: flex;
  417. width: 60rpx;
  418. float: left;
  419. height: 100%;
  420. font-size: $font-size-24;
  421. .checkbox {
  422. width: 40rpx;
  423. text-align: right;
  424. box-sizing: border-box;
  425. text-align: center;
  426. text-decoration: none;
  427. border-radius: 0;
  428. -webkit-tap-highlight-color: transparent;
  429. overflow: hidden;
  430. }
  431. }
  432. }
  433. }
  434. .balabce-b {
  435. width: 100%;
  436. float: left;
  437. overflow: hidden;
  438. .balabce-b-text {
  439. width: 100%;
  440. line-height: 58rpx;
  441. font-size: $font-size-24;
  442. color: #ff2a2a;
  443. text-align: right;
  444. float: right;
  445. }
  446. &.balabce-b--hide {
  447. padding: 0 0;
  448. height: 0px;
  449. line-height: 0px;
  450. }
  451. }
  452. }
  453. .clause {
  454. float: right;
  455. font-size: 24rpx;
  456. color: #999999;
  457. margin-top: 60rpx;
  458. margin-right: 24rpx;
  459. &.noclick {
  460. pointer-events: none;
  461. }
  462. .text {
  463. color: #1890f9;
  464. &.color-bg {
  465. color: #333333;
  466. }
  467. }
  468. }
  469. .status-text {
  470. overflow: hidden;
  471. padding: 24rpx;
  472. background: #fff;
  473. font-size: $font-size-26;
  474. .view-type {
  475. float: left;
  476. color: #ff2a2a;
  477. }
  478. .bage-buss {
  479. display: inline-block;
  480. width: 72rpx;
  481. height: 32rpx;
  482. background: radial-gradient(circle, rgba(255, 39, 180, 1) 0%, rgba(193, 77, 245, 1) 100%);
  483. border-radius: 6rpx;
  484. line-height: 32rpx;
  485. text-align: center;
  486. color: #ffffff;
  487. margin-top: 10rpx;
  488. float: right;
  489. }
  490. .bage-auto {
  491. display: inline-block;
  492. width: 72rpx;
  493. height: 32rpx;
  494. background: radial-gradient(circle, rgba(255, 180, 39, 1) 0%, rgba(245, 142, 77, 1) 100%);
  495. border-radius: 6rpx;
  496. line-height: 32rpx;
  497. text-align: center;
  498. color: #ffffff;
  499. margin-top: 10rpx;
  500. float: right;
  501. }
  502. }
  503. </style>