lhl 1 year ago
parent
commit
19b73db7dd
1 changed files with 125 additions and 44 deletions
  1. 125 44
      pages/goods/three/index.vue

+ 125 - 44
pages/goods/three/index.vue

@@ -16,7 +16,7 @@
 				充值
 			</view>
 		</view>
-		<template v-if="ctype == 2">
+		<template v-if="ctype == 2 || ctype == 3">
 			<picker @change="bindPickerChange" :value="chooseId" :range="provinces" range-key="label">
 				<view class="search-box sf-wrap flex">
 					<view class="">
@@ -30,30 +30,43 @@
 				<view class="">
 					姓名
 				</view>
-				<input type="text" placeholder="请输入户主姓名" class="name-inp" v-model="userName"/>
+				<input type="text" placeholder="请输入户主姓名" class="name-inp" v-model="userName" />
 			</view>
 			<!-- 户号 -->
 			<view class="search-box sf-wrap flex">
 				<view class="">
 					户号
 				</view>
-				<input type="text" placeholder="请输入户号" class="name-inp" v-model="rechargeno"/>
+				<input type="text" placeholder="请输入户号" class="name-inp" v-model="rechargeno" />
+			</view>
+			<view class="search-box sf-wrap flex" v-if="ctype == 3">
+				<view class="">
+					金额
+				</view>
+				<input type="text" placeholder="请输入充值金额" class="name-inp" v-model="sbjzt" />
+			</view>
+			<!-- jfjg -->
+			<view class="search-box sf-wrap flex" v-if="ctype == 3">
+				<view class="">
+					缴费机构
+				</view>
+				<input type="text" placeholder="请输入缴费机构" class="name-inp" v-model="jfjg" />
 			</view>
 		</template>
-		
-		<view class='search-box sf-wrap flex'>
+
+		<view class='search-box sf-wrap flex' v-if="userInfo.integral > 0">
 			<view>积分抵扣</view>
 			<view class='discount acea-row row-middle'>
 				<view style="margin-right: 10rpx;"> 当前积分
 					<text class='num font-color'>{{userInfo.integral || 0}}</text>
 				</view>
 				<view class="cb" @click="changeUseIntegral">
-					<view v-show="useIntegral" class="cb-in" >
+					<view v-show="useIntegral" class="cb-in">
 					</view>
 				</view>
 			</view>
 		</view>
-		<view class="item-wrap" v-for="item in info">
+		<view v-if="ctype != 3" class="item-wrap" v-for="item in info">
 			<view class="tit">
 				{{item.cname}}
 			</view>
@@ -78,7 +91,7 @@
 			</template>
 
 		</view>
-		<view class="item-wrap" v-if="content && ctype != 2 && info.length > 0">
+		<view class="item-wrap" v-if="content && ctype == 1 && info.length > 0">
 			<view class="tit">
 				注意事项
 			</view>
@@ -112,7 +125,7 @@
 				</view>
 			</view>
 		</uni-popup>
-		<payment  :payMode="cartArr" :pay_close="pay_close" :isCall="true" :totalPrice="totalPrice"
+		<payment :payMode="cartArr" :pay_close="pay_close" :isCall="true" :totalPrice="totalPrice"
 			@changePayType="changePayType" @onChangeFun="onChangeFun"></payment>
 	</view>
 
@@ -138,6 +151,8 @@
 		},
 		data() {
 			return {
+				jfjg: '',
+				sbjzt: 0,
 				rechargeno: '',
 				toPay: false,
 				paying: false,
@@ -152,6 +167,10 @@
 					{
 						name: '电费充值',
 						ctype: 2
+					},
+					{
+						name: '水费充值',
+						ctype: 3
 					}
 				],
 				useIntegral: false,
@@ -161,7 +180,7 @@
 				choose: {
 					goods_id: 0
 				},
-				payType:1,
+				payType: 1,
 				payName: 'weixin',
 				userInfo: {},
 				ctype: 0,
@@ -200,6 +219,14 @@
 		},
 		onReady() {
 
+		},
+		watch: {
+			sbjzt(n, o) {
+				// if(this.choos)
+				if (n > this.userInfo.integral) {
+					this.useIntegral = false
+				}
+			}
 		},
 		methods: {
 			changePayType(type) {
@@ -219,23 +246,46 @@
 			getYjList(tip, ctype) {
 				this.ctype = ctype
 				this.info = []
+				this.choose = {}
 				this.getCzList()
 			},
 			changeUseIntegral: function() {
-				this.useIntegral = !this.useIntegral;
-				if(this.choose.goods_id) {
-					this.computedPrice();
+				if (this.ctype == 3) {
+					if (!this.sbjzt) {
+						return this.$util.Tips({
+							title: '请输入充值金额'
+						});
+					}
+					if (this.sbjzt > this.userInfo.integral) {
+						this.useIntegral = false
+					} else {
+						this.useIntegral = !this.useIntegral
+						this.computedPrice();
+					}
+				} else {
+					if (this.choose.price > this.userInfo.integral) {
+						this.useIntegral = false
+					} else {
+						this.useIntegral = !this.useIntegral
+					}
+					if (this.choose.price) {
+						this.computedPrice();
+					}
 				}
+
 			},
 			// 计算价格
-			computedPrice() {
+			computedPrice(tit) {
 				computedCz({
-					integral: this.useIntegral ? 1: 0,
-					price: this.choose.price,
+					integral: this.useIntegral ? 1 : 0,
+					price: this.ctype == 3 ? this.sbjzt : this.choose.price,
 					uid: this.userInfo.uid
 				}).then(res => {
 					this.priceInfo = res.data
 					this.totalPrice = res.data.payPrice
+					if(tit == 'open') {
+						this.pay_close = true
+					}
 				})
 			},
 			getUserInfo: function() {
@@ -259,6 +309,7 @@
 				}
 			},
 			goCz() {
+			
 				if (!this.phone) {
 					return this.$util.Tips({
 						title: '请输入手机号'
@@ -270,12 +321,13 @@
 						title: '请输入正确的手机号'
 					});
 				}
-				if (!this.choose.goods_id) {
-					return this.$util.Tips({
-						title: '请选择需要充值的套餐'
-					});
-				}
+				
 				if (this.ctype == 2) {
+					if (!this.choose.goods_id) {
+						return this.$util.Tips({
+							title: '请选择需要充值的套餐'
+						});
+					}
 					if (!this.province) {
 						return this.$util.Tips({
 							title: '请选择省份'
@@ -286,7 +338,23 @@
 							title: '请输入姓名'
 						});
 					}
+				} else if (this.ctype == 3) {
+					if(!this.sbjzt) {
+						return this.$util.Tips({
+							title: '请输入充值金额'
+						});
+					}
+					if(!this.jfjg) {
+						return this.$util.Tips({
+							title: '请输入缴费机构'
+						});
+					}
 				} else {
+					if (!this.choose.goods_id) {
+						return this.$util.Tips({
+							title: '请选择需要充值的套餐'
+						});
+					}
 					// 校验手机
 					let phoneType = this.getMobileOperator(this.phone)
 					if (this.choose.goods_name.indexOf(phoneType) == -1) {
@@ -298,9 +366,12 @@
 						})
 					}
 				}
-
+				if(this.ctype == 3) {
+					this.computedPrice('open')
+				}else {
+					this.pay_close = true
+				}
 				// this.$refs.popup.open()
-				this.pay_close = true
 			},
 			getMobileOperator(phoneNumber) {
 				// 移动号段
@@ -331,32 +402,33 @@
 				// 
 				console.log(e)
 				let that = this
-				if(e.action == 'payClose') {
+				if (e.action == 'payClose') {
 					this.pay_close = false
 					return
-				}else {
-					if(e.value == 'yue') {
-						if(that.priceInfo.payPrice*1 > that.userInfo.now_money) {
+				} else {
+					if (e.value == 'yue') {
+						if (that.priceInfo.payPrice * 1 > that.userInfo.now_money) {
 							return this.$util.Tips({
 								title: '当前余额不足'
 							});
 						}
 					}
-					
+
 					let qdata = {
-						goods_id: this.choose.goods_id,
+						goods_id: this.ctype== 3?"": this.choose.goods_id,
 						rechargeno: this.phone,
 						province: this.province,
 						pay_type: e.value,
+						num: this.ctype == 3? this.sbjzt: this.choose.num,
 						pay_price: this.priceInfo.payPrice,
 						store_id: 0,
 						user_phone: this.phone,
 						real_name: this.userName,
 						deduction_price: this.priceInfo.deductionPrice,
 						deduction_integral: this.priceInfo.usedIntegral,
-						cid: this.choose.cid,
-						goods_name: this.choose.goods_name,
-						type: this.ctype,
+						cid:this.ctype==3?"": this.choose.cid,
+						goods_name:this.ctype==3?this.jfjg: this.choose.goods_name,
+						type: this.ctype == 0? 1: this.ctype,
 						// #ifdef MP
 						'from': 'routine',
 						// #endif
@@ -364,24 +436,24 @@
 						'from': this.$wechat.isWeixin() ? 'weixin' : 'weixinh5',
 						// #endif
 					}
-					if(this.ctype == 2) {
+					if (this.ctype == 2) {
 						qdata.rechargeno = this.rechargeno
 					}
-					if(that.paying) {
+					if (that.paying) {
 						return
 					}
 					that.paying = true
 					createCz(qdata).then(res => {
-						setTimeout(()=> {
+						setTimeout(() => {
 							that.paying = false
 							that.getUserInfo()
-						},2500)
+						}, 2500)
 						let status = res.data.status,
 							// orderId = res.data.result.order_id,
 							jsConfig = res.data.result.jsConfig
-							// goPages = '/pages/goods/order_pay_status/index?order_id=' + orderId + '&msg=' + res
-							// .msg +
-							// '&type=6' + '&totalPrice=' + this.totalPrice + '&pay_type=' + e.value
+						// goPages = '/pages/goods/order_pay_status/index?order_id=' + orderId + '&msg=' + res
+						// .msg +
+						// '&type=6' + '&totalPrice=' + this.totalPrice + '&pay_type=' + e.value
 						switch (status) {
 							case 'ORDER_EXIST':
 							case 'EXTEND_ORDER':
@@ -485,11 +557,11 @@
 									location.href = res.data.result.jsConfig.mweb_url;
 								}, 2000);
 								break;
-						
+
 							case 'ALIPAY_PAY':
 								//#ifdef H5
 								if (this.from === 'weixin') {
-									
+
 								} else {
 									uni.hideLoading();
 									that.formContent = res.data.result.jsConfig;
@@ -519,7 +591,7 @@
 												url: url
 											})
 										}, 2000)
-						
+
 									},
 									fail: (e) => {
 										let url = '/pages/goods/order_pay_status/index?order_id=' +
@@ -546,17 +618,24 @@
 								// #endif
 								break;
 						}
-					
+
+					}).catch(err => {
+						that.paying = false
 					})
 				}
-				
+
 			},
 			chooseGood(item) {
 				this.choose = item
+				if (this.choose.price > this.userInfo.integral) {
+					this.useIntegral = false
+				}
+				// if(this.userInfo)
 				this.computedPrice()
 			},
 			getCzList() {
 				let that = this
+				if (this.ctype == 3) return
 				uni.showLoading({
 					title: '加载中...'
 				})
@@ -833,6 +912,7 @@
 		display: flex;
 		justify-content: center;
 		align-items: center;
+
 		.cb-in {
 			width: 20rpx;
 			height: 20rpx;
@@ -840,6 +920,7 @@
 			background-color: #1890FF;
 		}
 	}
+
 	.name-inp {
 		// width: ;
 		flex-grow: 1;