detail.vue 18 KB

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