Browse Source

修复偶尔出现未知支付参数的情况。

程志平 3 years atrás
parent
commit
effc09d106
1 changed files with 23 additions and 18 deletions
  1. 23 18
      pagesElectric/jiaofei/jiaofei.vue

+ 23 - 18
pagesElectric/jiaofei/jiaofei.vue

@@ -153,8 +153,9 @@
 			 * 获取广告缩略图
 			 */
 			async get_img() {
+				var _this = this;
 				let res = await this.$myRequest({
-					host: this.ceshi,
+					host: _this.ceshi,
 					url: '/HotWaters/advertquery_h.action',
 					method: 'POST',
 					header: {
@@ -204,8 +205,7 @@
 					return
 				}
 				
-				let _this = this;
-				
+				let _this = this;				
 				uni.navigateTo({
 					url: '../dfxq/dfxq',
 					success: function(res) {
@@ -227,7 +227,6 @@
 				}
 
 				let _this = this;
-
 				uni.navigateTo({
 					url: '../sfxq/sfxq',
 					success: function(res) {
@@ -291,15 +290,16 @@
 			 */
 			getCode(options, param) {
 				// console.log(options, param)
+				var _this = this;
 				uni.login({
 					success: (res) => {
 						if (res.code) {
 							if (param == 'comfirm') {
 								// 组合地址,发起支付
-								this.jsapi(res.code)
+								_this.jsapi(res.code)
 							} else {
 								// 请求服务器,获得openid
-								this.getOpenId(options, res.code)
+								_this.getOpenId(options, res.code)
 							}
 						} else {
 							uni.showToast({
@@ -320,9 +320,10 @@
 			 */
 			async getOpenId(options, param_code) {
 				// console.log(options, param_code)
+				var _this = this;
 				if (param_code != '') {
 					const res = await this.$myRequest({
-						host: this.ceshi,
+						host: _this.ceshi,
 						url: '/HotWaters/wpget_stu.action',
 						method: 'POST',
 						header: {
@@ -396,23 +397,24 @@
 			 * 取得电费额度
 			 */
 			async getDianLiang() {
+				var _this = this;
 				if (this.roomSelect != '' && typeof(this.roomSelect) != 'undefined') {
 					const res = await this.$myRequest({
-						host: this.ceshi,
+						host: _this.ceshi,
 						url: '/HotWaters/buildoverElec.action',
 						method: 'POST',
 						header: {
 							'content-type': 'application/x-www-form-urlencoded'
 						},
 						data: {
-							'roomSelect': this.roomSelect
+							'roomSelect': _this.roomSelect
 						}
 					})
 
 					// console.log('取得电费额度', res);
 					if (res.data.mess == '0') {
 						setTimeout(() => {
-							this.remainElec = res.data.amount.toFixed(2)
+							_this.remainElec = res.data.amount.toFixed(2)
 						}, 30);
 					} else {
 						this.remainElec = 0.00.toFixed(2)
@@ -510,13 +512,14 @@
 			 * 确认充值对话框
 			 */
 			confirm_dialog() {
+				var _this = this;
 				uni.showModal({
 					// title: '确定充值'+this.amount+'元',
-					title: '确定充值' + this.amount + '元',
+					title: '确定充值' + _this.amount + '元',
 					success: (res) => {
 						if (res.confirm) {
 							// 获取code
-							this.getCode('options', 'comfirm')
+							_this.getCode('options', 'comfirm')
 						} else if (res.cancel) {
 							// console.log('用户点击取消');
 						}
@@ -539,8 +542,10 @@
 					});
 					return
 				}
+				var _this = this;
+				// console.log(_this.roomSelect);
 				const res = await this.$myRequest({
-					host: this.ceshi,
+					host: _this.ceshi,
 					url: '/HotWaters/elpay_ns.action',
 					method: 'POST',
 					header: {
@@ -548,9 +553,9 @@
 					},
 					data: {
 						code: param_code,
-						num: this.amount,
-						stu_number: this.stu_number,
-						roomSelect: this.roomSelect
+						num: _this.amount,
+						stu_number: _this.stu_number,
+						roomSelect: _this.roomSelect
 					}
 				})
 
@@ -621,9 +626,9 @@
 				}
 				this.$nextTick(() => {
 					if (final.toString() == '0') {
-						this.amount = ''
+						_this.amount = ''
 					} else {
-						this.amount = final.toString() || '0'
+						_this.amount = final.toString() || '0'
 					}
 				})
 			},