Browse Source

添加本地open_id存储

yuxingxing 2 years ago
parent
commit
8cd91d34c3

+ 1 - 1
api/user.js

@@ -7,7 +7,7 @@ import request from "@/utils/request.js";
  * 
  */
 export function getLoginAccount(data) {
-	let url = "username="+data.username+"&password="+data.password
+	let url = "username="+data.username+"&password="+data.password+"&code="+data.wxcode
 	return request.post('v1/login_account?'+url,null,{
 		noAuth: true
 	});

+ 2 - 2
config/app.js

@@ -2,8 +2,8 @@ module.exports = {
 	// 小程序配置
 	// #ifdef MP || APP-PLUS
 	// 请求域名 格式: https://您的域名
-	HTTP_REQUEST_URL: `https://www.gzzhsckj.com`,
-	// HTTP_REQUEST_URL: `http://wine.gzzzyd.com`,
+	// HTTP_REQUEST_URL: `https://www.gzzhsckj.com`,
+	HTTP_REQUEST_URL: `http://wine.gzzzyd.com`,
 	// HTTP_REQUEST_URL: `v4.crmeb.net`,
 	// #endif
 	

+ 2 - 0
config/cache.js

@@ -5,6 +5,8 @@ module.exports = {
 	LOGIN_STATUS: 'LOGIN_STATUS_TOKEN',
 	//uid
 	UID:'UID',
+	//open_id
+	OPENID:'OPENID',
 	//用户信息
 	USER_INFO: 'USER_INFO',
 	//token过期时间

+ 2 - 2
libs/routine.js

@@ -137,13 +137,13 @@ class Routine {
 	}
 
 	async getCode() {
-		let provider = await this.getProvider();
+		// let provider = await this.getProvider();
 		return new Promise((resolve, reject) => {
 			// if(Cache.has(STATE_R_KEY)){
 			// 	return resolve(Cache.get(STATE_R_KEY));
 			// }
 			uni.login({
-				provider: provider,
+				provider: 'weixin',
 				success(res) {
 					if (res.code) Cache.set(STATE_R_KEY, res.code, 10800);
 					return resolve(res.code);

+ 8 - 2
pages/users/components/login_mobile/index.vue

@@ -43,13 +43,17 @@
 			authKey: {
 				type: String,
 				default: '',
+			},
+			wxcode: {
+				type: String,
+				default: '',
 			}
 		},
 		data() {
 			return {
 				password: '123456789',
 				keyCode: '',
-				account: '18286053319',
+				account: '15772415772',
 				codeNum: ''
 			}
 		},
@@ -119,12 +123,14 @@
 				});
 				getLoginAccount({
 					username: that.account,
-					password: that.password
+					password: that.password,
+					wxcode: that.wxcode
 				}).then(res => {
 					this.$store.commit('LOGIN', {
 						token: res.data.access_token,
 						time: res.data.expires_in
 					});
+					this.$store.commit('OPENID',res.data.openId);
 					this.getUserInfo();
 				})
 				// Routine.getCode()

+ 1 - 1
pages/users/wechat_login/index.vue

@@ -30,7 +30,7 @@
 			</view>
 		</view>
 		<block v-if="isUp">
-			<mobileLogin :isUp="isUp" @close="maskClose" :authKey="authKey" @wechatPhone="wechatPhone"></mobileLogin>
+			<mobileLogin :isUp="isUp" @close="maskClose" :wxcode="code" :authKey="authKey" @wechatPhone="wechatPhone"></mobileLogin>
 		</block>
 		<block v-if="isPhoneBox">
 			<routinePhone :logoUrl="logoUrl" :isPhoneBox="isPhoneBox" @close="bindPhoneClose" :authKey="authKey">

+ 7 - 1
store/modules/app.js

@@ -5,7 +5,8 @@ import {
 } from "../../api/user.js";
 import {
 	LOGIN_STATUS,
-	UID
+	UID,
+	OPENID
 } from '../../config/cache';
 import Cache from '../../utils/cache';
 const user_res = require('@/mock/json/user_res.json')
@@ -18,6 +19,7 @@ const state = {
 	backgroundColor: "#fff",
 	userInfo: {},
 	uid: Cache.get(UID) || 0,
+	open_id: Cache.get(OPENID),
 	homeActive: false,
 	phoneStatus:true,
 	pageFooter:uni.getStorageSync('pageFoot') || {}
@@ -31,6 +33,10 @@ const mutations = {
 		state.token = opt.token;
 		Cache.set(LOGIN_STATUS, opt.token, opt.time);
 	},
+	OPENID(state, val) {
+		state.open_id = val;
+		Cache.set(OPENID, val);
+	},
 	SETUID(state,val){
 		state.uid = val;
 		Cache.set(UID, val);

+ 2 - 1
utils/request.js

@@ -49,7 +49,8 @@ function baseRequest(url, method, data, {
 				else if ([401, 110003, 110004].indexOf(res.data.code) !== -1) {
 					toLogin();
 					reject(res.data);
-				} else if (res.data.code == 100103) {
+				} else if (res.data.code == 400) {
+					uni.hideLoading()
 					uni.showModal({
 						title: i18n.t(`提示`),
 						content: res.data.msg,