Explorar o código

说明:准备微信支付,首页、热水洗浴页面接口测通

程志平 %!s(int64=5) %!d(string=hai) anos
pai
achega
36233f8187
Modificáronse 9 ficheiros con 219 adicións e 524 borrados
  1. 1 1
      App.vue
  2. 0 4
      manifest.json
  3. 1 4
      pages.json
  4. 73 311
      pages/index/index.vue
  5. 24 126
      pages/recharge/recharge.vue
  6. 77 64
      pages/reshui/reshui.vue
  7. 37 9
      pages/show/show.vue
  8. 4 4
      static/api.js
  9. 2 1
      store/index.js

+ 1 - 1
App.vue

@@ -11,7 +11,7 @@
 		},
 		globalData: {
 			primaryColor: '#1296db',
-			test: false  // 控制是否是测试环境
+			test: true  // 控制是否是测试环境
 		}
 	}
 </script>

+ 0 - 4
manifest.json

@@ -56,10 +56,6 @@
         },
         "usingComponents" : true,
         "plugins" : {
-            "myPlugin" : {
-                "provider" : "wx1549b963bbae9931",
-                "version" : "4.0.0"
-            }
         },
         "permission" : {}
     },

+ 1 - 4
pages.json

@@ -49,9 +49,6 @@
 		"navigationBarTextStyle": "black",
 		"navigationBarTitleText": "uni-app",
 		"navigationBarBackgroundColor": "#fff",
-		"backgroundColor": "#fff",
-		"usingComponents": {
-			"login": "plugin://myPlugin/login"
-		}
+		"backgroundColor": "#fff"
 	}
 }

+ 73 - 311
pages/index/index.vue

@@ -4,30 +4,25 @@
 			<image src="../../static/images/banner2x.png" mode=""></image>
 		</view>
 		<view class="nav">
-			<view class="menu" v-show="my_display">
-				<navigator :url="'/pages/reshui/reshui?item=' + encodeURIComponent(JSON.stringify(this.userinfo))"
-					open-type="redirect" class="menu_item">
+			<view class="menu">
+				<navigator :url="'/pages/reshui/reshui'" open-type="redirect" class="menu_item">
 					<image src="../../static/images/shower2x.png" mode=""></image>
 					<text>洗 浴</text>
 				</navigator>
-				<navigator
-					:url="'/pages/jiaofei/jiaofei?o=index&item=' + encodeURIComponent(JSON.stringify(this.userinfo))"
-					open-type="redirect" class="menu_item">
+				<navigator :url="'/pages/jiaofei/jiaofei?o=index'" open-type="redirect" class="menu_item">
 					<image src="../../static/images/recharge2x.png" mode=""></image>
 					<text>电费充值</text>
 				</navigator>
 			</view>
-			<view class="reset">
-				<navigator url="" open-type="redirect" @click="reauthorization()" class="menu_item">
-					<text class="iconfont icon-zhongzhi"></text>
-					<text>重新授权</text>
-				</navigator>
-			</view>
-		</view>
-		<view v-if="showLogin">
-			<login :ocode="ocode" :appkey="appkey" scope="snsapi_userinfo" :visible="visible" @success="callback()"
-				@cancel="callback()" @fail="callback()" />
 		</view>
+		<!--弹窗-->
+		<modal v-if="showPop" title="请输入学号" confirm-text="确定" cancel-text="取消" @cancel="cancelPop"
+			@confirm="confirmPop">
+			<view class="">学号:</view>
+			<input type='text' class="stu-number" maxlength="14" placeholder="请输入学号" v-model="stu_number" />
+			<view class="">身份证号:</view>
+			<input type='text' class="stu-number" maxlength="18" placeholder="请输入身份证号" v-model="id_card" />
+		</modal>
 	</view>
 </template>
 
@@ -35,306 +30,83 @@
 	export default {
 		data() {
 			return {
-				visible: false,
-				showLogin: true,
-				appkey: '5AA49F3E4CACA380',
-				sub_appid: '1015730314_1941301045',
-				appid: 'wxd6f090391d410534', // 获取用户信息
-				ocode: '1015730314', // 获取用户信息
-				app_secret: '58D34C81D82B35179ED896C4362B0FC0', // 获取用户信息
-				wxcode: '',
-				access_token: '',
-				access_token_for_amount: '', // 获取到应用有效凭证
-				my_display: false,
-				userinfo: {},
-				amount: 0.00
+				appId: 'wxd6f090391d410534',
+				ocode: '1015730314',
+				appSecret: '58D34C81D82B35179ED896C4362B0FC0',
+				code: '',
+				amount: 0.00,
+				showPop: false, //弹窗
+				stu_number: '20210210140101',
+				id_card: '88888888'
+				// stu_number: '',
+				// id_card: ''
 			}
 		},
 		onLoad() {
-			try {
-				const value = uni.getStorageSync('userinfo_storage_key');
-				if (value == '') {
-					if (JSON.stringify(this.userinfo) == '{}') {
-						this.showLogin = true
-						this.visible = true
-					} else {
-						this.showLogin = false
-						this.my_display = true
-					}
-				} else {
-					this.showLogin = false
-					this.userinfo = value
-					this.my_display = true
-				}
-
-				// 获取应用有效凭证,并查询余额
-				this.get_valid_credentials()
-
-			} catch (e) {
-				// console.log(e)
-				uni.showToast({
-					icon: 'success',
-					title: '用户获取失败',
-					duration: 2000
-				})
-			}
+			this.getCode()
 		},
 		methods: {
-			/**
-			 * 重新授权
-			 */
-			reauthorization() {
-				try {
-					uni.removeStorageSync('userinfo_storage_key');
-					setTimeout(() => {
-						this.showLogin = false
-						this.userinfo = {}
-						this.my_display = false
-					}, 300)
-
-					setTimeout(() => {
-						this.showLogin = true
-						this.visible = true
-					}, 300)
-				} catch (e) {
-					console.log(e)
-				}
-			},
-			/**
-			 * 授权回调
-			 */
-			callback: function({
-				detail
-			}) {
-				// console.log(detail)
-				// {wxcode: "7f7Qi9rN8zQ1nifQiysTZ3WIeIWlgcGk"}
-				if (detail === undefined) {
-					this.userinfo = {};
-					uni.showToast({
-						icon: 'success',
-						title: '需要先授权'
-					});
-				} else {
-					const {
-						wxcode = ""
-					} = detail
-
-					if (wxcode.length == 0) {
-						uni.showToast({
-							title: '未获得wxcode',
-							duration: 500
-						})
-					} else {
-						// 获取wxcode
-						this.wxcode = wxcode
-
-						// 通过wxcode换取access_token
-						this.get_access_token()
-					}
-				}
-			},
-
-			/**
-			 * 通过wxcode换取access_token
-			 */
-			async get_access_token() {
-				const res = await this.$myRequest({
-					host: 'wecard',
-					url: '/connect/oauth2/token',
-					method: 'POST',
-					header: {
-						'content-type': 'application/json'
-					},
-					data: {
-						'wxcode': this.wxcode,
-						'app_key': this.appkey,
-						'app_secret': this.app_secret,
-						'grant_type': 'authorization_code',
-						'redirect_uri': 'mnp://wxd6f090391d410534'
-					}
-				})
-
-				if (res.data.access_token == '' || res.data.access_token == 'undefined') {
-					uni.showToast({
-						title: '未获得token'
-					})
-				} else {
-					this.access_token = res.data.access_token
-
-					// 通过access_token换取用户信息
-					this.get_user_info();
-				}
-			},
-
-			/**
-			 * 通过access_token换取用户信息
-			 */
-			async get_user_info() {
-				const res = await this.$myRequest({
-					host: 'wecard',
-					url: '/connect/oauth/get-user-info',
-					method: 'POST',
-					header: {
-						'content-type': 'application/json'
-					},
-					data: {
-						"access_token": this.access_token
-					}
-				});
-
-				if (res.data.errcode == 0 && res.data.errmsg == 'OK') {
-					try {
-						this.userinfo = res.data
-						this.userinfo.amount = this.amount
-						// 微校参数
-						this.userinfo.appkey = this.appkey
-						this.userinfo.app_secret = this.app_secret
-						this.userinfo.ocode = this.ocode
-						this.userinfo.sub_appid = this.sub_appid
-						this.userinfo.appid = this.appid
-						// 存储用户信息
-						uni.setStorageSync('userinfo_storage_key', this.userinfo)
-						// 提示授权成功
-						uni.showToast({
-							icon: 'success',
-							title: '授权成功',
-							duration: 800,
-							success: (res) => {
-								this.my_display = true
-								
-								// 查询本系统后台是否存在该用户信息
-								this.select_user_info()
-							}
-						})
-					} catch (e) {
-						console.log(e)
-					}
+			//弹窗
+			confirmPop() { //确认
+				if (this.stu_number.length == 14 && this.id_card.length == 18) {
+					this.showPop = false
+					// 获得code
+					this.getCode()
 				} else {
 					uni.showToast({
-						title: '未获得用户信息',
-						duration: 1000
+						title: '学号长度错误 或 身份证号 长度错误!',
+						icon: 'none'
 					});
 				}
 			},
-			
-			/**
-			 * 查询用户信息
-			 */
-			async select_user_info() {
-				const res = await this.$myRequest({
-					host: 'code',
-					url: '/HotWater/userget_stu.action',
-					method: 'POST',
-					header: {
-						'content-type': 'application/x-www-form-urlencoded'
-					},
-					data: {
-						card_number: this.userinfo.card_number
-					}
-				});
-			
-				// console.log(res, 'select_user_info');
-				if (res.data.info) {
-					let cnumber = this.userinfo.card_number
-			
-					if (cnumber == null || cnumber == undefined || cnumber == '') {
-						// 之前未绑定用户信息,现在去绑定用户信息
-						this.send_save_user_info()
+			cancelPop() { //取消
+				// this.stu_number = ''
+				// this.showPop = false
+			},
+			// 获得code
+			getCode() {
+				wx.login({
+					success: (res) => {
+						// console.log(res);
+						if (res.code) {
+							this.code = res.code
+							// 请求服务器,获得openid
+							this.getOpenId()
+						} else {
+							uni.showToast({
+								title: res.errMsg,
+								icon: 'none'
+							});
+						}
 					}
-				} else {
-					uni.showToast({
-						icon: 'success',
-						title: '获取用户信息失败'
-					})
-				}
+				})
 			},
-			
 			/**
-			 * 绑定用户信息
+			 * 请求服务器,获得openid
 			 */
-			async send_save_user_info() {
+			async getOpenId() {
 				const res = await this.$myRequest({
 					host: 'code',
-					url: '/HotWater/userstu_info.action',
+					url: '/HotWaters/wpopenid.action',
 					method: 'POST',
 					header: {
 						'content-type': 'application/x-www-form-urlencoded'
 					},
 					data: {
-						user: JSON.stringify(this.userinfo)
-					}
-				});
-			
-				// console.log('send_save_user_info:', res)
-				let error = res.data.erro;
-				if (error == '未获取到数据!') {
-					uni.showToast({
-						title: '绑定用户失败',
-						duration: 2000
-					})
-				} else {
-					uni.showToast({
-						icon: 'success',
-						title: '绑定用户成功',
-						duration: 2000
-					})
-				}
-			},
-
-			/**
-			 * 获取应用有效凭证
-			 */
-			async get_valid_credentials() {
-				const res = await this.$myRequest({
-					host: 'wecard',
-					url: '/cgi-bin/oauth2/token',
-					method: 'POST',
-					header: {
-						'content-type': 'application/json'
-					},
-					data: {
-						'app_key': this.appkey,
-						'app_secret': this.app_secret,
-						"grant_type": "client_credentials",
-						"scope": "base",
-						"ocode": this.ocode
+						code: this.code,
+						stu_number: this.stu_number,
+						id_card: this.id_card
 					}
-				});
-
-				if (typeof(res.data.access_token) != 'undefined') {
-					// 获取到应用有效凭证,保存到页面变量中
-					this.access_token_for_amount = res.data.access_token
-					// 用户充值钱包余额查询
-					this.request_user_amount()
-
-				} else {
-					uni.showToast({
-						title: '获取凭证失败',
-						duration: 2000
-					})
-				}
-			},
-
-			/**
-			 * 用户充值钱包余额查询
-			 */
-			async request_user_amount() {
-				const res = await this.$myRequest({
-					host: 'wecard',
-					url: "/cgi-bin/pay/app/wallet-recharge-balance?access_token=" + this
-						.access_token_for_amount + "&sub_appid=" + this.sub_appid + "&user_id=" + this
-						.userinfo.card_number
-				});
+				})
 
-				if (res.data.code === 0) {
-					// 用户余额保存到页面变量中
-					this.amount = res.data.data.amount;
-				} else {
+				// console.log(res.data.mess);
+				if (res.data.mess == '绑定成功') {
 					uni.showToast({
-						icon: 'none',
-						title: '余额查询失败:\n' + res.data.message,
-						duration: 2000
-					})
+						title: '首次绑定成功!',
+						icon: 'success'
+					});
+				} else if (res.data.mess == '未查询到用户信息') {
+					this.showPop = true
 				}
 			}
 		}
@@ -392,26 +164,16 @@
 					color: #333333;
 				}
 			}
+		}
 
-			.reset {
-				position: fixed;
-				display: flex;
-				flex-direction: column;
-				align-items: flex-end;
-				right: 55rpx;
-				bottom: 55rpx;
-				font-family: Microsoft YaHei-3970(82674968);
-				color: #333333;
-
-				.icon-zhongzhi {
-					margin: 0 auto;
-					padding-top: 20rpx;
-					color: $my-color-primary;
-					width: 90rpx;
-					height: 70rpx;
-					font-size: 80rpx;
-				}
-			}
+		.stu-number {
+			margin-top: 20rpx;
+			color: #00c200;
+			text-align: center;
+			font-size: 38rpx;
+			font-weight: bold;
+			height: 50rpx;
+			line-height: 50rpx;
 		}
 	}
 </style>

+ 24 - 126
pages/recharge/recharge.vue

@@ -41,9 +41,11 @@
 				order_id: '', // 订单号
 				pay_info: '', // 支付参数。将此参数透传给支付 SDK 发起支付
 				access_token: '',
-				sub_appid: '',
+				appid: '',
 				card_number: '',
+				mchid: '',
 				user_name: '',
+				payer_openid: '',
 				test: getApp().globalData.test // 获取全局变量,控制是否是测试环境
 			};
 		},
@@ -78,146 +80,42 @@
 			if (this.test) //测试环境
 				this.amount = 0.01
 
-			this.sub_appid = this.userinfo.sub_appid
+			this.mchid = this.userinfo.ocode
 			this.card_number = this.userinfo.card_number
+			this.payer_openid = this.userinfo.weixiao_stu_id
+			this.appid = this.userinfo.appid
 			this.user_name = this.userinfo.name
-			// 获取应用有效凭证
-			this.get_valid_credentials()
 		},
 		methods: {
 			/**
-			 * 获取应用有效凭证
+			 * 组合地址,发起支付
 			 */
-			async get_valid_credentials() {
+			async jsapi() {
 				const res = await this.$myRequest({
-					host: 'wecard',
-					url: '/cgi-bin/oauth2/token',
+					host: 'wexin',
+					url: '/v3/pay/transactions/jsapi',
 					method: 'POST',
 					header: {
 						'content-type': 'application/json'
 					},
 					data: {
-						'app_key': this.userinfo.appkey,
-						'app_secret': this.userinfo.app_secret,
-						'grant_type': 'client_credentials',
-						'scope': 'base',
-						'ocode': this.userinfo.ocode
-					}
-				});
-
-				if (typeof(res.data.access_token) != 'undefined') {
-					// 获取到应用有效凭证,保存到页面变量中
-					this.access_token = res.data.access_token
-				} else {
-					uni.showToast({
-						title: '获取凭证失败',
-						duration: 2000
-					})
-				}
-			},
-			/**
-			 * 组合地址,发起支付
-			 */
-			async jsapi() {
-				if (this.test) { // 测试环境
-					const res = await this.$myRequest({
-						host: 'wecard',
-						url: '/cgi-bin/pay/app/mppay',
-						method: 'POST',
-						header: {
-							'content-type': 'application/json'
+						"mchid": this.mchid,
+						"out_trade_no": this.order_id = this.$getOrderId('shuifei'),
+						"appid": this.appid,
+						"description": "热水洗浴充值",
+						"notify_url": this.$code_base_url + '/HotWater/wxpayrecharge.action',
+						"amount": {
+							"total": this.amount * 100,
+							"currency": "CNY"
 						},
-						data: {
-							'access_token': this.access_token,
-							'sub_appid': this.sub_appid,
-							'user_id': this.card_number,
-							'order_id': this.order_id = this.$getOrderId('shuifei'),
-							'amount': this.amount * 100,
-							'order_type': 1,
-							'callback_url': 'http://wvwviw.natappfree.cc/HotWaters/wxpayrecharge.action'
+						"payer": {
+							"openid": this.payer_openid
 						}
-					})
-				} else {
-					const res = await this.$myRequest({
-						host: 'wecard',
-						url: '/cgi-bin/pay/app/mppay',
-						method: 'POST',
-						header: {
-							'content-type': 'application/json'
-						},
-						data: {
-							'access_token': this.access_token,
-							'sub_appid': this.sub_appid,
-							'user_id': this.card_number,
-							'order_id': this.order_id = this.$getOrderId('shuifei'),
-							'amount': this.amount * 100,
-							'order_type': 1,
-							'callback_url': this.$code_base_url + '/HotWater/wxpayrecharge.action'
-						}
-					})
-				}
-
-				this.pay_info = res.data.data.pay_info
-				// 发起支付
-				this.pay_amount()
-			},
-			// 调起支付
-			pay_amount() {
-				var OpenMidas = require("@/static/openMidas.js") // 引入小程序目录下的SDK文件
-				if (this.test) { // 测试环境
-					// 设置支付配置
-					wx['OpenMidasConfig'] = {
-						apiCommonConf: {
-							version: "weixiao"
-						},
-						cgiDomain: {
-							test: "midas.weixiao.qq.com/api", // 私有化参数联系微卡客服进行获取
-						},
-						webDomain: "https://midas.weixiao.qq.com/h5", // 私有化参数联系微卡客服进行获取
-						sandboxWebDomain: "https://midas.weixiao.qq.com/h5" // 私有化参数联系微卡客服进行获取
 					}
-
-					var payInfo = this.pay_info; // 请求mppay接口返回的数据
-					// var appMetaData = "card_number=" + this.card_number + "&user_name=" + this.user_name + "&account=" + this
-					// 	.amount; // 自定义回调数据
-					OpenMidas.init("test");
-				} else {
-					// 设置支付配置
-					wx['OpenMidasConfig'] = {
-						apiCommonConf: {
-							version: "weixiao"
-						},
-						cgiDomain: {
-							release: "midas.weixiao.qq.com/api", // 私有化参数联系微卡客服进行获取
-						},
-						webDomain: "https://midas.weixiao.qq.com/h5", // 私有化参数联系微卡客服进行获取
-						sandboxWebDomain: "https://midas.weixiao.qq.com/h5" // 私有化参数联系微卡客服进行获取
-					}
-
-					var payInfo = this.pay_info; // 请求mppay接口返回的数据
-					// var appMetaData = "card_number=" + this.card_number + "&user_name=" + this.user_name + "&account=" + this
-					// 	.amount; // 自定义回调数据
-					OpenMidas.init("release");
-				}
-				OpenMidas.pay(
-					payInfo,
-					// function(resultCode, innerCode, resultMsg, appMetaData) {
-					function(resultCode, innerCode, resultMsg) {
-						// console.log(resultCode); // 支付响应状态码
-						// console.log(innerCode); // 支付响应内部错误码
-						// console.log(resultMsg); // 支付响应说明
-						// console.log(appMetaData); // 自定义回调数据
-						
-						this.$store.state.payInfo.from = 'reshui_pay'
-						this.$store.state.payInfo.resultCode = resultCode
-						this.$store.state.payInfo.resultMsg = resultMsg
-						uni.navigateBack({
-							delta: 1
-						})
-					}
-					// },
-					// appMetaData
-				)
+				})
+				
+				console.log(res);
+				
 			},
 			/**
 			 * 输入充值金额

+ 77 - 64
pages/reshui/reshui.vue

@@ -8,7 +8,8 @@
 				</view>
 				<view class="qinshihao">
 					<text class="iconfont icon-zhuye"></text>
-					<text class="txt">{{dorm_number || '宿舍未知'}}</text>
+					<text class="dormtxt">{{dorm_number || '宿舍未知'}}</text>
+					<text class="compustxt">{{compus}}</text>
 				</view>
 			</view>
 			<view class="start_text">
@@ -108,59 +109,19 @@
 				byte35_tmp: '', // 70 个字符 临时变量
 				start_code: '',
 				// start_code: '3459A8C660F1C284E41003E80000120000',
-				xiaofei_items: [],
+				xiaofei_items: [], // 消费记录
 				userinfo: '',
 				card_number: '',
 				user_name: '',
 				use_amount: 0.0.toFixed(2), // 结算金额
 				amount: 0.0.toFixed(2), // 余额
-				dorm_number: '' // 宿舍号
+				dorm_number: '', // 宿舍号
+				compus: '', // 校区
+				code: ''
 			}
 		},
-		onLoad(options) {
-			try {
-				// 获取存储的用户数据
-				const value = uni.getStorageSync('userinfo_storage_key')
-				if (typeof(options.item) != 'undefined') {
-					let item = decodeURIComponent(options.item)
-					// console.log(value)
-					// console.log(item)
-					if (item === '{}') { // 如果没有用户信息,返回首页
-						uni.redirectTo({
-							url: '../index/index'
-						});
-						return;
-					}
-
-					if (item != '') {
-						// 处理JSON字符串
-						// this.userinfo = item.replace(/"/g, "'");
-						this.userinfo = JSON.parse(item);
-					}
-				} else if (value != '') {
-					// 处理JSON字符串
-					// this.userinfo = value.replace(/"/g, "'");
-					this.userinfo = value;
-				} else {
-					uni.showToast({
-						title: '未获得授权信息',
-						icon: 'success'
-					})
-
-					uni.redirectTo({
-						url: '../index/index'
-					});
-				}
-			} catch (e) {
-				console.log(e)
-			}
-
-			this.card_number = this.userinfo.card_number; // 卡号
-
-			if (this.$store.state.hasUserInfo == '') {
-				// 查询用户信息
-				this.select_user_info()
-			}
+		onLoad() {
+			this.getCode()
 		},
 		onShow() {
 			if (this.$store.state.payInfo.from == 'reshui_pay') {
@@ -180,6 +141,58 @@
 		},
 		methods: {
 			/**
+			 * 获得code
+			 */
+			getCode() {
+				wx.login({
+					success: (res) => {
+						// console.log(res);
+						if (res.code) {
+							this.code = res.code
+							// 请求服务器,获得openid
+							this.getOpenId()
+						} else {
+							uni.showToast({
+								title: res.errMsg,
+								icon: 'none'
+							});
+						}
+					}
+				})
+			},
+			/**
+			 * 请求服务器,获得openid
+			 */
+			async getOpenId() {
+				const res = await this.$myRequest({
+					host: 'code',
+					url: '/HotWaters/wpget_stu.action',
+					method: 'POST',
+					header: {
+						'content-type': 'application/x-www-form-urlencoded'
+					},
+					data: {
+						code: this.code
+					}
+				})
+
+				// console.log(res);
+				if (res.data.mess == '返回成功') {
+					this.$store.state.stu_number = res.data.info[0].stu_number
+					this.amount = res.data.info[0].balance
+					this.dorm_number = res.data.info[0].build + res.data.info[0].dom
+					this.compus = res.data.info[0].campus
+
+					// 请求选定的月份消费记录
+					this.request_consumption_records()
+					
+				} else if (res.data.mess == '未查询到用户信息') {
+					uni.redirectTo({
+						url: '../index/index'
+					});
+				}
+			},
+			/**
 			 * 选择消费年月
 			 */
 			bindDateChange(e) {
@@ -200,44 +213,38 @@
 			 * 请求选定的月份消费记录
 			 */
 			async request_consumption_records() {
-				if (this.card_number != '') {
+				if (this.$store.state.stu_number != '') {
 					this.xiaofei_items = []
 					const res = await this.$myRequest({
 						host: 'code',
-						url: '/HotWater/wxpayqueryConsume.action',
+						url: '/HotWaters/wpqueryConsume.action',
 						method: 'POST',
 						header: {
 							'content-type': 'application/x-www-form-urlencoded'
 						},
 						data: {
-							card_number: this.card_number,
+							stu_number: this.$store.state.stu_number,
 							begin_time: this.date
 						}
 					});
 
-					// console.log(res.data.mess, 'request_consumption_records');
-					if (typeof(res.data.mess) != 'undefined') {
-						let items = res.data.mess
-						// 按时间倒序排列
-						// items.sort((a, b) => {
-						// 	return a.begin_time < b.begin_time ? 1 : -1;
-						// })
+					// console.log(res, 'request_consumption_records');
+					if (res.data.mess == '返回成功') {
+						// 消费记录
+						let items = res.data.data
 						for (var i = 0; i < items.length; i++) {
-							// 过滤掉为0的记录,只显示消费大于0的记录
-							// if (items[i].use_amount > 0.00) {
 							this.xiaofei_items.push(items[i])
-							// }
 						}
 					} else {
 						uni.showToast({
 							icon: 'success',
-							title: '该月无消费记录'
+							title: res.data.mess
 						})
 					}
 				} else {
 					uni.showToast({
 						icon: 'success',
-						title: '用户卡号为空'
+						title: '号为空'
 					})
 				}
 			},
@@ -273,7 +280,7 @@
 						// 之前未绑定用户信息,现在去绑定用户信息
 						this.send_save_user_info()
 					}
-					
+
 					this.$store.state.hasUserInfo == true
 					// 请求选定的月份消费记录
 					this.request_consumption_records()
@@ -1186,9 +1193,11 @@
 				}
 
 				.qinshihao {
+					display: flex;
+					align-items: center;
 					position: fixed;
 					top: 20rpx;
-					right: 40rpx;
+					right: 10rpx;
 					font-size: 28rpx;
 
 					.icon-zhuye {
@@ -1196,6 +1205,10 @@
 						font-family: Microsoft YaHei-3970(82674968);
 						color: $my-color-primary;
 					}
+
+					.compustxt {
+						font-size: 18rpx;
+					}
 				}
 			}
 

+ 37 - 9
pages/show/show.vue

@@ -37,7 +37,7 @@
 						<text class="item-list-txt show-money">{{item.money}}</text>
 					</view>
 				</view>
-				
+
 			</view>
 		</view>
 	</view>
@@ -48,8 +48,6 @@
 	export default {
 		data() {
 			return {
-				date_time: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
-				use_elec: [5, 19, 16, 24, 38, 22, 15, 16, 14, 17, 22, 20],
 				chartData: {
 					categories: [],
 					series: [{
@@ -62,24 +60,54 @@
 				startDate: this.$getDate('start_date'),
 				endDate: this.$getDate('end_date'),
 				all_data: '', //所有数据
-				list: [] ,//消费列表
-				card_number: 0,   //用户卡号
+				list: [], //消费列表
+				card_number: 0, //用户卡号
 			}
 		},
-		onLoad(options){
-			this.chartData.categories = this.date_time;
-			this.chartData.series[0].data = this.use_elec;
+		onLoad(options) {
 			// console.log(this.chartData.series[0].data)
-			
+
 			// this.list = this.all_data.data[0].xiaofei;
 			// this.name = this.all_data.data[0].xiaofei.name;
 			// console.log(this.date)
 			this.card_number = options.card_number
 			// console.log(this.card_number)
+
+			this.get_data()
 		},
 		methods: {
 			bindDateChange: function(e) {
 				this.date = e.detail.value
+			},
+			async get_data() {
+				//http://ecu9ys.natappfree.cc/HotWaters/buildgetMonthBill.action
+				const res = await this.$myRequest({
+					host: 'ceshi',
+					url: 'http://ecu9ys.natappfree.cc/HotWaters/buildgetMonthBill.action',
+					method: 'POST',
+					header: {
+						'content-type': 'application/x-www-form-urlencoded'
+					},
+					data: {
+						'roomSelect': this.$store.state.building.roomSelect
+						// 'roomSelect': '墨轩湖校区1101'
+					}
+				})
+
+				// console.log(res.data);
+				let tmparr_date_time = []
+				let tmparr_use_elec = []
+				for (var i = 0; i < res.data.date_time.length; i++) {
+					tmparr_date_time.push(res.data.date_time[i])
+				}
+				for (var i = 0; i < res.data.use_elc.length; i++) {
+					tmparr_use_elec.push(res.data.use_elc[i])
+				}
+
+				setTimeout(() => {
+					this.chartData.categories = tmparr_date_time;
+					this.chartData.series[0].data = tmparr_use_elec;
+				}, 300)
 			}
 		}
 	}

+ 4 - 4
static/api.js

@@ -1,4 +1,4 @@
-const WECARD_BASE_URL = 'https://open.wecard.qq.com' // wecard
+const WEXIN_BASE_URL = 'https://api.mch.weixin.qq.com' // wexin
 const CODE_BASE_URL = 'https://developdomain.chuanghai-tech.com' // code
 
 const myRequest = (options) => {
@@ -10,9 +10,9 @@ const myRequest = (options) => {
 	return new Promise((resolve, reject) => {
 		let BASE_URL = '';
 
-		if (options.host == 'wecard') {
-			BASE_URL = WECARD_BASE_URL;
-		} else if (options.host == 'code') {
+		if (options.host == 'wexin') {
+			BASE_URL = WEXIN_BASE_URL;} 
+		else if (options.host == 'code') {
 			BASE_URL = CODE_BASE_URL;
 		} else if (options.host == 'ceshi') {
 			BASE_URL = '';

+ 2 - 1
store/index.js

@@ -14,7 +14,8 @@ const store = new Vuex.Store({
 			roomSelect: '',
 			add_class: 0,
 			dom: ''
-		}
+		},
+		stu_number: ''
 	},
 	mutations: {},
 	actions: {}