rent.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341
  1. <template>
  2. <view class="content">
  3. <view class="qrimg">
  4. <tki-qrcode :cid="cid" ref="qrcode" :val="val" :size="size" :unit="unit" :background="background"
  5. :foreground="foreground" :pdground="pdground" :icon="icon" :iconSize="iconSize" :lv="lv" :onval="onval"
  6. :showLoading="showLoading" :loadMake="loadMake" :usingComponents="usingComponents" @result="qrR" />
  7. <tki-qrcode :cid="ciddk" ref="qrcodet" :val="valdk" :size="size" :unit="unit" :background="background"
  8. :foreground="foreground" :pdground="pdground" :icon="icon" :iconSize="iconSize" :lv="lv" :onval="onval"
  9. :showLoading="showLoading" :loadMake="loadMake" :usingComponents="usingComponents" @result="qrRdk" />
  10. <canvas :style="{ width:cw + 'rpx', height: ch+'rpx',}" canvas-id="myCanvas" id="myCanvas"
  11. class="hb"></canvas>
  12. <canvas :style="{ width:cw + 'rpx', height: ch+'rpx',}" canvas-id="myCanvass" id="myCanvass"
  13. class="hb"></canvas>
  14. </view>
  15. <view class="top-tit">
  16. <view class="tit">
  17. 为您展示【台州市】地区套餐,其他地域套餐待开放。
  18. </view>
  19. </view>
  20. <!-- 推荐渠道 -->
  21. <view class="yt-list">
  22. <view class="top-wrap flex">
  23. <view class="top-left">
  24. 推荐渠道
  25. </view>
  26. </view>
  27. <view class="contet-list flex">
  28. <view class="tc " style="display: flex;text-align: center;" :class="{'action': is_tj}"
  29. @click="couldTj?istj==true:''">
  30. 推荐渠道
  31. </view>
  32. <view class="tc" style="display: flex;text-align: center;" :class="{'action': !is_tj}">
  33. {{isFj?'最近门店': '选择门店'}}
  34. </view>
  35. </view>
  36. </view>
  37. <!-- 门店选择 -->
  38. <view class="yt-list tc-wrap" @click="navTo('/pages/shop/shopTab?select=1')" v-if="!is_tj">
  39. <view class="top-wrap flex">
  40. <view class="top-left">
  41. {{isFj?'最近门店': '选择门店'}}
  42. </view>
  43. </view>
  44. <view class="store-wrap flex" v-if="selctStore && selctStore.id">
  45. <view class="imgBox">
  46. <image class="logo" :src="selctStore.image" mode="aspectFit"></image>
  47. </view>
  48. <view class="padding-l-20 flex-grow-true">
  49. <view class="title clamp flex">
  50. <view class="name">
  51. {{selctStore.name}}
  52. </view>
  53. <view class="km" v-if="selctStore.range">
  54. {{selctStore.range<1?selctStore.distance+'m':selctStore.range+'km'}}
  55. </view>
  56. </view>
  57. <view class="flex addressBox margin-t-20">
  58. <image class="iconA margin-r-10" src="../../static/icon/shop.png" mode="">
  59. </image>
  60. <text class="clamp">
  61. {{selctStore.detailed_address}}
  62. </text>
  63. </view>
  64. <view class="addressBox flex">
  65. <image class="iconA margin-r-10" src="../../static/icon/shopPhone.png" mode="">
  66. <text class="clamp">
  67. {{selctStore.phone}}
  68. </text>
  69. </view>
  70. <view class="yysj">
  71. 营业时间:{{selctStore.day_time}}
  72. </view>
  73. </view>
  74. </view>
  75. <view class="store-wrap-empty" v-else>
  76. 选择门店
  77. </view>
  78. </view>
  79. <!-- 套餐 -->
  80. <view class="tc-wrap">
  81. <view class="top-wrap flex">
  82. <view class="top-left">
  83. 选择套餐
  84. </view>
  85. </view>
  86. <view class="contet-list flex" style="position: relative;" :style="{'height': isShowAll? 'auto': '275rpx'}">
  87. <view class="flex" v-if="isShowAll == false"
  88. style="width: 100%; position: absolute;bottom: 0;background-color: #fff;height: 50rpx;left: 0;text-align: center;border-radius: 0 0 20rpx 20rpx;padding: 0 30px;"
  89. @click="isShowAll = true">
  90. <view class="">
  91. </view>
  92. <view class="">
  93. 查看更多套餐 <image src="../../static/icon/down1.png" mode="widthFix"
  94. style="width: 30rpx;margin-left: 10rpx;"></image>
  95. </view>
  96. <view class="">
  97. </view>
  98. </view>
  99. <view class="tc flex" v-for="(item,index) in tcList" :class="{'action': selectTcIndex == index}"
  100. @click="choosTc(index,item)" v-if="item.day == 30 || !userinfo.payRules">
  101. <view class="tc-price">
  102. {{item.price}}
  103. <text class="tc-time-t">
  104. &nbsp;/&nbsp;{{item.day}}天
  105. </text>
  106. </view>
  107. <view class="tc-time-price">
  108. <text>{{(item.price*1/(item.day*1)).toFixed(2)}}</text>元/天
  109. </view>
  110. </view>
  111. </view>
  112. </view>
  113. <view class="dy-wrap" v-if="selectTc.id && userInfo.battery_deposit != 1">
  114. <view class="top-wrap flex">
  115. <view class="top-left">
  116. 押金服务
  117. </view>
  118. <!-- <view class="top-right">
  119. <text>押金规则</text>
  120. <image src="../../static/icon/next1.png" mode="heightFix"></image>
  121. </view> -->
  122. </view>
  123. <view class="contet-list flex">
  124. <view class="tc flex dy" :class="{'action': ismy}" @click="ljmy()">
  125. <view class="tc-time">
  126. <!-- <image src="../../static/icon/orderAli.png" mode="heightFix"></image> -->
  127. 信用免押金
  128. </view>
  129. <!-- <view class="tc-time-price">
  130. 微信信用≥550分
  131. </view>
  132. <view class="tc-price">
  133. 77<text>¥88</text>
  134. </view> -->
  135. </view>
  136. <view class="tc flex dy " :class="{'action': !ismy}" @click="qxmy()">
  137. <view class="tc-time">
  138. 支付押金
  139. </view>
  140. <!-- <view class="tc-time-price">
  141. 元/天
  142. </view> -->
  143. <view class="tc-price">
  144. {{selectTc.deposit}}
  145. </view>
  146. </view>
  147. </view>
  148. </view>
  149. <view class="myj-wrap" v-if="showMyEwm">
  150. <view class="ewm-wrap">
  151. <!-- <canvas :style="{ width:cw + 'rpx', height: ch+'rpx',}" canvas-id="myCanvas" id="myCanvas"
  152. class="hb"></canvas> -->
  153. <image :src="shareQrcodeUrl" mode="" :style="{ width:cw + 'rpx', height: ch+'rpx',}"></image>
  154. </view>
  155. <view class="bcewm" @click="saveShareQrcode('shareQrcodeUrl')">
  156. 保存二维码
  157. </view>
  158. </view>
  159. <view class="dy-wrap">
  160. <view class="top-wrap flex">
  161. <view class="top-left">
  162. 代扣服务
  163. </view>
  164. <!-- <view class="top-right">
  165. <text>押金规则</text>
  166. <image src="../../static/icon/next1.png" mode="heightFix"></image>
  167. </view> -->
  168. </view>
  169. <view class="contet-list flex">
  170. <view class="tc flex dy" :class="{'action': isdk}" @click="ktdk()">
  171. <view class="tc-time">
  172. <!-- <image src="../../static/icon/orderAli.png" mode="heightFix"></image> -->
  173. 周期代扣
  174. </view>
  175. <!-- <view class="tc-time-price">
  176. 微信信用≥550分
  177. </view>
  178. <view class="tc-price">
  179. 77<text>¥88</text>
  180. </view> -->
  181. </view>
  182. <view class="tc flex dy " :class="{'action': !isdk}" @click="qxdk()">
  183. <view class="tc-time">
  184. 卡券/微信
  185. </view>
  186. <!-- <view class="tc-time-price">
  187. 元/天
  188. </view> -->
  189. <!-- <view class="tc-price">
  190. {{selectTc.deposit}}
  191. </view> -->
  192. </view>
  193. </view>
  194. </view>
  195. <view class="myj-wrap" v-if="showDkEwm">
  196. <view class="ewm-wrap">
  197. <!-- <canvas :style="{ width:cw + 'rpx', height: ch+'rpx',}" canvas-id="myCanvass" id="myCanvass"
  198. class="hb"></canvas> -->
  199. <image :src="dkQrcodeUrl" mode="" :style="{ width:cw + 'rpx', height: ch+'rpx',}"></image>
  200. </view>
  201. <view class="bcewm" @click="saveShareQrcode('dkQrcodeUrl')">
  202. 保存二维码
  203. </view>
  204. </view>
  205. <view class="dy-wrap">
  206. <view class="top-wrap flex">
  207. <view class="top-left">
  208. 使用说明
  209. </view>
  210. </view>
  211. <view class="sysm" v-html="sm">
  212. </view>
  213. </view>
  214. <view class="yt-list" v-if="!isdk">
  215. <view class="yt-list-cell b-b" @click="payType='weixin'">
  216. <view class="cell-tit flex">
  217. <image class="orderIcon" src="../../static/icon/orderWx.png" mode="widthFix"></image>
  218. <text class="margin-l-10">微信支付</text>
  219. </view>
  220. <image class="checked" v-if="payType=='weixin'" src="../../static/icon/addressIconXz.png"
  221. mode="widthFix"></image>
  222. <view v-else class="noChecked"></view>
  223. </view>
  224. <!-- #ifdef APP-PLUS -->
  225. <view class="yt-list-cell b-b" @click="payType='ali'">
  226. <view class="cell-tit flex">
  227. <image class="orderIcon" src="../../static/icon/orderAli.png" mode="widthFix"></image>
  228. <text class="margin-l-10">支付宝</text>
  229. </view>
  230. <image class="checked" v-if="payType=='ali'" src="../../static/icon/addressIconXz.png" mode="widthFix">
  231. </image>
  232. <view v-else class="noChecked"></view>
  233. </view>
  234. <!-- #endif -->
  235. <view class="yt-list-cell b-b" @click="payType='yue'">
  236. <view class="cell-tit flex">
  237. <image class="orderIcon" src="../../static/icon/ye.png" mode="widthFix"></image>
  238. <text class="margin-l-10">卡券({{now_money}})</text>
  239. </view>
  240. <image class="checked" v-if="payType=='yue'" src="../../static/icon/addressIconXz.png" mode="widthFix">
  241. </image>
  242. <view v-else class="noChecked"></view>
  243. </view>
  244. <view class="yt-list-cell b-b" @click="isqxdk= !isqxdk">
  245. <view class="cell-tit flex">
  246. <!-- <image class="orderIcon" src="../../static/icon/ye.png" mode="widthFix"></image> -->
  247. <text class="margin-l-10">使用骑行券抵扣(可用骑行券{{userInfo.certificate}})</text>
  248. </view>
  249. <image class="checked" v-if="isqxdk" src="../../static/icon/addressIconXz.png" mode="widthFix">
  250. </image>
  251. <view v-else class="noChecked"></view>
  252. </view>
  253. </view>
  254. <view class="ts" v-if="!isdk">
  255. </view>
  256. <view class="btm-btn flex" v-if="!isdk">
  257. <!-- <view class="pay-price" v-if="!ismy && userInfo.battery_deposit != 1">
  258. 总计费用:<text>{{(selectTc.price*1 + selectTc.deposit*1).toFixed(2) || ''}}</text>
  259. </view> -->
  260. <view class="pay-price">
  261. 总计费用:<text>{{showPrice}}</text>
  262. </view>
  263. <view class="pay-btn" @click="toBuy" :class="{'zfz': loading}">
  264. {{loading?'支付中':'立即支付'}}
  265. </view>
  266. </view>
  267. </view>
  268. </template>
  269. <script>
  270. // #ifdef MP-WEIXIN
  271. import {
  272. openMap
  273. } from '@/utils/rocessor.js';
  274. // #endif
  275. // #ifdef H5
  276. import weixinObj from "@/plugin/jweixin-module/index.js";
  277. // #endif
  278. import {
  279. mapState,
  280. mapMutations
  281. } from 'vuex'
  282. import {
  283. storeList,
  284. } from '@/api/product.js';
  285. import {
  286. getUserInfo
  287. } from '@/api/user.js';
  288. import {
  289. orderPay
  290. } from '@/api/order.js'
  291. import {
  292. getRents,
  293. rentCreate,
  294. details,
  295. rentFree,
  296. contractCreate,
  297. createSignFLow
  298. } from '@/api/index.js'
  299. export default {
  300. data() {
  301. return {
  302. isShowDk:true,
  303. isShowAll: false,
  304. showTc: [],
  305. isqxdk: false,
  306. isdk: false, //是否代扣
  307. ismy: false, //是否免押
  308. showbtn: false,
  309. ewmw: 300, //二维码相对宽度
  310. cw: 702, //画布相对宽度
  311. ch: 600, //画布相对高度
  312. shareQrcodeUrl: '', //画布生成的地址
  313. dkQrcodeUrl: '',
  314. canvasW: '', //画布宽度
  315. canvasH: '', //画布高度
  316. ewmImg: '', //二维码图片信息
  317. erweimasrc: '', //生成的二维码图片
  318. dkerweima: '',
  319. cid: 'tki-qrcode-canvas', //canvasId,页面存在多个二维码组件时需设置不同的ID
  320. ciddk: 'dk-qrcode-canvas', //canvasId,页面存在多个二维码组件时需设置不同的ID
  321. size: 300, //生成的二维码大小
  322. unit: 'upx', //大小单位尺寸
  323. // show: true,//默认使用组件中的image标签显示二维码
  324. val: '', //要生成的内容
  325. valdk: '',
  326. background: '#ffffff', //二维码背景色
  327. foreground: '#333333', //二维码前景色
  328. pdground: '#333333', //二维码角标色
  329. icon: '', //二维码图标URL(必须是本地图片,网络图需要先下载至本地)
  330. iconSize: 40, //二维码图标大小
  331. lv: 3, //容错级别
  332. onval: true, //监听val值变化自动重新生成二维码
  333. loadMake: true, //组件初始化完成后自动生成二维码,val需要有值
  334. usingComponents: false, //是否使用了自定义组件模式(主要是为了修复非自定义组件模式时 v-if 无法生成二维码的问题)
  335. showLoading: false, //是否显示loading
  336. is_tj: false, //是否使用推荐渠道
  337. couldTj: false, //是否可用推荐渠道
  338. isFj: false, //是否为最近门店
  339. selctStore: {
  340. id: ''
  341. },
  342. now_money: '',
  343. tcList: [],
  344. selectTc: {},
  345. selectTcIndex: 0,
  346. payType: 'yue',
  347. sm: '', //使用说明
  348. loading: false, //是否支付中
  349. renew: 0, //是否续费
  350. }
  351. },
  352. watch: {
  353. selctStore(n, o) {
  354. if (n) {
  355. if(this.userInfo.battery_deposit != 1) {
  356. this.ljmy()
  357. }
  358. if (this.selectTc.day*1 == 30 && !this.userInfo.payRules) {
  359. this.ktdk()
  360. }else {
  361. this.qxdk()
  362. this.isShowDk = false
  363. }
  364. }
  365. },
  366. selectTc(n,o) {
  367. if(n) {
  368. if(n.day*1 != 30) {
  369. this.qxdk()
  370. this.isShowDk = false
  371. }
  372. }
  373. }
  374. },
  375. computed: {
  376. ...mapState('user', ['address', 'userInfo']),
  377. //展示免押二维码
  378. showMyEwm() {
  379. return this.ismy && this.shareQrcodeUrl
  380. },
  381. //展示代扣二维码
  382. showDkEwm() {
  383. return this.isdk && this.dkQrcodeUrl
  384. },
  385. showPrice() {
  386. let price = this.selectTc.price * 1 + this.selectTc.deposit * 1
  387. if (!this.ismy && this.userInfo.battery_deposit != 1) {
  388. if (this.isqxdk) {
  389. let all = (price - this.userInfo.certificate * 1).toFixed(2)
  390. return all > 0 ? all : 0
  391. } else {
  392. return price
  393. }
  394. } else {
  395. if (this.isqxdk) {
  396. let all = (this.selectTc.price * 1 - this.userInfo.certificate * 1).toFixed(2)
  397. return all > 0 ? all : 0
  398. } else {
  399. return this.selectTc.price * 1
  400. }
  401. }
  402. }
  403. },
  404. onLoad(opt) {
  405. if (opt.renew) {
  406. this.renew = opt.renew
  407. }
  408. this.getRents()
  409. this.getSm()
  410. },
  411. onShow() {
  412. this.userinfo()
  413. if (this.address.latitude == '') {
  414. this.getlocation()
  415. }else {
  416. this.storeList()
  417. }
  418. },
  419. onReachBottom() {
  420. },
  421. onReady() {
  422. },
  423. methods: {
  424. ...mapMutations('user', ['setUserInfo', 'setAddress']),
  425. //取消免押
  426. qxdk() {
  427. this.isdk = false
  428. },
  429. qxmy() {
  430. this.ismy = false
  431. },
  432. ktdk() {
  433. let that = this
  434. that.dkQrcodeUrl = ''
  435. if (!that.is_tj && that.selctStore.id == '') {
  436. return that.$api.msg('请选择门店')
  437. }
  438. if(!that.isShowDk) {
  439. return
  440. }
  441. this.isdk = true
  442. // this.contractCreate()
  443. this.toBuy()
  444. },
  445. contractCreate() {
  446. contractCreate().then(res => {
  447. // console.log(res);
  448. })
  449. },
  450. createSignFLow() {
  451. uni.showLoading({
  452. title: '二维码生成中...'
  453. })
  454. createSignFLow().then(res => {
  455. this.valdk = res.data.result.link
  456. })
  457. },
  458. // 选择免押
  459. ljmy() {
  460. let that = this
  461. if (!that.is_tj && that.selctStore.id == '') {
  462. return that.$api.msg('请选择门店')
  463. }
  464. this.ismy = true
  465. this.rentFree()
  466. },
  467. rentFree() {
  468. let that = this
  469. if (!that.is_tj && that.selctStore.id == '') {
  470. return that.$api.msg('请选择门店')
  471. }
  472. uni.showLoading({
  473. title: '二维码生成中...'
  474. })
  475. rentFree({
  476. rent_id: that.selectTc.id
  477. }).then(res => {
  478. that.val = res.data.result.link
  479. })
  480. },
  481. //保存图片
  482. saveShareQrcode(img) {
  483. uni.saveImageToPhotosAlbum({
  484. filePath: this[img],
  485. success: (res) => {
  486. uni.showToast({
  487. icon: 'none',
  488. position: 'bottom',
  489. title: "成功保存到相册",
  490. });
  491. },
  492. fail: (err) => {
  493. //重新提示用户打开保存图片的授权
  494. if (err.errMsg === "saveImageToPhotosAlbum:fail auth deny") {
  495. uni.showModal({
  496. title: '提示',
  497. content: '需要您授权保存相册',
  498. showCancel: false,
  499. success(res) {
  500. if (res.confirm) {
  501. uni.openSetting({
  502. success(settingdata) {
  503. if (settingdata.authSetting[
  504. 'scope.writePhotosAlbum']) {
  505. uni.showModal({
  506. title: '提示',
  507. content: '获取权限成功,再次保存图片即可成功',
  508. showCancel: false,
  509. })
  510. } else {
  511. uni.showModal({
  512. title: '提示',
  513. content: '获取权限失败,无法保存到相册',
  514. showCancel: false
  515. })
  516. }
  517. }
  518. })
  519. }
  520. }
  521. })
  522. }
  523. },
  524. })
  525. },
  526. mychange(e) {
  527. this.showbtn = e.show
  528. },
  529. //获取二维码
  530. getEwm() {
  531. let that = this
  532. setTimeout(() => {
  533. that.val = '阿强是个大傻逼'
  534. this.$refs.mypopup.open()
  535. }, 100)
  536. },
  537. // 获取图片信息
  538. getImageInfo(image) {
  539. return new Promise((req, rej) => {
  540. uni.getImageInfo({
  541. src: image,
  542. success: function(res) {
  543. req(res)
  544. },
  545. });
  546. })
  547. },
  548. // 获取设备信息
  549. getSystemInfo() {
  550. return new Promise((req, rej) => {
  551. uni.getSystemInfo({
  552. success: function(res) {
  553. req(res)
  554. }
  555. });
  556. })
  557. },
  558. async createPoster(imgname, ewmimg, cavid, tit = '') {
  559. let that = this
  560. // 获取设备信息,主要获取宽度,赋值给canvasW 也就是宽度:100%
  561. that.SystemInfo = await that.getSystemInfo();
  562. that.ewmImg = await that.getImageInfo(ewmimg);
  563. // this.canvasW = this.SystemInfo.windowWidth; // 画布宽度
  564. that.ratio = that.SystemInfo.windowWidth / 750;
  565. that.canvasW = that.cw * that.ratio;
  566. this.canvasH = that.ch * that.ratio;
  567. that.ewmW = that.ewmw * that.ratio;
  568. // 如果主图,二维码图片,设备信息都获取成功,开始绘制海报,这里需要用setTimeout延时绘制,否则可能会出现图片不显示。
  569. if (that.ewmImg.errMsg == 'getImageInfo:ok' && that.SystemInfo.errMsg == 'getSystemInfo:ok') {
  570. console.log('二维码和屏幕信息加载完成')
  571. setTimeout(() => {
  572. var ctx = uni.createCanvasContext(cavid, that);
  573. // 填充背景色,白色
  574. ctx.setFillStyle('#fff'); // 默认白色
  575. ctx.fillRect(0, 0, this.canvasW, this.canvasH) // fillRect(x,y,宽度,高度)
  576. // drawImage(图片路径,x,y,绘制图像的宽度,绘制图像的高度)
  577. ctx.drawImage(this.ewmImg.path, (this.canvasW / 2 - this.ewmW / 2), 100 * that.ratio,
  578. this.ewmW, this.ewmW) // drawImage(图片路径,x,y,绘制图像的宽度,绘制图像的高度,二维码的宽,高)
  579. // 3、绘制商品标题,多余文字自动换行
  580. ctx.setFontSize(16); // setFontSize() 设置字体字号
  581. ctx.setFillStyle('#333'); // setFillStyle() 设置字体颜色
  582. ctx.setTextAlign('center')
  583. ctx.fillText('请使用支付宝扫描上方二维码', this.canvasW / 2, 200 * that.ratio + that.ewmW)
  584. ctx.fillText(tit, this.canvasW / 2, 260 * that.ratio + that.ewmW)
  585. ctx.draw(false, (ret) => { // draw方法 把以上内容画到 canvas 中。
  586. that.fina = true
  587. uni.canvasToTempFilePath({ // 保存canvas为图片
  588. canvasId: cavid,
  589. quality: 1,
  590. fileType: 'jpg',
  591. complete: function(res) {
  592. // 在H5平台下,tempFilePath 为 base64, // 图片提示跨域 H5保存base64失败,APP端正常输出临时路径
  593. console.log(res)
  594. // that.canvasShow = false
  595. that[imgname] = res.tempFilePath
  596. that.$forceUpdate()
  597. uni.hideLoading()
  598. // setTimeout(function() {
  599. // console.log(that.shareQrcodeUrl, that
  600. // .canvasShow)
  601. // }, 2000)
  602. },
  603. })
  604. });
  605. }, 1500)
  606. } else {
  607. console.log('err')
  608. }
  609. },
  610. qrR(res) {
  611. this.erweimasrc = res
  612. this.createPoster('shareQrcodeUrl', this.erweimasrc, 'myCanvas', '完成免押服务')
  613. },
  614. qrRdk(res) {
  615. this.dkerweima = res
  616. this.createPoster('dkQrcodeUrl', this.dkerweima, 'myCanvass', '完成代扣服务')
  617. },
  618. // 获取附近门店
  619. storeList(source) {
  620. let that = this
  621. storeList({
  622. page: 1,
  623. limit: 1,
  624. latitude: that.address.latitude,
  625. longitude: that.address.longitude,
  626. })
  627. .then(({
  628. data
  629. }) => {
  630. // console.log(data, '结果');
  631. if (data && data.list && data.list.length > 0) {
  632. that.selctStore = data.list[0]
  633. // if (data.list[0].distance * 1 <= 100) {
  634. that.isFj = true
  635. // }
  636. }
  637. })
  638. .catch(e => {
  639. console.log(e);
  640. });
  641. },
  642. // 获取经纬度
  643. getlocation() {
  644. let obj = this;
  645. // #ifdef H5 || APP
  646. uni.getLocation({
  647. type: 'gcj02',
  648. success(e) {
  649. obj.getlocationSetInit(e)
  650. },
  651. fail(e) {
  652. if (e.errCode == 22) {
  653. uni.showModal({
  654. title: '定位开启错误',
  655. content: '请查看是否已经开启定位服务',
  656. showCancel: false,
  657. });
  658. }
  659. console.log(e, 'cw');
  660. }
  661. })
  662. // #endif
  663. // #ifdef MP-WEIXIN
  664. openMap().then((e) => {
  665. console.log("授权");
  666. wx.getLocation({
  667. type: 'gcj02',
  668. success: (e) => {
  669. console.log(e);
  670. // 调用鉴定位置变化事件
  671. this.getlocationSetInit(e)
  672. },
  673. fail() {}
  674. })
  675. })
  676. // #endif
  677. },
  678. // 获取经纬度完毕后回调处理
  679. getlocationSetInit(data) {
  680. const obj = this;
  681. try {
  682. console.log(data, '位置数据');
  683. // 保存当前经纬度
  684. obj.setAddress({
  685. latitude: data.latitude,
  686. longitude: data.longitude
  687. })
  688. this.storeList()
  689. } catch (e) {
  690. console.log(e, 'cww');
  691. this.storeList()
  692. }
  693. },
  694. // 获取使用说明
  695. getSm() {
  696. details({}, 1).then(res => {
  697. this.sm = res.data.content
  698. })
  699. },
  700. navTo(url) {
  701. uni.navigateTo({
  702. url,
  703. fail() {
  704. uni.switchTab({
  705. url
  706. })
  707. }
  708. })
  709. },
  710. userinfo() {
  711. getUserInfo({}).then(({
  712. data
  713. }) => {
  714. this.now_money = data.now_money;
  715. if (data.store_id > 0) {
  716. this.couldTj = true
  717. this.is_tj = true
  718. }
  719. this.setUserInfo(data)
  720. if (!data.pxz_user_id) {
  721. this.contractCreate()
  722. }
  723. });
  724. },
  725. choosTc(index, item) {
  726. this.selectTcIndex = index
  727. this.selectTc = item
  728. if (this.isdk) {
  729. this.ktdk()
  730. }
  731. },
  732. getRents() {
  733. let that = this
  734. getRents({
  735. store_id: that.is_tj ? that.userinfo.store_id : that.selctStore.id
  736. }).then(res => {
  737. that.tcList = res.data.rent
  738. that.selectTc = that.tcList[0]
  739. })
  740. },
  741. paySuccessTo() {
  742. uni.hideLoading();
  743. this.loading = false
  744. // uni.redirectTo({
  745. // url: '/pages/user_home/money/paySuccess?orderid=' + this.orderId,
  746. // });
  747. uni.redirectTo({
  748. url: '/pages/user_home/myRent'
  749. })
  750. },
  751. toBuy() {
  752. let that = this
  753. if (!that.is_tj && that.selctStore.id == '') {
  754. return that.$api.msg('请选择门店')
  755. }
  756. // uni.showLoading({
  757. // title:'二维码生成中...'
  758. // })
  759. if (!this.isdk) {
  760. that.loading = true
  761. }
  762. rentCreate({
  763. store_id: that.is_tj ? that.userinfo.store_id : that.selctStore.id,
  764. rent_id: that.selectTc.id,
  765. // #ifdef H5
  766. from: 'weixin', //来源
  767. // #endif
  768. // #ifdef MP-WEIXIN
  769. from: 'routine', //来源
  770. // #endif
  771. // #ifdef APP-PLUS
  772. from: 'app', //来源
  773. // #endif
  774. pay_type: that.isdk ? 'pxz' : that.payType, //支付方式
  775. renew: that.renew,
  776. is_certificate: that.isdk ? 0 : (that.isqxdk ? 1 : 0)
  777. }).then(({
  778. data,
  779. status,
  780. msg
  781. }) => {
  782. if (that.isdk) {
  783. this.createSignFLow()
  784. } else {
  785. if (data.status == 'ORDER_EXIST') {
  786. uni.showModal({
  787. title: '提示',
  788. content: msg,
  789. showCancel: false
  790. });
  791. uni.hideLoading();
  792. that.loading = false;
  793. return;
  794. }
  795. // 保存订单号
  796. that.orderId = data.result.orderId;
  797. // 判断是否为卡券支付
  798. if (that.payType == 'yue') {
  799. console.log('卡券支付', status == 200 && data.status == 'SUCCESS');
  800. that.loading = false
  801. if (status == 200 && data.status == 'SUCCESS') {
  802. that.paySuccessTo();
  803. } else {
  804. that.$api.msg(msg);
  805. }
  806. } else {
  807. // 立即支付
  808. // obj.orderMoneyPay();
  809. if (data.status == 'SUCCESS' && that.payType == 'weixin') {
  810. that.paySuccessTo();
  811. } else {
  812. let da = data.result.jsConfig;
  813. let paydata = {
  814. nonceStr: da.nonceStr,
  815. package: da.package,
  816. signType: da.signType,
  817. paySign: da.paySign,
  818. success: function(res) {
  819. that.paySuccessTo();
  820. },
  821. fail: () => {
  822. that.loading = false;
  823. }
  824. };
  825. // #ifdef H5
  826. paydata.timestamp = da.timestamp;
  827. weixinObj.chooseWXPay(paydata);
  828. // #endif
  829. // #ifdef MP-WEIXIN
  830. paydata.timeStamp = da.timestamp;
  831. wx.requestPayment(paydata);
  832. // #endif
  833. }
  834. }
  835. }
  836. // that.val = data.result.link
  837. // uni.hideLoading()
  838. // that.$refs.mypopup.open()
  839. })
  840. },
  841. orderMoneyPay() {
  842. let obj = this;
  843. orderPay({
  844. uni: obj.orderId,
  845. // #ifdef H5
  846. from: 'weixin', //来源
  847. // #endif
  848. // #ifdef MP-WEIXIN
  849. from: 'routine', //来源
  850. // #endif
  851. // #ifdef APP-PLUS
  852. from: 'app', //来源
  853. // #endif
  854. paytype: obj.payType //支付类型 weixin-微信 yue-卡券
  855. })
  856. .then(e => {
  857. // 判断是否微信小程序支付
  858. if (obj.payType == 'weixin') {
  859. // #ifdef H5 || MP
  860. let da = e.data.result.jsConfig;
  861. let data = {
  862. nonceStr: da.nonceStr,
  863. package: da.package,
  864. signType: da.signType,
  865. paySign: da.paySign,
  866. success: function(res) {
  867. obj.paySuccessTo();
  868. },
  869. fail: () => {
  870. uni.navigateTo({
  871. url: '/pages/order/order?state=0'
  872. });
  873. }
  874. };
  875. // #endif
  876. // #ifdef H5
  877. data.timestamp = da.timestamp;
  878. weixinObj.chooseWXPay(data);
  879. // #endif
  880. // #ifdef MP-WEIXIN
  881. data.timeStamp = da.timestamp;
  882. wx.requestPayment(data);
  883. // #endif
  884. // #ifdef APP
  885. console.log(e.data.result.jsConfig, '返回数值');
  886. uni.requestPayment({
  887. provider: 'wxpay',
  888. orderInfo: e.data.result.jsConfig,
  889. success(e) {
  890. obj.paySuccessTo();
  891. },
  892. fail: (e) => {
  893. console.log(e, '支付失败');
  894. uni.navigateTo({
  895. url: '/pages/order/order?state=0'
  896. });
  897. }
  898. })
  899. // #endif
  900. }
  901. // #ifdef APP
  902. if (obj.payType == 'ali') {
  903. uni.requestPayment({
  904. provider: 'alipay',
  905. orderInfo: e.data.result.jsConfig,
  906. success(e) {
  907. obj.paySuccessTo();
  908. },
  909. fail: (e) => {
  910. console.log(e, '支付失败');
  911. uni.navigateTo({
  912. url: '/pages/order/order?state=0'
  913. });
  914. }
  915. })
  916. }
  917. // #endif
  918. uni.hideLoading();
  919. obj.payLoding = false;
  920. })
  921. .catch(e => {
  922. // 支付完成
  923. uni.hideLoading();
  924. obj.payLoding = false;
  925. console.log(e);
  926. });
  927. },
  928. }
  929. }
  930. </script>
  931. <style lang="scss" scoped>
  932. .content {
  933. padding-top: 1rpx;
  934. }
  935. .dy-wrap,
  936. .tc-wrap {
  937. width: 702rpx;
  938. background: #FFFFFF;
  939. border-radius: 15rpx;
  940. // padding: 25rpx 25rpx 45rpx;
  941. margin: 20rpx auto;
  942. }
  943. .contet-list {
  944. flex-wrap: wrap;
  945. justify-content: space-between;
  946. padding: 0 25rpx 45rpx;
  947. height: 275rpx;
  948. overflow: hidden;
  949. .tc {
  950. width: 315rpx;
  951. height: 212rpx;
  952. background: #FFFFFF;
  953. border: 2px solid #E9E9E9;
  954. border-radius: 10rpx;
  955. margin-bottom: 20rpx;
  956. flex-direction: column;
  957. justify-content: center;
  958. // align-items: center;
  959. .tc-time {
  960. font-size: 28rpx;
  961. font-weight: bold;
  962. color: #00001A;
  963. display: flex;
  964. align-items: center;
  965. image {
  966. height: 34rpx;
  967. margin-right: 10rpx;
  968. }
  969. }
  970. .tc-price {
  971. font-size: 55rpx;
  972. font-weight: bold;
  973. color: #52C696;
  974. padding: 4rpx 0;
  975. &::before {
  976. content: '¥';
  977. font-size: 20rpx;
  978. }
  979. text {
  980. font-size: 22rpx;
  981. font-weight: 500;
  982. text-decoration: line-through;
  983. color: #999999;
  984. }
  985. .tc-time-t {
  986. font-size: 28rpx;
  987. font-weight: bold;
  988. color: #00001A;
  989. text-decoration: none;
  990. }
  991. }
  992. .tc-time-price {
  993. font-size: 22rpx;
  994. font-weight: 500;
  995. color: #999999;
  996. text {
  997. font-weight: bold;
  998. }
  999. }
  1000. }
  1001. .dy {
  1002. height: 187rpx;
  1003. }
  1004. .action {
  1005. background: #F3FFFB;
  1006. border: 2px solid #5FCCA7;
  1007. }
  1008. }
  1009. .top-wrap {
  1010. justify-content: space-between;
  1011. padding: 0 25rpx;
  1012. font-size: 32rpx;
  1013. font-weight: bold;
  1014. color: #00001A;
  1015. height: 85rpx;
  1016. .top-left {}
  1017. .top-right {
  1018. text {
  1019. font-size: 25rpx;
  1020. font-weight: 500;
  1021. color: #999999;
  1022. }
  1023. image {
  1024. height: 22rpx;
  1025. margin-left: 10rpx;
  1026. }
  1027. }
  1028. }
  1029. .sysm {
  1030. padding: 34rpx;
  1031. font-size: 22rpx;
  1032. font-weight: 500;
  1033. color: #666666;
  1034. }
  1035. .ts {
  1036. height: 200rpx;
  1037. }
  1038. .btm-btn {
  1039. width: 750rpx;
  1040. height: 100rpx;
  1041. position: fixed;
  1042. bottom: 0;
  1043. background-color: #fff;
  1044. z-index: 999;
  1045. .pay-price {
  1046. padding-left: 33rpx;
  1047. flex-grow: 1;
  1048. font-size: 32rpx;
  1049. font-weight: 500;
  1050. color: #333333;
  1051. text {
  1052. font-size: 48rpx;
  1053. font-weight: 500;
  1054. color: #FF6B2E;
  1055. &::before {
  1056. content: '¥';
  1057. font-size: 28rpx;
  1058. }
  1059. }
  1060. }
  1061. .pay-btn {
  1062. flex-shrink: 0;
  1063. width: 287rpx;
  1064. height: 98rpx;
  1065. background: linear-gradient(-38deg, #6CDBC3, #6DD6B8);
  1066. line-height: 100rpx;
  1067. text-align: center;
  1068. font-size: 34rpx;
  1069. font-weight: 500;
  1070. color: #FFFFFF;
  1071. }
  1072. }
  1073. .yt-list {
  1074. background: #fff;
  1075. margin: 0 $page-row-spacing;
  1076. margin-top: 30rpx;
  1077. border-radius: 20rpx;
  1078. }
  1079. .yt-list-cell {
  1080. display: flex;
  1081. align-items: center;
  1082. justify-content: space-between;
  1083. padding: 10rpx 30rpx 10rpx 40rpx;
  1084. line-height: 70rpx;
  1085. position: relative;
  1086. .checked,
  1087. .noChecked {
  1088. width: 36rpx;
  1089. height: 36rpx;
  1090. }
  1091. .noChecked {
  1092. border: 1px solid $font-color-light;
  1093. border-radius: 100rpx;
  1094. }
  1095. &.cell-hover {
  1096. background: #fafafa;
  1097. }
  1098. &.b-b:after {
  1099. left: 30rpx;
  1100. }
  1101. .cell-icon {
  1102. height: 32rpx;
  1103. width: 32rpx;
  1104. font-size: 22rpx;
  1105. color: #fff;
  1106. text-align: center;
  1107. line-height: 32rpx;
  1108. background: #f85e52;
  1109. border-radius: 4rpx;
  1110. margin-right: 12rpx;
  1111. &.hb {
  1112. background: #ffaa0e;
  1113. }
  1114. &.lpk {
  1115. background: #3ab54a;
  1116. }
  1117. }
  1118. .cell-more {
  1119. align-self: center;
  1120. font-size: 24rpx;
  1121. color: $font-color-light;
  1122. margin-left: 8rpx;
  1123. margin-right: -10rpx;
  1124. }
  1125. .cell-tit {
  1126. font-size: 26rpx;
  1127. color: $font-color-light;
  1128. margin-right: 10rpx;
  1129. .orderIcon {
  1130. width: 48rpx;
  1131. }
  1132. }
  1133. .cell-tip {
  1134. font-size: 26rpx;
  1135. color: $font-color-dark;
  1136. &.disabled {
  1137. color: $font-color-light;
  1138. }
  1139. &.active {
  1140. color: $base-color;
  1141. }
  1142. &.red {
  1143. color: $base-color;
  1144. }
  1145. }
  1146. &.desc-cell {
  1147. .cell-tit {
  1148. max-width: 90rpx;
  1149. }
  1150. }
  1151. .desc {
  1152. text-align: right;
  1153. font-size: $font-base;
  1154. color: $font-color-light;
  1155. }
  1156. }
  1157. .store-wrap-empty {
  1158. text-align: center;
  1159. height: 100rpx;
  1160. }
  1161. .store-wrap {
  1162. background-color: #FFFFFF;
  1163. margin-bottom: 30rpx;
  1164. padding: 30rpx;
  1165. border-radius: 20rpx;
  1166. .list,
  1167. .km {
  1168. color: $font-color-light;
  1169. font-size: $font-sm;
  1170. }
  1171. .logo {
  1172. height: 200rpx;
  1173. width: 200rpx;
  1174. border-radius: 20rpx;
  1175. }
  1176. .title {
  1177. font-size: 36rpx;
  1178. color: $font-color-dark;
  1179. }
  1180. .iconR {
  1181. height: 24rpx;
  1182. }
  1183. .iconA {
  1184. width: 24rpx;
  1185. height: 24rpx;
  1186. }
  1187. .addressBox {
  1188. font-size: 24rpx;
  1189. color: $font-color-light;
  1190. justify-content: flex-start;
  1191. padding: 10rpx 0;
  1192. }
  1193. .yysj {
  1194. display: inline-block;
  1195. // width: 239rpx;
  1196. padding: 0 10rpx;
  1197. height: 32rpx;
  1198. background: #ddf8f1;
  1199. border-radius: 16rpx 16rpx 16rpx 0rpx;
  1200. font-size: 20rpx;
  1201. font-weight: bold;
  1202. color: #5FCCA7;
  1203. text-align: center;
  1204. line-height: 32rpx;
  1205. margin-top: 10rpx;
  1206. }
  1207. }
  1208. .zfz {
  1209. background: #999 !important;
  1210. }
  1211. .top-tit {
  1212. width: 750rpx;
  1213. background-color: #fff;
  1214. padding: 10rpx;
  1215. .tit {
  1216. font-size: 28rpx;
  1217. background-color: rgba(108, 217, 192, 0.4);
  1218. border-radius: 5rpx;
  1219. padding: 10rpx;
  1220. }
  1221. }
  1222. .myj-wrap {
  1223. width: 702rpx;
  1224. margin: auto;
  1225. }
  1226. .qrimg {
  1227. position: absolute;
  1228. left: -9999rpx;
  1229. top: -9999rpx;
  1230. }
  1231. .ewm-wrap {
  1232. border-radius: 20rpx;
  1233. overflow: hidden;
  1234. }
  1235. .bcewm {
  1236. background-color: $base-color;
  1237. color: #fff;
  1238. text-align: center;
  1239. height: 80rpx;
  1240. width: 702rpx;
  1241. border-radius: 40rpx;
  1242. margin: auto;
  1243. margin-top: 30rpx;
  1244. display: flex;
  1245. justify-content: center;
  1246. align-items: center;
  1247. // margin-left: 75rpx;
  1248. }
  1249. </style>