rent.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. <template>
  2. <view class="content">
  3. <!-- 门店选择 -->
  4. <view class="yt-list tc-wrap" @click="navTo('/pages/shop/shopTab?select=1')">
  5. <view class="top-wrap flex">
  6. <view class="top-left">
  7. 选择门店
  8. </view>
  9. </view>
  10. <view class="store-wrap flex" v-if="selctStore && selctStore.id">
  11. <view class="imgBox">
  12. <image class="logo" :src="selctStore.image" mode="aspectFit"></image>
  13. </view>
  14. <view class="padding-l-20 flex-grow-true">
  15. <view class="title clamp flex">
  16. <view class="name">
  17. {{selctStore.name}}
  18. </view>
  19. <view class="km" v-if="selctStore.range">
  20. {{selctStore.range<1?selctStore.distance+'m':selctStore.range+'km'}}
  21. </view>
  22. </view>
  23. <view class="flex addressBox margin-t-20">
  24. <image class="iconA margin-r-10" src="../../static/icon/shop.png" mode="">
  25. </image>
  26. <text class="clamp">
  27. {{selctStore.detailed_address}}
  28. </text>
  29. </view>
  30. <view class="addressBox flex">
  31. <image class="iconA margin-r-10" src="../../static/icon/shopPhone.png" mode="">
  32. <text class="clamp">
  33. {{selctStore.phone}}
  34. </text>
  35. </view>
  36. <view class="yysj">
  37. 营业时间:{{selctStore.day_time}}
  38. </view>
  39. </view>
  40. </view>
  41. <view class="store-wrap-empty" v-else>
  42. 选择门店
  43. </view>
  44. </view>
  45. <!-- 套餐 -->
  46. <view class="tc-wrap">
  47. <view class="top-wrap flex">
  48. <view class="top-left">
  49. 选择套餐
  50. </view>
  51. </view>
  52. <view class="contet-list flex">
  53. <view class="tc flex" v-for="(item,index) in tcList" :class="{'action': selectTcIndex == index}" @click="choosTc(index,item)">
  54. <view class="tc-time">
  55. {{item.month}}月
  56. </view>
  57. <view class="tc-price">
  58. {{item.price}}
  59. </view>
  60. <view class="tc-time-price">
  61. <text>{{(item.price*1/(item.month*1*30)).toFixed(2)}}</text>元/天
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="dy-wrap" v-if="selectTc.id && userInfo.battery_deposit != 1">
  67. <view class="top-wrap flex">
  68. <view class="top-left">
  69. 押金服务
  70. </view>
  71. <!-- <view class="top-right">
  72. <text>押金规则</text>
  73. <image src="../../static/icon/next1.png" mode="heightFix"></image>
  74. </view> -->
  75. </view>
  76. <view class="contet-list flex">
  77. <!-- <view class="tc flex dy">
  78. <view class="tc-time">
  79. <image src="../../static/icon/orderWx.png" mode="heightFix"></image>微信信用免押金
  80. </view>
  81. <view class="tc-time-price">
  82. 微信信用≥550分
  83. </view>
  84. <view class="tc-price">
  85. 77<text>¥88</text>
  86. </view>
  87. </view> -->
  88. <view class="tc flex dy action">
  89. <view class="tc-time">
  90. 支付押金
  91. </view>
  92. <!-- <view class="tc-time-price">
  93. 元/天
  94. </view> -->
  95. <view class="tc-price">
  96. {{selectTc.deposit}}
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. <view class="dy-wrap">
  102. <view class="top-wrap flex">
  103. <view class="top-left">
  104. 使用说明
  105. </view>
  106. </view>
  107. <view class="sysm" v-html="sm">
  108. </view>
  109. </view>
  110. <view class="yt-list">
  111. <view class="yt-list-cell b-b" @click="payType='weixin'">
  112. <view class="cell-tit flex">
  113. <image class="orderIcon" src="../../static/icon/orderWx.png" mode="widthFix"></image>
  114. <text class="margin-l-10">微信支付</text>
  115. </view>
  116. <image class="checked" v-if="payType=='weixin'" src="../../static/icon/addressIconXz.png"
  117. mode="widthFix"></image>
  118. <view v-else class="noChecked"></view>
  119. </view>
  120. <!-- #ifdef APP-PLUS -->
  121. <view class="yt-list-cell b-b" @click="payType='ali'">
  122. <view class="cell-tit flex">
  123. <image class="orderIcon" src="../../static/icon/orderAli.png" mode="widthFix"></image>
  124. <text class="margin-l-10">支付宝</text>
  125. </view>
  126. <image class="checked" v-if="payType=='ali'" src="../../static/icon/addressIconXz.png" mode="widthFix">
  127. </image>
  128. <view v-else class="noChecked"></view>
  129. </view>
  130. <!-- #endif -->
  131. <view class="yt-list-cell b-b" @click="payType='yue'">
  132. <view class="cell-tit flex">
  133. <image class="orderIcon" src="../../static/icon/ye.png" mode="widthFix"></image>
  134. <text class="margin-l-10">卡券({{now_money}})</text>
  135. </view>
  136. <image class="checked" v-if="payType=='yue'" src="../../static/icon/addressIconXz.png" mode="widthFix">
  137. </image>
  138. <view v-else class="noChecked"></view>
  139. </view>
  140. </view>
  141. <view class="ts">
  142. </view>
  143. <view class="btm-btn flex">
  144. <view class="pay-price" v-if="userInfo.battery_deposit == 1">
  145. 总计费用:<text>{{(selectTc.price*1) || ''}}</text>
  146. </view>
  147. <view class="pay-price" v-else>
  148. 总计费用:<text>{{(selectTc.price*1 + selectTc.deposit*1) || ''}}</text>
  149. </view>
  150. <view class="pay-btn" @click="toBuy" :class="{'zfz': loading}">
  151. {{loading?'支付中':'立即支付'}}
  152. </view>
  153. </view>
  154. </view>
  155. </template>
  156. <script>
  157. // #ifdef H5
  158. import weixinObj from "@/plugin/jweixin-module/index.js";
  159. // #endif
  160. import { mapState,mapMutations} from 'vuex'
  161. import {
  162. storeList,
  163. } from '@/api/product.js';
  164. import {
  165. getUserInfo
  166. } from '@/api/user.js';
  167. import { orderPay } from '@/api/order.js'
  168. import {getRents,rentCreate,details} from '@/api/index.js'
  169. export default {
  170. data() {
  171. return {
  172. selctStore: {id: ''},
  173. now_money: '',
  174. tcList: [],
  175. selectTc: {},
  176. selectTcIndex: 0,
  177. payType: 'yue',
  178. sm: '',//使用说明
  179. loading: false,//是否支付中
  180. }
  181. },
  182. computed: {
  183. ...mapState('user', ['address','userInfo'])
  184. },
  185. onLoad() {
  186. this.getRents()
  187. this.getSm()
  188. },
  189. onShow() {
  190. this.userinfo()
  191. },
  192. onReachBottom() {
  193. },
  194. onReady() {
  195. },
  196. methods: {
  197. ...mapMutations('user',['setUserInfo']),
  198. // 获取使用说明
  199. getSm() {
  200. details({},1).then(res => {
  201. this.sm = res.data.content
  202. })
  203. },
  204. navTo(url) {
  205. uni.navigateTo({
  206. url,
  207. fail() {
  208. uni.switchTab({
  209. url
  210. })
  211. }
  212. })
  213. },
  214. userinfo() {
  215. getUserInfo({}).then(({
  216. data
  217. }) => {
  218. this.now_money = data.now_money;
  219. this.setUserInfo(data)
  220. });
  221. },
  222. choosTc(index,item) {
  223. this.selectTcIndex = index
  224. this.selectTc = item
  225. },
  226. getRents() {
  227. getRents().then(res => {
  228. this.tcList = res.data.rent
  229. this.selectTc = this.tcList[0]
  230. })
  231. },
  232. paySuccessTo() {
  233. uni.hideLoading();
  234. this.loading = false
  235. // uni.redirectTo({
  236. // url: '/pages/user_home/money/paySuccess?orderid=' + this.orderId,
  237. // });
  238. uni.redirectTo({
  239. url: '/pages/user_home/myRent'
  240. })
  241. },
  242. toBuy() {
  243. let that = this
  244. if(that.selctStore.id == '') {
  245. return that.$api.msg('请选择门店')
  246. }
  247. that.loading = true
  248. rentCreate({
  249. store_id: that.selctStore.id,
  250. rent_id: that.selectTc.id,
  251. // #ifdef H5
  252. from: 'weixin', //来源
  253. // #endif
  254. // #ifdef MP-WEIXIN
  255. from: 'routine', //来源
  256. // #endif
  257. // #ifdef APP-PLUS
  258. from: 'app', //来源
  259. // #endif
  260. pay_type: that.payType//支付方式
  261. }).then(({
  262. data,
  263. status,
  264. msg
  265. }) => {
  266. if (data.status == 'ORDER_EXIST') {
  267. uni.showModal({
  268. title: '提示',
  269. content: msg,
  270. showCancel: false
  271. });
  272. uni.hideLoading();
  273. that.loading = false;
  274. return;
  275. }
  276. // 保存订单号
  277. that.orderId = data.result.orderId;
  278. // 判断是否为卡券支付
  279. if (that.payType == 'yue') {
  280. console.log('卡券支付', status == 200 && data.status == 'SUCCESS');
  281. that.loading = false
  282. if (status == 200 && data.status == 'SUCCESS') {
  283. that.paySuccessTo();
  284. } else {
  285. that.$api.msg(msg);
  286. }
  287. } else {
  288. // 立即支付
  289. // obj.orderMoneyPay();
  290. let da = data.result.jsConfig;
  291. let paydata = {
  292. nonceStr: da.nonceStr,
  293. package: da.package,
  294. signType: da.signType,
  295. paySign: da.paySign,
  296. success: function(res) {
  297. that.paySuccessTo();
  298. },
  299. fail: () => {
  300. that.loading = false;
  301. }
  302. };
  303. // #ifdef H5
  304. paydata.timestamp = da.timestamp;
  305. weixinObj.chooseWXPay(paydata);
  306. // #endif
  307. // #ifdef MP-WEIXIN
  308. paydata.timeStamp = da.timestamp;
  309. wx.requestPayment(paydata);
  310. // #endif
  311. }
  312. })
  313. },
  314. orderMoneyPay() {
  315. let obj = this;
  316. orderPay({
  317. uni: obj.orderId,
  318. // #ifdef H5
  319. from: 'weixin', //来源
  320. // #endif
  321. // #ifdef MP-WEIXIN
  322. from: 'routine', //来源
  323. // #endif
  324. // #ifdef APP-PLUS
  325. from: 'app', //来源
  326. // #endif
  327. paytype: obj.payType //支付类型 weixin-微信 yue-卡券
  328. })
  329. .then(e => {
  330. // 判断是否微信小程序支付
  331. if (obj.payType == 'weixin') {
  332. // #ifdef H5 || MP
  333. let da = e.data.result.jsConfig;
  334. let data = {
  335. nonceStr: da.nonceStr,
  336. package: da.package,
  337. signType: da.signType,
  338. paySign: da.paySign,
  339. success: function(res) {
  340. obj.paySuccessTo();
  341. },
  342. fail: () => {
  343. uni.navigateTo({
  344. url: '/pages/order/order?state=0'
  345. });
  346. }
  347. };
  348. // #endif
  349. // #ifdef H5
  350. data.timestamp = da.timestamp;
  351. weixinObj.chooseWXPay(data);
  352. // #endif
  353. // #ifdef MP-WEIXIN
  354. data.timeStamp = da.timestamp;
  355. wx.requestPayment(data);
  356. // #endif
  357. // #ifdef APP
  358. console.log( e.data.result.jsConfig,'返回数值');
  359. uni.requestPayment({
  360. provider: 'wxpay',
  361. orderInfo: e.data.result.jsConfig,
  362. success(e) {
  363. obj.paySuccessTo();
  364. },
  365. fail: (e) => {
  366. console.log(e,'支付失败');
  367. uni.navigateTo({
  368. url: '/pages/order/order?state=0'
  369. });
  370. }
  371. })
  372. // #endif
  373. }
  374. // #ifdef APP
  375. if(obj.payType == 'ali'){
  376. uni.requestPayment({
  377. provider: 'alipay',
  378. orderInfo: e.data.result.jsConfig,
  379. success(e) {
  380. obj.paySuccessTo();
  381. },
  382. fail: (e) => {
  383. console.log(e,'支付失败');
  384. uni.navigateTo({
  385. url: '/pages/order/order?state=0'
  386. });
  387. }
  388. })
  389. }
  390. // #endif
  391. uni.hideLoading();
  392. obj.payLoding = false;
  393. })
  394. .catch(e => {
  395. // 支付完成
  396. uni.hideLoading();
  397. obj.payLoding = false;
  398. console.log(e);
  399. });
  400. },
  401. }
  402. }
  403. </script>
  404. <style lang="scss" scoped>
  405. .content {
  406. padding-top: 1rpx;
  407. }
  408. .dy-wrap, .tc-wrap {
  409. width: 702rpx;
  410. background: #FFFFFF;
  411. border-radius: 15rpx;
  412. // padding: 25rpx 25rpx 45rpx;
  413. margin: 20rpx auto;
  414. }
  415. .contet-list {
  416. flex-wrap: wrap;
  417. justify-content: space-between;
  418. padding: 0 25rpx 45rpx;
  419. .tc {
  420. width: 315rpx;
  421. height: 212rpx;
  422. background: #FFFFFF;
  423. border: 2px solid #E9E9E9;
  424. border-radius: 10rpx;
  425. margin-bottom: 20rpx;
  426. flex-direction: column;
  427. justify-content: center;
  428. // align-items: center;
  429. .tc-time {
  430. font-size: 28rpx;
  431. font-weight: bold;
  432. color: #00001A;
  433. display: flex;
  434. align-items: center;
  435. image {
  436. height: 34rpx;
  437. margin-right: 10rpx;
  438. }
  439. }
  440. .tc-price {
  441. font-size: 55rpx;
  442. font-weight: bold;
  443. color: #52C696;
  444. padding: 4rpx 0;
  445. &::before {
  446. content: '¥';
  447. font-size: 20rpx;
  448. }
  449. text {
  450. font-size: 22rpx;
  451. font-weight: 500;
  452. text-decoration: line-through;
  453. color: #999999;
  454. }
  455. }
  456. .tc-time-price {
  457. font-size: 22rpx;
  458. font-weight: 500;
  459. color: #999999;
  460. text {
  461. font-weight: bold;
  462. }
  463. }
  464. }
  465. .dy {
  466. height: 187rpx;
  467. }
  468. .action {
  469. background: #F3FFFB;
  470. border: 2px solid #5FCCA7;
  471. }
  472. }
  473. .top-wrap {
  474. justify-content: space-between;
  475. padding: 0 25rpx;
  476. font-size: 32rpx;
  477. font-weight: bold;
  478. color: #00001A;
  479. height: 85rpx;
  480. .top-left {
  481. }
  482. .top-right {
  483. text {
  484. font-size: 25rpx;
  485. font-weight: 500;
  486. color: #999999;
  487. }
  488. image {
  489. height: 22rpx;
  490. margin-left: 10rpx;
  491. }
  492. }
  493. }
  494. .sysm {
  495. padding: 34rpx;
  496. font-size: 22rpx;
  497. font-weight: 500;
  498. color: #666666;
  499. }
  500. .ts {
  501. height: 200rpx;
  502. }
  503. .btm-btn {
  504. width: 750rpx;
  505. height: 100rpx;
  506. position: fixed;
  507. bottom: 0;
  508. background-color: #fff;
  509. z-index: 999;
  510. .pay-price {
  511. padding-left: 33rpx;
  512. flex-grow: 1;
  513. font-size: 32rpx;
  514. font-weight: 500;
  515. color: #333333;
  516. text {
  517. font-size:48rpx;
  518. font-weight: 500;
  519. color: #FF6B2E;
  520. &::before {
  521. content: '¥';
  522. font-size: 28rpx;
  523. }
  524. }
  525. }
  526. .pay-btn {
  527. flex-shrink: 0;
  528. width: 287rpx;
  529. height: 98rpx;
  530. background: linear-gradient(-38deg, #6CDBC3, #6DD6B8);
  531. line-height: 100rpx;
  532. text-align: center;
  533. font-size: 34rpx;
  534. font-weight: 500;
  535. color: #FFFFFF;
  536. }
  537. }
  538. .yt-list {
  539. background: #fff;
  540. margin: 0 $page-row-spacing;
  541. margin-top: 30rpx;
  542. border-radius: 20rpx;
  543. }
  544. .yt-list-cell {
  545. display: flex;
  546. align-items: center;
  547. justify-content: space-between;
  548. padding: 10rpx 30rpx 10rpx 40rpx;
  549. line-height: 70rpx;
  550. position: relative;
  551. .checked,
  552. .noChecked {
  553. width: 36rpx;
  554. height: 36rpx;
  555. }
  556. .noChecked {
  557. border: 1px solid $font-color-light;
  558. border-radius: 100rpx;
  559. }
  560. &.cell-hover {
  561. background: #fafafa;
  562. }
  563. &.b-b:after {
  564. left: 30rpx;
  565. }
  566. .cell-icon {
  567. height: 32rpx;
  568. width: 32rpx;
  569. font-size: 22rpx;
  570. color: #fff;
  571. text-align: center;
  572. line-height: 32rpx;
  573. background: #f85e52;
  574. border-radius: 4rpx;
  575. margin-right: 12rpx;
  576. &.hb {
  577. background: #ffaa0e;
  578. }
  579. &.lpk {
  580. background: #3ab54a;
  581. }
  582. }
  583. .cell-more {
  584. align-self: center;
  585. font-size: 24rpx;
  586. color: $font-color-light;
  587. margin-left: 8rpx;
  588. margin-right: -10rpx;
  589. }
  590. .cell-tit {
  591. font-size: 26rpx;
  592. color: $font-color-light;
  593. margin-right: 10rpx;
  594. .orderIcon {
  595. width: 48rpx;
  596. }
  597. }
  598. .cell-tip {
  599. font-size: 26rpx;
  600. color: $font-color-dark;
  601. &.disabled {
  602. color: $font-color-light;
  603. }
  604. &.active {
  605. color: $base-color;
  606. }
  607. &.red {
  608. color: $base-color;
  609. }
  610. }
  611. &.desc-cell {
  612. .cell-tit {
  613. max-width: 90rpx;
  614. }
  615. }
  616. .desc {
  617. text-align: right;
  618. font-size: $font-base;
  619. color: $font-color-light;
  620. }
  621. }
  622. .store-wrap-empty {
  623. text-align: center;
  624. height: 100rpx;
  625. }
  626. .store-wrap {
  627. background-color: #FFFFFF;
  628. margin-bottom: 30rpx;
  629. padding: 30rpx;
  630. border-radius: 20rpx;
  631. .list,.km{
  632. color: $font-color-light;
  633. font-size: $font-sm;
  634. }
  635. .logo {
  636. height: 200rpx;
  637. width: 200rpx;
  638. border-radius: 20rpx;
  639. }
  640. .title {
  641. font-size: 36rpx;
  642. color: $font-color-dark;
  643. }
  644. .iconR {
  645. height: 24rpx;
  646. }
  647. .iconA {
  648. width: 24rpx;
  649. height: 24rpx;
  650. }
  651. .addressBox {
  652. font-size: 24rpx;
  653. color: $font-color-light;
  654. justify-content: flex-start;
  655. padding: 10rpx 0;
  656. }
  657. .yysj {
  658. display: inline-block;
  659. // width: 239rpx;
  660. padding: 0 10rpx;
  661. height: 32rpx;
  662. background: #ddf8f1;
  663. border-radius: 16rpx 16rpx 16rpx 0rpx;
  664. font-size: 20rpx;
  665. font-weight: bold;
  666. color: #5FCCA7;
  667. text-align: center;
  668. line-height: 32rpx;
  669. margin-top: 10rpx;
  670. }
  671. }
  672. .zfz {
  673. background: #999 !important;
  674. }
  675. </style>