order-details.vue 13 KB

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