detail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  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,closeOrder} 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*15) - 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. // 获取订单详情
  233. payDetails(orderNo){
  234. payDetails(orderNo).then(res=>{
  235. this.pageLoading = false
  236. this.info = res.content
  237. if(!this.info.goodsList[0].refundLog){
  238. this.info.goodsList[0].refundLog = {}
  239. }
  240. if(this.info.goodsList[0].goodsState == 'WAIT_USE'){
  241. qrCode(this.info.goodsList[0].id).then(res=>{
  242. this.loading = false
  243. if(res.state == 'Success'){
  244. this.codeData = res.content
  245. }
  246. })
  247. }
  248. })
  249. },
  250. // 取消支付
  251. cancel(){
  252. uni.showLoading({
  253. title: '取消中'
  254. })
  255. closeOrder(this.info.orderNo).then(res=>{
  256. if(res.state == 'Success'){
  257. uni.showToast({
  258. title: '取消成功',
  259. icon: 'success'
  260. })
  261. this.payDetails(this.info.orderNo)
  262. }
  263. })
  264. },
  265. // 支付
  266. pay(){
  267. let that = this
  268. if (this.btnLoading) return
  269. this.btnLoading = true
  270. uni.showLoading({
  271. title: '支付中'
  272. })
  273. let miniPayRequest = JSON.parse(this.info.payment.miniPayRequest)
  274. uni.requestPayment({
  275. "provider": "wxpay",
  276. "orderInfo": miniPayRequest,
  277. "appid": miniPayRequest.appId, // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
  278. "paySign": miniPayRequest.paySign,
  279. "nonceStr": miniPayRequest.nonceStr, // 随机字符串
  280. "package": miniPayRequest.package, // 固定值
  281. // "prepayid": miniPayRequest.package, // 统一下单订单号
  282. "timeStamp": miniPayRequest.timeStamp, // 时间戳(单位:秒)
  283. "signType": miniPayRequest.signType, //签名算法
  284. success(msg) {
  285. console.log('msg', msg);
  286. queryPayOrder(that.info.orderNo).then(res1 => {
  287. if (res1.state == 'Success') {
  288. uni.hideLoading()
  289. uni.showToast({
  290. title: '支付成功',
  291. icon: 'success'
  292. })
  293. that.btnLoading = false
  294. that.payDetails(that.info.orderNo)
  295. }
  296. })
  297. },
  298. fail(e) {
  299. that.btnLoading = false
  300. uni.hideLoading()
  301. uni.showToast({
  302. title: '取消支付',
  303. icon: 'fail'
  304. })
  305. // 取消支付后,获取支付信息以备再次支付
  306. that.payDetails(that.info.orderNo)
  307. console.log('err', e,this);
  308. }
  309. })
  310. },
  311. // 取消退款申请
  312. cancelReply(){
  313. if (this.btnLoading) return
  314. this.btnLoading = true
  315. uni.showLoading({
  316. title: '取消中'
  317. })
  318. unRefund({id:this.info.goodsList[0].id}).then(res=>{
  319. this.btnLoading = false
  320. uni.hideLoading()
  321. if (res.state == 'Success') {
  322. this.payDetails(this.info.orderNo)
  323. uni.showToast({
  324. title:'取消成功',
  325. icon:'success'
  326. })
  327. }
  328. })
  329. }
  330. },
  331. onReady() {
  332. },
  333. onLoad(options) {
  334. this.info.orderNo = options.id
  335. },
  336. onShow() {
  337. this.pageLoading = true
  338. this.payDetails(this.info.orderNo)
  339. },
  340. created() {
  341. // this.info = JSON.parse(uni.getStorageSync('order'))
  342. }
  343. }
  344. </script>
  345. <style lang="scss">
  346. .order-detail{
  347. background: #F9F9F9;
  348. min-height: 100vh;
  349. padding-bottom: 100rpx;
  350. .status-box{
  351. padding: 24rpx 24rpx 4rpx;
  352. display: flex;
  353. justify-content: space-between;
  354. .text-box{
  355. color: #181818;
  356. .status{
  357. font-weight: bold;
  358. font-size: 32rpx;
  359. display: flex;
  360. .u-count-down__text{
  361. color: $uni-color-primary!important;
  362. }
  363. }
  364. .notice{
  365. font-size: 24rpx;
  366. margin-top: 20rpx;
  367. }
  368. }
  369. }
  370. .goods-box{
  371. .goods-item{
  372. display: flex;
  373. align-items: center;
  374. justify-content: space-between;
  375. padding: 12rpx 0;
  376. .left{
  377. display: flex;
  378. align-items: center;
  379. .icon{
  380. width: 80rpx;
  381. height: 80rpx;
  382. border-radius: 16rpx 16rpx 16rpx 16rpx;
  383. }
  384. .name{
  385. font-size: 28rpx;
  386. color: #222222;
  387. margin-left: 20rpx;
  388. max-width: 400rpx;
  389. white-space: nowrap;
  390. overflow: hidden;
  391. text-overflow: ellipsis;
  392. }
  393. .num{
  394. font-size: 24rpx;
  395. color: #AAAAAA;
  396. margin-left: 20rpx;
  397. }
  398. }
  399. .right{
  400. font-size: 28rpx;
  401. color: #222222;
  402. }
  403. }
  404. .total-box{
  405. display: flex;
  406. align-items: center;
  407. justify-content: flex-end;
  408. font-size: 28rpx;
  409. color: #222222;
  410. padding-top: 24rpx;
  411. border-top: 1rpx solid #F0F0F0;
  412. .num{
  413. }
  414. .price{
  415. margin-left: 20rpx;
  416. }
  417. }
  418. }
  419. .shop-box{
  420. width: 690rpx;
  421. // margin: 0 30rpx;
  422. // padding: 24rpx 24rpx 30rpx;
  423. background: #fff;
  424. border-radius: 16rpx;
  425. margin-top: -30rpx;
  426. box-sizing: border-box;
  427. .shop-name{
  428. font-weight: 600;
  429. font-size: 32rpx;
  430. color: #181818;
  431. width: 100%;
  432. white-space: nowrap;
  433. overflow: hidden;
  434. text-overflow: ellipsis;
  435. }
  436. .address{
  437. font-weight: 300;
  438. font-size: 24rpx;
  439. color: #AAAAAA;
  440. margin-top: 20rpx;
  441. width: 100%;
  442. white-space: nowrap;
  443. overflow: hidden;
  444. text-overflow: ellipsis;
  445. }
  446. }
  447. .black{
  448. color: #222222!important;
  449. }
  450. .red{
  451. color: red!important;
  452. }
  453. .fs28{
  454. font-size: 28rpx!important;
  455. font-weight: bold;
  456. }
  457. .code-box{
  458. // .left{
  459. // .title{
  460. // font-weight: 500;
  461. // font-size: 28rpx;
  462. // color: #222222;
  463. // }
  464. // .codeNum{
  465. // font-weight: 300;
  466. // font-size: 24rpx;
  467. // color: #AAAAAA;
  468. // margin-top: 15rpx;
  469. // }
  470. // }
  471. .qrcode{
  472. display: flex;
  473. align-items: center;
  474. justify-content: center;
  475. margin-top: 20rpx;
  476. }
  477. .code-btn{
  478. display: flex;
  479. align-items: center;
  480. font-weight: 300;
  481. font-size: 24rpx;
  482. color: #AAAAAA;
  483. .jiantou{
  484. width: 24rpx;
  485. height: 24rpx;
  486. }
  487. }
  488. }
  489. .input-box{
  490. margin: 20rpx 30rpx;
  491. padding: 28rpx 24rpx;
  492. background: #FFFFFF;
  493. border-radius: 16rpx 16rpx 16rpx 16rpx;
  494. display: flex;
  495. align-items: center;
  496. justify-content: space-between;
  497. .label {
  498. color: #222;
  499. font-size: 28rpx;
  500. }
  501. .value {
  502. font-size: 28rpx;
  503. color: #AAAAAA;
  504. }
  505. }
  506. .content{
  507. margin: 20rpx 30rpx;
  508. padding: 28rpx 24rpx;
  509. border-radius: 16rpx;
  510. background: #fff;
  511. .title{
  512. font-weight: 600;
  513. font-size: 28rpx;
  514. color: #222222;
  515. }
  516. .item{
  517. display: flex;
  518. align-items: center;
  519. justify-content: space-between;
  520. margin-top: 28rpx;
  521. .label{
  522. font-size: 28rpx;
  523. color: #AAAAAA;
  524. }
  525. .value{
  526. font-size: 28rpx;
  527. color: #222222;
  528. }
  529. }
  530. }
  531. .pay-btn{
  532. background: $uni-color-primary;
  533. width: 688rpx;
  534. height: 80rpx;
  535. line-height: 80rpx;
  536. border-radius: 46rpx;
  537. color: #fff;
  538. margin-top: 50rpx;
  539. }
  540. .refund-box{
  541. .refund-msg{
  542. font-weight: 300;
  543. font-size: 24rpx;
  544. color: #222222;
  545. margin-top: 15rpx;
  546. line-height: 40rpx;
  547. }
  548. }
  549. .apply-box{
  550. position: relative;
  551. .label{
  552. font-weight: 600;
  553. font-size: 28rpx;
  554. color: #222222;
  555. }
  556. .value{
  557. color: #999999;
  558. font-size: 24rpx;
  559. margin-top: 15rpx;
  560. }
  561. .jiantou{
  562. position: absolute;
  563. top: 50%;
  564. right: 24rpx;
  565. transform: translateY(-50%);
  566. width: 24rpx;
  567. height: 24rpx;
  568. }
  569. }
  570. .btn-box {
  571. position: fixed;
  572. bottom: 0%;
  573. left: 0%;
  574. width: 100%;
  575. display: flex;
  576. align-items: center;
  577. justify-content: flex-end;
  578. box-sizing: border-box;
  579. padding: 10rpx 24rpx env(safe-area-inset-bottom);
  580. background: #fff;
  581. border-top: 1rpx solid #EEEEEE;
  582. .cancel-btn{
  583. width: 240rpx;
  584. height: 80rpx;
  585. line-height: 80rpx;
  586. text-align: center;
  587. border-radius: 40rpx;
  588. border: 2rpx solid #EE4320;
  589. font-weight: 600;
  590. font-size: 28rpx;
  591. color: #EE4320;
  592. margin: 0;
  593. }
  594. .btn {
  595. width: 240rpx;
  596. height: 80rpx;
  597. line-height: 80rpx;
  598. text-align: center;
  599. background: $uni-color-primary;
  600. border-radius: 40rpx;
  601. font-weight: 600;
  602. font-size: 28rpx;
  603. color: #FFFFFF;
  604. margin: 0;
  605. margin-left: 20rpx;
  606. }
  607. }
  608. .info{
  609. .order-info{
  610. display: flex;
  611. .icon{
  612. width: 164rpx;
  613. height: 164rpx;
  614. border-radius: 16rpx;
  615. flex-shrink: 0;
  616. }
  617. .shop-info{
  618. display: flex;
  619. flex-direction: column;
  620. justify-content: space-between;
  621. padding-left: 24rpx;
  622. flex: 1;
  623. box-sizing: border-box;
  624. .title{
  625. color: #181818;
  626. font-size: 28rpx;
  627. width: 450rpx;
  628. white-space: nowrap;
  629. overflow: hidden;
  630. text-overflow: ellipsis;
  631. }
  632. .price-box{
  633. display: flex;
  634. align-items: center;
  635. justify-content: space-between;
  636. .price{
  637. color: #181818;
  638. color: $uni-color-primary;
  639. font-size: 32rpx;
  640. font-weight: bold;
  641. }
  642. }
  643. .start-time,.goods-desc{
  644. font-size: 24rpx;
  645. color: #AAAAAA;
  646. width: 450rpx;
  647. white-space: nowrap;
  648. overflow: hidden;
  649. text-overflow: ellipsis;
  650. }
  651. }
  652. }
  653. }
  654. .wrap{
  655. display: flex;
  656. justify-content: center;
  657. align-items: center;
  658. height: 100vh;
  659. overflow: hidden;
  660. }
  661. }
  662. </style>