order-details.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. <template>
  2. <view class="container details clearfix" :style="{ paddingBottom: isIphoneX ? 130 + 68 + 'rpx' : '130rpx' }">
  3. <!-- 自定义返回 -->
  4. <header-order
  5. :systeminfo="systeminfo"
  6. :navbar-data="nvabarData"
  7. :headerBtnPosi="headerBtnPosi"
  8. :isShare="isOrderShare"
  9. >
  10. </header-order>
  11. <view class="container-details" :style="{ paddingTop: navbarHeight + 'px' }">
  12. <view class="status-text">
  13. <view class="view-type">{{ information.status | TextFormat }}</view>
  14. </view>
  15. <!-- 地址选择 -->
  16. <order-address ref="orderAddress" v-if="isRequest" :addressData="addressData"></order-address>
  17. <!-- 商品 -->
  18. <goods-list
  19. ref="goods"
  20. v-if="isRequest"
  21. :shopOrderData="shopOrderData"
  22. :information="information"
  23. @popupClick="hanldePopupFn"
  24. ></goods-list>
  25. <!-- 订单信息 -->
  26. <order-information ref="information" v-if="isRequest" :information="information"></order-information>
  27. <!-- 底部button -->
  28. <order-button
  29. ref="orderButton"
  30. v-if="isRequest"
  31. :status="btnStatus"
  32. :shareCode="shareCode"
  33. :order="orderInfo"
  34. @buttonConfirm="handButtonConfirm"
  35. >
  36. </order-button>
  37. </view>
  38. <!-- 操作弹窗 -->
  39. <tui-modal
  40. :show="modal"
  41. @click="handleClick"
  42. @cancel="hideMobel(1)"
  43. :content="contentModalText"
  44. color="#333"
  45. :size="32"
  46. shape="circle"
  47. :maskClosable="false"
  48. ></tui-modal>
  49. <!-- 再次购买订单商品全部下架弹窗 -->
  50. <tui-modal
  51. :show="modal2"
  52. @click="handleClick2"
  53. @cancel="hideMobel(2)"
  54. shape="circle"
  55. content="订单内商品已全部下架,不能购买!"
  56. :button="button"
  57. ></tui-modal>
  58. <!-- 再次购买部分商品失效弹窗 -->
  59. <tui-modal :show="modal3" @cancel="hideMobel(3)" :custom="true">
  60. <view class="tui-modal-custom">
  61. <view class="tui-modal-custom-text">
  62. <view class="title">以下商品已失效,不能进行购买;是否先将其他商品加入购物车?</view>
  63. <scroll-view scroll-y class="tui-modal-custom-list">
  64. <view class="custom-list" v-for="(invalid, index) in invalidList" :key="index">
  65. <view class="custom-list-image"><image :src="invalid.productImage" mode=""></image></view>
  66. <view class="custom-list-name">{{ invalid.name }}</view>
  67. </view>
  68. </scroll-view>
  69. </view>
  70. <view class="tui-modal-button">
  71. <button class="modal-button cancel" @click="hideMobel(3)">我再想想</button>
  72. <button class="modal-button confirm" @click="handleClick3">加入购物车</button>
  73. </view>
  74. </view>
  75. </tui-modal>
  76. <!-- 促销活动弹窗 -->
  77. <activi-popup :Promotion="handlerPros" :popupShow="popupShow"></activi-popup>
  78. </view>
  79. </template>
  80. <script>
  81. import authorize from '@/common/authorize.js'
  82. import HeaderOrder from '@/components/cm-module/headerNavbar/header-order' //自定义导航
  83. import orderAddress from '@/components/cm-module/orderDetails/orderAddress' //地址信息
  84. import goodsList from '@/components/cm-module/orderDetails/goodsList' //商品列表
  85. import orderInformation from '@/components/cm-module/orderDetails/orderInformation' //订单信息
  86. import transfeRecord from '@/components/cm-module/orderDetails/transfeRecord' //转账信息
  87. import paymentRecord from '@/components/cm-module/orderDetails/paymentRecord' //支付记录
  88. import refundRecord from '@/components/cm-module/orderDetails/refundRecord' //退款记录
  89. import orderButton from '@/components/cm-module/orderDetails/orderButton' //底部按钮
  90. export default {
  91. components: {
  92. HeaderOrder,
  93. orderInformation,
  94. orderAddress,
  95. goodsList,
  96. transfeRecord,
  97. paymentRecord,
  98. refundRecord,
  99. orderButton
  100. },
  101. data() {
  102. return {
  103. state: 0,
  104. orderId: '',
  105. shareCode: '', //分享码
  106. shareType: '', //分享登录页过来记录的状态
  107. cellPhone: '', //客服电话
  108. payStatus: 0,
  109. btnStatus: 0, //按钮组件状态
  110. onlinePayFlag: '',
  111. isRequest: false, //是否加载完成渲染子组件
  112. isOrderShare: false,
  113. isConfim: false,
  114. modelType: 0,
  115. orderInfo: {},
  116. alertOrderInfo: {},
  117. addressData: {}, //地址信息初始化
  118. information: {}, //订单信息初始化
  119. shopOrderData: {}, //商品信息初始化
  120. orderInvoice: {}, //发票信息初始化
  121. returnedPurchaseList: {}, //退款信息初始化
  122. discernReceiptList: {}, //支付信息初始化
  123. receiptAmount: 0, //支付金额
  124. returnedPurchaseFee: 0, //退款金额
  125. navbarHeight: '',
  126. headerBtnPosi: this.setHeaderBtnPosi(), //获取设备顶部胶囊高度
  127. systeminfo: this.setSysteminfo(), //获取设备信息
  128. isIphoneX: this.$store.getters.isIphoneX,
  129. CustomBar: this.CustomBar, // 顶部导航栏高度
  130. popupShow: false,
  131. handlerPros: {},
  132. nvabarData: {
  133. //顶部自定义导航
  134. showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示
  135. title: '订单详情' // 导航栏 中间的标题
  136. },
  137. clauseData: {},
  138. orderSubmitType: false, //自主订单
  139. userId: 0,
  140. modal: false,
  141. modal2: false,
  142. modal3: false,
  143. OperationType: '',
  144. contentModalText: '',
  145. button: [
  146. {
  147. text: '确定',
  148. type: 'danger'
  149. }
  150. ],
  151. invalidList: []
  152. }
  153. },
  154. onLoad(option) {
  155. console.log(option)
  156. this.$api.getStorage().then(resolve => {
  157. this.userId = resolve.userId ? resolve.userId : 0
  158. })
  159. this.shareType = option.type
  160. this.orderId = option.orderId
  161. if (this.shareType === 'share') {
  162. this.state = 0
  163. this.isOrderShare = true
  164. } else if (option.type === 'confim' || option.type === 'search') {
  165. this.state = 0
  166. this.isConfim = true
  167. } else {
  168. this.state = option.state
  169. }
  170. this.getHeaderTopHeight()
  171. this.GetOrderDetaileData()
  172. },
  173. filters: {
  174. TextFormat(status) {
  175. //处理金额
  176. let HtmlText,
  177. typeTextObject = {
  178. 4: '交易完成',
  179. 5: '订单完成',
  180. 6: '已关闭',
  181. 7: '交易全退',
  182. 77: '交易全退',
  183. 11: '待付款待发货',
  184. 12: '待付款部分发货',
  185. 13: '待付款已发货',
  186. 21: '部分付款待发货',
  187. 22: '部分付款部分发货',
  188. 23: '部分付款已发货',
  189. 31: '已付款待发货',
  190. 32: '已付款部分发货',
  191. 33: '已付款已发货',
  192. 111: '待付款待发货'
  193. }
  194. Object.keys(typeTextObject).forEach(key => {
  195. if (key == status) {
  196. HtmlText = typeTextObject[key]
  197. }
  198. })
  199. return HtmlText
  200. }
  201. },
  202. methods: {
  203. openclauseConten(id) {
  204. this.$api.navigateTo(`/pages/service/sellconten?clauseId=${id}`)
  205. },
  206. GetOrderDetaileData() {
  207. //初始化页面数据@参数:订单ID
  208. this.OrderService.QueryOrderDetails({ orderId: this.orderId })
  209. .then(response => {
  210. let resData = response.data
  211. this.isRequest = true
  212. this.orderInfo = resData.order
  213. this.userId = resData.order.userId
  214. this.shareCode = resData.shareCode
  215. this.addressData = resData.userInfo
  216. this.information = resData.order
  217. this.btnStatus = resData.order.status
  218. this.payStatus = resData.order.payStatus
  219. this.payableAmount = resData.order.payableAmount
  220. this.shopOrderData = resData.shopOrderList
  221. this.orderInvoice = resData.orderInvoice
  222. this.onlinePayFlag = resData.order.onlinePayFlag
  223. this.returnedPurchaseList = resData.returnedPurchaseList
  224. this.discernReceiptList = resData.discernReceiptList
  225. this.receiptAmount = resData.order.receiptAmount
  226. this.returnedPurchaseFee = resData.order.returnedPurchaseFee
  227. this.clauseData = resData.clause
  228. if (
  229. this.information.orderSubmitType == 0 ||
  230. this.information.orderSubmitType == 1 ||
  231. this.information.orderSubmitType == 2
  232. ) {
  233. this.orderSubmitType = true
  234. } else {
  235. this.orderSubmitType = false
  236. }
  237. })
  238. .catch(error => {
  239. this.$util.modal('提示', '订单查询失败,请稍后重试~', '确定', '', false, () => {
  240. this.$api.switchTabTo('/pages/tabBar/index/index')
  241. })
  242. })
  243. },
  244. handButtonConfirm(data) {
  245. //获取点击
  246. console.log(data)
  247. this.hanldOrder = data
  248. this.btnoRderID = data.orderId
  249. this.OperationType = data.type
  250. this.handShowAlert(data)
  251. },
  252. handShowAlert(data) {
  253. //执行
  254. switch (data.type) {
  255. case 'cancel':
  256. this.modal = true
  257. this.contentModalText = '确认取消该订单吗?'
  258. break
  259. case 'delete':
  260. this.modal = true
  261. this.contentModalText = '确认删除该订单吗?'
  262. break
  263. case 'confirm':
  264. this.modal = true
  265. this.contentModalText = '是否确认收货?'
  266. break
  267. case 'query':
  268. this.isModalLayer = true
  269. this.$api.navigateTo('/pages/user/order/order-logistics?orderId=' + data.orderId)
  270. break
  271. case 'again':
  272. this.handBuyAgainInfo()
  273. break
  274. case 'pay':
  275. this.MiniWxPayFor(data.order)
  276. break
  277. }
  278. },
  279. handleClick(e) {
  280. //用户操作订单
  281. let index = e.index
  282. if (index == 1) {
  283. switch (this.OperationType) {
  284. case 'delete':
  285. this.handOrderDetele(this.orderId)
  286. break
  287. case 'cancel':
  288. this.handCenceConfirm(this.orderId)
  289. break
  290. case 'confirm':
  291. this.handOrderConfirm(this.orderId)
  292. break
  293. }
  294. }
  295. this.modal = false
  296. },
  297. handleClick2() {
  298. this.modal2 = false
  299. },
  300. handleClick3() {
  301. this.handShoppingAgainCart()
  302. this.modal3 = false
  303. },
  304. hideMobel(index) {
  305. switch (index) {
  306. case 1:
  307. this.modal = false
  308. break
  309. case 2:
  310. this.modal2 = false
  311. break
  312. case 3:
  313. this.modal3 = false
  314. break
  315. }
  316. },
  317. handBuyAgainInfo() {
  318. //再次购买初始化查询订单商品信息
  319. this.OrderService.GetOrderBuyAgain({
  320. orderId: this.orderId
  321. })
  322. .then(response => {
  323. this.handShoppingAgainCart()
  324. })
  325. .catch(error => {
  326. console.log(error.data)
  327. if (error.data && error.data.length > 0) {
  328. this.modal3 = true
  329. this.invalidList = error.data
  330. } else {
  331. this.modal2 = true
  332. }
  333. })
  334. },
  335. handShoppingAgainCart() {
  336. //一键加入购物车
  337. this.ProductService.ShoppingAgainCart({
  338. orderId: this.orderId
  339. })
  340. .then(response => {
  341. this.ProductService.QueryShoppingQuantity({ userId: this.userId })
  342. .then(response => {
  343. this.$api.switchTabTo('/pages/tabBar/cart/index')
  344. })
  345. .catch(error => {
  346. console.log('查询购物车数量错误信息', error)
  347. })
  348. })
  349. .catch(error => {
  350. this.$util.msg(error.msg, 2000)
  351. })
  352. },
  353. handOrderConfirm(id) {
  354. //确认收货
  355. this.OrderService.ConfirmReceipt({ orderId: id })
  356. .then(response => {
  357. this.$util.msg(response.msg, 2000, true, 'success')
  358. setTimeout(() => {
  359. this.GetOrderDetaileData(this.currentTab)
  360. }, 2000)
  361. })
  362. .catch(error => {
  363. this.$util.msg(error.msg, 2000)
  364. })
  365. },
  366. handOrderDetele(id) {
  367. //删除订单
  368. this.OrderService.DeleteOrder({ orderId: id })
  369. .then(response => {
  370. this.$util.msg(response.msg, 2000, true, 'success')
  371. setTimeout(() => {
  372. this.GetOrderDetaileData(this.currentTab)
  373. }, 2000)
  374. })
  375. .catch(error => {
  376. this.$util.msg(error.msg, 2000)
  377. })
  378. },
  379. handCenceConfirm(id) {
  380. //取消订单
  381. this.OrderService.CancelOrder({ orderId: id })
  382. .then(response => {
  383. this.$util.msg(response.msg, 2000, true, 'success')
  384. setTimeout(() => {
  385. this.GetOrderDetaileData(this.currentTab)
  386. }, 2000)
  387. })
  388. .catch(error => {
  389. this.$util.msg(error.msg, 2000)
  390. })
  391. },
  392. MiniWxPayFor(data) {
  393. this.PayService.PayOrderOnLineSwitch().then(response => {
  394. if (response.data === 1) {
  395. this.WeChatMiniWxPay(data)
  396. } else {
  397. this.$api.navigateTo(`/pages/user/order/order-payment?money=${data.payableAmount}`)
  398. }
  399. })
  400. },
  401. async WeChatMiniWxPay(data) {
  402. const wechatCode = await authorize.getCode('weixin')
  403. this.PayService.WeChatMiniWxPay({
  404. payAmount: data.payableAmount * 100,
  405. payWay: 'WEIXIN',
  406. code: wechatCode,
  407. orderId: data.orderId
  408. })
  409. .then(response => {
  410. let PayInfo = JSON.parse(response.data.data.payInfo)
  411. this.WxRequestPayment(PayInfo)
  412. })
  413. .catch(error => {
  414. this.$util.msg(error.msg, 2000)
  415. })
  416. },
  417. WxRequestPayment(data) {
  418. let self = this
  419. wx.requestPayment({
  420. timeStamp: data.timeStamp,
  421. nonceStr: data.nonceStr,
  422. package: data.package,
  423. signType: data.signType,
  424. paySign: data.paySign,
  425. success: function(res) {
  426. wx.reLaunch({ url: '/pages/tabBar/index/index' })
  427. },
  428. fail: function(res) {
  429. console.log(res)
  430. console.log('ORDERiD', self.hanldOrder)
  431. self.$api.redirectTo(
  432. `/pages/user/order/success?data=${JSON.stringify({ data: self.hanldOrder.order })}`
  433. )
  434. },
  435. complete: function(res) {}
  436. })
  437. },
  438. hanldePopupFn(data) {
  439. //监听活动内容
  440. this.popupShow = true
  441. this.handlerPros = data
  442. },
  443. getHeaderTopHeight() {
  444. let statusBarHeight = this.systeminfo.statusBarHeight // 状态栏高度
  445. let headerPosi = this.headerBtnPosi
  446. let btnPosi = {
  447. // 胶囊实际位置,坐标信息不是左上角原点
  448. height: headerPosi.height,
  449. width: headerPosi.width,
  450. // 胶囊top - 状态栏高度
  451. top: headerPosi.top - statusBarHeight,
  452. // 胶囊bottom - 胶囊height - 状态栏height (现胶囊bottom 为距离导航栏底部的长度)
  453. bottom: headerPosi.bottom - headerPosi.height - statusBarHeight,
  454. // 屏幕宽度 - 胶囊right
  455. right: this.systeminfo.screenWidth - headerPosi.right
  456. }
  457. this.navbarHeight = headerPosi.bottom + btnPosi.bottom // 原胶囊bottom + 现胶囊bottom
  458. },
  459. setHeaderBtnPosi() {
  460. // 获得胶囊按钮位置信息
  461. let headerBtnPosi = uni.getMenuButtonBoundingClientRect()
  462. return headerBtnPosi
  463. },
  464. setSysteminfo() {
  465. let systeminfo
  466. uni.getSystemInfo({
  467. // 获取设备信息
  468. success: res => {
  469. systeminfo = res
  470. }
  471. })
  472. return systeminfo
  473. }
  474. },
  475. onShow() {}
  476. }
  477. </script>
  478. <style lang="scss">
  479. page {
  480. height: auto;
  481. background: #f7f7f7;
  482. }
  483. .details {
  484. padding-bottom: 130rpx;
  485. }
  486. .btn-hover {
  487. background: #ffffff;
  488. }
  489. .animation {
  490. /* transition: transform 0.3s ease;*/
  491. transition-property: transform;
  492. transition-duration: 0.3s;
  493. transition-timing-function: ease;
  494. }
  495. .invoice-balance {
  496. width: 702rpx;
  497. height: auto;
  498. padding: 0 24rpx;
  499. background: #ffffff;
  500. float: left;
  501. margin-top: 24rpx;
  502. margin-bottom: 24rpx;
  503. .balabce-t {
  504. width: 100%;
  505. height: 86rpx;
  506. line-height: 86rpx;
  507. font-size: $font-size-28;
  508. color: $text-color;
  509. float: left;
  510. .balabce-t-le {
  511. float: left;
  512. font-weight: bold;
  513. }
  514. .balabce-t-ri {
  515. float: right;
  516. display: flex;
  517. align-items: center;
  518. .money {
  519. display: flex;
  520. float: left;
  521. }
  522. .checkbox-box {
  523. display: flex;
  524. width: 60rpx;
  525. float: left;
  526. height: 100%;
  527. font-size: $font-size-24;
  528. .checkbox {
  529. width: 40rpx;
  530. text-align: right;
  531. box-sizing: border-box;
  532. text-align: center;
  533. text-decoration: none;
  534. border-radius: 0;
  535. -webkit-tap-highlight-color: transparent;
  536. overflow: hidden;
  537. }
  538. }
  539. }
  540. }
  541. .balabce-b {
  542. width: 100%;
  543. float: left;
  544. overflow: hidden;
  545. .balabce-b-text {
  546. width: 100%;
  547. line-height: 58rpx;
  548. font-size: $font-size-24;
  549. color: #ff2a2a;
  550. text-align: right;
  551. float: right;
  552. }
  553. &.balabce-b--hide {
  554. padding: 0 0;
  555. height: 0px;
  556. line-height: 0px;
  557. }
  558. }
  559. }
  560. .clause {
  561. float: right;
  562. font-size: 24rpx;
  563. color: #999999;
  564. margin-top: 60rpx;
  565. margin-right: 24rpx;
  566. &.noclick {
  567. pointer-events: none;
  568. }
  569. .text {
  570. color: #1890f9;
  571. &.color-bg {
  572. color: #333333;
  573. }
  574. }
  575. }
  576. .status-text {
  577. overflow: hidden;
  578. padding: 0 24rpx;
  579. background: #fff;
  580. font-size: $font-size-26;
  581. .view-type {
  582. float: left;
  583. color: $color-system;
  584. }
  585. }
  586. .tui-modal-custom-text {
  587. min-height: 300rpx;
  588. margin-bottom: 30rpx;
  589. .title {
  590. width: 100%;
  591. height: auto;
  592. font-size: $font-size-30;
  593. text-align: justify;
  594. color: #333333;
  595. line-height: 40rpx;
  596. margin-bottom: 30rpx;
  597. }
  598. .tui-modal-custom-list {
  599. width: 100%;
  600. height: 350rpx;
  601. overflow: hidden;
  602. .custom-list {
  603. width: 100%;
  604. height: 117rpx;
  605. box-sizing: border-box;
  606. float: left;
  607. padding: 15rpx 0;
  608. .custom-list-image {
  609. width: 86rpx;
  610. height: 86rpx;
  611. float: left;
  612. border-radius: 6rpx;
  613. box-sizing: border-box;
  614. border: 1px solid #e1e1e1;
  615. image {
  616. width: 84rpx;
  617. height: 84rpx;
  618. border-radius: 6rpx;
  619. display: block;
  620. }
  621. }
  622. .custom-list-name {
  623. width: 400rpx;
  624. height: 86rpx;
  625. float: right;
  626. line-height: 43rpx;
  627. font-size: $font-size-26;
  628. color: #666666;
  629. text-overflow: ellipsis;
  630. overflow: hidden;
  631. display: -webkit-box;
  632. -webkit-line-clamp: 2;
  633. line-clamp: 2;
  634. -webkit-box-orient: vertical;
  635. }
  636. }
  637. }
  638. }
  639. .tui-modal-button {
  640. width: 100%;
  641. height: 72rpx;
  642. display: flex;
  643. .modal-button {
  644. width: 200rpx;
  645. height: 72rpx;
  646. line-height: 72rpx;
  647. border-radius: 36rpx;
  648. box-sizing: border-box;
  649. &.cancel {
  650. border: 1px solid #b2b2b2;
  651. background: #ffffff;
  652. color: #333333;
  653. }
  654. &.confirm {
  655. background: $btn-confirm;
  656. color: #ffffff;
  657. }
  658. }
  659. }
  660. </style>