lhl 2 lat temu
rodzic
commit
474a0485d0
3 zmienionych plików z 267 dodań i 126 usunięć
  1. 26 0
      api/index.js
  2. 240 126
      pages/shop/rent.vue
  3. 1 0
      pages/shop/shopTab.vue

+ 26 - 0
api/index.js

@@ -108,4 +108,30 @@ export function idcards(data) {
 		method: 'post',
 		data
 	});
+}
+
+//创建免押
+export function rentFree(data) {
+	return request({
+		url: '/api/rent/free',
+		method: 'post',
+		data
+	});
+}
+
+//
+export function contractCreate(data) {
+	return request({
+		url: '/api/rent/contract_create',
+		method: 'post',
+		data
+	});
+}
+
+export function createSignFLow(data) {
+	return request({
+		url: '/api/rent/createSignFLow',
+		method: 'post',
+		data
+	});
 }

+ 240 - 126
pages/shop/rent.vue

@@ -4,6 +4,13 @@
 			<tki-qrcode :cid="cid" ref="qrcode" :val="val" :size="size" :unit="unit" :background="background"
 				:foreground="foreground" :pdground="pdground" :icon="icon" :iconSize="iconSize" :lv="lv" :onval="onval"
 				:showLoading="showLoading" :loadMake="loadMake" :usingComponents="usingComponents" @result="qrR" />
+			<tki-qrcode :cid="ciddk" ref="qrcodet" :val="valdk" :size="size" :unit="unit" :background="background"
+				:foreground="foreground" :pdground="pdground" :icon="icon" :iconSize="iconSize" :lv="lv" :onval="onval"
+				:showLoading="showLoading" :loadMake="loadMake" :usingComponents="usingComponents" @result="qrRdk" />
+			<canvas :style="{ width:cw + 'rpx', height: ch+'rpx',}" canvas-id="myCanvas" id="myCanvas"
+				class="hb"></canvas>
+			<canvas :style="{ width:cw + 'rpx', height: ch+'rpx',}" canvas-id="myCanvass" id="myCanvass"
+				class="hb"></canvas>
 		</view>
 
 		<view class="top-tit">
@@ -66,8 +73,6 @@
 					<view class="yysj">
 						营业时间:{{selctStore.day_time}}
 					</view>
-
-
 				</view>
 			</view>
 			<view class="store-wrap-empty" v-else>
@@ -97,7 +102,7 @@
 				</view>
 			</view>
 		</view>
-		<view class="dy-wrap" >
+		<view class="dy-wrap" v-if="selectTc.id && userInfo.battery_deposit  != 1">
 			<view class="top-wrap flex">
 				<view class="top-left">
 					押金服务
@@ -108,28 +113,85 @@
 				</view> -->
 			</view>
 			<view class="contet-list flex">
-				<view class="tc flex dy">
+				<view class="tc flex dy " :class="{'action': !ismy}" @click="qxmy()">
 					<view class="tc-time">
-						<image src="../../static/icon/orderWx.png" mode="heightFix"></image>微信信用免押金
+						支付押金
 					</view>
-					<view class="tc-time-price">
+					<!-- <view class="tc-time-price">
+					元/天
+					</view> -->
+					<view class="tc-price">
+						{{selectTc.deposit}}
+					</view>
+				</view>
+				<view class="tc flex dy" :class="{'action': ismy}" @click="ljmy()">
+					<view class="tc-time">
+						<image src="../../static/icon/orderAli.png" mode="heightFix"></image>信用免押金
+					</view>
+					<!-- <view class="tc-time-price">
 					微信信用≥550分
 					</view>
 					<view class="tc-price">
 						77<text>¥88</text>
-					</view>
+					</view> -->
 				</view>
-				<view class="tc flex dy action">
+
+			</view>
+		</view>
+		<view class="myj-wrap" v-if="showMyEwm">
+			<view class="ewm-wrap">
+				<!-- <canvas :style="{ width:cw + 'rpx', height: ch+'rpx',}" canvas-id="myCanvas" id="myCanvas"
+					class="hb"></canvas> -->
+				<image :src="shareQrcodeUrl" mode="" :style="{ width:cw + 'rpx', height: ch+'rpx',}"></image>
+			</view>
+			<view class="bcewm" @click="saveShareQrcode">
+				保存二维码
+			</view>
+		</view>
+		<view class="dy-wrap">
+			<view class="top-wrap flex">
+				<view class="top-left">
+					代扣服务
+				</view>
+				<!-- <view class="top-right">
+					<text>押金规则</text>
+					<image src="../../static/icon/next1.png" mode="heightFix"></image>
+				</view> -->
+			</view>
+			<view class="contet-list flex">
+				<view class="tc flex dy " :class="{'action': !isdk}" @click="qxdk()">
 					<view class="tc-time">
-						支付押金
+						不使用代扣
 					</view>
 					<!-- <view class="tc-time-price">
 					元/天
 					</view> -->
-					<view class="tc-price">
+					<!-- <view class="tc-price">
 						{{selectTc.deposit}}
+					</view> -->
+				</view>
+				<view class="tc flex dy" :class="{'action': isdk}" @click="ktdk()">
+					<view class="tc-time">
+						<image src="../../static/icon/orderAli.png" mode="heightFix"></image>开通代扣
+					</view>
+					<!-- <view class="tc-time-price">
+					微信信用≥550分
 					</view>
+					<view class="tc-price">
+						77<text>¥88</text>
+					</view> -->
 				</view>
+
+			</view>
+		</view>
+		<view class="myj-wrap" v-if="showDkEwm">
+			<view class="ewm-wrap">
+				<!-- 	<canvas :style="{ width:cw + 'rpx', height: ch+'rpx',}" canvas-id="myCanvass" id="myCanvass"
+					class="hb"></canvas> -->
+				<image :src="dkQrcodeUrl" mode="" :style="{ width:cw + 'rpx', height: ch+'rpx',}"></image>
+			</view>
+			<view class="bcewm" @click="saveShareQrcode">
+				保存二维码
 			</view>
 		</view>
 		<view class="dy-wrap">
@@ -142,7 +204,7 @@
 			</view>
 		</view>
 
-		<view class="yt-list">
+		<view class="yt-list" v-if="!isdk">
 			<view class="yt-list-cell b-b" @click="payType='weixin'">
 				<view class="cell-tit flex">
 					<image class="orderIcon" src="../../static/icon/orderWx.png" mode="widthFix"></image>
@@ -173,50 +235,21 @@
 				<view v-else class="noChecked"></view>
 			</view>
 		</view>
-		<view class="ts">
+		<view class="ts" v-if="!isdk">
 
 		</view>
-		<!-- <view class="btm-btn flex">
-			<view class="pay-price">
-				总计费用:<text>{{(selectTc.price*1) || ''}}</text>
+		<view class="btm-btn flex" v-if="!isdk">
+			
+			<view class="pay-price" v-if="!ismy && userInfo.battery_deposit  != 1">
+				总计费用:<text>{{(selectTc.price*1 + selectTc.deposit*1).toFixed(2) || ''}}</text>
 			</view>
-			<view class="pay-btn" @click="toBuy" :class="{'zfz': loading}" v-if="">
-				{{loading?'支付中':''}}
-			</view>
-		</view> -->
-		<view class="btm-btn flex" >
-			<view class="pay-price">
-				押金:<text>{{(selectTc.deposit*1) || ''}}</text>
+			<view class="pay-price" v-else>
+				总计费用:<text>{{(selectTc.price*1).toFixed(2) || ''}}</text>
 			</view>
 			<view class="pay-btn" @click="toBuy" :class="{'zfz': loading}">
-				{{loading?'支付中':'支付押金'}}
-			</view>
-		</view>
-<!-- 		<view class="btm-btn flex" v-if="!showbtn">
-			<view class="pay-price">
-				总计费用:<text>{{(selectTc.price*1) || ''}}</text>
-			</view>
-			<view class="pay-btn" @click="getEwm">
-				获取免押二维码
+				{{loading?'支付中':'立即支付'}}
 			</view>
 		</view>
-		<view class="btm-btn flex" v-else
-			style="text-align: center;color: #fff;background-color: #6cd9c0;justify-content: center;"
-			@click="saveShareQrcode">
-			保存二维码
-		</view> -->
-		<uni-popup ref="mypopup" type="center" @change="mychange">
-			<view class="myj-wrap">
-				<view class="ewm-wrap">
-					<canvas :style="{ width:cw + 'rpx', height: ch+'rpx',}" canvas-id="myCanvas" id="myCanvas"
-						class="hb"></canvas>
-				</view>
-				<view class="bcewm" @click="saveShareQrcode">
-					保存二维码
-				</view>
-			</view>
-
-		</uni-popup>
 	</view>
 </template>
 
@@ -245,25 +278,35 @@
 	import {
 		getRents,
 		rentCreate,
-		details
+		details,
+		rentFree,
+		contractCreate,
+		createSignFLow
 	} from '@/api/index.js'
 	export default {
 		data() {
 			return {
+				
+				isdk: false, //是否代扣
+				ismy: false, //是否免押
 				showbtn: false,
 				ewmw: 300, //二维码相对宽度
-				cw: 600, //画布相对宽度
+				cw: 702, //画布相对宽度
 				ch: 600, //画布相对高度
 				shareQrcodeUrl: '', //画布生成的地址
+				dkQrcodeUrl: '',
 				canvasW: '', //画布宽度
 				canvasH: '', //画布高度
 				ewmImg: '', //二维码图片信息
 				erweimasrc: '', //生成的二维码图片
+				dkerweima: '',
 				cid: 'tki-qrcode-canvas', //canvasId,页面存在多个二维码组件时需设置不同的ID
+				ciddk: 'dk-qrcode-canvas', //canvasId,页面存在多个二维码组件时需设置不同的ID
 				size: 300, //生成的二维码大小
 				unit: 'upx', //大小单位尺寸
 				// show: true,//默认使用组件中的image标签显示二维码
 				val: '', //要生成的内容
+				valdk: '',
 				background: '#ffffff', //二维码背景色
 				foreground: '#333333', //二维码前景色
 				pdground: '#333333', //二维码角标色
@@ -291,7 +334,15 @@
 			}
 		},
 		computed: {
-			...mapState('user', ['address', 'userInfo'])
+			...mapState('user', ['address', 'userInfo']),
+			//展示免押二维码
+			showMyEwm() {
+				return  this.ismy && this.shareQrcodeUrl
+			},
+			//展示代扣二维码
+			showDkEwm() {
+				return  this.isdk && this.dkQrcodeUrl
+			},
 		},
 		onLoad() {
 			this.getRents()
@@ -311,6 +362,58 @@
 		},
 		methods: {
 			...mapMutations('user', ['setUserInfo', 'setAddress']),
+			//取消免押
+			qxdk() {
+				this.isdk = false
+			},
+			qxmy() {
+				this.ismy = false
+			},
+			ktdk() {
+				let that = this
+				if (!that.is_tj && that.selctStore.id == '') {
+					return that.$api.msg('请选择门店')
+				}
+				this.isdk = true
+				// this.contractCreate()
+				this.toBuy()
+			},
+			contractCreate() {
+				contractCreate().then(res => {
+					// console.log(res);
+				})
+			},
+			createSignFLow() {
+				uni.showLoading({
+					title: '二维码生成中...'
+				})
+				createSignFLow().then(res => {
+					this.valdk = res.data.result.link
+				})
+			},
+			// 选择免押
+			ljmy() {
+				let that = this
+				if (!that.is_tj && that.selctStore.id == '') {
+					return that.$api.msg('请选择门店')
+				}
+				this.ismy = true
+				this.rentFree()
+			},
+			rentFree() {
+				let that = this
+				if (!that.is_tj && that.selctStore.id == '') {
+					return that.$api.msg('请选择门店')
+				}
+				uni.showLoading({
+					title: '二维码生成中...'
+				})
+				rentFree({
+					rent_id: that.selectTc.id
+				}).then(res => {
+					that.val = res.data.result.link
+				})
+			},
 			//保存图片
 			saveShareQrcode() {
 				console.log(this.shareQrcodeUrl)
@@ -390,12 +493,12 @@
 					});
 				})
 			},
-			async createPoster() {
+			async createPoster(imgname, ewmimg, cavid, tit = '') {
 				let that = this
 				// 获取设备信息,主要获取宽度,赋值给canvasW 也就是宽度:100%
 				that.SystemInfo = await that.getSystemInfo();
 
-				that.ewmImg = await that.getImageInfo(that.erweimasrc);
+				that.ewmImg = await that.getImageInfo(ewmimg);
 				// this.canvasW = this.SystemInfo.windowWidth; // 画布宽度
 				that.ratio = that.SystemInfo.windowWidth / 750;
 				that.canvasW = that.cw * that.ratio;
@@ -405,44 +508,38 @@
 				// 如果主图,二维码图片,设备信息都获取成功,开始绘制海报,这里需要用setTimeout延时绘制,否则可能会出现图片不显示。
 				if (that.ewmImg.errMsg == 'getImageInfo:ok' && that.SystemInfo.errMsg == 'getSystemInfo:ok') {
 					console.log('二维码和屏幕信息加载完成')
-					// uni.showToast({
-					// 	icon: 'loading',
-					// 	mask: true,
-					// 	duration: 10000,
-					// 	title: '二维码生成中',
-					// });
 					setTimeout(() => {
-						var ctx = uni.createCanvasContext('myCanvas', that);
+						var ctx = uni.createCanvasContext(cavid, that);
 						// 填充背景色,白色
 						ctx.setFillStyle('#fff'); // 默认白色
 						ctx.fillRect(0, 0, this.canvasW, this.canvasH) // fillRect(x,y,宽度,高度)
 						// drawImage(图片路径,x,y,绘制图像的宽度,绘制图像的高度)
 						ctx.drawImage(this.ewmImg.path, (this.canvasW / 2 - this.ewmW / 2), 100 * that.ratio,
 							this.ewmW, this.ewmW) // drawImage(图片路径,x,y,绘制图像的宽度,绘制图像的高度,二维码的宽,高)
-
-
 						// 3、绘制商品标题,多余文字自动换行
 						ctx.setFontSize(16); // setFontSize() 设置字体字号
 						ctx.setFillStyle('#333'); // setFillStyle() 设置字体颜色
 						ctx.setTextAlign('center')
 						ctx.fillText('请使用支付宝扫描上方二维码', this.canvasW / 2, 200 * that.ratio + that.ewmW)
+						ctx.fillText(tit, this.canvasW / 2, 260 * that.ratio + that.ewmW)
 						ctx.draw(false, (ret) => { // draw方法 把以上内容画到 canvas 中。
 							that.fina = true
 							uni.canvasToTempFilePath({ // 保存canvas为图片
-								canvasId: 'myCanvas',
+								canvasId: cavid,
 								quality: 1,
 								fileType: 'jpg',
 								complete: function(res) {
 									// 在H5平台下,tempFilePath 为 base64, // 图片提示跨域 H5保存base64失败,APP端正常输出临时路径
 									console.log(res)
-									that.canvasShow = false
-									that.shareQrcodeUrl = res.tempFilePath
+									// that.canvasShow = false
+									that[imgname] = res.tempFilePath
 									that.$forceUpdate()
 									uni.hideLoading()
-									setTimeout(function() {
-										console.log(that.shareQrcodeUrl, that
-											.canvasShow)
-									}, 2000)
+									
+									// setTimeout(function() {
+									// 	console.log(that.shareQrcodeUrl, that
+									// 		.canvasShow)
+									// }, 2000)
 								},
 							})
 						});
@@ -453,8 +550,11 @@
 			},
 			qrR(res) {
 				this.erweimasrc = res
-				console.log(res, '二维码图片');
-				this.createPoster()
+				this.createPoster('shareQrcodeUrl', this.erweimasrc, 'myCanvas', '完成免押服务')
+			},
+			qrRdk(res) {
+				this.dkerweima = res
+				this.createPoster('dkQrcodeUrl', this.dkerweima, 'myCanvass', '完成代扣服务')
 			},
 			// 获取附近门店
 			storeList(source) {
@@ -559,6 +659,9 @@
 						this.is_tj = true
 					}
 					this.setUserInfo(data)
+					if (!data.pxz_user_id) {
+						this.contractCreate()
+					}
 				});
 			},
 			choosTc(index, item) {
@@ -566,7 +669,9 @@
 				this.selectTc = item
 			},
 			getRents() {
-				getRents().then(res => {
+				getRents({
+					store_id: this.selctStore.id
+				}).then(res => {
 					this.tcList = res.data.rent
 					this.selectTc = this.tcList[0]
 				})
@@ -586,10 +691,12 @@
 				if (!that.is_tj && that.selctStore.id == '') {
 					return that.$api.msg('请选择门店')
 				}
-				uni.showLoading({
-					title:'二维码生成中...'
-				})
-				that.loading = true
+				// uni.showLoading({
+				// 	title:'二维码生成中...'
+				// })
+				if(!this.isdk) {
+					that.loading = true
+				}
 				rentCreate({
 					store_id: that.is_tj ? that.userinfo.store_id : that.selctStore.id,
 					rent_id: that.selectTc.id,
@@ -602,63 +709,68 @@
 					// #ifdef APP-PLUS
 					from: 'app', //来源
 					// #endif
-					pay_type: that.payType //支付方式
+					pay_type: that.isdk ? 'pxz' : that.payType //支付方式
 				}).then(({
 					data,
 					status,
 					msg
 				}) => {
-					that.val = data.result.link
-					// uni.hideLoading()
-					that.$refs.mypopup.open()
-					/**
-					if (data.status == 'ORDER_EXIST') {
-						uni.showModal({
-							title: '提示',
-							content: msg,
-							showCancel: false
-						});
-						uni.hideLoading();
-						that.loading = false;
-						return;
-					}
-					// 保存订单号
-					that.orderId = data.result.orderId;
-					// 判断是否为卡券支付
-					if (that.payType == 'yue') {
-						console.log('卡券支付', status == 200 && data.status == 'SUCCESS');
-						that.loading = false
-						if (status == 200 && data.status == 'SUCCESS') {
-							that.paySuccessTo();
-						} else {
-							that.$api.msg(msg);
+					if (that.isdk) {
+						this.createSignFLow()
+					}else {
+						
+						if (data.status == 'ORDER_EXIST') {
+							uni.showModal({
+								title: '提示',
+								content: msg,
+								showCancel: false
+							});
+							uni.hideLoading();
+							that.loading = false;
+							return;
 						}
-					} else {
-						// 立即支付
-						// obj.orderMoneyPay();
-						let da = data.result.jsConfig;
-						let paydata = {
-							nonceStr: da.nonceStr,
-							package: da.package,
-							signType: da.signType,
-							paySign: da.paySign,
-							success: function(res) {
+						// 保存订单号
+						that.orderId = data.result.orderId;
+						// 判断是否为卡券支付
+						if (that.payType == 'yue') {
+							console.log('卡券支付', status == 200 && data.status == 'SUCCESS');
+							that.loading = false
+							if (status == 200 && data.status == 'SUCCESS') {
 								that.paySuccessTo();
-							},
-							fail: () => {
-								that.loading = false;
+							} else {
+								that.$api.msg(msg);
 							}
-						};
-						// #ifdef H5
-						paydata.timestamp = da.timestamp;
-						weixinObj.chooseWXPay(paydata);
-						// #endif
-						// #ifdef MP-WEIXIN
-						paydata.timeStamp = da.timestamp;
-						wx.requestPayment(paydata);
-						// #endif
+						} else {
+							// 立即支付
+							// obj.orderMoneyPay();
+							let da = data.result.jsConfig;
+							let paydata = {
+								nonceStr: da.nonceStr,
+								package: da.package,
+								signType: da.signType,
+								paySign: da.paySign,
+								success: function(res) {
+									that.paySuccessTo();
+								},
+								fail: () => {
+									that.loading = false;
+								}
+							};
+							// #ifdef H5
+							paydata.timestamp = da.timestamp;
+							weixinObj.chooseWXPay(paydata);
+							// #endif
+							// #ifdef MP-WEIXIN
+							paydata.timeStamp = da.timestamp;
+							wx.requestPayment(paydata);
+							// #endif
+						}
+						
 					}
-					**/
+					// that.val = data.result.link
+					// uni.hideLoading()
+					// that.$refs.mypopup.open()
+					
 				})
 			},
 			orderMoneyPay() {
@@ -1099,7 +1211,8 @@
 	}
 
 	.myj-wrap {
-		width: 600rpx;
+		width: 702rpx;
+		margin: auto;
 
 	}
 
@@ -1113,12 +1226,13 @@
 		border-radius: 20rpx;
 		overflow: hidden;
 	}
+
 	.bcewm {
 		background-color: $base-color;
 		color: #fff;
 		text-align: center;
 		height: 80rpx;
-		width: 450rpx;
+		width: 702rpx;
 		border-radius: 40rpx;
 		margin: auto;
 		margin-top: 30rpx;

+ 1 - 0
pages/shop/shopTab.vue

@@ -223,6 +223,7 @@
 				if(that.select == 1) {
 					let prepage = that.$api.prePage();
 					prepage.selctStore = item
+					prepage.getRents()
 					uni.navigateBack()
 				}
 			},