choosePayment.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. <template>
  2. <view>
  3. <u-modal
  4. v-model="payWayPop"
  5. :title-style="{ color: '#1E1E1E', fontSize: '34rpx' }"
  6. title="选择支付方式"
  7. width="600rpx"
  8. :show-confirm-button="false"
  9. :show-cancel-button="false"
  10. :mask-close-able="true"
  11. @input="modalClose"
  12. >
  13. <view class="pay-content">
  14. <view class="pay-list">
  15. <radio-group @change="payRadioChange">
  16. <!-- #ifdef H5 || MP-WEIXIN -->
  17. <view class="pay-list-item" v-if="wxEnv">
  18. <view class="pay-list-item-image">
  19. <image class="image" src="/static/img/wechat-icon-new.png" mode="aspectFit" />
  20. <view>微信支付</view>
  21. </view>
  22. <view class="radioBox">
  23. <radio color="#2DCF8C" value="weixin" :checked="'weixin' === radioCurrent" />
  24. </view>
  25. </view>
  26. <!-- #endif -->
  27. <template v-if="alipayEnv">
  28. <view class="pay-list-item">
  29. <view class="pay-list-item-image">
  30. <image class="image" src="/static/img/alipay-icon-new.png" mode="aspectFit" />
  31. <view>支付宝支付<text>随机立减最高10元</text></view>
  32. </view>
  33. <view class="radioBox">
  34. <radio color="#2DCF8C" value="juhe" :checked="'juhe' === radioCurrent" />
  35. </view>
  36. </view>
  37. </template>
  38. <view class="pay-list-item">
  39. <view class="pay-list-item-image">
  40. <image class="image" src="/static/img/gy-icon-new.png" mode="aspectFit" />
  41. <view>贵州银行</view>
  42. </view>
  43. <view class="radioBox">
  44. <radio color="#2DCF8C" value="gzyh" :checked="'gzyh' === radioCurrent" />
  45. </view>
  46. </view>
  47. <template v-if="!alipayEnv">
  48. <view class="pay-list-item">
  49. <view class="pay-list-item-image">
  50. <image class="image" src="/static/img/juhe-icon-new.png" mode="aspectFit" />
  51. <view>聚合支付</view>
  52. </view>
  53. <view class="radioBox">
  54. <radio color="#2DCF8C" value="juhe" :checked="'juhe' === radioCurrent" />
  55. </view>
  56. </view>
  57. </template>
  58. </radio-group>
  59. </view>
  60. <view class="pay-coupon" v-if="radioCurrent === 'weixin' && isShowCoupon">
  61. <u-cell-group :border="false">
  62. <u-cell-item
  63. icon=""
  64. title="优惠券"
  65. :value="couponPopup.currentCoupon.couponName || (couponPopup.couponList.length ? '暂未选择优惠券' : '无可用优惠券')"
  66. :border-bottom="false"
  67. @click="chooseCoupon"
  68. ></u-cell-item>
  69. </u-cell-group>
  70. </view>
  71. <view class="pay-money">
  72. <text class="discount-money" v-if="couponPopup.currentCoupon.couponContent && radioCurrent === 'weixin'"
  73. >¥ {{ getDifference(orderMoney, couponPopup.currentCoupon.couponContent).toFixed(2) }}</text
  74. >
  75. <text class="original-money" :class="couponPopup.currentCoupon.couponContent && radioCurrent === 'weixin' && 'original-discount-money'"
  76. >¥ {{ orderMoney }}</text
  77. >
  78. </view>
  79. <view class="pay-btn">
  80. <u-button type="primary" shape="circle" :disabled="!radioCurrent" @click="immediatePayment">立即支付</u-button>
  81. </view>
  82. </view>
  83. </u-modal>
  84. <!-- 选择优惠券弹框 -->
  85. <u-popup v-model="couponPopup.show" mode="top" length="100%">
  86. <view class="coupon-popup">
  87. <u-navbar
  88. back-text=""
  89. title="我的优惠券"
  90. :background="couponPopup.background"
  91. title-color="#fff"
  92. back-icon-color="#fff"
  93. :custom-back="customBack"
  94. />
  95. <view class="coupon-popup-list">
  96. <template v-if="couponPopup.couponList.length">
  97. <radio-group @change="couponRadioChange">
  98. <view class="coupon-popup-list-item" v-for="(item, index) in couponPopup.couponList" :key="index">
  99. <view class="coupon-popup-list-item-top">
  100. <view class="coupon-popup-list-item-top-left">
  101. <view class="cplitl-left">
  102. <view>
  103. <text>¥</text>
  104. <text>{{ item.couponContent }}</text>
  105. </view>
  106. <view class="cplitl-left-bottom">{{ Number(item.threshold) > 0 ? `停车时长满${item.threshold}分钟` : '无门槛' }}</view>
  107. </view>
  108. <view class="cplitl-right">
  109. <view>{{ item.couponName }}</view>
  110. <view>有限期:剩余{{ calcValidity(item.startTime, item.endTime) }}</view>
  111. </view>
  112. </view>
  113. <view class="coupon-popup-list-item-top-right">
  114. <radio color="#FF6D6D" :value="item.id" :checked="item.id === couponPopup.radioCurrent" @click="couponItemClick(item)" />
  115. </view>
  116. </view>
  117. <view class="coupon-popup-list-item-bottom">
  118. 适用停车点:
  119. <template v-if="item.parkList">
  120. <template v-if="item.parkList.length > 1"> 适用多个停车点 </template>
  121. <template v-else> 仅限{{ item.parkList.map((item) => item.parkName).join('、') }} </template>
  122. <template v-if="item.parkList && item.parkList.length > 1">
  123. <view class="cplib-point">
  124. <u-read-more
  125. text-indent="0"
  126. show-height="0"
  127. :toggle="true"
  128. :shadow-style="{ backgroundImage: 'none' }"
  129. fontSize="20rpx"
  130. close-text="展开所有停车点"
  131. >
  132. <view class="cplib-point-content">{{ item.parkList.map((item) => item.parkName).join('、') }}</view>
  133. </u-read-more>
  134. </view>
  135. </template>
  136. </template>
  137. </view>
  138. </view>
  139. </radio-group>
  140. </template>
  141. <template v-else>
  142. <u-empty text="没有适合的优惠券" mode="coupon" margin-top="300"></u-empty>
  143. </template>
  144. </view>
  145. <view class="coupon-popup-btn">
  146. <u-button type="primary" shape="circle" @click="confimCoupon">确 定</u-button>
  147. </view>
  148. </view>
  149. </u-popup>
  150. <u-toast ref="uToast" />
  151. </view>
  152. </template>
  153. <script>
  154. import { getEnvIsWx, getEnvIsAlipay } from '@/utils/judgEnvironment.js';
  155. import $wxPay from '@/utils/wxPay.js';
  156. export default {
  157. props: {
  158. // 订单数组
  159. curOrderList: {
  160. type: Array,
  161. default: null
  162. },
  163. // 设备编号
  164. deviceNo: {
  165. type: String,
  166. default: null
  167. },
  168. // 地磁支付需要字段
  169. payeeId: {
  170. type: String,
  171. default: undefined
  172. },
  173. // 地磁支付需要字段
  174. payeeName: {
  175. type: String,
  176. default: undefined
  177. },
  178. // 扫码支付需要字段
  179. sanPay: {
  180. type: Boolean,
  181. default: false
  182. },
  183. // 追缴类型
  184. pursueType: {
  185. type: String,
  186. default: undefined
  187. },
  188. // 车牌号
  189. vehicleNo: {
  190. type: String,
  191. default: undefined
  192. },
  193. // 跳转页面
  194. jumpUrl: {
  195. type: String,
  196. default: null
  197. },
  198. // 出口扫码 接口不一样
  199. exportFlag: {
  200. type: Boolean,
  201. default: false
  202. },
  203. // 区分包月支付
  204. isMonthPay: {
  205. type: Boolean,
  206. default: false
  207. },
  208. // 包月id
  209. monthId: {
  210. type: String,
  211. default: null
  212. }
  213. },
  214. data() {
  215. return {
  216. // 支付弹框显示
  217. payWayPop: false,
  218. // 是否微信环境
  219. wxEnv: true,
  220. // 支付宝环境
  221. alipayEnv: true,
  222. // 支付方式选择
  223. radioCurrent: '',
  224. // 订单金额
  225. orderMoney: '',
  226. // 显示优惠券选项
  227. isShowCoupon: false,
  228. // 选择优惠券弹框
  229. couponPopup: {
  230. // 弹框标识
  231. show: false,
  232. // 优惠券列表
  233. couponList: [],
  234. // 优惠券选中项value
  235. radioCurrent: '',
  236. // navbar背景
  237. background: {
  238. backgroundColor: '#008CFF'
  239. },
  240. // 优惠券选中项
  241. currentCoupon: {}
  242. }
  243. };
  244. },
  245. methods: {
  246. /**
  247. * 打开弹框触发
  248. * @date 2023-02-17
  249. * @param {any} details
  250. * @param {any} numType single 单笔订单 multiple 多比订单 用于区分多笔订单不能使用优惠券
  251. * @param {any} orderType road 路段订单 parking 停车场订单 用于区分路段订单不使用优惠券
  252. * @returns {any}
  253. */
  254. openPopup(details, numType = 'single', orderType = 'road') {
  255. this.wxEnv = getEnvIsWx();
  256. this.alipayEnv = getEnvIsAlipay();
  257. this.payWayPop = true;
  258. this.orderMoney = details.payAmount.toFixed(2);
  259. if (numType === 'single' && orderType === 'parking' && !this.isMonthPay) {
  260. this.isShowCoupon = true;
  261. this.getCouponList(details.id);
  262. }
  263. },
  264. /**
  265. * 获取优惠券列表
  266. * @date 2023-02-17
  267. * @param {any} orderId
  268. * @returns {any}
  269. */
  270. getCouponList(orderId) {
  271. this.$u.api.getCouponByOrderIdApi({ orderId }).then((res) => {
  272. this.couponPopup.couponList = res?.data ?? [];
  273. });
  274. },
  275. /**
  276. * 选中支付类型
  277. * @date 2023-02-17
  278. * @param {any} {detail}
  279. * @returns {any}
  280. */
  281. payRadioChange({ detail }) {
  282. this.radioCurrent = detail.value;
  283. },
  284. /**
  285. * 选中优惠券
  286. * @date 2023-02-17
  287. * @returns {any}
  288. */
  289. chooseCoupon() {
  290. this.couponPopup.show = true;
  291. },
  292. /**
  293. * 贵阳银行支付
  294. * @param {Array} orderList 需要支付的订单号组成的数组
  295. * @param {String} deviceNo 设备编号(只有车位锁部分有)
  296. * */
  297. gyBankPay() {
  298. const params = {
  299. orderList: this.curOrderList,
  300. deviceNo: this.deviceNo,
  301. jumpUrl: this.jumpUrl,
  302. payeeId: this.payeeId,
  303. payeeName: this.payeeName,
  304. pursueType: this.pursueType,
  305. vehicleNo: this.vehicleNo,
  306. sanPay: this.sanPay
  307. };
  308. if (this.exportFlag == true) {
  309. this.$u.api
  310. .quickPayExportApi(params)
  311. .then((res) => {
  312. if (res.data.needPay) {
  313. let payUrl = res.data.url;
  314. location.href = payUrl;
  315. } else {
  316. this.$refs.uToast.show({
  317. title: '无需支付',
  318. type: 'info'
  319. });
  320. setTimeout(() => {
  321. uni.hideLoading();
  322. location.reload();
  323. }, 1000);
  324. }
  325. })
  326. .catch((err) => {
  327. this.$refs.uToast.show({
  328. title: err.msg,
  329. type: 'error'
  330. });
  331. });
  332. } else {
  333. this.$u.api
  334. .payGzbank(params)
  335. .then((res) => {
  336. if (res.data.needPay) {
  337. let payUrl = res.data.url;
  338. location.href = payUrl;
  339. } else {
  340. this.$refs.uToast.show({
  341. title: '无需支付',
  342. type: 'info'
  343. });
  344. setTimeout(() => {
  345. uni.hideLoading();
  346. location.reload();
  347. }, 1000);
  348. }
  349. })
  350. .catch((err) => {
  351. this.$refs.uToast.show({
  352. title: err.msg,
  353. type: 'error'
  354. });
  355. });
  356. }
  357. },
  358. /**
  359. * @description: 贵阳银行包月支付
  360. * @return {*}
  361. */
  362. gyBankMonthPay() {
  363. this.$u.api
  364. .monthPay({
  365. monthId: this.monthId,
  366. jumpUrl: this.jumpUrl
  367. })
  368. .then((res) => {
  369. if (res.code === 200) {
  370. location.href = res?.data?.url;
  371. } else {
  372. this.$refs.uToast.show({
  373. title: res.msg,
  374. type: 'error'
  375. });
  376. }
  377. })
  378. .catch((err) => {
  379. this.$refs.uToast.show({
  380. title: '无法调起支付!',
  381. type: 'error'
  382. });
  383. });
  384. },
  385. /**
  386. * 聚合支付
  387. * */
  388. juhePay() {
  389. this.getWXPayByJava(this.curOrderList, this.deviceNo);
  390. },
  391. /**
  392. * @description: 聚合包月支付
  393. * @return {*}
  394. */
  395. juheMonthPay() {
  396. // 支付成功跳转到包月页面
  397. let params = {
  398. monthId: this.monthId,
  399. jumpUrl: this.jumpUrl
  400. };
  401. this.$u.api
  402. .monthlyWxPay(params)
  403. .then((res) => {
  404. if (res.code === 200) {
  405. localStorage.setItem('jumpUrl', this.jumpUrl);
  406. location.href = res.data.qrCodeUrl;
  407. }
  408. })
  409. .catch((err) => {
  410. this.$refs.uToast.show({
  411. title: `无法调起${this.alipayEnv ? '支付宝' : this.wxEnv ? '微信' : '聚合'}支付!`,
  412. type: 'error'
  413. });
  414. });
  415. },
  416. /**
  417. * 微信支付
  418. */
  419. wechatPay() {
  420. const params = {
  421. orderList: this.curOrderList,
  422. openid: this.vuex_wxinfo.openId,
  423. deviceNo: this.deviceNo || undefined,
  424. payeeId: this.payeeId || undefined,
  425. payeeName: this.payeeName || undefined,
  426. vehicleNo: this.vehicleNo,
  427. sanPay: this.sanPay
  428. };
  429. if (this.couponPopup.radioCurrent) {
  430. params.couponMemberId = this.couponPopup.radioCurrent;
  431. }
  432. if (this.exportFlag) {
  433. this.$u.api.parkingWechatPayApi(params).then((res) => {
  434. if (res.code === 200) {
  435. if (res.data.needPay) {
  436. $wxPay.wexinPay(res.data.wx).then((r) => {
  437. switch (Number(r.code)) {
  438. case 0: // 成功
  439. //#ifdef H5
  440. window.location.reload();
  441. //#endif
  442. break;
  443. case 1: // 取消
  444. this.$u.api
  445. .updateCouponStatusApi({
  446. orderList: this.curOrderList
  447. })
  448. .then((res) => {
  449. if (res.code === 200) {
  450. this.$refs.uToast.show({
  451. title: '已取消支付',
  452. type: 'info'
  453. });
  454. window.location.reload();
  455. }
  456. });
  457. break;
  458. case 2: // 支付失败
  459. this.$refs.uToast.show({
  460. title: '支付失败,请检查!',
  461. type: 'error'
  462. });
  463. break;
  464. }
  465. });
  466. } else {
  467. this.$refs.uToast.show({
  468. title: '无需支付',
  469. type: 'info'
  470. });
  471. setTimeout(() => {
  472. uni.hideLoading();
  473. location.reload();
  474. }, 1000);
  475. }
  476. }
  477. });
  478. } else {
  479. this.$u.api.wechatPayApi(params).then((res) => {
  480. if (res.code === 200) {
  481. if (res.data.needPay) {
  482. $wxPay.wexinPay(res.data.wx).then((r) => {
  483. switch (Number(r.code)) {
  484. case 0: // 成功
  485. //#ifdef H5
  486. window.location.reload();
  487. //#endif
  488. break;
  489. case 1: // 取消
  490. this.$u.api
  491. .updateCouponStatusApi({
  492. orderList: this.curOrderList
  493. })
  494. .then((res) => {
  495. if (res.code === 200) {
  496. this.$refs.uToast.show({
  497. title: '已取消支付',
  498. type: 'info'
  499. });
  500. window.location.reload();
  501. }
  502. });
  503. break;
  504. case 2: // 支付失败
  505. this.$refs.uToast.show({
  506. title: '支付失败,请检查!',
  507. type: 'error'
  508. });
  509. break;
  510. }
  511. });
  512. } else {
  513. this.$refs.uToast.show({
  514. title: '无需支付',
  515. type: 'info'
  516. });
  517. setTimeout(() => {
  518. uni.hideLoading();
  519. location.reload();
  520. }, 1000);
  521. }
  522. }
  523. });
  524. }
  525. },
  526. /**
  527. * @description: 微信包月支付
  528. * @return {*}
  529. */
  530. wechatMonthPay() {
  531. this.$u.api
  532. .wechatMonthlyPayapi({
  533. monthId: this.monthId,
  534. openid: this.vuex_wxinfo.openId
  535. })
  536. .then((r) => {
  537. if (r.code === 200) {
  538. $wxPay.wexinPay(r.data.wx).then((res) => {
  539. switch (Number(res.code)) {
  540. case 0: // 成功
  541. //#ifdef H5
  542. location.href = this.jumpUrl;
  543. //#endif
  544. break;
  545. case 1: // 取消
  546. this.$refs.uToast.show({
  547. title: '已取消支付',
  548. type: 'info'
  549. });
  550. break;
  551. case 2: // 支付失败
  552. this.$refs.uToast.show({
  553. title: '支付失败,请检查!',
  554. type: 'error'
  555. });
  556. break;
  557. }
  558. });
  559. }
  560. });
  561. },
  562. /**
  563. * 直接通过后台获取贵阳银行微信支付地址
  564. * @param {Array} list 需要支付的订单组合数组
  565. * @param {Number} deviceNo 设备编号(在停车锁部分需要)
  566. * */
  567. getWXPayByJava(orderList, deviceNo) {
  568. let params = {
  569. orderList: orderList,
  570. openid: this.vuex_wxinfo.openId,
  571. jumpUrl: this.jumpUrl,
  572. deviceNo: deviceNo ? deviceNo : null,
  573. payeeId: this.payeeId,
  574. payeeName: this.payeeName,
  575. pursueType: this.pursueType,
  576. vehicleNo: this.vehicleNo,
  577. sanPay: this.sanPay
  578. };
  579. if (this.exportFlag) {
  580. this.$u.api
  581. .polyPayExportApi(params)
  582. .then((res) => {
  583. if (res.code === 200) {
  584. if (res.data.needPay) {
  585. localStorage.setItem('jumpUrl', this.jumpUrl);
  586. location.href = res.data.qrCodeUrl;
  587. } else {
  588. this.$refs.uToast.show({
  589. title: '无需支付',
  590. type: 'info'
  591. });
  592. setTimeout(() => {
  593. uni.hideLoading();
  594. location.href = this.jumpUrl;
  595. }, 1000);
  596. }
  597. } else {
  598. uni.hideLoading();
  599. }
  600. })
  601. .catch((err) => {
  602. this.$refs.uToast.show({
  603. title: `无法调起${this.alipayEnv ? '支付宝' : this.wxEnv ? '微信' : '聚合'}支付!`,
  604. type: 'error'
  605. });
  606. });
  607. } else {
  608. this.$u.api
  609. .ordinaryWxPay(params)
  610. .then((res) => {
  611. if (res.code === 200) {
  612. if (res.data.needPay) {
  613. localStorage.setItem('jumpUrl', this.jumpUrl);
  614. location.href = res.data.qrCodeUrl;
  615. } else {
  616. this.$refs.uToast.show({
  617. title: '无需支付',
  618. type: 'info'
  619. });
  620. setTimeout(() => {
  621. uni.hideLoading();
  622. location.href = this.jumpUrl;
  623. }, 1000);
  624. }
  625. } else {
  626. uni.hideLoading();
  627. }
  628. })
  629. .catch((err) => {
  630. this.$refs.uToast.show({
  631. title: `无法调起${this.alipayEnv ? '支付宝' : this.wxEnv ? '微信' : '聚合'}支付!`,
  632. type: 'error'
  633. });
  634. });
  635. }
  636. },
  637. /**
  638. * 支付弹框支付触发
  639. * @date 2023-02-17
  640. * @returns {any}
  641. */
  642. modalClose() {
  643. (this.wxEnv = true),
  644. (this.radioCurrent = ''),
  645. (this.orderMoney = ''),
  646. (this.isShowCoupon = false),
  647. (this.couponPopup = {
  648. show: false,
  649. couponList: [],
  650. radioCurrent: '',
  651. background: {
  652. backgroundColor: '#008CFF'
  653. },
  654. currentCoupon: {}
  655. });
  656. this.$emit('closePaymentMethod');
  657. },
  658. /**
  659. * 关闭优惠券弹框
  660. * @date 2023-02-17
  661. * @returns {any}
  662. */
  663. customBack() {
  664. this.couponPopup.show = false;
  665. },
  666. /**
  667. * 优惠券单选触发
  668. * @date 2023-02-17
  669. * @param {any} val
  670. * @returns {any}
  671. */
  672. couponRadioChange(val) {
  673. // this.couponPopup.radioCurrent = val.detail.value;
  674. // this.couponPopup.currentCoupon = this.couponPopup.couponList.find((item) => item.id === this.couponPopup.radioCurrent);
  675. },
  676. couponItemClick(item) {
  677. if (item.id === this.couponPopup.radioCurrent) {
  678. this.couponPopup.radioCurrent = '';
  679. } else {
  680. this.couponPopup.radioCurrent = item.id;
  681. }
  682. },
  683. /**
  684. * 优惠券确认
  685. * @date 2023-02-17
  686. * @returns {any}
  687. */
  688. confimCoupon() {
  689. if (this.couponPopup.radioCurrent) {
  690. this.couponPopup.currentCoupon = this.couponPopup.couponList.find((item) => item.id === this.couponPopup.radioCurrent);
  691. } else {
  692. this.couponPopup.currentCoupon = {};
  693. }
  694. this.couponPopup.show = false;
  695. },
  696. /**
  697. * 立即支付
  698. * @date 2023-02-17
  699. * @returns {any}
  700. */
  701. immediatePayment() {
  702. switch (this.radioCurrent) {
  703. case 'weixin': // 微信支付
  704. this.isMonthPay ? this.wechatMonthPay() : this.wechatPay();
  705. break;
  706. case 'gzyh':
  707. this.isMonthPay ? this.gyBankMonthPay() : this.gyBankPay();
  708. break;
  709. case 'juhe':
  710. this.isMonthPay ? this.juheMonthPay() : this.juhePay();
  711. break;
  712. }
  713. },
  714. /**
  715. * 计算剩余时间
  716. * @date 2022-02-17
  717. * @param {any} datetime
  718. * @returns {any}
  719. */
  720. calcValidity(startTime, endTime) {
  721. let endTimeStr = new Date(endTime).valueOf(),
  722. nowTimeStr = new Date(startTime).valueOf() < Date.now() ? Date.now() : new Date(startTime).valueOf(),
  723. remainTimeStr = endTimeStr - nowTimeStr,
  724. day = Math.floor(remainTimeStr / (1000 * 3600 * 24)),
  725. dayOver = remainTimeStr % (1000 * 3600 * 24),
  726. hours = Math.floor(dayOver / (3600 * 1000)),
  727. hourOver = dayOver % (3600 * 1000),
  728. minutes = Math.floor(hourOver / (60 * 1000));
  729. return `${day}天${hours}小时${minutes}分`;
  730. },
  731. getDifference(a, b) {
  732. return a > b ? a - b : 0;
  733. }
  734. }
  735. };
  736. </script>
  737. <style lang="scss" scoped>
  738. @import './choosePayment.scss';
  739. </style>