rent.vue 30 KB

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