rent.vue 16 KB

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