detail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  1. <template>
  2. <view class="order-detail">
  3. <zs-skeleton type="orderDetail" :loading="pageLoading"></zs-skeleton>
  4. <view class="status-box">
  5. <view class="text-box">
  6. <view class="status" v-if="info.goodsList[0].goodsState == 'WAIT_PAYMENT'&&!isNotTime">
  7. 等待支付,剩余<u-count-down :time="closeTime" format="mm:ss" @finish="finish"></u-count-down>
  8. </view>
  9. <view class="status" v-else>
  10. {{info.goodsList[0] |filterType }}
  11. </view>
  12. </view>
  13. </view>
  14. <view class="content shop-box">
  15. <view class="shop-name">
  16. {{info.shopInfo.shopName}}
  17. </view>
  18. <view class="address">
  19. {{info.shopInfo.address}}
  20. </view>
  21. </view>
  22. <view class="content goods-box">
  23. <view class="title">
  24. 订单信息
  25. </view>
  26. <view class="goods-item" v-for="(item,index) in info.goodsList[0].goodsInfo.products" :key="index">
  27. <view class="left">
  28. <image class="icon" :src="item.imageUrl" mode=""></image>
  29. <view class="name">
  30. {{item.nameCn}}
  31. </view>
  32. <view class="num">
  33. x{{item.quantity}}
  34. </view>
  35. </view>
  36. <view class="right">
  37. ¥{{item.selPrice}}
  38. </view>
  39. </view>
  40. <view class="total-box">
  41. <view class="num">
  42. 共{{info.goodsList[0].goodsInfo.products.length}}件
  43. </view>
  44. <view class="price">
  45. 小计¥{{info.payAmount}}
  46. </view>
  47. </view>
  48. </view>
  49. <view class="content code-box" v-if="info.goodsList[0].goodsState == 'WAIT_USE'">
  50. <view class="title">
  51. 券码信息
  52. </view>
  53. <uqrcode class="qrcode" ref="uqrcode" type="2d" auto canvas-id="qrcode" :value="codeData" :loading="loading" :options="{ margin: 20 }">
  54. <template v-slot:loading>
  55. <text style="color: black;">拼命加载中...</text>
  56. </template>
  57. </uqrcode>
  58. </view>
  59. <view class="content">
  60. <view class="item">
  61. <view class="label">
  62. 联系号码
  63. </view>
  64. <view class="value">
  65. {{info.goodsList[0].goodsInfo.phone}}
  66. </view>
  67. </view>
  68. <view class="item">
  69. <view class="label">
  70. 就餐方式
  71. </view>
  72. <view class="value">
  73. {{info.goodsList[0].goodsInfo.eatType == 0?'店内就餐':'打包带走'}}
  74. </view>
  75. </view>
  76. <view class="item">
  77. <view class="label">
  78. 备注
  79. </view>
  80. <view class="value">
  81. {{info.goodsList[0].goodsInfo.remark ||'-'}}
  82. </view>
  83. </view>
  84. </view>
  85. <view class="content">
  86. <view class="title">
  87. 订单信息
  88. </view>
  89. <view class="item">
  90. <view class="label">
  91. 订单编号
  92. </view>
  93. <view class="value">
  94. {{info.orderNo}}
  95. </view>
  96. </view>
  97. <view class="item" v-if="info.goodsList[0].goodsState == 'WAIT_USE'">
  98. <view class="label">
  99. 付款方式
  100. </view>
  101. <view class="value">
  102. {{info.payment | filterPay}}
  103. </view>
  104. </view>
  105. <view class="item">
  106. <view class="label">
  107. 下单时间
  108. </view>
  109. <view class="value">
  110. {{$u.timeFormat(info.createTime,'yyyy-mm-dd hh:MM:ss')}}
  111. </view>
  112. </view>
  113. <view class="item" v-if="info.goodsList[0].goodsState != 'WAIT_PAYMENT' && info.goodsList[0].goodsState != 'CLOSE'">
  114. <view class="label">
  115. 支付时间
  116. </view>
  117. <view class="value" >
  118. {{payTime}}
  119. </view>
  120. </view>
  121. </view>
  122. <view class="btn-box" v-if="info.goodsList[0].goodsState == 'WAIT_PAYMENT'">
  123. <button class="cancel-btn" @click="cancel" :loading="btnLoading">
  124. 取消订单
  125. </button>
  126. <button class="btn" @click="pay" :loading="btnLoading">
  127. 立即支付
  128. </button>
  129. </view>
  130. </view>
  131. </template>
  132. <script>
  133. import {qrCode} from '@/api/order.js'
  134. import {payDetails,queryPayOrder,unRefund,refundIntervene} from '@/api/payment.js';
  135. import {cancelOrder} from '@/api/refuel.js'
  136. export default {
  137. data() {
  138. return {
  139. codeData:'123',
  140. show:false,
  141. loading:false,
  142. pageLoading:true,
  143. btnLoading:false,
  144. btnLoading1:false,
  145. oldBright:0,
  146. info:{
  147. // goodsList:[{goodsState:'CLOSE'}]
  148. },
  149. isNotTime:false
  150. }
  151. },
  152. watch: {
  153. // isNotTime(val) {
  154. // if(this.isNotTime){
  155. // this.payDetails(this.info.orderNo)
  156. // }
  157. // }
  158. },
  159. filters: {
  160. filterType: function(val) {
  161. if(val.refundLog&&val.refundLog.refund == 'REFUSAL_REFUND'&&!val.change){
  162. return '拒绝退款'
  163. }
  164. else if(val.goodsState == 'APPLY_REFUND'){
  165. return '退款审核中'
  166. }else if(val.goodsState == 'CLOSE'){
  167. return '关闭订单'
  168. }else if(val.goodsState == 'REFUNDED'){
  169. return '已退款'
  170. }else if(val.goodsState == 'REFUSAL_REFUND'){
  171. return '拒绝退款'
  172. }else if(val.goodsState == 'APPLY_REFUNDING'){
  173. return '退款中'
  174. }else if(val.goodsState == 'USED'){
  175. return '订单已完成'
  176. }else if(val.goodsState == 'WAIT_PAYMENT'){
  177. return '待付款'
  178. }else if(val.goodsState == 'WAIT_USE'){
  179. return '待使用'
  180. }else{
  181. return ''
  182. }
  183. },
  184. filterPay(val){
  185. if(val){
  186. if(val.paymentWay == 'wx.unifiedOrder'){
  187. return '微信支付'
  188. }else if(val.paymentWay == 'trade.create'){
  189. return '支付宝支付'
  190. }else if(val.paymentWay == 'uac.miniOrder'){
  191. return '云闪付支付'
  192. }
  193. }
  194. else{
  195. return '-'
  196. }
  197. }
  198. },
  199. computed: {
  200. closeTime() {
  201. return (this.info.createTime + 1000*60*30) - new Date().getTime()
  202. },
  203. payTime(){
  204. if(this.info.payment && this.info.payment.paymentTime){
  205. return uni.$u.timeFormat(this.info.payment.paymentTime,'yyyy-mm-dd hh:MM:ss')
  206. }else{
  207. return '-'
  208. }
  209. }
  210. },
  211. methods: {
  212. finish(){
  213. this.isNotTime = true
  214. this.payDetails(this.info.orderNo)
  215. },
  216. refundDetail(){
  217. uni.navigateTo({
  218. url:`/my/order/refundDetail?id=${this.info.orderNo}`
  219. })
  220. },
  221. close(){
  222. this.show = false
  223. // uni.setScreenBrightness({
  224. // value:this.oldBright
  225. // })
  226. },
  227. handleCall(){
  228. uni.makePhoneCall({
  229. phoneNumber: '4000016553'//仅为示例
  230. });
  231. },
  232. apply(){
  233. let that = this
  234. if(this.info.goodsList[0].jobFlowMap == 'XiaoJu'){
  235. uni.navigateTo({
  236. url:'./webView'
  237. })
  238. }else{
  239. uni.navigateTo({
  240. url:'./refund',
  241. success: function(res) {
  242. // 通过eventChannel向被打开页面传送数据
  243. res.eventChannel.emit('orderInfo', that.info)
  244. }
  245. })
  246. }
  247. },
  248. // 获取订单详情
  249. payDetails(orderNo){
  250. payDetails(orderNo).then(res=>{
  251. this.pageLoading = false
  252. this.info = res.content
  253. if(!this.info.goodsList[0].refundLog){
  254. this.info.goodsList[0].refundLog = {}
  255. }
  256. if(this.info.goodsList[0].jobFlowMap != 'P802'&&this.info.goodsList[0].goodsState == 'WAIT_USE'&&this.info.goodsList[0].goodsName!='二维码支付'){
  257. qrCode(this.info.goodsList[0].id).then(res=>{
  258. this.loading = false
  259. if(res.state == 'Success'){
  260. this.codeData = res.content
  261. }
  262. })
  263. }
  264. })
  265. },
  266. // 取消支付
  267. cancel(){
  268. uni.showLoading({
  269. title: '取消中'
  270. })
  271. let obj = this.info.goodsList[0].extend
  272. cancelOrder(obj).then(res=>{
  273. if(res.state == 'Success'){
  274. uni.showToast({
  275. title: '取消成功',
  276. icon: 'success'
  277. })
  278. this.payDetails(this.info.orderNo)
  279. }
  280. })
  281. },
  282. // 支付
  283. pay(){
  284. let that = this
  285. if(this.info.goodsList[0].jobFlowMap == 'XiaoJu'){
  286. let {xjOrderId,tradeId} = this.info.goodsList[0].extend
  287. uni.navigateToMiniProgram({
  288. appId:"wx0d252f6ed9755862", // 滴滴加油小程序appId
  289. path: `packageA/pages/open-energy-pay/index?orderId=${xjOrderId}&tradeId=${tradeId}`, // 滴滴加油收银台页面地址,需要拼接orderId和tradeId
  290. envVersion: 'release', // 固定release
  291. })
  292. }else{
  293. if (this.btnLoading) return
  294. this.btnLoading = true
  295. uni.showLoading({
  296. title: '支付中'
  297. })
  298. let miniPayRequest = JSON.parse(this.info.payment.miniPayRequest)
  299. uni.requestPayment({
  300. "provider": "wxpay",
  301. "orderInfo": miniPayRequest,
  302. "appid": miniPayRequest.appId, // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
  303. "paySign": miniPayRequest.paySign,
  304. "nonceStr": miniPayRequest.nonceStr, // 随机字符串
  305. "package": miniPayRequest.package, // 固定值
  306. // "prepayid": miniPayRequest.package, // 统一下单订单号
  307. "timeStamp": miniPayRequest.timeStamp, // 时间戳(单位:秒)
  308. "signType": miniPayRequest.signType, //签名算法
  309. success(msg) {
  310. console.log('msg', msg);
  311. queryPayOrder(that.info.orderNo).then(res1 => {
  312. if (res1.state == 'Success') {
  313. uni.hideLoading()
  314. uni.showToast({
  315. title: '支付成功',
  316. icon: 'success'
  317. })
  318. that.btnLoading = false
  319. that.payDetails(that.info.orderNo)
  320. }
  321. })
  322. },
  323. fail(e) {
  324. that.btnLoading = false
  325. uni.hideLoading()
  326. uni.showToast({
  327. title: '取消支付',
  328. icon: 'fail'
  329. })
  330. // 取消支付后,获取支付信息以备再次支付
  331. that.payDetails(that.info.orderNo)
  332. console.log('err', e,this);
  333. }
  334. })
  335. }
  336. },
  337. // 取消退款申请
  338. cancelReply(){
  339. if (this.btnLoading) return
  340. this.btnLoading = true
  341. uni.showLoading({
  342. title: '取消中'
  343. })
  344. unRefund({id:this.info.goodsList[0].id}).then(res=>{
  345. this.btnLoading = false
  346. uni.hideLoading()
  347. if (res.state == 'Success') {
  348. this.payDetails(this.info.orderNo)
  349. uni.showToast({
  350. title:'取消成功',
  351. icon:'success'
  352. })
  353. }
  354. })
  355. }
  356. },
  357. onReady() {
  358. },
  359. onLoad(options) {
  360. this.info.orderNo = options.id
  361. },
  362. onShow() {
  363. this.pageLoading = true
  364. this.payDetails(this.info.orderNo)
  365. },
  366. created() {
  367. // this.info = JSON.parse(uni.getStorageSync('order'))
  368. }
  369. }
  370. </script>
  371. <style lang="scss">
  372. .order-detail{
  373. background: #F9F9F9;
  374. min-height: 100vh;
  375. padding-bottom: 100rpx;
  376. .status-box{
  377. padding: 24rpx 24rpx 4rpx;
  378. display: flex;
  379. justify-content: space-between;
  380. .text-box{
  381. color: #181818;
  382. .status{
  383. font-weight: bold;
  384. font-size: 32rpx;
  385. display: flex;
  386. .u-count-down__text{
  387. color: $uni-color-primary!important;
  388. }
  389. }
  390. .notice{
  391. font-size: 24rpx;
  392. margin-top: 20rpx;
  393. }
  394. }
  395. }
  396. .goods-box{
  397. .goods-item{
  398. display: flex;
  399. align-items: center;
  400. justify-content: space-between;
  401. padding: 12rpx 0;
  402. .left{
  403. display: flex;
  404. align-items: center;
  405. .icon{
  406. width: 80rpx;
  407. height: 80rpx;
  408. border-radius: 16rpx 16rpx 16rpx 16rpx;
  409. }
  410. .name{
  411. font-size: 28rpx;
  412. color: #222222;
  413. margin-left: 20rpx;
  414. max-width: 400rpx;
  415. white-space: nowrap;
  416. overflow: hidden;
  417. text-overflow: ellipsis;
  418. }
  419. .num{
  420. font-size: 24rpx;
  421. color: #AAAAAA;
  422. margin-left: 20rpx;
  423. }
  424. }
  425. .right{
  426. font-size: 28rpx;
  427. color: #222222;
  428. }
  429. }
  430. .total-box{
  431. display: flex;
  432. align-items: center;
  433. justify-content: flex-end;
  434. font-size: 28rpx;
  435. color: #222222;
  436. padding-top: 24rpx;
  437. border-top: 1rpx solid #F0F0F0;
  438. .num{
  439. }
  440. .price{
  441. margin-left: 20rpx;
  442. }
  443. }
  444. }
  445. .shop-box{
  446. width: 690rpx;
  447. // margin: 0 30rpx;
  448. // padding: 24rpx 24rpx 30rpx;
  449. background: #fff;
  450. border-radius: 16rpx;
  451. margin-top: -30rpx;
  452. box-sizing: border-box;
  453. .shop-name{
  454. font-weight: 600;
  455. font-size: 32rpx;
  456. color: #181818;
  457. width: 100%;
  458. white-space: nowrap;
  459. overflow: hidden;
  460. text-overflow: ellipsis;
  461. }
  462. .address{
  463. font-weight: 300;
  464. font-size: 24rpx;
  465. color: #AAAAAA;
  466. margin-top: 20rpx;
  467. width: 100%;
  468. white-space: nowrap;
  469. overflow: hidden;
  470. text-overflow: ellipsis;
  471. }
  472. }
  473. .black{
  474. color: #222222!important;
  475. }
  476. .red{
  477. color: red!important;
  478. }
  479. .fs28{
  480. font-size: 28rpx!important;
  481. font-weight: bold;
  482. }
  483. .code-box{
  484. // .left{
  485. // .title{
  486. // font-weight: 500;
  487. // font-size: 28rpx;
  488. // color: #222222;
  489. // }
  490. // .codeNum{
  491. // font-weight: 300;
  492. // font-size: 24rpx;
  493. // color: #AAAAAA;
  494. // margin-top: 15rpx;
  495. // }
  496. // }
  497. .qrcode{
  498. display: flex;
  499. align-items: center;
  500. justify-content: center;
  501. margin-top: 20rpx;
  502. }
  503. .code-btn{
  504. display: flex;
  505. align-items: center;
  506. font-weight: 300;
  507. font-size: 24rpx;
  508. color: #AAAAAA;
  509. .jiantou{
  510. width: 24rpx;
  511. height: 24rpx;
  512. }
  513. }
  514. }
  515. .input-box{
  516. margin: 20rpx 30rpx;
  517. padding: 28rpx 24rpx;
  518. background: #FFFFFF;
  519. border-radius: 16rpx 16rpx 16rpx 16rpx;
  520. display: flex;
  521. align-items: center;
  522. justify-content: space-between;
  523. .label {
  524. color: #222;
  525. font-size: 28rpx;
  526. }
  527. .value {
  528. font-size: 28rpx;
  529. color: #AAAAAA;
  530. }
  531. }
  532. .content{
  533. margin: 20rpx 30rpx;
  534. padding: 28rpx 24rpx;
  535. border-radius: 16rpx;
  536. background: #fff;
  537. .title{
  538. font-weight: 600;
  539. font-size: 28rpx;
  540. color: #222222;
  541. }
  542. .item{
  543. display: flex;
  544. align-items: center;
  545. justify-content: space-between;
  546. margin-top: 28rpx;
  547. .label{
  548. font-size: 28rpx;
  549. color: #AAAAAA;
  550. }
  551. .value{
  552. font-size: 28rpx;
  553. color: #222222;
  554. }
  555. }
  556. }
  557. .pay-btn{
  558. background: $uni-color-primary;
  559. width: 688rpx;
  560. height: 80rpx;
  561. line-height: 80rpx;
  562. border-radius: 46rpx;
  563. color: #fff;
  564. margin-top: 50rpx;
  565. }
  566. .refund-box{
  567. .refund-msg{
  568. font-weight: 300;
  569. font-size: 24rpx;
  570. color: #222222;
  571. margin-top: 15rpx;
  572. line-height: 40rpx;
  573. }
  574. }
  575. .apply-box{
  576. position: relative;
  577. .label{
  578. font-weight: 600;
  579. font-size: 28rpx;
  580. color: #222222;
  581. }
  582. .value{
  583. color: #999999;
  584. font-size: 24rpx;
  585. margin-top: 15rpx;
  586. }
  587. .jiantou{
  588. position: absolute;
  589. top: 50%;
  590. right: 24rpx;
  591. transform: translateY(-50%);
  592. width: 24rpx;
  593. height: 24rpx;
  594. }
  595. }
  596. .btn-box {
  597. position: fixed;
  598. bottom: 0%;
  599. left: 0%;
  600. width: 100%;
  601. display: flex;
  602. align-items: center;
  603. justify-content: flex-end;
  604. box-sizing: border-box;
  605. padding: 10rpx 24rpx env(safe-area-inset-bottom);
  606. background: #fff;
  607. border-top: 1rpx solid #EEEEEE;
  608. .cancel-btn{
  609. width: 240rpx;
  610. height: 80rpx;
  611. line-height: 80rpx;
  612. text-align: center;
  613. border-radius: 40rpx;
  614. border: 2rpx solid #EE4320;
  615. font-weight: 600;
  616. font-size: 28rpx;
  617. color: #EE4320;
  618. margin: 0;
  619. }
  620. .btn {
  621. width: 240rpx;
  622. height: 80rpx;
  623. line-height: 80rpx;
  624. text-align: center;
  625. background: $uni-color-primary;
  626. border-radius: 40rpx;
  627. font-weight: 600;
  628. font-size: 28rpx;
  629. color: #FFFFFF;
  630. margin: 0;
  631. margin-left: 20rpx;
  632. }
  633. }
  634. .info{
  635. .order-info{
  636. display: flex;
  637. .icon{
  638. width: 164rpx;
  639. height: 164rpx;
  640. border-radius: 16rpx;
  641. flex-shrink: 0;
  642. }
  643. .shop-info{
  644. display: flex;
  645. flex-direction: column;
  646. justify-content: space-between;
  647. padding-left: 24rpx;
  648. flex: 1;
  649. box-sizing: border-box;
  650. .title{
  651. color: #181818;
  652. font-size: 28rpx;
  653. width: 450rpx;
  654. white-space: nowrap;
  655. overflow: hidden;
  656. text-overflow: ellipsis;
  657. }
  658. .price-box{
  659. display: flex;
  660. align-items: center;
  661. justify-content: space-between;
  662. .price{
  663. color: #181818;
  664. color: $uni-color-primary;
  665. font-size: 32rpx;
  666. font-weight: bold;
  667. }
  668. }
  669. .start-time,.goods-desc{
  670. font-size: 24rpx;
  671. color: #AAAAAA;
  672. width: 450rpx;
  673. white-space: nowrap;
  674. overflow: hidden;
  675. text-overflow: ellipsis;
  676. }
  677. }
  678. }
  679. }
  680. .wrap{
  681. display: flex;
  682. justify-content: center;
  683. align-items: center;
  684. height: 100vh;
  685. overflow: hidden;
  686. }
  687. }
  688. </style>