lhl 4 years ago
parent
commit
038f1cb1b6

+ 2 - 2
manifest.json

@@ -78,8 +78,8 @@
         "devServer" : {
             "proxy" : {
                 "/api" : {
-                    // "target" : "http://www.zjxwcm.cn/api",
-					"target" : "http://xw.liuniu946.com/api",
+                    "target" : "http://www.zjxwcm.cn/api",
+					// "target" : "http://xw.liuniu946.com/api",
                     // "changeOrigin": true,
                     "pathRewrite" : {
                         "/api" : "" // rewrite path

+ 11 - 6
pages/index/index.vue

@@ -117,7 +117,7 @@ import { loadIndexs, getStoreList } from '@/api/index.js';
 import { getUserInfo } from '@/api/user.js';
 import { setCoupons } from '@/api/functionalUnit.js';
 import { getBargainList, getProducts } from '@/api/product.js';
-import { interceptor } from '@/utils/loginUtils';
+import { saveUrl,interceptor } from '@/utils/loginUtils';
 import { mapState, mapMutations } from 'vuex';
 	// #ifdef H5
 	import { weixindata, weixinlocation,shareLoad } from '@/utils/wxAuthorized';
@@ -196,10 +196,17 @@ export default {
 		...mapState('latlon', ['lat', 'lon'])
 	},
 	onLoad: function(option) {
+		
 		// #ifndef MP
 		if (option.spread) {
 			// 存储其他邀请人
-			uni.setStorageSync('spread', option.spread);
+			uni.setStorageSync('spread',option.spread);
+		}
+		if (!this.hasLogin) {
+			// 保存地址
+			saveUrl();
+			// 登录拦截
+			interceptor();
 		}
 		// #endif
 		// #ifdef MP
@@ -216,10 +223,7 @@ export default {
 	},
 	onShow: function() {
 		// 判断是否强制登录
-		// if (this.loginInterceptor && !this.hasLogin) {
-		// 	// 登录拦截
-		// 	interceptor();
-		// }
+		
 		
 		this.loadData();
 		this.getBargainList();
@@ -290,6 +294,7 @@ export default {
 			})
 		},
 		...mapMutations('latlon', ['setLat', 'setLon']),
+		...mapMutations('user',['setSpread']),
 		navToTab(url) {
 			uni.switchTab({
 				url: url

+ 2 - 2
pages/redirect/redirect.vue

@@ -13,7 +13,7 @@ import { wechatMpAuth } from '@/api/wx';
 // #endif
 export default {
 	computed: {
-		...mapState('user',['urlFile'])
+		...mapState('user',['urlFile','spreadid'])
 	},
 	onLoad(option) {
 		let obj = this;
@@ -32,7 +32,7 @@ export default {
 			let obj = this;
 			let url = window.location.href;
 			let code = url.match(/code=([0-9]|[a-z]|[A-Z])*/g)[0].replace('code=', '');
-			let spread = uni.getStorageSync('spread')||'';
+			let spread = uni.getStorageSync('spread') || ''
 			wechatAuth({
 				code: code,
 				spread:spread,

+ 10 - 5
pages/store/apply.vue

@@ -70,9 +70,13 @@
 						<view class="item-tit">联系方式:</view>
 						<input type="text" v-model="phone" placeholder="请输入您的手机号"/>
 					</view>
-					<view class="itemx">
+					<!-- <view class="itemx">
 						<view class="item-tit">店铺名称:</view>
 						<input type="text" v-model="merchant_name" placeholder="请输入店铺名称"/>
+					</view> -->
+					<view class="itemx">
+						<view class="item-tit">店长区域(镇/街道):</view>
+						<input type="text" v-model="area" placeholder="请输入店长区域"/>
 					</view>
 				</view>
 			</view>
@@ -126,6 +130,7 @@ export default {
 			sfzf: '', //身份证反面
 			yyzz: '',//营业执照
 			merchant_name: '',//店铺名称
+			area: ''//店长区域
 		};
 	},
 	onLoad() {
@@ -218,8 +223,8 @@ export default {
 				obj.$api.msg('请上传营业执照')
 				return
 			}
-			if(obj.merchant_name == '') {
-				obj.$api.msg('请输入店铺名称')
+			if(obj.area == '') {
+				obj.$api.msg('请输入会员区域')
 				return
 			}
 			let card_id = obj.sfzz + ',' + obj.sfzf
@@ -229,7 +234,7 @@ export default {
 			})
 			enter({
 				type: 1,
-				merchant_name: obj.merchant_name,
+				merchant_name: obj.area,
 				link_user: obj.name,
 				link_tel: obj.phone,
 				spread_uid: obj.speed_id,
@@ -394,7 +399,7 @@ export default {
 			height: 100rpx;
 			line-height: 100rpx;
 			padding-left: 30rpx;
-			width: 250rpx;
+			width: 310rpx;
 			font-size: 30rpx;
 			font-family: PingFang SC;
 			font-weight: 500;

+ 11 - 11
pages/user/applyMember.vue

@@ -14,11 +14,10 @@
 					<view class="item-tit">联系方式:</view>
 					<input type="text" v-model="phone" placeholder="请输入您的手机号"/>
 				</view>
-				<!-- <view class="itemx">
-					<view class="item-tit">验证码:</view>
-					<input type="text" v-model="code" placeholder="请输入验证码"/>
-					<view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
-				</view> -->
+				<view class="itemx">
+					<view class="item-tit">会员区域(村/社区):</view>
+					<input type="text" v-model="area" placeholder="请输入会员区域"/>
+				</view>
 			</view>
 		</view>
 		<view class="up-wrapper">
@@ -54,6 +53,7 @@
 				name: '',
 				speed_id: '',
 				phone: '',
+				area: '',
 				// code: '',
 				sfzz: '', //身份证正面
 				sfzf: '' //身份证反面
@@ -134,10 +134,10 @@
 					this.$api.msg('请输入正确的手机号');
 					return;
 				}
-				// if(obj.code == '') {
-				// 	obj.$api.msg('请输入验证码')
-				// 	return
-				// }
+				if(obj.area == '') {
+					obj.$api.msg('请输入会员区域')
+					return
+				}
 				if(obj.sfzz == '') {
 					obj.$api.msg('请上传身份证证件照')
 					return
@@ -153,7 +153,7 @@
 				})
 				enter({
 					type: 0,
-					// merchant_name: obj.merchant_name,
+					merchant_name: obj.area,
 					link_user: obj.name,
 					link_tel: obj.phone,
 					spread_uid: obj.speed_id,
@@ -206,7 +206,7 @@
 				height: 100rpx;
 				line-height: 100rpx;
 				padding-left: 30rpx;
-				width: 250rpx;
+				width: 310rpx;
 				font-size: 30rpx;
 				font-family: PingFang SC;
 				font-weight: 500;

+ 6 - 5
pages/user/shareQrCode.vue

@@ -17,7 +17,7 @@
 	</view>
 </template>
 <script>
-	// import weixinObj from "@/plugin/jweixin-module/index.js";
+import weixinObj from "@/plugin/jweixin-module/index.js";
 import { mapState } from 'vuex';
 import { spreadBanner } from '@/api/user.js';
 import { interceptor, saveUrl } from '@/utils/loginUtils';
@@ -32,13 +32,14 @@ export default {
 			imgSrc: ''
 		};
 	},
-	onLoad(option) {
+	async onLoad(option) {
 		uni.showLoading({
 			title: '邀请图生成中',
 			mask: true
 		});
 		// 判断是否强制登录
-		this.loadCodeList();
+		weixinObj.hideAllNonBaseMenuItem();
+		await this.loadCodeList();
 		// #ifdef MP-WEIXIN
 		uni.authorize({
 			scope: 'scope.writePhotosAlbum',
@@ -46,7 +47,7 @@ export default {
 		});
 		// #endif
 		// #ifdef H5
-		
+		weixinObj.showAllNonBaseMenuItem()
 		// weixinObj.showAllNonBaseMenuItem();
 		this.IndexShare()
 		// wx.ready(function () {   //需在用户可能点击分享按钮前就先调用
@@ -183,7 +184,7 @@ export default {
 				link: this.baseURL + path,
 				title: this.userInfo.nickname + '邀请您进入Xingwang鑫旺',
 				desc:'欢迎加入Xingwang鑫旺',
-				imgUrl: ''
+				imgUrl: 'http://xw.liuniu946.com/static/img/logo.png'
 			};
 			console.log(data,'分享数据');
 			shareLoad(data);

+ 2 - 2
store/index.js

@@ -8,8 +8,8 @@ Vue.use(Vuex)
 const store = new Vuex.Store({
 	state: {
 		// baseURL:"http://yrh.liuniu946.com",//'http://eb.shuibo.net',//请求地址配置 
-		baseURL:'http://xw.liuniu946.com',//请求地址配置 
-		// baseURL:'http://www.zjxwcm.cn',
+		// baseURL:'http://xw.liuniu946.com',//请求地址配置 
+		baseURL:'http://www.zjxwcm.cn',
 		urlFile:'/index',//项目部署所在文件夹
 		userInfo: {}, //登录信息
 		loginInterceptor:false,//是否打开强制登录

+ 65 - 61
store/model/user.js

@@ -1,61 +1,65 @@
-let state = {
-	userInfo: {}, //用户信息
-	orderInfo: {
-		complete_count: 0, //完成
-		received_count: 0, //待收货
-		unshipped_count: 0, //待发货
-		order_count: 0, //订单总数
-		unpaid_count: 0 //待付款
-	}, //订单信息
-	hasLogin: false, //是否登录
-}
-
-let mutations = {
-	// 登录
-	login(state) {
-		state.hasLogin = true;
-	},
-	// 退出登录
-	logout(state, provider) {
-		state.hasLogin = false;
-		// 清空基础信息
-		state.userInfo = {};
-		state.orderInfo = {
-			complete_count: 0, //完成
-			received_count: 0, //待收货
-			unshipped_count: 0, //待发货
-			order_count: 0, //订单总数
-			unpaid_count: 0 //待付款
-		};
-		// 清除缓存用户信息
-		uni.removeStorage({
-			key: 'userInfo'
-		})
-		// 清除缓存token
-		uni.removeStorage({
-			key: 'token'
-		})
-	},
-	// 保存用户信息
-	setUserInfo(state, provider) {
-		state.userInfo = provider;
-		uni.setStorage({ //缓存用户登陆状态
-			key: 'userInfo',
-			data: provider
-		})
-	},
-	// 保存订单信息
-	setOrderInfo(state, provider) {
-		state.orderInfo = provider;
-	}
-
-}
-
-let getters = {}
-
-export default {
-	namespaced: true,
-	state,
-	mutations,
-	getters
-}
+let state = {
+	userInfo: {}, //用户信息
+	orderInfo: {
+		complete_count: 0, //完成
+		received_count: 0, //待收货
+		unshipped_count: 0, //待发货
+		order_count: 0, //订单总数
+		unpaid_count: 0 //待付款
+	}, //订单信息
+	hasLogin: false, //是否登录
+	spreadid: '',
+}
+
+let mutations = {
+	setSpread(state,provider) {
+		state.spreadid = provider;
+	},
+	// 登录
+	login(state) {
+		state.hasLogin = true;
+	},
+	// 退出登录
+	logout(state, provider) {
+		state.hasLogin = false;
+		// 清空基础信息
+		state.userInfo = {};
+		state.orderInfo = {
+			complete_count: 0, //完成
+			received_count: 0, //待收货
+			unshipped_count: 0, //待发货
+			order_count: 0, //订单总数
+			unpaid_count: 0 //待付款
+		};
+		// 清除缓存用户信息
+		uni.removeStorage({
+			key: 'userInfo'
+		})
+		// 清除缓存token
+		uni.removeStorage({
+			key: 'token'
+		})
+	},
+	// 保存用户信息
+	setUserInfo(state, provider) {
+		state.userInfo = provider;
+		uni.setStorage({ //缓存用户登陆状态
+			key: 'userInfo',
+			data: provider
+		})
+	},
+	// 保存订单信息
+	setOrderInfo(state, provider) {
+		state.orderInfo = provider;
+	}
+
+}
+
+let getters = {}
+
+export default {
+	namespaced: true,
+	state,
+	mutations,
+	getters
+}

+ 59 - 59
utils/loginUtils.js

@@ -1,59 +1,59 @@
-export function getActionPage() {
-	let pages = getCurrentPages();
-	return pages[pages.length - 1]
-}
-//登录拦截
-export function interceptor() {
-	let pages = getActionPage();
-	// 获取当前页面
-	let pageUrl = '/' + pages.route;
-	let url = '/pages/public/login'
-	// #ifdef H5
-	// 判断是否为公众号调用微信授权登录
-	let weichatBrowser = uni.getStorageSync('weichatBrowser');
-	if (weichatBrowser) {
-		url = '/pages/public/wxLogin';
-	}
-	// #endif
-	// #ifdef MP-WEIXIN
-	url = '/pages/public/wxLogin';
-	// #endif
-	if (pageUrl != url) {
-		uni.navigateTo({
-			url
-		})
-	}
-}
-
-// 保存页面
-export function saveUrl() {
-	let path = getPageUrl(true)
-	uni.setStorageSync('present', path);
-}
-
-// 处理分享链接地址
-export function getPageUrl(showSpeard=false) {
-	let page = getActionPage();
-	let path = '/' + page.route;
-	let url = '';
-	// 获取对象可枚举键值列表
-	let objKeys = Object.keys(page.options);
-	// 判断有无传值
-	if (objKeys.length > 0) {
-		// 循环赋值对象数据
-		for (let a in page.options) {
-			// 判断有无邀请人
-			if (a != 'speard') {
-				url += a + "=" + page.options[a] + "&"
-			}else{
-				// 判断是否需要存储邀请人
-				if(showSpeard){
-					url += a + "=" + page.options[a] + "&"
-				}
-			}
-		}
-		path += '?' + url.substr(0, url.length - 1);
-	}
-	// 返回处理邀请人后的邀请地址
-	return path
-}
+export function getActionPage() {
+	let pages = getCurrentPages();
+	return pages[pages.length - 1]
+}
+//登录拦截
+export function interceptor() {
+	let pages = getActionPage();
+	// 获取当前页面
+	let pageUrl = '/' + pages.route;
+	let url = '/pages/public/login'
+	// #ifdef H5
+	// 判断是否为公众号调用微信授权登录
+	let weichatBrowser = uni.getStorageSync('weichatBrowser');
+	if (weichatBrowser) {
+		url = '/pages/public/wxLogin';
+	}
+	// #endif
+	// #ifdef MP-WEIXIN
+	url = '/pages/public/wxLogin';
+	// #endif
+	if (pageUrl != url) {
+		uni.navigateTo({
+			url
+		})
+	}
+}
+
+// 保存页面
+export function saveUrl() {
+	let path = getPageUrl(true)
+	uni.setStorageSync('present', path);
+}
+
+// 处理分享链接地址
+export function getPageUrl(showSpeard=false) {
+	let page = getActionPage();
+	let path = '/' + page.route;
+	let url = '';
+	// 获取对象可枚举键值列表
+	let objKeys = Object.keys(page.options);
+	// 判断有无传值
+	if (objKeys.length > 0) {
+		// 循环赋值对象数据
+		for (let a in page.options) {
+			// 判断有无邀请人
+			if (a != 'spread') {
+				url += a + "=" + page.options[a] + "&"
+			}else{
+				// 判断是否需要存储邀请人
+				if(showSpeard){
+					url += a + "=" + page.options[a] + "&"
+				}
+			}
+		}
+		path += '?' + url.substr(0, url.length - 1);
+	}
+	// 返回处理邀请人后的邀请地址
+	return path
+}

+ 120 - 119
utils/rocessor.js

@@ -1,120 +1,121 @@
-//身份证验证	
-export function isCardNo(card) {
-	// 身份证号码为15位或者18位,15位时全为数字,18位前17位为数字,最后一位是校验位,可能为数字或字符X 
-	var reg =
-		/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/;
-	if (reg.test(card) === false) {
-		console.log(card);
-		return false;
-
-	}
-	return true
-}
-
-// 金额显示变化
-export function getMoneyStyle(value = 0) {
-	if (typeof value == 'string') {
-		value = (+value).toFixed(2)
-	}
-	if (typeof value == 'number') {
-		value = value.toFixed(2)
-	}
-	// 将字符串转为数组
-	let n = value.split("");
-	// 反转数组并复制循环处理
-	let arr = n.reverse().map(function(e, ind, ar) {
-		// 判断当前下标是否为3的整数倍数且不为最后一个下标
-		if (ind % 3 == 0 && ind / 3 > 1 && ind != ar.length) {
-			return e + ','
-		} else {
-			return e
-		}
-	})
-	// 反转数组回复原来排序并合并回字符串
-	arr = arr.reverse().join('')
-	return arr;
-}
-
-// 倒计时计算
-// 计算倒计时时间
-export function timeComputed(time) {
-	// 获取当前时间
-	const actTime = (new Date()).getTime();
-	// 获取到期时间
-	let stopTime = time - actTime;
-	// 判断是否小于0
-	if (stopTime < 0) {
-		stopTime = stopTime * -1
-	}
-	let day = Math.floor(stopTime / 1000 / 60 / 60 / 24) //获取剩余天数
-	let hours = Math.floor((stopTime / 1000 / 60 / 60) % 24); //获取剩余小时数
-	let minutes = Math.floor((stopTime / 1000 / 60) % 60); //获取分钟
-	let seconds = Math.floor((stopTime / 1000) % 60); //获取秒数
-	return {
-		hours, //倒计时小时数
-		minutes, //倒计时分钟数
-		seconds, //倒计时秒数
-		day //倒计时天数
-	}
-}
-
-// 调用打开地图方法
-export function openMap(e) {
-	const that = this
-	return new Promise((resolve, reject) => {
-		wx.getSetting({
-			success(res) {
-				//这里判断是否有地位权限
-				if (!res.authSetting['scope.userLocation']) {
-					wx.showModal({
-						title: '提示',
-						content: '请求获取位置权限',
-						success: function(res) {
-							if (res.confirm == false) {
-								// 授权失败
-								reject()
-								return false;
-							}
-							wx.openSetting({
-								success(res) {
-									//如果再次拒绝则返回页面并提示
-									if (!res.authSetting['scope.userLocation']) {
-										wx.showToast({
-											title: '此功能需获取位置信息,请重新设置',
-											duration: 3000,
-											icon: 'none'
-										})
-									} else {
-										//允许授权,调用地图
-										resolve()
-									}
-								}
-							})
-						}
-					})
-				} else {
-					//如果有定位权限,调用地图
-					resolve()
-				}
-			}
-		})
-	})
-}
-//时间戳转换成时间
-export function getTime(time) {
-	const num =13 - (time+'').length;
-	let l = 1;//倍数
-	for (let i = 0; i < num; i++) {
-		l+='0';
-	}
-	// 重新解析为数字
-	l = parseInt(l)
-	const date = new Date(parseInt(time) * l);
-	const year = date.getFullYear();
-	const mon = date.getMonth() + 1;
-	const day = date.getDate();
-	const hours = date.getHours();
-	const minu = date.getMinutes();
-	const sec = date.getSeconds();
-	return year + '-' + mon + '-' + day + ' ' + hours + ':' + minu + ':' + sec;
+//身份证验证	
+export function isCardNo(card) {
+	// 身份证号码为15位或者18位,15位时全为数字,18位前17位为数字,最后一位是校验位,可能为数字或字符X 
+	var reg =
+		/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/;
+	if (reg.test(card) === false) {
+		console.log(card);
+		return false;
+
+	}
+	return true
+}
+
+// 金额显示变化
+export function getMoneyStyle(value = 0) {
+	if (typeof value == 'string') {
+		value = (+value).toFixed(2)
+	}
+	if (typeof value == 'number') {
+		value = value.toFixed(2)
+	}
+	// 将字符串转为数组
+	let n = value.split("");
+	// 反转数组并复制循环处理
+	let arr = n.reverse().map(function(e, ind, ar) {
+		// 判断当前下标是否为3的整数倍数且不为最后一个下标
+		if (ind % 3 == 0 && ind / 3 > 1 && ind != ar.length) {
+			return e + ','
+		} else {
+			return e
+		}
+	})
+	// 反转数组回复原来排序并合并回字符串
+	arr = arr.reverse().join('')
+	return arr;
+}
+
+// 倒计时计算
+// 计算倒计时时间
+export function timeComputed(time) {
+	// 获取当前时间
+	const actTime = (new Date()).getTime();
+	// 获取到期时间
+	let stopTime = time - actTime;
+	// 判断是否小于0
+	if (stopTime < 0) {
+		stopTime = stopTime * -1
+	}
+	let day = Math.floor(stopTime / 1000 / 60 / 60 / 24) //获取剩余天数
+	let hours = Math.floor((stopTime / 1000 / 60 / 60) % 24); //获取剩余小时数
+	let minutes = Math.floor((stopTime / 1000 / 60) % 60); //获取分钟
+	let seconds = Math.floor((stopTime / 1000) % 60); //获取秒数
+	return {
+		hours, //倒计时小时数
+		minutes, //倒计时分钟数
+		seconds, //倒计时秒数
+		day //倒计时天数
+	}
+}
+
+// 调用打开地图方法
+export function openMap(e) {
+	const that = this
+	return new Promise((resolve, reject) => {
+		wx.getSetting({
+			success(res) {
+				console.log(res,'dingwei')
+				//这里判断是否有地位权限
+				if (!res.authSetting['scope.userLocation']) {
+					wx.showModal({
+						title: '提示',
+						content: '请求获取位置权限',
+						success: function(res) {
+							if (res.confirm == false) {
+								// 授权失败
+								reject()
+								return false;
+							}
+							wx.openSetting({
+								success(res) {
+									//如果再次拒绝则返回页面并提示
+									if (!res.authSetting['scope.userLocation']) {
+										wx.showToast({
+											title: '此功能需获取位置信息,请重新设置',
+											duration: 3000,
+											icon: 'none'
+										})
+									} else {
+										//允许授权,调用地图
+										resolve()
+									}
+								}
+							})
+						}
+					})
+				} else {
+					//如果有定位权限,调用地图
+					resolve()
+				}
+			}
+		})
+	})
+}
+//时间戳转换成时间
+export function getTime(time) {
+	const num =13 - (time+'').length;
+	let l = 1;//倍数
+	for (let i = 0; i < num; i++) {
+		l+='0';
+	}
+	// 重新解析为数字
+	l = parseInt(l)
+	const date = new Date(parseInt(time) * l);
+	const year = date.getFullYear();
+	const mon = date.getMonth() + 1;
+	const day = date.getDate();
+	const hours = date.getHours();
+	const minu = date.getMinutes();
+	const sec = date.getSeconds();
+	return year + '-' + mon + '-' + day + ' ' + hours + ':' + minu + ':' + sec;
 }

+ 252 - 245
utils/wxAuthorized.js

@@ -1,245 +1,252 @@
-import {
-	wechatConfig,
-	share
-} from '@/api/wx';
-// 加载日志
-import * as log from './log.js'
-import {
-	isAndroid
-} from './platform.js'
-import store from '../store';
-// 保存wx对象
-import weixinObj from "@/plugin/jweixin-module/index.js";
-// 保存分享数据
-let shareData = '';
-// 保存注册返回appId数据
-let appId = '';
-//保存路由对象
-let router = '';
-//微信登录
-/**
- * @param {string} 当前页面地址信息
- */
-export function loginWinxin() {
-	console.log('1');
-	let pages, page, path;
-	try {
-		pages = getCurrentPages();
-		// 获取跳转前页面
-		page = pages[pages.length - 1];
-		// 获取跳转前路由地址
-		path = page.route;
-	} catch (e) {
-		console.log(e);
-		//TODO handle the exception
-	}
-	// 判断是否在登录页
-	if (path != 'pages/redirect/redirect') {
-		log.addLog('开始注册微信')
-		weixindata().then(() => {
-			console.log('2');
-			// 调用
-			try {
-				weixinSq();
-			} catch (e) {
-				console.log(e);
-				//TODO handle the exception
-			}
-		});
-	}
-};
-// 微信授权登录
-function weixinSq() {
-	// 微信授权后跳转页面
-	try {
-		// 判断是否真实路由模式
-		const type = router.mode === "history"?'':'/#'
-		let ul = encodeURIComponent(store.state.baseURL + store.state.urlFile +type+ '/pages/redirect/redirect');
-		// 打开微信授权页面
-		let url =
-			'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' +
-			appId +
-			'&redirect_uri=' +
-			ul +
-			'&response_type=code&scope=snsapi_userinfo&state=' +
-			new Date().getTime() +
-			'#wechat_redirect';
-		window.location.href = url;
-	} catch (e) {
-		console.log(e);
-		//TODO handle the exception
-	}
-};
-
-// 微信注册
-export function weixindata(config) {
-	let url;
-	try {
-		if (router.mode === "history") {
-			// 在ios中时候注册为微信刚进入时候的页面
-			if (window.entryUrl === '') {
-				window.entryUrl = location.href.split('#')[0]
-			}
-			url = isAndroid() ? location.href.split('#')[0] : window.entryUrl;
-		}
-		if (router.mode === "hash") {
-			url = location.href.split('#')[0];
-		}
-		log.addLog('注册开始', url)
-		console.log('开始注册', url);
-
-	} catch (e) {
-		console.log('错误', e);
-	}
-	return new Promise((ok, error) => {
-		try {
-			//注册微信信息
-			wechatConfig({
-					url
-				})
-				.then(({
-					data
-				}) => {
-					try {
-						// 保存appId
-						appId = data.appId
-						// 微信信息配置
-						weixinObj.config({
-							debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
-							appId: data.appId, // 必填,企业号的唯一标识,此处填写企业号corpid
-							timestamp: data.timestamp, // 必填,生成签名的时间戳
-							nonceStr: data.nonceStr, // 必填,生成签名的随机串
-							signature: data.signature, // 必填,签名,见附录1
-							jsApiList: data.jsApiList // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
-						});
-						weixinObj.ready((e) => {
-							log.addLog("注册完毕", data)
-							console.log('注册完毕');
-							ok(data)
-						})
-					} catch (e) {
-						console.log(e)
-					}
-				})
-				.catch(e => {
-					error(e);
-					console.log(e);
-				});
-		} catch (e) {
-			console.log(e);
-			//TODO handle the exception
-		}
-	})
-}
-
-// 判断分享调用方法
-export function shareLoad(config) {
-	console.log('开始调用分享')
-	try {
-		weixindata().then((e) => {
-			// 判断有无自定义数据
-			if (config) {
-				shareFun(config)
-			} else {
-				// 判断是否已经缓存了默认数据
-				if (shareData) {
-					shareFun()
-				} else {
-					// 请求获取默认数据
-					share({}).then(({
-						data
-					}) => {
-						shareData = data.data
-						shareFun()
-					});
-				}
-			}
-		})
-	} catch (e) {
-		console.log('报错', e)
-		//TODO handle the exception
-	}
-}
-// 配置分享数据
-function shareFun(config) {
-	try {
-		console.log('再付分享内容', config);
-		// uni.showModal({
-		// 	title: '链接',
-		// 	content: config.link,
-		// 	showCancel: false,
-		// 	cancelText: '',
-		// 	confirmText: '',
-		// 	success: res => {},
-		// 	fail: () => {},
-		// 	complete: () => {}
-		// });
-		let mess;
-		if (config) {
-			mess = {
-				link: config.link, // 分享链接
-				imgUrl: config.imgUrl,
-				desc: config.desc,
-				title: config.title,
-				success: config.success || function(e) {
-					console.log(e);
-				},
-				fail: config.fail || function(e) {
-					console.log(e);
-				}
-			}
-		} else {
-			const userInfo = uni.getStorageSync('userInfo')
-			console.log(userInfo);
-			const url = window.location.href + '?spread=' + userInfo.uid;
-			url = url.replace(/[\?,&]{0,1}from=singlemessage/g, '');
-			mess = {
-				title: shareData.title,
-				link: url, // 分享链接
-				imgUrl: shareData.img, // 分享图标
-				desc: shareData.synopsis,
-				success: function() {
-					// uni.showModal({
-					// 	title: '分享',
-					// 	content: '分享成功',
-					// 	showCancel: false,
-					// 	success: res => {
-					//    console.log('分享成功回调接口');
-					// 	},
-					// 	fail: () => {},
-					// 	complete: () => {}
-					// });
-				}
-			}
-		}
-		// uni.showModal({
-		// 	title:"提示",
-		// 	content:JSON.stringify(mess)
-		// })
-		console.log(mess,'data')
-		// 获取仓库数据
-		// 分享好友
-		weixinObj.updateAppMessageShareData(mess);
-		// weixinObj.onMenuShareAppMessage(mess);// 即将废弃
-
-		// 分享朋友圈
-		weixinObj.updateTimelineShareData(mess)
-		// weixinObj.onMenuShareTimeline(mess);// 即将废弃
-	} catch (e) {
-		console.log(e);
-		//TODO handle the exception
-	}
-}
-
-// 保存路由对象
-export function setRouter(route) {
-	router = route
-}
-
-export default {
-	weixinObj,
-	shareData,
-	appId,
-	setRouter,
-	shareLoad
-}
+import {
+	wechatConfig,
+	share
+} from '@/api/wx';
+// 加载日志
+import * as log from './log.js'
+import {
+	isAndroid
+} from './platform.js'
+import store from '../store';
+// 保存wx对象
+import weixinObj from "@/plugin/jweixin-module/index.js";
+// 保存分享数据
+let shareData = '';
+// 保存注册返回appId数据
+let appId = '';
+//保存路由对象
+let router = '';
+//微信登录
+/**
+ * @param {string} 当前页面地址信息
+ */
+export async function loginWinxin() {
+	console.log('1');
+	let pages, page, path;
+	if (!router) {
+		router = await setRouter();
+	}
+	try {
+		pages = getCurrentPages();
+		// 获取跳转前页面
+		page = pages[pages.length - 1];
+		// 获取跳转前路由地址
+		path = page.route;
+	} catch (e) {
+		console.log(e);
+		//TODO handle the exception
+	}
+	// 判断是否在登录页
+	if (path != 'pages/redirect/redirect') {
+		log.addLog('开始注册微信')
+		weixindata().then(() => {
+			// 调用
+			try {
+				weixinSq();
+			} catch (e) {
+				console.log(e);
+				//TODO handle the exception
+			}
+		});
+	}
+};
+// 微信授权登录
+function weixinSq() {
+	// 微信授权后跳转页面
+	try {
+		// 判断是否真实路由模式
+		const type = router.mode === "history"?'':'/#'
+		let ul = encodeURIComponent(store.state.baseURL + store.state.urlFile +type+ '/pages/redirect/redirect');
+		// 打开微信授权页面
+		let url =
+			'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' +
+			appId +
+			'&redirect_uri=' +
+			ul +
+			'&response_type=code&scope=snsapi_userinfo&state=' +
+			new Date().getTime() +
+			'#wechat_redirect';
+		window.location.href = url;
+	} catch (e) {
+		console.log(e);
+		//TODO handle the exception
+	}
+};
+
+// 微信注册
+export async function weixindata(config) {
+	let url;
+	store.commit('setWeiChatObj', weixinObj)
+	try {
+		// 判断是否存在router
+		if (!router) {
+			router = await setRouter();
+		}
+		if (router.mode === "history") {
+			// 在ios中时候注册为微信刚进入时候的页面
+			if (!window.entryUrl) {
+				window.entryUrl = location.href.split('#')[0]
+			}
+			url = isAndroid() ? location.href.split('#')[0] : window.entryUrl;
+		}
+		if (router.mode === "hash") {
+			url = location.href.split('#')[0];
+		}
+		log.addLog('注册开始', url)
+		console.log('开始注册', url);
+
+	} catch (e) {
+		console.log('错误', e);
+	}
+	return new Promise((ok, error) => {
+		try {
+			//注册微信信息
+			wechatConfig({
+					url
+				})
+				.then(({
+					data
+				}) => {
+					try {
+						// 保存appId
+						appId = data.appId
+						// 微信信息配置
+						weixinObj.config({
+							debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+							appId: data.appId, // 必填,企业号的唯一标识,此处填写企业号corpid
+							timestamp: data.timestamp, // 必填,生成签名的时间戳
+							nonceStr: data.nonceStr, // 必填,生成签名的随机串
+							signature: data.signature, // 必填,签名,见附录1
+							jsApiList: data.jsApiList // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
+						});
+						weixinObj.ready((e) => {
+							log.addLog("注册完毕", data)
+							console.log('注册完毕');
+							ok(data)
+						})
+					} catch (e) {
+						console.log(e)
+					}
+				})
+				.catch(e => {
+					error(e);
+					console.log(e);
+				});
+		} catch (e) {
+			console.log(e);
+			//TODO handle the exception
+		}
+	})
+}
+
+// 判断分享调用方法
+export function shareLoad(config) {
+	console.log('开始调用分享')
+	try {
+		weixindata().then((e) => {
+			// 判断有无自定义数据
+			if (config) {
+				shareFun(config)
+			} else {
+				// 判断是否已经缓存了默认数据
+				if (shareData) {
+					shareFun()
+				} else {
+					// 请求获取默认数据
+					share({}).then(({
+						data
+					}) => {
+						shareData = data.data
+						shareFun()
+					});
+				}
+			}
+		})
+	} catch (e) {
+		console.log('报错', e)
+		//TODO handle the exception
+	}
+}
+// 配置分享数据
+function shareFun(config) {
+	try {
+		console.log('再付分享内容', config);
+		let mess;
+		if (config) {
+			mess = {
+				link: config.link, // 分享链接
+				imgUrl: config.imgUrl,
+				desc: config.desc,
+				title: config.title,
+				success: config.success || function(e) {
+					console.log(e);
+				},
+				fail: config.fail || function(e) {
+					console.log(e);
+				}
+			}
+		} else {
+			const userInfo = uni.getStorageSync('userInfo')
+			console.log(userInfo);
+			const url = window.location.href + '?spread=' + userInfo.uid;
+			url = url.replace(/[\?,&]{0,1}from=singlemessage/g, '');
+			mess = {
+				title: shareData.title,
+				link: url, // 分享链接
+				imgUrl: shareData.img, // 分享图标
+				desc: shareData.synopsis,
+				success: function() {
+					// uni.showModal({
+					// 	title: '分享',
+					// 	content: '分享成功',
+					// 	showCancel: false,
+					// 	success: res => {
+					//    console.log('分享成功回调接口');
+					// 	},
+					// 	fail: () => {},
+					// 	complete: () => {}
+					// });
+				}
+			}
+		}
+		// 获取仓库数据
+		// 分享好友
+		weixinObj.updateAppMessageShareData(mess);
+
+		// 分享朋友圈
+		weixinObj.updateTimelineShareData(mess)
+	} catch (e) {
+		console.log(e);
+		//TODO handle the exception
+	}
+}
+
+// 保存路由对象
+export function setRouter(route) {
+	return new Promise((ok, err) => {
+		router = getApp().$router;
+		// console.log(router,'开始数据');
+		if (!router) {
+			const set = setInterval(() => {
+				router = getApp().$router;
+				// console.log(router,'返回数据');
+				if (router) {
+					// console.log(router,'结束');
+					clearInterval(set)
+					ok(router)
+				}
+			}, 100);
+		}else{
+			// console.log(router,'成功');
+			ok(router)
+		}
+	})
+}
+
+export default {
+	weixinObj,
+	shareData,
+	appId,
+	setRouter,
+	shareLoad
+}