zizhong.wang 2 年 前
コミット
2c079cf7e6
共有3 個のファイルを変更した46 個の追加15 個の削除を含む
  1. 12 0
      App.vue
  2. 33 14
      pages/heatingPage/pay.vue
  3. 1 1
      pages/selfCenter/index.vue

+ 12 - 0
App.vue

@@ -90,6 +90,18 @@ export default {
 		  let url = getApp().globalData.shareUrl+'api/api.php'+'?method='+method+'&source='+source+'&action='+action+'&timestamp='+timestamp +'&sign='+md5Sign;
 		  return url;
 	  },
+	  MD5(str){
+		let md5str = md5(str);
+		return md5str.toUpperCase();  
+	  },
+	  randomStr(len){
+		  let str = '';
+		  let chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+		  for (let i = 0; i < len; i++){
+			  str += chars.charAt(Math.random() * chars.length);
+		  }
+		  return str;
+	  },
 	  loginRequest(codeRes){
 	  	let md5Sign = md5("method="+'user'+"&timestamp="+getApp().globalData.globalTimestamp+"&secret="+getApp().globalData.secret)
 	  	let url = getApp().globalData.shareUrl+'api/api.php'+'?method=user&source=user&action=login&timestamp='+getApp().globalData.globalTimestamp +'&sign='+md5Sign

+ 33 - 14
pages/heatingPage/pay.vue

@@ -24,8 +24,8 @@
 	  <view class="tel flex">
 	    <label>缴费类型:</label>
 		<radio-group  @change="payChange">
-		  <radio value="1" :checked="payInfo.type!=2" style="margin-right: 30rpx;transform: scale(0.85);">金额</radio>
-		  <radio value="2" :checked="payInfo.type==2" style="transform: scale(0.85);">空置</radio>
+		  <radio value="1" :checked="payInfo.type!=2" style="margin-right: 30rpx;transform: scale(0.85);" >金额</radio>
+		  <radio value="2" :checked="payInfo.type==2" style="transform: scale(0.85);" :disabled="payInfo.status==1 || payInfo.status==3">空置</radio>
 		</radio-group>
 	  </view>
 	  <view class="tel flex">
@@ -97,7 +97,10 @@ export default {
 	this.getPayDetail(option.id);
 	this.pay_code = option.id;
   },
-  methods: {   
+  methods: {
+	reload(){
+		this.getPayDetail(this.pay_code);
+	},
     getPayDetail(payId) {
      
 	  let url = getApp().makeApiUrl("user",'user','get_order_info');
@@ -119,6 +122,9 @@ export default {
 			   if (this.payInfo.status > 0 && this.payInfo.invoice_status == 0){
 				   this.needInvoice = 1;
 			   }
+			   else{
+				   this.needInvoice = 0;
+			   }
 			   if (this.payInfo.status == 2){
 				   this.payStatusStr = '补充缴费';
 			   }
@@ -156,6 +162,7 @@ export default {
 		this.payInfo.type = e.detail.value;
 	},
 	paySubmit(){
+		let that = this;
 		let type = this.payInfo.type;
 		if (this.payInfo.status == 2)
 		{
@@ -176,19 +183,28 @@ export default {
 		  data: postData,
 		  success: (res) => {
 		    if (res.data.code === 200) {
-		         let r = res.data.data;
+				let r = res.data.data;
+				let timeStamp = Date.now().toString();
+				let nonceStr = getApp().randomStr(32);
+				let p = 'prepay_id=' + r.prepay_id;
+				let key = 'd2452k56khlk987HJ456uy7856HKJsd3';    //支付的key
+				
+				let origin = "appId="+"wx3cf5d0fd376116e2"+"&nonceStr="+nonceStr+"&package="+p+"&signType=MD5&timeStamp="+timeStamp+"&key="+key;
+				let md5Sign = getApp().MD5(origin);
+//		        console.log('md5Sign_origin:' + origin);
+//				console.log('md5Sign:' + md5Sign);
 				 uni.requestPayment({
-				 	provider: 'wxpay',
-				 	timeStamp: String(Date.now()),
-				 	nonceStr: r.nonce_str,
-				 	package: 'prepay_id=' + r.prepay_id,
+				 	appId: 'wx3cf5d0fd376116e2',
+				 	timeStamp: timeStamp,
+				 	nonceStr: nonceStr,
+				 	package: p,
 				 	signType: 'MD5',
-				 	paySign: r.sign,
+				 	paySign: md5Sign,
 				 	success: function (res) {
 				 		console.log('success:' + JSON.stringify(res));
 				 		setTimeout(function() {
-				 			Location.reload();
-				 		}, 2500);
+				 			that.reload();
+				 		}, 500);
 				 	},
 				 	fail: function (err) {
 				 		console.log('fail:' + JSON.stringify(err));
@@ -224,6 +240,7 @@ export default {
 	  },
 	closePopup() {
 		  this.$refs.popup.close();
+		  let that = this;
 		  let url = getApp().makeApiUrl("user",'user','invoice');
 		  let postData = {
 		    code:this.pay_code,
@@ -240,14 +257,16 @@ export default {
 		    data: postData,
 		    success: (res) => {
 		      if (res.data.code === 200) {
-				  /*
+				  
 		           uni.showToast({
 		             title: res.data.msg,
 		             icon: "none",
 		             duration: 2500,
 		           });
-				  */
-				   window.location.reload();
+				  
+				   setTimeout(function() {
+				   	 that.reload();
+				   }, 500);
 				   
 		      } else {
 		        uni.showToast({

+ 1 - 1
pages/selfCenter/index.vue

@@ -1,7 +1,7 @@
 <template>
   <view class="content">
 	<!-- <top-title :titleValue="title" :btnTop="btnPos" style="width: 100%;"></top-title> -->
-    <view class="self-inf">
+    <view class="self-inf" style="margin-top:20rpx">
       <view class="img-name-box" v-if="isAuth">
         <image :src="userHeadImg ? userHeadImg : '/static/auth-icon.png'" class="heade-img" mode="aspectFill"></image>
         <!-- <p class="nickname">{{ userNickName }}</p> -->