order-details.vue 13 KB

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