rent.vue 30 KB

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