detail.vue 16 KB

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