rent.vue 33 KB

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