detail.vue 12 KB

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