소스 검색

重新获取openId

zhengkaixin 3 년 전
부모
커밋
bfd07e6974
3개의 변경된 파일62개의 추가작업 그리고 14개의 파일을 삭제
  1. 2 2
      manifest.json
  2. 58 10
      pages/user/finance/recharge.vue
  3. 2 2
      utils/mixin.js

+ 2 - 2
manifest.json

@@ -1,6 +1,6 @@
 {
-    "name" : "jp-charge",
-    "appid" : "__UNI__2D3A5D0",
+    "name" : "JP-ChargeTeam51",
+    "appid" : "__UNI__8C17748",
     "description" : "",
     "versionName" : "1.0.0",
     "versionCode" : "100",

+ 58 - 10
pages/user/finance/recharge.vue

@@ -5,16 +5,20 @@
 			<view class="title">选择充值金额</view>
 			<p>当前余额{{detail.balance}}</p>
 			<view class="rechargeMain">
-				<view class="recharge-item" :class="moneyActiveClass == item.id ? 'active' : ''"
-					v-for="(item,index) in moneyList" :key="item.id" @click="moneyClick(item,item.id)">
+				<view class="recharge-item" :class="otherNum&&moneyActiveClass == item.id ? 'active' : ''"
+					v-for="(item,index) in moneyList" :key="item.id" @click="moneyClick(item.id,item)">
 					{{item.rechargeAmount}}
 					<view class="amount">赠20元</view>
 					</view>
 				
 			</view>
 			<p>其他充值金额</p>
-			<view class="recharge-input">
-				<u-input v-model="value1" type="text" :border="true" />
+			<view 
+			
+			@click="moneyClick(-1)"
+			:class="!otherNum&&moneyActiveClass == -1? 'active' : ''"
+			class="recharge-input self-stop">
+				<u-input v-model="otherNum" @input="ckInput" type="text" :border="true" />
 			</view>
 			<view class="title">选择支付方式</view>
 			<view class="recharge-radio">
@@ -52,6 +56,7 @@
 	export default {
 		data() {
 			return {
+				selectItem:{},
 				userId: '',
 				detail: {},
 				moneyActiveClass: 1,
@@ -71,6 +76,7 @@
 				],
 				// u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
 				value2: '微信支付',
+				otherNum:"",
 				value1: '',
 				checked: true,
 			}
@@ -83,6 +89,31 @@
 			this.init();
 		},
 		methods: {
+			ckInput(text){
+				if(text.indexOf('.')>0){
+					
+					this.$nextTick(()=>{
+						this.otherNum=text.substring(0,text.indexOf('.'))
+						uni.showToast({
+							title:"请输入正整数"
+						})
+					})
+				}
+				var t	=Number(text);
+				if(t<1){
+					this.$nextTick(()=>{
+						this.otherNum='';
+					})
+						
+				}
+				if(t>500){
+					this.$nextTick(()=>{
+						this.otherNum=500;
+					})
+						
+				}
+				
+			},
 			submit() {
 				uni.showLoading({
 					title: "加载中",
@@ -144,6 +175,7 @@
 					if (this.moneyList.length > 0) {
 						this.selectItem = this.moneyList[0];
 						this.moneyActiveClass = this.moneyList[0].id
+						console.log(this.moneyActiveClass)
 
 					}
 					uni.hideLoading()
@@ -155,9 +187,10 @@
 					})
 				})
 			},
-			moneyClick(item, index) {
+			moneyClick(index,item) {
 				this.moneyActiveClass = index;
-				this.selectItem = item
+				this.selectItem=item;
+				
 			},
 			// 选中某个单选框时,由radio时触发
 			radioChange(e) {
@@ -171,9 +204,18 @@
 				this.checked = !this.checked;
 			},
 			rechargeNow() {
-				uni.redirectTo({
-					url: '/pages/user/finance/rechargeRes'
-				})
+				if(this.moneyActiveClass==-1&&!this.otherNum){
+					this.submitForm.chargeStrategy=0;
+					this.submitForm.amount=0
+				}else{
+					this.submitForm.chargeStrategy=2;
+					if(this.otherNum){
+						this.submitForm.amount=this.otherNum
+					}else{
+						this.submitForm.amount=this.moneyActiveClass
+					}
+				}
+				console.log(this.submitForm)
 			}
 		},
 		onShow() {
@@ -214,7 +256,13 @@
 			color: #666;
 			margin-top: 4px;
 		}
-
+	.self-stop.active{
+		 
+			background-color: #EFFFF7;
+			border-color: #00B962;
+			color: #00B962;
+		
+	}
 		.rechargeMain {
 			display: flex;
 			flex-wrap: wrap;

+ 2 - 2
utils/mixin.js

@@ -32,13 +32,13 @@ var app = {
 		 return uni.getStorageSync(prefix + 'personInfo')
 	},
 	signOut:()=>  uni.removeStorageSync(prefix  + 'personInfo'),
-	getOpenId : () =>   uni.getStorageSync(prefix + 'wx_openId'),
+	getOpenId : () =>   uni.getStorageSync(prefix + 'wx_openId'+process.car.VUE_APP_WXAPPID),
 	
 	getUserInfo : () => {
 		 return uni.getStorageSync(prefix + 'xpgj_wx_user_info')
 	},
 
-	setOpenId : (value) => uni.setStorageSync(prefix + 'wx_openId', value),
+	setOpenId : (value) => uni.setStorageSync(prefix + 'wx_openId'+process.car.VUE_APP_WXAPPID, value),
 	setPersonInfo : (value) => uni.setStorageSync(prefix + 'personInfo', value),
 	
 	setUserInfo : (value) => uni.setStorageSync(prefix + 'xpgj_wx_user_info', value),