rent.vue 33 KB

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