index.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014
  1. <template>
  2. <view>
  3. <!-- index.wxml -->
  4. <view class="wrap">
  5. <view class="order_wrap">
  6. <text class="price">
  7. <text class="unit">¥</text>
  8. {{ totalPrice }}
  9. </text>
  10. <view class="order_price">账单金额</view>
  11. </view>
  12. <view class="payment_wrap">
  13. <view class="payment_item" @tap="changeCard">
  14. <view class="item_t">
  15. <view class="item_t_l">
  16. <image class="item_icon" mode="heightFix" src="/static/statics/img/icon_dengji.png"></image>
  17. <view class="item_name">会员卡支付</view>
  18. </view>
  19. <view class="item_t_r">
  20. <!-- <text class="unit"></text> -->
  21. <view class="price">{{ userMoney > totalPrice ? '-' + totalPrice : '-' + userMoney }}</view>
  22. <van-checkbox :value="checkedCard" checked-color="#295C56"></van-checkbox>
  23. </view>
  24. </view>
  25. <view class="item_b">
  26. <text class="wenzi">
  27. <text class="label">卡内余额</text>
  28. ¥{{ userMoney }}
  29. </text>
  30. <text class="wenzi">
  31. <text class="label">可用</text>
  32. ¥{{ userMoney > totalPrice ? totalPrice : userMoney }}
  33. </text>
  34. </view>
  35. </view>
  36. <view class="card_list">
  37. <view class="card_item_w" @tap="clickCard" :data-id="item.id" v-for="(item, index) in cardList" :key="index">
  38. <view :class="item.checked ? 'card_item active' : 'card_item'">
  39. <view v-if="item.type == 2">
  40. <!-- 年卡 -->
  41. <view class="card_item_col">
  42. <view class="card_text">{{ item.price }}元购{{ item.title }}</view>
  43. <view class="card_send">得</view>
  44. <view class="card_text">会员</view>
  45. </view>
  46. </view>
  47. <view v-else>
  48. <view class="card_item_col">
  49. <view class="card_text">充值{{ item.price }}元</view>
  50. <view class="card_send">得</view>
  51. <view class="card_text">{{ item.priceAddCoupons }}元</view>
  52. </view>
  53. <view class="card_item_col desc" v-if="item.coupon_rule">
  54. <text class="">{{ item.price }}元卡金</text>
  55. <text class="">+ {{ item.coupon_rule.coupon.price }}元x{{ item.coupon_rule.num }}张券</text>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="payment_item" @tap="changeWechat">
  62. <view class="item_t">
  63. <view class="item_t_l">
  64. <image class="item_icon" mode="heightFix" src="/static/statics/img/icon_weixin.png"></image>
  65. <view class="item_name">微信支付</view>
  66. </view>
  67. <view class="item_t_r">
  68. <van-checkbox :value="checkedWechat" checked-color="#295C56"></van-checkbox>
  69. </view>
  70. </view>
  71. </view>
  72. <view class="payment_item" v-if="couponNums && !order_id" @tap="onShowCoupons">
  73. <view class="item_t">
  74. <view class="item_t_l">
  75. <image class="item_icon" mode="heightFix" src="/static/statics/img/icon_quan.png"></image>
  76. <view class="item_name">优惠券</view>
  77. </view>
  78. <view class="item_t_r">
  79. <view class="quan">
  80. <!-- <text wx:if="{{ checkedCoupon }}">{{ checkedCoupon.type == 3 ? '折扣优惠券' : checkedCoupon.type == 2 ? '金额优惠券' : '满减券' }}</text> -->
  81. <text v-if="checkedCoupon">{{ checkedCoupon.type == 3 ? checkedCoupon.discount + '折' : '-' + checkedCoupon.price }}</text>
  82. <text v-else>{{ couponNums }}张可用</text>
  83. </view>
  84. <van-icon name="arrow" color="#333333" />
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. <view class="btn_tijiao" @tap="confirmCreateOrder">
  90. <text class="label">{{ checkedCard ? '会员卡支付' : '微信支付' }}</text>
  91. <text class="price">
  92. <text class="unit">¥</text>
  93. {{ totalPrice }}
  94. </text>
  95. </view>
  96. </view>
  97. <!-- 余额不足提醒 -->
  98. <van-overlay :z-index="2" class-style="background: rgba(0,0,0,.3);" :show="showCashPop">
  99. <view class="cash_pop">
  100. <view class="cash_pop_t">余额不足充值享更多优惠</view>
  101. <view class="cash_pop_b">
  102. <view class="cash_pop_btn" @tap="onAddWechat">加微信支付</view>
  103. <view class="cash_pop_btn recharge" @tap="onRecharge">先充值</view>
  104. </view>
  105. <!-- <image class="tip_tu" src="/statics/img/fail_tu.png"></image> -->
  106. </view>
  107. </van-overlay>
  108. <!-- 选择优惠券 -->
  109. <van-overlay :z-index="2" class-style="background: rgba(0,0,0,.3);" :show="showCoupons">
  110. <view class="coupon_wrap">
  111. <view class="coupon_t">
  112. <view class="coupon_t_l">选择优惠券</view>
  113. <van-icon name="cross" color="rgba(0,0,0,.36)" @tap.native="onCloseCoupons" />
  114. </view>
  115. <scroll-view scroll-y class="coupon_wrap_scroll">
  116. <view class="coupon_list">
  117. <van-checkbox-group :value="couponIdArr" :max="1">
  118. <van-cell-group>
  119. <van-cell
  120. clickable
  121. :data-name="item.id"
  122. @click="onClickCoupons($event, { name: item.id, item })"
  123. :data-item="item"
  124. v-for="(item, index) in couponList"
  125. :key="index"
  126. >
  127. <view class="coupon_item" :style="'background-image: url(' + couponBg + ')'">
  128. <view class="item_l" v-if="item.type == 1">
  129. <view class="price">
  130. <text class="unit">¥</text>
  131. {{ item.price }}
  132. </view>
  133. <view class="tips">满{{ item.base_price }}元可用</view>
  134. </view>
  135. <view class="item_l" v-if="item.type == 2">
  136. <view class="price">
  137. <text class="unit">¥</text>
  138. {{ item.price }}
  139. </view>
  140. <view class="tips">无门槛</view>
  141. </view>
  142. <view class="item_l" v-if="item.type == 3">
  143. <view class="price">{{ item.discount }}折</view>
  144. </view>
  145. <view class="item_r">
  146. <view class="item_r_l">
  147. <view class="quan_name">{{ item.type == 3 ? '折扣优惠券' : item.type == 2 ? '金额优惠券' : '满减券' }}</view>
  148. <view class="quan_time">有效期至{{ item.due_time }}</view>
  149. </view>
  150. <van-checkbox slot="right-icon" :name="item.id" checked-color="#295C56" />
  151. </view>
  152. </view>
  153. </van-cell>
  154. </van-cell-group>
  155. </van-checkbox-group>
  156. </view>
  157. </scroll-view>
  158. </view>
  159. </van-overlay>
  160. <!-- loading -->
  161. <!-- <van-overlay show="{{ loading }}" z-index="100">
  162. <van-loading custom-class="custom_loading" />
  163. </van-overlay> -->
  164. </view>
  165. </template>
  166. <script>
  167. // index.js
  168. let myPro = require('../../utils/wxRequest.js');
  169. let util = require('../../utils/util.js');
  170. export default {
  171. data() {
  172. return {
  173. couponBg: '/static/statics/img/quan_bg_tu.png',
  174. checkedCard: true,
  175. // 默认选择余额付
  176. result: [],
  177. checkedWechat: false,
  178. showCashPop: false,
  179. // 会员卡钱不足时
  180. couponIdArr: [],
  181. // 优惠券选中 数组
  182. couponId: 0,
  183. showCoupons: false,
  184. cardList: [],
  185. // 充值券
  186. userMoney: 0,
  187. // 用户余额
  188. totalPrice: 0,
  189. // 订单总金额
  190. fare_type: 0,
  191. // 配送方式 0外卖 1自提
  192. order_id: null,
  193. // 订单id(未支付订单)
  194. loading: false,
  195. // 全局loading
  196. is_member: getApp().globalData.is_member,
  197. // 会员 0否 1是
  198. // 测试锁
  199. addLock: false,
  200. address_id: '',
  201. store: '',
  202. user_mark: '',
  203. couponList: '',
  204. couponNums: '',
  205. pay_type: '',
  206. checkedCoupon: {
  207. type: 0,
  208. discount: '',
  209. price: ''
  210. }
  211. };
  212. },
  213. onLoad: function (options) {
  214. // Do some initialize when page load.
  215. let that = this; // 配送方式
  216. if (options.fare_type) {
  217. that.setData({
  218. fare_type: options.fare_type
  219. });
  220. } // 地址
  221. if (options.address_id) {
  222. that.setData({
  223. address_id: options.address_id
  224. });
  225. }
  226. if (options.order_id) {
  227. that.setData({
  228. order_id: options.order_id
  229. });
  230. that.getOrderDetail();
  231. }
  232. that.setData({
  233. couponBg: 'data:image/png;base64,' + uni.getFileSystemManager().readFileSync(that.couponBg, 'base64')
  234. });
  235. },
  236. onShow: function () {
  237. // Do something when page show.
  238. let that = this; // 店铺
  239. if (uni.getStorageSync('store')) {
  240. that.setData({
  241. store: JSON.parse(uni.getStorageSync('store'))
  242. });
  243. } // 获取用户余额
  244. that.getUserCash(); // 获取充值卡
  245. that.getRechargeCard(); // 获取券(只支持初次订单,不支持二次支付订单)
  246. if (!that.order_id && !that.addLock) {
  247. that.getCreatelist();
  248. } // console.log('show=====');
  249. },
  250. onReady: function () {
  251. // Do something when page ready.
  252. },
  253. onHide: function () {
  254. // Do something when page hide.
  255. },
  256. onUnload: function () {
  257. // Do something when page close.
  258. },
  259. onPullDownRefresh: function () {
  260. // Do something when pull down.
  261. },
  262. onReachBottom: function () {
  263. // Do something when page reach bottom.
  264. },
  265. onPageScroll: function () {
  266. // Do something when page scroll
  267. },
  268. onResize: function () {
  269. // Do something when page resize
  270. },
  271. methods: {
  272. // 获取可用优惠券(同时总了总价等)
  273. getCreatelist() {
  274. let that = this;
  275. let params = {
  276. fare_type: that.fare_type
  277. };
  278. if (that.fare_type == 0) {
  279. params.address_id = that.address_id;
  280. }
  281. if (uni.getStorageSync('user_mark')) {
  282. that.setData({
  283. user_mark: uni.getStorageSync('user_mark')
  284. });
  285. params.user_mark = that.user_mark;
  286. }
  287. if (that.couponId) {
  288. params.user_coupon_id = that.couponId;
  289. } // return;
  290. myPro
  291. .wxRequest('user/v3/order/createlist', 'GET', params)
  292. .then((res) => {
  293. let couponList = res.result.userCouponList;
  294. that.setData({
  295. totalPrice: res.result.orderInfo.pay_price,
  296. couponList: couponList,
  297. couponNums: couponList.length // 几张券
  298. });
  299. })
  300. .catch((err) => {
  301. console.log('报错信息', err);
  302. uni.showToast({
  303. title: err,
  304. icon: 'none'
  305. });
  306. });
  307. },
  308. // 获取用户的余额
  309. getUserCash() {
  310. let that = this;
  311. myPro
  312. .wxRequest('user/v2/userinfo', 'GET', {})
  313. .then((res) => {
  314. that.setData({
  315. userMoney: parseFloat(res.result.money)
  316. });
  317. })
  318. .catch((err) => {
  319. console.log('报错信息', err);
  320. uni.showToast({
  321. title: err,
  322. icon: 'none'
  323. });
  324. });
  325. },
  326. // 选卡付
  327. changeCard() {
  328. let that = this;
  329. that.setData({
  330. checkedCard: !that.checkedCard
  331. }); // 余额和微信方式只能选一种
  332. if (that.checkedCard) {
  333. that.setData({
  334. checkedWechat: false
  335. });
  336. }
  337. },
  338. // 选微信付
  339. changeWechat() {
  340. let that = this;
  341. that.setData({
  342. checkedWechat: !that.checkedWechat
  343. }); // 余额和微信方式只能选一种
  344. if (that.checkedWechat) {
  345. that.setData({
  346. checkedCard: false
  347. });
  348. }
  349. },
  350. // 创建订单前的相关判断
  351. confirmCreateOrder() {
  352. let that = this; // wx.redirectTo({
  353. // url: '/pages/pay-success/index?order_id=176',
  354. // complete: function(){
  355. // // 清掉备注
  356. // // wx.removeStorageSync("user_mark");
  357. // }
  358. // });
  359. // return;
  360. // that.setData({
  361. // loading: true
  362. // });
  363. // 是否勾选支付方式
  364. if (!that.checkedCard && !that.checkedWechat) {
  365. uni.showToast({
  366. title: '请选择支付方式',
  367. icon: 'none'
  368. }); // that.setData({
  369. // loading: false
  370. // });
  371. return;
  372. } // 判断支付方式
  373. let pay_type = that.checkedWechat ? 1 : 2; //1微信 2充值卡
  374. that.setData({
  375. pay_type: pay_type
  376. }); // 余额不足以支付时
  377. if (that.pay_type == 2 && that.userMoney < that.totalPrice) {
  378. that.setData({
  379. showCashPop: true
  380. }); // that.setData({
  381. // loading: false
  382. // });
  383. return;
  384. } // 余额付
  385. if (that.pay_type == 2) {
  386. if (that.order_id) {
  387. that.orderPay(2);
  388. } else {
  389. that.createOrder(2);
  390. }
  391. } // 微信付
  392. if (that.pay_type == 1) {
  393. if (that.order_id) {
  394. that.orderPay(1);
  395. } else {
  396. that.createOrder(1);
  397. }
  398. }
  399. },
  400. // 创建订单
  401. createOrder(pay_type) {
  402. // pay_type 有三种类型 1微信 2余额 3混合
  403. let that = this;
  404. let data = {
  405. pay_type: pay_type,
  406. fare_type: that.fare_type
  407. }; // 收货地址
  408. if (that.fare_type == 0 && that.address_id) {
  409. data.address_id = that.address_id;
  410. } // 券
  411. if (that.couponId) {
  412. data.user_coupon_id = that.couponId;
  413. } // 备注
  414. if (that.user_mark) {
  415. data.user_mark = that.user_mark;
  416. } // 创建订单
  417. myPro
  418. .wxRequest('user/v3/order/create', 'POST', data)
  419. .then((res) => {
  420. let order = res.result.order;
  421. if (res.result.config) {
  422. that.goWxPay(order, res.result.config);
  423. } else {
  424. // 不需要调微信支付,直接创建成功
  425. that.onCreateOrderAfter(order, 1);
  426. }
  427. })
  428. .catch((err) => {
  429. console.log('报错信息', err);
  430. uni.showToast({
  431. title: err,
  432. icon: 'none'
  433. });
  434. });
  435. },
  436. // 余额不足,加微信支付
  437. onAddWechat() {
  438. let that = this; // 混合付
  439. if (that.order_id) {
  440. that.orderPay(3);
  441. } else {
  442. that.createOrder(3);
  443. }
  444. that.setData({
  445. showCashPop: false
  446. });
  447. },
  448. // 余额不足,充值
  449. onRecharge() {
  450. let that = this;
  451. that.setData({
  452. showCashPop: false
  453. });
  454. },
  455. // 调起微信
  456. goWxPay(order, config) {
  457. let that = this;
  458. const configArr = JSON.parse(config);
  459. uni.requestPayment({
  460. timeStamp: configArr.timeStamp,
  461. nonceStr: configArr.nonceStr,
  462. package: configArr.package,
  463. signType: configArr.signType,
  464. paySign: configArr.paySign,
  465. success(res) {
  466. // console.log(res);
  467. // 执行支付成功后续操作
  468. that.onCreateOrderAfter(order, 1);
  469. },
  470. fail(res) {
  471. // console.error(res);
  472. if (res.errMsg == 'requestPayment:fail cancel') {
  473. that.setData({
  474. addLock: true // 为了避免付款后,又进了onshow,影响了调优惠券的接口
  475. });
  476. uni.showToast({
  477. title: '您取消了支付,请到我的订单中继续付款',
  478. icon: 'none'
  479. });
  480. } else {
  481. uni.showToast({
  482. title: '支付失败,请到我的订单中继续付款',
  483. icon: 'none'
  484. });
  485. } // 订单创建成功,但取消了支付 -1
  486. that.onCreateOrderAfter(order, -1);
  487. }
  488. });
  489. },
  490. // 支付后的处理
  491. onCreateOrderAfter(order, type) {
  492. let that = this; // 清掉下单时的备注
  493. uni.removeStorageSync('user_mark'); // type 1成功 -1失败
  494. if (type == 1) {
  495. that.setData({
  496. addLock: true // 为了避免付款后,又进了onshow,影响了调优惠券的接口
  497. });
  498. uni.redirectTo({
  499. url: '/pages/pay-success/index?order_id=' + order.id
  500. });
  501. } else {
  502. // 支付失败后 跳转到订单详情(此时订单已创建成功)
  503. setTimeout(function () {
  504. uni.redirectTo({
  505. url: '/pages/user/order/detail/index?order_id=' + order.id
  506. });
  507. }, 1000);
  508. }
  509. },
  510. // 打开优惠券弹层
  511. onShowCoupons() {
  512. let that = this;
  513. that.setData({
  514. showCoupons: true
  515. });
  516. },
  517. // 获取当前点击的优惠券
  518. onClickCoupons(event, _dataset) {
  519. /* ---处理dataset begin--- */
  520. this.datasetHandle(event, _dataset);
  521. /* ---处理dataset end--- */
  522. let that = this;
  523. let item = event.currentTarget.dataset.item;
  524. if (that.couponId == item.id) {
  525. that.setData({
  526. couponIdArr: [],
  527. couponId: 0,
  528. checkedCoupon: null
  529. }); // 更新金额
  530. that.getCreatelist();
  531. } else {
  532. that.setData({
  533. couponIdArr: ['' + item.id],
  534. couponId: item.id
  535. });
  536. if (that.couponId == item.id) {
  537. that.setData({
  538. checkedCoupon: item,
  539. showCoupons: false
  540. }); // 更新金额
  541. that.getCreatelist();
  542. } else {
  543. that.setData({
  544. checkedCoupon: null,
  545. showCoupons: false
  546. });
  547. }
  548. } // console.log('选中的优惠券',that.data.checkedCoupon)
  549. },
  550. // 关闭优惠券弹层
  551. onCloseCoupons() {
  552. let that = this;
  553. that.setData({
  554. showCoupons: false
  555. });
  556. },
  557. // 获取订单详情
  558. getOrderDetail() {
  559. let that = this;
  560. let params = {
  561. order_id: that.order_id
  562. };
  563. myPro
  564. .wxRequest('user/v2/order/detail', 'GET', params)
  565. .then((res) => {
  566. that.setData({
  567. totalPrice: res.result.pay_price
  568. });
  569. })
  570. .catch((err) => {
  571. console.log('报错信息', err);
  572. uni.showToast({
  573. title: err,
  574. icon: 'none'
  575. });
  576. });
  577. },
  578. // 未支付订单,进行支付
  579. orderPay(pay_type) {
  580. let that = this;
  581. let params = {
  582. order_id: that.order_id,
  583. pay_type: pay_type
  584. };
  585. myPro
  586. .wxRequest('user/v2/order/topay', 'POST', params)
  587. .then((res) => {
  588. let order = res.result.order; // res.result.type 1余额支付成功 2走微信
  589. if (res.result.config) {
  590. that.goWxPay(order, res.result.config);
  591. } else {
  592. that.onCreateOrderAfter(order, 1);
  593. }
  594. })
  595. .catch((err) => {
  596. console.log('报错信息', err);
  597. uni.showToast({
  598. title: err,
  599. icon: 'none'
  600. });
  601. });
  602. },
  603. // 获取充值卡
  604. getRechargeCard() {
  605. let that = this;
  606. let params = {
  607. type: 1,
  608. // 1返回3条数据 2返回全部数据
  609. card_type: 1 // 1普通 2年卡(会员卡)
  610. };
  611. myPro
  612. .wxRequest('user/v2/rechargecardlist', 'GET', params)
  613. .then((res) => {
  614. let list = res.result;
  615. for (let i in list) {
  616. list[i].checked = false; // 卡+券的总金额 (都按代金券走,折扣券不考虑)
  617. if (list[i].coupon_rule) {
  618. list[i].priceAddCoupons = (list[i].coupon_rule.coupon.price * list[i].coupon_rule.num + parseFloat(list[i].price)).toFixed(2);
  619. } else {
  620. list[i].priceAddCoupons = list[i].price;
  621. }
  622. }
  623. that.setData({
  624. cardList: list
  625. });
  626. })
  627. .catch((err) => {
  628. console.log('报错信息', err);
  629. uni.showToast({
  630. title: err,
  631. icon: 'none'
  632. });
  633. });
  634. },
  635. // 选择充值卡
  636. clickCard(event) {
  637. let that = this;
  638. let id = event.currentTarget.dataset.id;
  639. let list = that.cardList; // 测试(模拟流程,能跑了再删)
  640. // that.setData({
  641. // is_member: 1
  642. // })
  643. // that.getUserCash();
  644. // return;
  645. for (let i in list) {
  646. if (list[i].id == id) {
  647. list[i].checked = !list[i].checked; // 选中状态,则去购卡
  648. if (list[i].checked) {
  649. that.nextFun(list[i].id);
  650. }
  651. } else {
  652. list[i].checked = false;
  653. }
  654. }
  655. that.setData({
  656. cardList: list
  657. });
  658. },
  659. // 充值
  660. nextFun(id) {
  661. let that = this;
  662. let params = {
  663. recharge_card_id: id,
  664. store_id: that.store ? that.store.id : 1 // 门店id
  665. };
  666. myPro
  667. .wxRequest('user/recharge', 'POST', params)
  668. .then((res) => {
  669. let config = res.result.config;
  670. that.wxPayCard(JSON.parse(config));
  671. })
  672. .catch((err) => {
  673. that.setData({
  674. loading: false
  675. });
  676. console.log('报错信息', err);
  677. uni.showToast({
  678. title: err,
  679. icon: 'none'
  680. });
  681. });
  682. },
  683. // 卡充值微信付款
  684. wxPayCard: function (result) {
  685. let that = this;
  686. uni.requestPayment({
  687. timeStamp: result.timeStamp,
  688. nonceStr: result.nonceStr,
  689. package: result.package,
  690. signType: result.signType,
  691. paySign: result.paySign,
  692. success(res) {
  693. uni.showToast({
  694. title: '充值成功',
  695. icon: 'none'
  696. }); // 拉取用户余额
  697. that.getUserCash(); // 获取券(非商品待支付订单)
  698. if (!that.order_id) {
  699. that.getCreatelist();
  700. }
  701. },
  702. fail(res) {
  703. uni.showToast({
  704. title: '充值失败',
  705. icon: 'none'
  706. });
  707. console.log('报错信息', res);
  708. }
  709. });
  710. }
  711. }
  712. };
  713. </script>
  714. <style>
  715. /**index.wxss**/
  716. .wrap {
  717. min-height: 100vh;
  718. background: #f6f6f6;
  719. padding-top: 20rpx;
  720. padding-bottom: 200rpx;
  721. }
  722. .order_wrap {
  723. width: 690rpx;
  724. padding: 20rpx;
  725. text-align: center;
  726. /* background: #FFFFFF; */
  727. border-radius: 5rpx;
  728. margin: 0 auto;
  729. position: relative;
  730. }
  731. .order_wrap .order_price {
  732. font-size: 30rpx;
  733. color: rgba(0, 0, 0, 0.54);
  734. }
  735. .order_wrap .price {
  736. /* padding-left: 14rpx; */
  737. color: #0e0e0e;
  738. font-size: 68rpx;
  739. font-weight: bold;
  740. }
  741. .order_wrap .price .unit {
  742. font-size: 40rpx;
  743. }
  744. .order_wrap .line_bg {
  745. position: absolute;
  746. bottom: 0;
  747. left: 0;
  748. width: 690rpx;
  749. height: 20rpx;
  750. border-radius: 0 0 5rpx 5rpx;
  751. background-repeat: repeat-x;
  752. background-size: 18rpx 30rpx;
  753. }
  754. /* 支付方式 */
  755. .payment_wrap {
  756. width: 690rpx;
  757. margin: 20rpx auto 0;
  758. background: #ffffff;
  759. }
  760. .payment_item {
  761. padding: 30rpx;
  762. }
  763. .payment_item .item_t {
  764. display: flex;
  765. align-items: center;
  766. justify-content: space-between;
  767. }
  768. .payment_item .item_t .item_t_l {
  769. display: flex;
  770. align-items: center;
  771. }
  772. .payment_item .item_icon {
  773. width: 53rpx;
  774. height: 43rpx;
  775. margin-right: 18rpx;
  776. }
  777. .payment_item .item_name {
  778. font-size: 30rpx;
  779. color: #000;
  780. }
  781. .payment_item .item_t_r {
  782. display: flex;
  783. align-items: center;
  784. }
  785. .payment_item .price {
  786. font-size: 32rpx;
  787. font-weight: bold;
  788. color: #d54c43;
  789. padding-right: 20rpx;
  790. }
  791. .payment_item .price .unit {
  792. font-size: 24rpx;
  793. }
  794. .payment_item .item_b {
  795. padding-left: 70rpx;
  796. font-size: 24rpx;
  797. color: rgba(1, 1, 1, 0.54);
  798. }
  799. .payment_item .item_b .wenzi:not(:first-child) {
  800. padding-left: 30rpx;
  801. }
  802. .payment_item .item_b .label {
  803. padding-right: 8rpx;
  804. }
  805. .payment_item .item_t_r .quan {
  806. font-size: 30rpx;
  807. color: #d54c43;
  808. padding-right: 26rpx;
  809. }
  810. /* .payment_item .item_t_r .icon_arrow{
  811. width: 12rpx;
  812. height: 20rpx;
  813. } */
  814. /* 充会员卡 */
  815. /* .scroll_card{
  816. height: 500rpx;
  817. } */
  818. .card_list {
  819. padding: 0 30rpx;
  820. }
  821. /* 提交 */
  822. .btn_tijiao {
  823. width: 405rpx;
  824. height: 98rpx;
  825. background: #295c56;
  826. border-radius: 10rpx;
  827. margin: 0 auto;
  828. font-size: 28rpx;
  829. color: #ffffff;
  830. display: flex;
  831. align-items: center;
  832. justify-content: center;
  833. position: fixed;
  834. bottom: 50rpx;
  835. left: 50%;
  836. transform: translateX(-50%);
  837. }
  838. .btn_tijiao .label {
  839. padding-right: 10rpx;
  840. }
  841. .btn_tijiao .price {
  842. font-size: 42rpx;
  843. font-weight: bold;
  844. }
  845. .btn_tijiao .price .unit {
  846. font-size: 27rpx;
  847. }
  848. /* 余额不足提醒 */
  849. .cash_pop {
  850. width: 586rpx;
  851. background: #ffffff;
  852. border-radius: 10rpx;
  853. font-size: 30rpx;
  854. color: #000000;
  855. text-align: center;
  856. position: fixed;
  857. top: 50%;
  858. left: 50%;
  859. transform: translate(-50%, -50%);
  860. }
  861. .cash_pop_t {
  862. padding: 120rpx 0 40rpx;
  863. border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  864. }
  865. .cash_pop_b {
  866. height: 98rpx;
  867. display: flex;
  868. align-items: center;
  869. position: relative;
  870. }
  871. .cash_pop_b .cash_pop_btn {
  872. flex: 1;
  873. height: 98rpx;
  874. color: rgba(0, 0, 0, 0.54);
  875. display: flex;
  876. align-items: center;
  877. justify-content: center;
  878. }
  879. .cash_pop_b .cash_pop_btn.recharge {
  880. color: #d54c43;
  881. border-left: 1rpx solid rgba(0, 0, 0, 0.1);
  882. }
  883. .cash_pop .tip_tu {
  884. width: 134rpx;
  885. height: 245rpx;
  886. position: absolute;
  887. left: 50%;
  888. top: -135rpx;
  889. transform: translateX(-50%);
  890. }
  891. /* 优惠券 */
  892. .coupon_wrap {
  893. width: 750rpx;
  894. position: fixed;
  895. bottom: 0;
  896. left: 0;
  897. }
  898. .coupon_wrap .coupon_t {
  899. width: 750rpx;
  900. height: 98rpx;
  901. background: #ffffff;
  902. border-radius: 20rpx 20rpx 0 0;
  903. font-size: 34rpx;
  904. color: #333333;
  905. display: flex;
  906. align-items: center;
  907. justify-content: center;
  908. position: relative;
  909. }
  910. .coupon_wrap .coupon_t .van-icon {
  911. position: absolute;
  912. top: 50%;
  913. right: 30rpx;
  914. transform: translateY(-50%);
  915. }
  916. .coupon_wrap_scroll {
  917. /* height: 480rpx; */
  918. height: 820rpx;
  919. background: #f6f6f6;
  920. }
  921. .coupon_list {
  922. padding-top: 0;
  923. /* min-height: 480rpx;
  924. height: 100%; */
  925. }
  926. .coupon_item:first-child {
  927. margin-top: 30rpx;
  928. }
  929. </style>