detail.vue 16 KB

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