detail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. <template>
  2. <view class="order-detail">
  3. <view class="status-box">
  4. <view class="text-box">
  5. <view class="status" v-if="info.goodsList[0].goodsState == 'WAIT_PAYMENT'&&!isNotTime">
  6. 等待支付,剩余<u-count-down :time="closeTime" format="HH:mm:ss" @finish="finish"></u-count-down>
  7. </view>
  8. <view class="status" v-else>
  9. {{info.goodsList[0].goodsState | filterType}}
  10. </view>
  11. </view>
  12. </view>
  13. <view class="content progress" v-if="info.goodsList[0].goodsState == 'APPLY_REFUND' || info.goodsList[0].goodsState == 'REFUNDED'" @click="refundDetail">
  14. <view class="progress-title">
  15. 退款进度
  16. </view>
  17. <view class="progress-desc">
  18. 查看退款详情
  19. </view>
  20. </view>
  21. <view class="content shop-box" v-if="!isVisual">
  22. <view class="shop-name">
  23. {{info.shopInfo.shopName}}
  24. </view>
  25. <view class="address">
  26. {{info.shopInfo.address}}
  27. </view>
  28. </view>
  29. <view class="content info">
  30. <view class="order-info">
  31. <image class="icon" :src="info.goodsList[0].goodsInfo.goodsPath" mode=""></image>
  32. <view class="shop-info">
  33. <view class="title">
  34. {{info.goodsList[0].goodsInfo.goodsName}}
  35. </view>
  36. <view class="goods-desc">
  37. {{info.goodsList[0].goodsInfo.goodsDescribe}}
  38. </view>
  39. <view class="price-box">
  40. <view class="price">
  41. ¥{{info.goodsList[0].goodsInfo.realPrice}}
  42. </view>
  43. </view>
  44. <!-- 有extend并且不是虚拟商品 -->
  45. <!-- <view class="start-time" v-if="info.extend&&!isVisual">
  46. 出发时间:{{info.extend}}
  47. </view> -->
  48. </view>
  49. </view>
  50. </view>
  51. <view class="content code-box" v-if="info.goodsList[0].goodsState == 'WAIT_USE'&&info.goodsList[0].goodsName!='二维码支付'">
  52. <view class="left">
  53. <view class="title">
  54. 券码信息
  55. </view>
  56. <view class="codeNum">
  57. </view>
  58. </view>
  59. <view class="code-btn" @click="checkCode">
  60. 查看券码 <image class="jiantou" src="../../static/jiantou-icon.png" mode=""></image>
  61. </view>
  62. </view>
  63. <view class="content" v-if="info.goodsList[0].goodsState == 'USED'">
  64. <view class="title">
  65. 消费记录
  66. </view>
  67. <view class="item">
  68. <view class="label">
  69. 消费时间
  70. </view>
  71. <view class="value">
  72. {{$u.timeFormat(info.goodsList[0].verifyModel.checkTime,'yyyy-mm-dd hh:MM:ss')}}
  73. </view>
  74. </view>
  75. <view class="item">
  76. <view class="label">
  77. 消费门店
  78. </view>
  79. <view class="value">
  80. {{info.goodsList[0].verifyModel.shopName}}
  81. </view>
  82. </view>
  83. </view>
  84. <view class="content">
  85. <view class="title">
  86. 订单信息
  87. </view>
  88. <view class="item">
  89. <view class="label">
  90. 订单编号
  91. </view>
  92. <view class="value">
  93. {{info.orderNo}}
  94. </view>
  95. </view>
  96. <view class="item">
  97. <view class="label">
  98. 付款方式
  99. </view>
  100. <view class="value">
  101. {{info.payment.paymentWay | filterPay}}
  102. </view>
  103. </view>
  104. <view class="item">
  105. <view class="label">
  106. 下单时间
  107. </view>
  108. <view class="value">
  109. {{$u.timeFormat(info.createTime,'yyyy-mm-dd hh:MM:ss')}}
  110. </view>
  111. </view>
  112. <view class="item" v-if="info.goodsList[0].goodsState != 'WAIT_PAYMENT' && info.goodsList[0].goodsState != 'CLOSE'">
  113. <view class="label">
  114. 支付时间
  115. </view>
  116. <view class="value">
  117. {{$u.timeFormat(info.payment.paymentTime,'yyyy-mm-dd hh:MM:ss')}}
  118. </view>
  119. </view>
  120. </view>
  121. <view class="content">
  122. <view class="title">
  123. 交易信息
  124. </view>
  125. <view class="item">
  126. <view class="label">
  127. 商品金额
  128. </view>
  129. <view class="value black">
  130. ¥{{info.goodsList[0].goodsInfo.realPrice}}
  131. </view>
  132. </view>
  133. <view class="item" >
  134. <view class="label">
  135. 优惠券
  136. </view>
  137. <view class="value red">
  138. -¥{{info.discountAmount}}
  139. </view>
  140. </view>
  141. <view class="item">
  142. <view class="label">
  143. 合计
  144. </view>
  145. <view class="value">
  146. <text class="red fs28">¥{{info.payAmount}}</text>
  147. </view>
  148. </view>
  149. </view>
  150. <view class="input-box" v-if="isVisual">
  151. <view class="label">
  152. 充值账号
  153. </view>
  154. <view class="value">
  155. {{JSON.parse(info.extend).account}}
  156. </view>
  157. </view>
  158. <template v-if="info.goodsList[0].goodsState == 'APPLY_REFUND'">
  159. <view class="content refund-box">
  160. <view class="title">
  161. 退款原因
  162. </view>
  163. <view class="refund-msg">
  164. {{info.goodsList[0].refundLog.remark}}
  165. </view>
  166. </view>
  167. <button type="default" :loading="btnLoading" v-if="!info.payment.transferAll" class="pay-btn" @click="cancelReply" >取消退款</button>
  168. </template>
  169. <button type="default" :loading="btnLoading" class="pay-btn" v-if="info.goodsList[0].goodsState == 'WAIT_PAYMENT'" @click="pay" >立即支付</button>
  170. <view class="content apply-box" v-else-if="(info.goodsList[0].goodsState == 'WAIT_USE'||info.goodsList[0].goodsState == 'USED')&&isRefund()" @click="apply">
  171. <view class="label">
  172. 退款申请
  173. </view>
  174. <view class="value">
  175. 如引发商品争议,可申请平台介入处理
  176. </view>
  177. <image class="jiantou" src="../../static/jiantou-icon.png" mode=""></image>
  178. </view>
  179. <!-- 二维码 -->
  180. <u-overlay :show="show" v-if="show" :opacity="0.6">
  181. <view class="wrap" @click.stop="close">
  182. <uqrcode ref="uqrcode" type="2d" auto canvas-id="qrcode" :value="codeData" :loading="loading" :options="{ margin: 20 }">
  183. <template v-slot:loading>
  184. <text style="color: black;">拼命加载中...</text>
  185. </template>
  186. </uqrcode>
  187. </view>
  188. </u-overlay>
  189. </view>
  190. </template>
  191. <script>
  192. import {qrCode} from '@/api/order.js'
  193. import {payDetails,queryPayOrder,unRefund} from '@/api/payment.js'
  194. export default {
  195. data() {
  196. return {
  197. isVisual:false,//是否是虚拟商品
  198. codeData:'123',
  199. show:false,
  200. loading:false,
  201. btnLoading:false,
  202. oldBright:0,
  203. info:{
  204. goodsList:[{goodsState:''}]
  205. },
  206. isNotTime:false
  207. }
  208. },
  209. watch: {
  210. // isNotTime(val) {
  211. // if(this.isNotTime){
  212. // this.payDetails(this.info.orderNo)
  213. // }
  214. // }
  215. },
  216. filters: {
  217. filterType: function(val) {
  218. if(val == 'APPLY_REFUND'){
  219. return '退款审核中'
  220. }else if(val == 'CLOSE'){
  221. return '关闭订单'
  222. }else if(val == 'REFUNDED'){
  223. return '已退款'
  224. }else if(val == 'REFUSAL_REFUND'){
  225. return '拒绝退款'
  226. }else if(val == 'USED'){
  227. return '订单已完成'
  228. }else if(val == 'WAIT_PAYMENT'){
  229. return '待付款'
  230. }else if(val == 'WAIT_USE'){
  231. return '待使用'
  232. }
  233. },
  234. filterPay(val){
  235. if(val == 'wx.unifiedOrder'){
  236. return '微信支付'
  237. }else if(val == 'trade.create'){
  238. return '支付宝支付'
  239. }else if(val == 'uac.miniOrder'){
  240. return '云闪付支付'
  241. }else{
  242. return '-'
  243. }
  244. }
  245. },
  246. computed: {
  247. closeTime() {
  248. // if((this.info.createTime + 1000*60*15) - new Date().getTime()){
  249. // this.isNotTime = false
  250. // }else{
  251. // this.isNotTime = true
  252. // }
  253. return (this.info.createTime + 1000*60*30) - new Date().getTime()
  254. },
  255. },
  256. methods: {
  257. isRefund(){
  258. if(!this.info.goodsList[0].verifyModel){//没核销
  259. return true
  260. }else if(this.info.goodsList[0].verifyModel && (new Date().getTime() < (this.info.goodsList[0].verifyModel.checkTime + 1000*60*60*48))){// 已核销 并且没超过48小时
  261. return true
  262. }else{
  263. return false
  264. }
  265. },
  266. finish(){
  267. this.isNotTime = true
  268. console.log(222222,this.isNotTime);
  269. this.payDetails(this.info.orderNo)
  270. },
  271. refundDetail(){
  272. uni.navigateTo({
  273. url:`/my/order/refundDetail?id=${this.info.orderNo}`
  274. })
  275. },
  276. checkCode() {
  277. this.codeData = ''
  278. this.$nextTick(()=>{
  279. this.show = true
  280. this.loading = true
  281. let that = this
  282. // uni.getScreenBrightness({
  283. // success(res) {
  284. // // 获取用户手机亮度 保存起来
  285. // that.oldBright = res.value
  286. // setTimeout(()=>{
  287. // uni.setScreenBrightness({
  288. // value:1
  289. // })
  290. // },200)
  291. // }
  292. // })
  293. qrCode(this.info.goodsList[0].id).then(res=>{
  294. this.loading = false
  295. if(res.state == 'Success'){
  296. this.codeData = res.content
  297. }
  298. })
  299. })
  300. },
  301. close(){
  302. this.show = false
  303. // uni.setScreenBrightness({
  304. // value:this.oldBright
  305. // })
  306. },
  307. apply(){
  308. let that = this
  309. uni.navigateTo({
  310. url:'./refund',
  311. success: function(res) {
  312. // 通过eventChannel向被打开页面传送数据
  313. res.eventChannel.emit('orderInfo', that.info)
  314. }
  315. })
  316. },
  317. // 获取订单详情
  318. payDetails(orderNo){
  319. payDetails(orderNo).then(res=>{
  320. this.info = res.content
  321. try{
  322. let extend = JSON.parse(this.info.extend)
  323. if(extend.account){
  324. this.isVisual = true
  325. }
  326. }catch(e){
  327. //TODO handle the exception
  328. }
  329. })
  330. },
  331. // 支付
  332. pay(){
  333. if (this.btnLoading) return
  334. this.btnLoading = true
  335. uni.showLoading({
  336. title: '支付中'
  337. })
  338. let that = this
  339. let miniPayRequest = JSON.parse(this.info.payment.miniPayRequest)
  340. uni.requestPayment({
  341. "provider": "wxpay",
  342. "orderInfo": miniPayRequest,
  343. "appid": miniPayRequest.appId, // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
  344. "paySign": miniPayRequest.paySign,
  345. "nonceStr": miniPayRequest.nonceStr, // 随机字符串
  346. "package": miniPayRequest.package, // 固定值
  347. // "prepayid": miniPayRequest.package, // 统一下单订单号
  348. "timeStamp": miniPayRequest.timeStamp, // 时间戳(单位:秒)
  349. "signType": miniPayRequest.signType, //签名算法
  350. success(msg) {
  351. console.log('msg', msg);
  352. queryPayOrder(that.info.orderNo).then(res1 => {
  353. if (res1.state == 'Success') {
  354. uni.hideLoading()
  355. uni.showToast({
  356. title: '支付成功',
  357. icon: 'success'
  358. })
  359. that.btnLoading = false
  360. that.payDetails(that.info.orderNo)
  361. }
  362. })
  363. },
  364. fail(e) {
  365. that.btnLoading = false
  366. uni.hideLoading()
  367. uni.showToast({
  368. title: '取消支付',
  369. icon: 'fail'
  370. })
  371. // 取消支付后,获取支付信息以备再次支付
  372. that.payDetails(that.info.orderNo)
  373. console.log('err', e,this);
  374. }
  375. })
  376. },
  377. // 取消退款申请
  378. cancelReply(){
  379. if (this.btnLoading) return
  380. this.btnLoading = true
  381. uni.showLoading({
  382. title: '取消中'
  383. })
  384. unRefund({id:this.info.goodsList[0].id}).then(res=>{
  385. this.btnLoading = false
  386. uni.hideLoading()
  387. if (res.state == 'Success') {
  388. this.payDetails(this.info.orderNo)
  389. uni.showToast({
  390. title:'取消成功',
  391. icon:'success'
  392. })
  393. }
  394. })
  395. }
  396. },
  397. onReady() {
  398. },
  399. onLoad(options) {
  400. this.info.orderNo = options.id
  401. },
  402. onShow() {
  403. this.payDetails(this.info.orderNo)
  404. },
  405. created() {
  406. // this.info = JSON.parse(uni.getStorageSync('order'))
  407. }
  408. }
  409. </script>
  410. <style lang="scss">
  411. .order-detail{
  412. background: #F9F9F9;
  413. min-height: 100vh;
  414. padding-bottom: 100rpx;
  415. .status-box{
  416. padding: 24rpx 24rpx 4rpx;
  417. display: flex;
  418. justify-content: space-between;
  419. .text-box{
  420. color: #181818;
  421. .status{
  422. font-weight: bold;
  423. font-size: 32rpx;
  424. display: flex;
  425. .u-count-down__text{
  426. color: #FF4D3A!important;
  427. }
  428. }
  429. .notice{
  430. font-size: 24rpx;
  431. margin-top: 20rpx;
  432. }
  433. }
  434. }
  435. .progress{
  436. .progress-title{
  437. font-weight: 600;
  438. font-size: 32rpx;
  439. color: #181818;
  440. }
  441. .progress-desc{
  442. font-weight: 300;
  443. font-size: 24rpx;
  444. color: #AAAAAA;
  445. margin-top: 15rpx;
  446. }
  447. }
  448. .shop-box{
  449. width: 690rpx;
  450. // margin: 0 30rpx;
  451. // padding: 24rpx 24rpx 30rpx;
  452. background: #fff;
  453. border-radius: 16rpx;
  454. margin-top: -30rpx;
  455. box-sizing: border-box;
  456. .shop-name{
  457. font-weight: 600;
  458. font-size: 32rpx;
  459. color: #181818;
  460. width: 100%;
  461. white-space: nowrap;
  462. overflow: hidden;
  463. text-overflow: ellipsis;
  464. }
  465. .address{
  466. font-weight: 300;
  467. font-size: 24rpx;
  468. color: #AAAAAA;
  469. margin-top: 20rpx;
  470. width: 100%;
  471. white-space: nowrap;
  472. overflow: hidden;
  473. text-overflow: ellipsis;
  474. }
  475. }
  476. .black{
  477. color: #222222!important;
  478. }
  479. .red{
  480. color: red!important;
  481. }
  482. .fs28{
  483. font-size: 28rpx!important;
  484. font-weight: bold;
  485. }
  486. .code-box{
  487. display: flex;
  488. align-items: center;
  489. justify-content: space-between;
  490. .left{
  491. .title{
  492. font-weight: 500;
  493. font-size: 28rpx;
  494. color: #222222;
  495. }
  496. .codeNum{
  497. font-weight: 300;
  498. font-size: 24rpx;
  499. color: #AAAAAA;
  500. margin-top: 15rpx;
  501. }
  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. color: #222222;
  549. font-size: 28rpx;
  550. }
  551. .value{
  552. color: #999999;
  553. font-size: 28rpx;
  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. .info{
  597. .order-info{
  598. display: flex;
  599. .icon{
  600. width: 164rpx;
  601. height: 164rpx;
  602. border-radius: 16rpx;
  603. flex-shrink: 0;
  604. }
  605. .shop-info{
  606. display: flex;
  607. flex-direction: column;
  608. justify-content: space-between;
  609. padding-left: 24rpx;
  610. flex: 1;
  611. box-sizing: border-box;
  612. .title{
  613. color: #181818;
  614. font-size: 28rpx;
  615. width: 450rpx;
  616. white-space: nowrap;
  617. overflow: hidden;
  618. text-overflow: ellipsis;
  619. }
  620. .price-box{
  621. display: flex;
  622. align-items: center;
  623. justify-content: space-between;
  624. .price{
  625. color: #181818;
  626. font-size: 32rpx;
  627. font-weight: bold;
  628. }
  629. }
  630. .start-time,.goods-desc{
  631. font-size: 24rpx;
  632. color: #AAAAAA;
  633. width: 450rpx;
  634. white-space: nowrap;
  635. overflow: hidden;
  636. text-overflow: ellipsis;
  637. }
  638. }
  639. }
  640. }
  641. .wrap{
  642. display: flex;
  643. justify-content: center;
  644. align-items: center;
  645. height: 100vh;
  646. overflow: hidden;
  647. }
  648. }
  649. </style>