detail.vue 16 KB

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