choosePayment.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  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" @tap="$u.debounce(immediatePayment, 1500, true)">立即支付</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. isIndoor: {
  215. type: Boolean,
  216. default: false
  217. }
  218. },
  219. data() {
  220. return {
  221. // 支付弹框显示
  222. payWayPop: false,
  223. // 是否微信环境
  224. wxEnv: true,
  225. // 支付宝环境
  226. alipayEnv: true,
  227. // 支付方式选择
  228. radioCurrent: '',
  229. // 订单金额
  230. orderMoney: '',
  231. // 显示优惠券选项
  232. isShowCoupon: false,
  233. // 是否取消优惠券标识
  234. isCancelCoupon: false,
  235. // 选择优惠券弹框
  236. couponPopup: {
  237. // 弹框标识
  238. show: false,
  239. // 优惠券列表
  240. couponList: [],
  241. // 优惠券选中项value
  242. radioCurrent: '',
  243. // navbar背景
  244. background: {
  245. backgroundColor: '#008CFF'
  246. },
  247. // 优惠券选中项
  248. currentCoupon: {}
  249. }
  250. };
  251. },
  252. methods: {
  253. /**
  254. * 打开弹框触发
  255. * @date 2023-02-17
  256. * @param {any} details
  257. * @param {any} numType single 单笔订单 multiple 多比订单 用于区分多笔订单不能使用优惠券
  258. * @param {any} orderType road 路段订单 parking 停车场订单 用于区分路段订单不使用优惠券
  259. * @returns {any}
  260. */
  261. openPopup(details, numType = 'single', orderType = 'road') {
  262. // 获取环境信息
  263. this.wxEnv = getEnvIsWx();
  264. // 判断支付宝环境
  265. this.alipayEnv = getEnvIsAlipay();
  266. if (this.wxEnv) {
  267. this.radioCurrent = 'weixin';
  268. } else {
  269. this.radioCurrent = 'juhe';
  270. }
  271. // 打开弹出层
  272. this.payWayPop = true;
  273. // 计算订单金额
  274. this.orderMoney = details.payAmount.toFixed(2);
  275. // 如果是单个停车订单,且是路边停车,且不是月卡支付,则显示优惠券
  276. if (numType === 'single' && orderType === 'parking' && !this.isMonthPay && this.wxEnv) {
  277. this.isShowCoupon = true;
  278. this.isCancelCoupon = true;
  279. this.getCouponList(details.id);
  280. }
  281. },
  282. /**
  283. * 获取优惠券列表
  284. * @date 2023-02-17
  285. * @param {any} orderId
  286. * @returns {any}
  287. */
  288. getCouponList(orderId) {
  289. this.$u.api.getCouponByOrderIdApi({ orderId }).then((res) => {
  290. this.couponPopup.couponList = res?.data ?? [];
  291. });
  292. },
  293. /**
  294. * 选中支付类型
  295. * @date 2023-02-17
  296. * @param {any} {detail}
  297. * @returns {any}
  298. */
  299. payRadioChange({ detail }) {
  300. this.radioCurrent = detail.value;
  301. },
  302. /**
  303. * 选中优惠券
  304. * @date 2023-02-17
  305. * @returns {any}
  306. */
  307. chooseCoupon() {
  308. this.couponPopup.show = true;
  309. },
  310. /**
  311. * 贵阳银行支付
  312. * @param {Array} orderList 需要支付的订单号组成的数组
  313. * @param {String} deviceNo 设备编号(只有车位锁部分有)
  314. * */
  315. async gyBankPay() {
  316. const { curOrderList, deviceNo, jumpUrl, payeeName, payeeId, pursueType, sanPay } = this;
  317. const params = {
  318. orderList: curOrderList,
  319. deviceNo,
  320. jumpUrl,
  321. payeeId,
  322. payeeName,
  323. pursueType,
  324. vehicleNo,
  325. sanPay
  326. };
  327. const apiCall = this.exportFlag ? this.$u.api.quickPayExportApi : this.$u.api.payGzbank;
  328. try {
  329. const res = await apiCall({ ...params });
  330. if (res.data.needPay) {
  331. location.href = res?.data?.url;
  332. } else {
  333. this.showToast('无需支付', 'info');
  334. setTimeout(() => {
  335. location.reload();
  336. }, 1000);
  337. }
  338. } catch (err) {
  339. // this.showToast(err.msg, 'error');
  340. }
  341. },
  342. /**
  343. * @description: 贵阳银行包月支付
  344. * @return {*}
  345. */
  346. async gyBankMonthPay() {
  347. try {
  348. const params = {
  349. monthId: this.monthId,
  350. jumpUrl: this.jumpUrl
  351. };
  352. const { code, data } = await this.$u.api.monthPay({ ...params });
  353. if (code === 200) {
  354. location.href = data?.url;
  355. }
  356. } catch (error) {
  357. this.showToast(error?.msg ?? '无法调起支付', 'error');
  358. }
  359. },
  360. /**
  361. * 聚合支付
  362. * */
  363. juhePay() {
  364. this.getWXPayByJava(this.curOrderList, this.deviceNo);
  365. },
  366. /**
  367. * @description: 聚合包月支付
  368. * @return {*}
  369. */
  370. async juheMonthPay() {
  371. try {
  372. const { monthId, jumpUrl } = this;
  373. const { code, data } = await this.$u.api.monthlyWxPay({ monthId, jumpUrl });
  374. if (code === 200) {
  375. localStorage.setItem('jumpUrl', this.jumpUrl);
  376. location.href = data?.qrCodeUrl;
  377. }
  378. } catch (error) {
  379. this.showToast(error?.msg ?? '拉起支付失败!', 'error');
  380. }
  381. },
  382. /**
  383. * 微信支付
  384. */
  385. async wechatPay() {
  386. const { curOrderList, vuex_wxinfo, deviceNo, payeeId, payeeName, vehicleNo, sanPay, couponPopup } = this;
  387. const params = {
  388. orderList: curOrderList,
  389. openid: vuex_wxinfo?.openId,
  390. deviceNo,
  391. payeeId,
  392. payeeName,
  393. vehicleNo,
  394. sanPay,
  395. couponMemberId: couponPopup?.radioCurrent
  396. };
  397. const apiCall = this.exportFlag ? this.$u.api.parkingWechatPayApi : this.$u.api.wechatPayApi;
  398. try {
  399. const { code, data } = await apiCall({ ...params });
  400. if (code === 200) {
  401. if (data.needPay) {
  402. $wxPay.weixinPay(data.wx).then((r) => {
  403. const messageMap = {
  404. 0: '成功',
  405. 1: '已取消支付',
  406. 2: '支付失败,请检查!'
  407. };
  408. switch (Number(r.code)) {
  409. case 0: // 成功
  410. //#ifdef H5
  411. location.reload();
  412. //#endif
  413. break;
  414. case 1: // 取消
  415. if (this.isCancelCoupon) {
  416. this.cancelCoupon(messageMap[r.code]);
  417. } else {
  418. this.showToast(messageMap[r.code], 'info');
  419. }
  420. break;
  421. case 2: // 支付失败
  422. this.showToast(messageMap[r.code], 'error');
  423. break;
  424. }
  425. });
  426. } else {
  427. this.showToast('无需支付', 'info');
  428. setTimeout(() => {
  429. this.jumpUrl ? (location.href = `${this.jumpUrl}`) : location.reload();
  430. }, 1000);
  431. }
  432. }
  433. } catch (error) {}
  434. },
  435. /**
  436. * @description: 取消优惠券
  437. * @param {*} msg
  438. * @return {*}
  439. */
  440. async cancelCoupon(msg) {
  441. try {
  442. const { code } = await this.$u.api.updateCouponStatusApi({ orderList: this.curOrderList });
  443. if (code === 200) {
  444. this.showToast(msg, 'info');
  445. location.reload();
  446. }
  447. } catch (error) {}
  448. },
  449. /**
  450. * @description: 微信包月支付
  451. * @return {*}
  452. */
  453. async wechatMonthPay() {
  454. const { code, data } = await this.$u.api.wechatMonthlyPayapi({ monthId: this.monthId, openid: this.vuex_wxinfo.openId });
  455. if (code === 200) {
  456. $wxPay.weixinPay(data?.wx).then((res) => {
  457. this.handleMonthlyPay.call(this, res);
  458. });
  459. }
  460. },
  461. /**
  462. * @description: 微信包月支付响应处理
  463. * @param {*} response
  464. * @return {*}
  465. */
  466. handleMonthlyPay(response) {
  467. const messageMap = {
  468. 0: { title: '成功', jumpUrl: this.jumpUrl },
  469. 1: { title: '已取消支付' },
  470. 2: { title: '支付失败,请检查!', type: 'error' }
  471. };
  472. const message = messageMap[Number(response.code)];
  473. this.showToast(message.title, message.type || 'info');
  474. if (message.jumpUrl) {
  475. location.href = message.jumpUrl;
  476. }
  477. },
  478. /**
  479. * 直接通过后台获取贵阳银行微信支付地址
  480. * @param {Array} list 需要支付的订单组合数组
  481. * @param {Number} deviceNo 设备编号(在停车锁部分需要)
  482. * */
  483. async getWXPayByJava(orderList, deviceNo) {
  484. const params = {
  485. orderList,
  486. openid: this.vuex_wxinfo.openId,
  487. jumpUrl: this.jumpUrl,
  488. deviceNo: deviceNo || null,
  489. payeeId: this.payeeId,
  490. payeeName: this.payeeName,
  491. pursueType: this.pursueType,
  492. vehicleNo: this.vehicleNo,
  493. sanPay: this.sanPay
  494. };
  495. const apiCall = this.exportFlag ? this.$u.api.polyPayExportApi : this.$u.api.ordinaryWxPay;
  496. try {
  497. const { code, data } = await apiCall({ ...params });
  498. if (code === 200) {
  499. if (data.needPay) {
  500. localStorage.setItem('jumpUrl', this.jumpUrl);
  501. location.href = data.qrCodeUrl;
  502. } else {
  503. this.showToast('无需支付', 'info');
  504. setTimeout(() => {
  505. uni.hideLoading();
  506. location.href = this.jumpUrl;
  507. }, 1000);
  508. }
  509. }
  510. } catch (error) {
  511. // this.showToast(`无法调起${this.alipayEnv ? '支付宝' : this.wxEnv ? '微信' : '聚合'}支付!`, 'error');
  512. }
  513. },
  514. /**
  515. * 支付弹框支付触发
  516. * @date 2023-02-17
  517. * @returns {any}
  518. */
  519. modalClose() {
  520. Object.assign(this, {
  521. payWayPop: false,
  522. wxEnv: true,
  523. alipayEnv: true,
  524. radioCurrent: '',
  525. orderMoney: '',
  526. isShowCoupon: false,
  527. isCancelCoupon: false,
  528. couponPopup: {
  529. show: false,
  530. couponList: [],
  531. radioCurrent: '',
  532. background: {
  533. backgroundColor: '#008CFF'
  534. },
  535. currentCoupon: {}
  536. }
  537. });
  538. this.$emit('closePaymentMethod');
  539. },
  540. /**
  541. * 关闭优惠券弹框
  542. * @date 2023-02-17
  543. * @returns {any}
  544. */
  545. customBack() {
  546. this.couponPopup.show = false;
  547. },
  548. /**
  549. * 优惠券单选触发
  550. * @date 2023-02-17
  551. * @param {any} val
  552. * @returns {any}
  553. */
  554. couponRadioChange(val) {
  555. // this.couponPopup.radioCurrent = val.detail.value;
  556. // this.couponPopup.currentCoupon = this.couponPopup.couponList.find((item) => item.id === this.couponPopup.radioCurrent);
  557. },
  558. couponItemClick(item) {
  559. this.couponPopup.radioCurrent = item.id === this.couponPopup.radioCurrent ? '' : item.id;
  560. },
  561. /**
  562. * 优惠券确认
  563. * @date 2023-02-17
  564. * @returns {any}
  565. */
  566. confimCoupon() {
  567. this.couponPopup.currentCoupon = this.couponPopup.radioCurrent
  568. ? this.couponPopup.couponList.find((item) => item.id === this.couponPopup.radioCurrent)
  569. : {};
  570. this.couponPopup.show = false;
  571. },
  572. /**
  573. * 立即支付
  574. * @date 2023-02-17
  575. * @returns {any}
  576. */
  577. immediatePayment() {
  578. if (this.isIndoor) {
  579. const relationObj = {
  580. weixin: 'wechat',
  581. gzyh: 'quick',
  582. juhe: 'poly'
  583. };
  584. this.indoorPayment(relationObj[this.radioCurrent]);
  585. } else {
  586. switch (this.radioCurrent) {
  587. case 'weixin': // 微信支付
  588. this.isMonthPay ? this.wechatMonthPay() : this.wechatPay();
  589. break;
  590. case 'gzyh': // 贵州银行支付或快捷支付
  591. this.isMonthPay ? this.gyBankMonthPay() : this.gyBankPay();
  592. break;
  593. case 'juhe': // 聚合支付
  594. this.isMonthPay ? this.juheMonthPay() : this.juhePay();
  595. break;
  596. }
  597. }
  598. },
  599. /**
  600. * @description: 室内支付
  601. * @param {*} payMode
  602. * @return {*}
  603. */
  604. async indoorPayment(payMode) {
  605. const { curOrderList, couponPopup, vuex_wxinfo, jumpUrl } = this;
  606. const params = {
  607. orderList: curOrderList,
  608. payMode,
  609. couponMemberId: couponPopup?.radioCurrent,
  610. openid: vuex_wxinfo?.openId,
  611. sanPay: true,
  612. jumpUrl
  613. };
  614. const { code, data } = await this.$u.api.indoorPaymentApi({ ...params });
  615. if (code === 200) {
  616. if (data?.needPay) {
  617. switch (payMode) {
  618. case 'wechat': // 微信支付
  619. $wxPay.weixinPay(data?.wechat?.wx).then((r) => {
  620. const messageMap = {
  621. 0: '成功',
  622. 1: '已取消支付',
  623. 2: '支付失败,请检查!'
  624. };
  625. switch (Number(r.code)) {
  626. case 0: // 成功
  627. //#ifdef H5
  628. this.jumpUrl ? (location.href = `${this.jumpUrl}&polyOrderId=${data.polyOrderId}`) : location.reload();
  629. //#endif
  630. break;
  631. case 1: // 取消
  632. if (this.isCancelCoupon) {
  633. this.cancelCoupon(messageMap[r.code]);
  634. } else {
  635. this.showToast(messageMap[r.code], 'info');
  636. }
  637. break;
  638. case 2: // 支付失败
  639. this.showToast(messageMap[r.code], 'error');
  640. break;
  641. }
  642. });
  643. break;
  644. case 'quick': // 快捷支付
  645. location.href = data?.quick?.url;
  646. break;
  647. case 'poly':
  648. localStorage.setItem('jumpUrl', this.jumpUrl);
  649. location.href = data?.poly?.qrCodeUrl;
  650. break;
  651. }
  652. } else {
  653. this.showToast('无需支付', 'info');
  654. setTimeout(() => {
  655. this.jumpUrl ? (location.href = `${this.jumpUrl}&polyOrderId=${data.polyOrderId}`) : location.reload();
  656. }, 1000);
  657. }
  658. }
  659. },
  660. /**
  661. * 计算剩余时间
  662. * @date 2022-02-17
  663. * @param {any} datetime
  664. * @returns {any}
  665. */
  666. calcValidity(startTime, endTime) {
  667. let endTimeStr = new Date(endTime).valueOf(),
  668. nowTimeStr = new Date(startTime).valueOf() < Date.now() ? Date.now() : new Date(startTime).valueOf(),
  669. remainTimeStr = endTimeStr - nowTimeStr,
  670. day = Math.floor(remainTimeStr / (1000 * 3600 * 24)),
  671. dayOver = remainTimeStr % (1000 * 3600 * 24),
  672. hours = Math.floor(dayOver / (3600 * 1000)),
  673. hourOver = dayOver % (3600 * 1000),
  674. minutes = Math.floor(hourOver / (60 * 1000));
  675. return `${day}天${hours}小时${minutes}分`;
  676. },
  677. getDifference(a, b) {
  678. return a > b ? a - b : 0;
  679. },
  680. /**
  681. * @description: 显示报错信息
  682. * @param {*} title
  683. * @param {*} type
  684. * @return {*}
  685. */
  686. showToast(title, type = 'error') {
  687. this.$refs.uToast.show({ title, type });
  688. }
  689. }
  690. };
  691. </script>
  692. <style lang="scss" scoped>
  693. @import './choosePayment.scss';
  694. </style>