فهرست منبع

【说明】修改为农商行支付

程志平 4 سال پیش
والد
کامیت
6c28f5fe0f
7فایلهای تغییر یافته به همراه62 افزوده شده و 62 حذف شده
  1. 4 0
      .hbuilderx/launch.json
  2. 1 1
      manifest.json
  3. 9 11
      pages.json
  4. 7 5
      pages/index/index.vue
  5. 33 44
      pages/jiaofei/jiaofei.vue
  6. 7 0
      pages/reshui/reshui.vue
  7. 1 1
      static/api.js

+ 4 - 0
.hbuilderx/launch.json

@@ -6,6 +6,10 @@
      	{
      		"launchtype" : "remote"
      	},
+     	"h5" : 
+     	{
+     		"launchtype" : "remote"
+     	},
      	"mp-weixin" : 
      	{
      		"launchtype" : "remote"

+ 1 - 1
manifest.json

@@ -59,7 +59,7 @@
     "quickapp" : {},
     /* 小程序特有相关 */
     "mp-weixin" : {
-        "appid" : "wx2fc3f45732fae5d3",
+        "appid" : "wxd6f090391d410534",
         "setting" : {
             "urlCheck" : false
         },

+ 9 - 11
pages.json

@@ -20,7 +20,8 @@
 				"navigationBarTitleText": "热水钱包充值",
 				"enablePullDownRefresh": false
 			}
-		}, {
+		}, 
+		{
 			"path": "pages/jiaofei/jiaofei",
 			"style": {
 				"navigationBarTitleText": "电费充值",
@@ -42,17 +43,14 @@
 				"enablePullDownRefresh": false
 			}
 
+		}, {
+			"path": "pages/qr_code/qr_code",
+			"style": {
+				"navigationBarTitleText": "校园卡二维码",
+				"enablePullDownRefresh": false
+			}
 		}
-	    ,{
-            "path" : "pages/qr_code/qr_code",
-            "style" :                                                                                    
-            {
-                "navigationBarTitleText": "",
-                "enablePullDownRefresh": false
-            }
-            
-        }
-    ],
+	],
 	"globalStyle": {
 		"navigationBarTextStyle": "black",
 		"navigationBarTitleText": "uni-app",

+ 7 - 5
pages/index/index.vue

@@ -33,10 +33,10 @@
 				huanjing: '部署环境', // 部署环境是key,用来获取环境
 				visible: false, // 是否授权可见
 				showLogin: true, // 是否启动授权
-				appkey: '5AA49F3E4CACA380', // 商户appkey
-				appid: 'wx2fc3f45732fae5d3', // 获取用户信息
+				appkey: '3183DC96A6DABA8D', // 商户appkey
+				appid: 'wxd6f090391d410534', // 获取用户信息
 				ocode: '1015730314', // 获取用户信息
-				app_secret: '58D34C81D82B35179ED896C4362B0FC0', // 获取用户信息
+				app_secret: '05742955578EC5BD29B7BC4CAC5AFACA', // 获取用户信息
 				userinfo: '', // 用户信息
 				showQR_code: false, // 显示校园卡二维码
 				validation_failed: false, // 验证失败
@@ -102,6 +102,7 @@
 				try {
 					// console.log(111111);
 					const value = uni.getStorageSync('userinfo_storage_key');
+					// console.log(value);
 					if (value == '') {
 						this.showLogin = true
 						this.visible = true
@@ -271,6 +272,7 @@
 					}
 				});
 
+				// console.log(res);
 				if (res.data.errcode == 0 && res.data.errmsg == 'OK') {
 					try {
 						this.userinfo = res.data
@@ -344,8 +346,8 @@
 					})
 				} else {
 					uni.showToast({
-						icon: 'success',
-						title: '授权失败:' + res.data.mess,
+						icon: 'none',
+						title: '授权失败:' + res.data.msg,
 						success: (res) => {}
 					})
 				}

+ 33 - 44
pages/jiaofei/jiaofei.vue

@@ -75,6 +75,7 @@
 				sub_appid: '', //商户号
 				xiaofei_items: '', // 消费记录
 				dorm_number: '', //栋宿舍号
+				stu_number: '',
 				compus: '', //校区
 				ceshi: 'code',
 				test: this.$store.state.test
@@ -103,7 +104,7 @@
 				try {
 					// 获取学号
 					this.stu_number = this.$store.state.userInfo.card_number
-
+					
 					if (this.stu_number == '' || typeof(this.stu_number) == 'undefined') {
 						const userinfo = uni.getStorageSync('userinfo_storage_key')
 						if (userinfo) {
@@ -140,7 +141,6 @@
 						}
 					}
 				}
-
 				// 初始化参数
 				this.$store.state.building.add_class = 0;
 
@@ -155,18 +155,19 @@
 				uni.login({
 					success: (res) => {
 						if (res.code) {
-							// 请求服务器,获得openid
 							if (param == 'comfirm') {
-								// 获取IP
-								this.getIP(res.code)
-							} else
+								// 组合地址,发起支付
+								this.jsapi(res.code)
+							} else {
+								// 请求服务器,获得openid
 								this.getOpenId(options, res.code)
+							}
 						} else {
 							uni.showToast({
 								title: res.errMsg,
 								icon: 'none'
 							});
-
+							
 							// 跳转到首页
 							uni.redirectTo({
 								url: '../index/index?from=0'
@@ -176,26 +177,6 @@
 				})
 			},
 			/**
-			 * 获取IP
-			 */
-			async getIP(param_code) {
-				// console.log(param_code)
-				const res = await this.$myRequest({
-					host: 'ip',
-					url: '?ie=utf-8',
-					method: 'POST'
-				})
-
-				if (res) {
-					// console.log(res);
-					const reg = /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/;
-					let ip = reg.exec(res.data);
-
-					// 组合地址,发起支付
-					this.jsapi(param_code, ip[0])
-				}
-			},
-			/**
 			 * 请求服务器,获得openid
 			 */
 			async getOpenId(options, param_code) {
@@ -216,7 +197,7 @@
 					// console.log('获得openid', res);
 					if (res.data.mess == '返回成功') {
 						if (!(this.$store.state.building.roomSelect && typeof(this.$store.state.building.roomSelect) !=
-							'undefined')) {
+								'undefined')) {
 							// 栋宿舍号
 							this.dorm_number = res.data.info[0].build + res.data.info[0].dom
 							// 校区
@@ -236,6 +217,13 @@
 						// 请求选定的月份消费记录
 						this.getDianLiang()
 					} else if (res.data.mess == '未查询到用户信息') {
+						// 数据库中 未查询到用户信息,就清除本地存储
+						uni.removeStorageSync('userinfo_storage_key');
+						
+						uni.showToast({
+							title: '获取用户信息失败!'
+						})
+						
 						// 跳转到首页
 						if (options && typeof(options.from) != 'undefined' && typeof(options.from) != '') {
 							uni.navigateTo({
@@ -389,8 +377,8 @@
 			/**
 			 * 请求服务器,获取支付参数,并支付
 			 */
-			async jsapi(param_code, param_ip) {
-				if (param_code == '' || this.amount == '' || param_ip == '' || this.roomSelect == '') {
+			async jsapi(param_code) {
+				if (param_code == '' || this.amount == '' || this.roomSelect == '') {
 					uni.showToast({
 						title: 'code、充值金额、宿舍号或IP为空'
 					});
@@ -398,7 +386,7 @@
 				}
 				const res = await this.$myRequest({
 					host: this.ceshi,
-					url: '/HotWaters/elPay.action',
+					url: '/HotWaters/elpay_ns.action',
 					method: 'POST',
 					header: {
 						'content-type': 'application/x-www-form-urlencoded'
@@ -406,25 +394,20 @@
 					data: {
 						code: param_code,
 						num: this.amount,
-						ip: param_ip,
+						stu_number: this.stu_number,
 						roomSelect: this.roomSelect
 					}
 				})
 
 				// console.log(res);
-				if (res.data.pay == 'error') {
-					uni.showToast({
-						title: '未获得支付参数',
-						icon: 'success',
-						duration: 3000
-					});
-				} else {
+				if (res.statusCode == 200 && res.data.sub_openid && res.data.sub_openid != '') {
 					wx.requestPayment({
-						timeStamp: res.data.pay.timeStamp,
-						nonceStr: res.data.pay.nonceStr,
-						package: 'prepay_id=' + res.data.pay.prepay_id,
-						signType: res.data.pay.signType,
-						paySign: res.data.pay.paySign,
+						appId: res.data.appId,
+						timeStamp: res.data.timeStamp,
+						nonceStr: res.data.nonceStr,
+						package: res.data.package,
+						signType: res.data.signType,
+						paySign: res.data.paySign,
 						success: res => {
 							if (res.errMsg == 'requestPayment:ok') {
 								uni.showToast({
@@ -446,6 +429,12 @@
 							// console.log(res);
 						}
 					});
+				} else {
+					uni.showToast({
+						title: '未获得支付参数',
+						icon: 'success',
+						duration: 3000
+					});
 				}
 			},
 			/**

+ 7 - 0
pages/reshui/reshui.vue

@@ -303,6 +303,13 @@
 						})
 					}
 				} else if (res.data.mess == '未查询到用户信息') {
+					// 数据库中 未查询到用户信息,就清除本地存储
+					uni.removeStorageSync('userinfo_storage_key');
+					
+					uni.showToast({
+						title: '获取用户信息失败!'
+					})
+					
 					if (options && typeof(options.from) != 'undefined' && typeof(options.from) != '') {
 						uni.navigateTo({
 							url: '../index/index?from=' + options.from

+ 1 - 1
static/api.js

@@ -1,7 +1,7 @@
 const WEXIN_BASE_URL = 'https://api.mch.weixin.qq.com' // wexin
 const WECARD_BASE_URL = 'https://open.wecard.qq.com' // wecard
 const CODE_BASE_URL = 'https://jtishfw.ncjti.edu.cn/jxch-smartmp' // code
-// const CODE_BASE_URL = 'http://cfnifb.natappfree.cc' // code
+// const CODE_BASE_URL = 'http://4hssv8.natappfree.cc' // code
 const IP_BASE_URL = 'https://pv.sohu.com/cityjson' // ip
 
 const myRequest = (options) => {