order-details.vue 15 KB

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