Преглед изворни кода

commit -m 用户授权登录

zhengjinyi пре 4 година
родитељ
комит
9adb8995b3
5 измењених фајлова са 139 додато и 271 уклоњено
  1. 14 1
      App.vue
  2. 9 9
      common/config/addressdata.js
  3. 91 213
      pages/index/index.vue
  4. 23 46
      pages/login/login.vue
  5. 2 2
      services/user.service.js

+ 14 - 1
App.vue

@@ -67,12 +67,25 @@
 			}
 		},
 		methods:{
+			async getWxAuthorize() {
+				const wechatCode = await authorize.getCode('weixin')
+				this.UserService.userInfoLogin({code:wechatCode}).then(response=>{
+					this.login(response.data);
+					this.$store.commit('updateStatus',response.data)
+				}).catch(error =>{
+					uni.setStorage({//缓存游客用户openid
+					    key: 'openid',
+					    data: error.data.openid
+					})
+					this.logout()
+				})
+			},
 			refresh(){
 				let TIME = (20*60)*1000;
 				setInterval(()=>{
 					authorize.getSetting().then(res =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
 						if(res == 1){
-							wxLogin.wxLoginAuthorize()
+							this.getWxAuthorize()
 						}else{
 							console.log('授权失败============>:'+'用户取消授权或者未操作')
 						}

+ 9 - 9
common/config/addressdata.js

@@ -7,15 +7,15 @@ const provinceData=[];
 const cityData=[];
 const areaData=[];
 
-queryAddressInformation().then(res =>{
-	let list = res.data;
-	list.forEach(item => {
-		let xxx = handleCitys(item);
-		provinceData.push(item);
-		cityData.push(xxx.e);
-		areaData.push(xxx.f);
-	})
-})
+// queryAddressInformation().then(res =>{
+// 	let list = res.data;
+// 	list.forEach(item => {
+// 		let xxx = handleCitys(item);
+// 		provinceData.push(item);
+// 		cityData.push(xxx.e);
+// 		areaData.push(xxx.f);
+// 	})
+// })
 //获取市后继续处理
 function handleCitys(data) {
     const x = [];

+ 91 - 213
pages/index/index.vue

@@ -1,79 +1,81 @@
 <template>
 	<view class="container">
 		<!-- 机构信息区域 -->
-		<view class="ws-header">
-			<!-- 用户信息 -->
-			<view class="user-info">
-				<image src="@/static/ws/default_avatar.png" mode="widthFix"></image>
-				<view
-					class="ws-login"
-					@click="navigator('/pages/login/login')"
-					v-if="!hasLogin"
-				>
-					请登录
+		<template v-if="isRequest">
+			<view class="ws-header">
+				<!-- 用户信息 -->
+				<view class="user-info">
+					<image src="@/static/ws/default_avatar.png" mode="widthFix"></image>
+					<view
+						class="ws-login"
+						@click="navigator('/pages/login/login')"
+						v-if="!hasLogin"
+					>
+						请登录
+					</view>
+					<view class="user-text" v-else> {{ organizeName }} </view>
 				</view>
-				<view class="user-text" v-else> 瑞恺迪光电科技有限公司有限公司 </view>
+				<!-- 背景图 -->
+				<image class="user-bg" src="@/static/ws/user_bg.png" mode="widthFix"></image>
 			</view>
-			<!-- 背景图 -->
-			<image class="user-bg" src="@/static/ws/user_bg.png" mode="widthFix"></image>
-		</view>
-		<!-- 机构信息END -->
-		<!-- 订单状态区域 -->
-		<view class="order-wrap">
-			<view class="more">
-				<text class="title">我的订单</text>
-				<view @click="navigator('/pages/user/order/order-list?state=0')">
-					<text class="more-right">全部订单</text>
-					<text class="iconfont icon-chakangengduo"></text>
+			<!-- 机构信息END -->
+			<!-- 订单状态区域 -->
+			<view class="order-wrap">
+				<view class="more">
+					<text class="title">我的订单</text>
+					<view @click="navigator('/pages/user/order/order-list?state=0')">
+						<text class="more-right">全部订单</text>
+						<text class="iconfont icon-chakangengduo"></text>
+					</view>
 				</view>
-			</view>
-			<view class="line"></view>
-			<!-- 菜单选项 -->
-			<view class="order-nav">
-				<view
-					class="order-nav-item"
-					@click="navigator('/pages/user/order/order-list?state=1')"
-				>
-					<image src="@/static/ws/dh_dfk_02.png" mode="widthFix"></image>
-					<text>待付款</text>
-				</view>
-				<view
-					class="order-nav-item"
-					@click="navigator('/pages/user/order/order-list?state=2')"
-				>
-					<image src="@/static/ws/dh_dfh_03.png" mode="widthFix"></image>
-					<text>待发货</text>
-				</view>
-				<view
-					class="order-nav-item"
-					@click="navigator('/pages/user/order/order-list?state=3')"
-				>
-					<image src="@/static/ws/dh_yfh_04.png" mode="widthFix"></image>
-					<text>已发货</text>
-				</view>
-				<view
-					class="order-nav-item"
-					@click="navigator('/pages/user/order/order-list?state=4')"
-				>
-					<image src="@/static/ws/dh_tk_05.png" mode="widthFix"></image>
-					<text>退货/款</text>
+				<view class="line"></view>
+				<!-- 菜单选项 -->
+				<view class="order-nav">
+					<view
+						class="order-nav-item"
+						@click="navigator('/pages/user/order/order-list?state=1')"
+					>
+						<image src="@/static/ws/dh_dfk_02.png" mode="widthFix"></image>
+						<text>待付款</text>
+					</view>
+					<view
+						class="order-nav-item"
+						@click="navigator('/pages/user/order/order-list?state=2')"
+					>
+						<image src="@/static/ws/dh_dfh_03.png" mode="widthFix"></image>
+						<text>待发货</text>
+					</view>
+					<view
+						class="order-nav-item"
+						@click="navigator('/pages/user/order/order-list?state=3')"
+					>
+						<image src="@/static/ws/dh_yfh_04.png" mode="widthFix"></image>
+						<text>已发货</text>
+					</view>
+					<view
+						class="order-nav-item"
+						@click="navigator('/pages/user/order/order-list?state=4')"
+					>
+						<image src="@/static/ws/dh_tk_05.png" mode="widthFix"></image>
+						<text>退货/款</text>
+					</view>
 				</view>
 			</view>
-		</view>
-		<!-- 订单状态区域END -->
-		<!-- 帮机构下单 -->
-		<view class="place-order" @click="navigator('/pages/user/club/club-list')">
-			<view class="place-left">
-				<text class="iconfont icon-bangjigouxiadan"></text>
-				<text class="title">帮机构下单</text>
+			<!-- 订单状态区域END -->
+			<!-- 帮机构下单 -->
+			<view class="place-order" @click="navigator('/pages/user/club/club-list')">
+				<view class="place-left">
+					<text class="iconfont icon-bangjigouxiadan"></text>
+					<text class="title">帮机构下单</text>
+				</view>
+				<text class="iconfont icon-chakangengduo"></text>
 			</view>
-			<text class="iconfont icon-chakangengduo"></text>
-		</view>
-		<!-- 帮机构下单END -->
-		<!-- 客服 -->
-		<button class="ws-service" open-type="contact" @bindcontact="handleContact">
-			<text class="iconfont icon-zaixiankefu"></text> 在线客服
-		</button>
+			<!-- 帮机构下单END -->
+			<!-- 客服 -->
+			<button class="ws-service" open-type="contact" @bindcontact="handleContact">
+				<text class="iconfont icon-zaixiankefu"></text> 在线客服
+			</button>
+		</template>
 	</view>
 </template>
 
@@ -97,33 +99,12 @@ export default {
 			},
 			CustomBar: this.CustomBar, // 顶部导航栏高度
 			StatusBar: this.StatusBar,
-			isCmcustom: false,
-			isUpgradeAlert: false,
-			bgImgUrl:
-				'https://img.caimei365.com/group1/M00/03/B0/Cmis217Z_i6ASHobAAhl69yz3SM078.png',
-			name: '',
-			userType: '',
-			headpic: '',
-			userMoney: '0.00',
-			contactNumber: '',
-			openid: '',
-			aboutHtml: '',
-			telPhone: '',
-			bindMobile: '',
-			clubStatus: '', //机构升级会员机构审核状态1:待审核  91:审核失败
-			userIdentity: '', //机构等级
-			confirmedCount: 0, //待确认
+			organizeName:'',
+			isRequest:false,
 			paymentCount: 0, //待付款角标
 			waitShipmentsCount: 0, //待收货角标
 			shipmentsCount: 0, //已发货角标
-			salesReturnCount: '', //退货/款角标
-			firstList: [
-				{
-					name: '帮机构下单',
-					path: '/pages/user/club/club-list',
-					icon: 'icon-yunyingrenyuanguanli'
-				}
-			]
+			salesReturnCount: '' //退货/款角标
 		}
 	},
 	onLoad() {
@@ -132,15 +113,7 @@ export default {
 			if (res == 1) {
 				this.getWxAuthorize()
 			} else {
-				this.$api
-					.getComStorage('userInfo')
-					.then(resolve => {
-						this.userID = resolve.userID ? resolve.userID : 0
-						// this.getHomeInformation()
-					})
-					.catch(error => {
-						// this.getHomeInformation()
-					})
+
 			}
 		})
 	},
@@ -154,96 +127,28 @@ export default {
 			// const wechatCode = await
 			const wechatCode = await authorize.getCode('weixin')
 			// 初始化用户状态
-			// const res = await userInfoLogin({code:wechatCode})
-			const res = await this.UserService.userInfoLogin({code:wechatCode})
-			console.log(res)
-			if(res.code === -1){
-				this.navigator('/pages/login/login')
-			}
+			this.UserService.userInfoLogin({code:wechatCode}).then(response=>{
+				this.login(response.data);
+				this.$store.commit('updateStatus',response.data)
+				this.organizeName = response.data.organizeName
+				this.paymentCount = this.showBadge(response.data.paymentCount) //待付款
+				this.waitShipmentsCount = this.showBadge(response.data.waitShipmentsCount) //待收货
+				this.shipmentsCount = this.showBadge(response.data.shipmentsCount) //已发货
+				this.salesReturnCount = this.showBadge(response.data.salesReturnCount) //退货/款
+				this.isRequest = true
+			}).catch(error =>{
+				uni.setStorage({//缓存游客用户openid
+				    key: 'openid',
+				    data: error.data.openid
+				})
+				this.logout()
+			})
 		},
 		// 客服
 		handleContact(e) {
 			console.log(e.detail.path)
 			console.log(e.detail.query)
 		},
-		getUserInfo() {
-			let self = this
-			this.UserService.PersonalInfo({ userID: this.userID })
-				.then(response => {
-					this.$store.commit('updateAllNum', response.data.count)
-					let data = response.data
-					let $userData = data.user
-					let $clubData = data.club
-					if ($userData.ableUserMoney == 0 || $userData.ableUserMoney == null) {
-						this.userMoney = '0.00'
-					} else {
-						let i = $userData.ableUserMoney.toString().lastIndexOf('.')
-						let money
-						if (i == -1) {
-							money = this.$api.FormatMoney($userData.ableUserMoney) //会所剩余余额
-							this.userMoney = money + '.00'
-						} else {
-							money = this.$api.FormatMoney($userData.ableUserMoney) //会所剩余余额
-							this.userMoney = money
-						}
-					}
-					this.userIdentity = $userData.userIdentity //机构等级
-					if (this.userIdentity == 2) {
-						this.name = $clubData.name //会员机构名称
-						this.userType = '会员机构'
-					} else {
-						this.name = $userData.userName //普通机构名称
-						this.userType = '普通机构'
-					}
-					this.headpic = $userData.image //会所头像
-					this.bindMobile = $userData.bindMobile //登录手机号
-					this.clubStatus = $userData.clubStatus //机构审核状态
-					this.contactNumber = data.organize.contactNumber //联系电话
-					this.confirmedCount = this.showBadge(data.confirmedCount) //待确认
-					this.paymentCount = this.showBadge(data.paymentCount) //待付款
-					this.waitShipmentsCount = this.showBadge(data.waitShipmentsCount) //待收货
-					this.shipmentsCount = this.showBadge(data.shipmentsCount) //已发货
-					this.salesReturnCount = this.showBadge(data.salesReturnCount) //退货/款
-					let clubInfo = {
-						name: this.name,
-						image: this.headpic,
-						clubID: $clubData.clubID
-					}
-					if ($userData.tipStatus == '0') {
-						this.isUpgradeAlert = true
-					}
-					uni.setStorage({ key: 'clubInfo', data: clubInfo })
-				})
-				.catch(error => {
-					this.$util.msg(error.msg, 2000)
-				})
-		},
-		getPhone() {
-			this.CommonService.QueryAfterSale()
-				.then(response => {
-					this.contactNumber = response.data.contactNumber
-				})
-				.catch(error => {
-					this.$util.msg(error.msg, 2000)
-				})
-		},
-		toPhone() {
-			uni.makePhoneCall({
-				phoneNumber: this.contactNumber //仅为示例
-			})
-		},
-		hanldUnBindUpgrade() {
-			//普通用户不升级会员机构
-			cancelPrompt({ userId: this.userID }).then(response => {
-				this.isUpgradeAlert = false
-			})
-		},
-		hanldGoApply() {
-			cancelPrompt({ userId: this.userID }).then(response => {
-				this.isUpgradeAlert = false
-				this.$api.navigateTo(`/pages/login/apply?clubStatus=${this.clubStatus}`)
-			})
-		},
 		navigator(url) {
 			authorize.getSetting().then(wxResponse => {
 				// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
@@ -251,7 +156,7 @@ export default {
 					if (this.hasLogin) {
 						this.$api.navigateTo(url)
 					} else {
-						this.$api.navigateTo('/pages/login/login?type=0')
+						this.$api.navigateTo('/pages/login/login')
 					}
 				} else {
 					this.$api.navigateTo('/pages/authorization/authorization?type=1')
@@ -278,39 +183,12 @@ export default {
 				num = n
 			}
 			return num
-		},
-		clubStatusText(state) {
-			let stateText
-			switch (state) {
-				case 90:
-					stateText = ''
-					break
-				case 1:
-					stateText = '正在审核中'
-					break
-				case 92:
-					stateText = '审核不通过'
-					break
-			}
-			return stateText
-		}
-	},
-	onPageScroll(e) {
-		//实时获取到滚动的值
-		if (e.scrollTop > 20) {
-			this.isCmcustom = true
-			this.nvabarData.bgColor = '#E37A4B'
-			this.nvabarData.textColor = '#FFFFFF'
-		} else {
-			this.isCmcustom = false
-			this.nvabarData.bgColor = ''
-			this.nvabarData.textColor = '#FFFFFF'
 		}
 	},
 	onPullDownRefresh() {
 		//下拉刷新
 		if (this.hasLogin) {
-			this.getUserInfo()
+			this.getWxAuthorize()
 			uni.stopPullDownRefresh()
 		} else {
 			uni.stopPullDownRefresh()

+ 23 - 46
pages/login/login.vue

@@ -53,59 +53,30 @@ export default {
 		...mapMutations(['login']),
 		// 登录
 		goLogin() {
-			if (this.invitationCode == '') {
-				this.$util.msg('请输入邀请码', 2000)
-				return
-			}
-			// 获取用户信息
+			// 获取用户微信信息
 			wx.getUserInfo({
 				success: res => {
 					this.isUserInfo = false
 					this.userInfo = res.userInfo
 					let params = {
-						invitationCode: this.invitationCode,
-						nickName: res.userInfo.nickName,
-						headimgurl: res.userInfo.avatarUrl
+							invitationCode: this.invitationCode,
+							nickName: res.userInfo.nickName,
+							openid: uni.getStorageSync('openid')
 					}
 					// 验证邀请码
-					invitationCodeLogin(params)
-						.then(response => {
-							// 保存用户信息
-							this.login(response.data)
-							wxLogin.wxLoginAuthorize()
-							if (response.data.userIdentity === 3) {
-								setTimeout(() => {
-									this.$api.navigateTo('/supplier/pages/index/index')
-								}, 1000)
-							} else {
-								setTimeout(() => {
-									switch (this.isLoginType) {
-										case 9:
-											this.$api.navigateTo(`/h5/pages/activity/activity_mid`)
-											break
-										case 8:
-											this.$api.navigateTo(
-												`/pages/goods/product?id=${this.isLoginProductId}`
-											)
-											break
-										case 7:
-											this.$api.navigateTo(
-												`/pages/user/order/order-details?type=share&orderID=${
-													this.isLoginOrderId
-												}`
-											)
-											break
-										default:
-											this.$api.switchTabTo('/pages/tabBar/user/user')
-									}
-								}, 1000)
-							}
-						})
-						.catch(error => {
-							// this.$util.msg(error.msg, 2000)
-							this.loginMessage = error.msg
-							this.isUserInfo = false
-						})
+					this.UserService.userInvitation(params).then(response => {
+						console.log(response)
+						// 保存用户信息
+						this.login(response.data)
+						this.$store.commit('updateStatus',response.data)
+						setTimeout(()=>{
+							this.$api.navigateTo(`/pages/index/index`)
+						},1500)
+					}).catch(error => {
+						this.loginMessage = error.msg
+						this.isUserInfo = false
+						// this.$util.msg(error.msg, 2000)
+					})
 				}
 			})
 		},
@@ -131,6 +102,10 @@ export default {
 		clearValue() {
 			this.$refs.VcodeInput.clearValue()
 		}
+	},
+	onShow() {
+		
+		
 	}
 }
 </script>
@@ -172,6 +147,8 @@ export default {
 		background-color: #000;
 		border-radius: 45rpx;
 		color: #fff;
+		box-shadow: 4rpx 4rpx 40rpx rgba(0, 0, 0, 0.2);
+		margin-top: 40rpx;
 	}
 	.login-input {
 		margin: 30rpx 0;

+ 2 - 2
services/user.service.js

@@ -14,7 +14,7 @@ export default class UserService {
 			url: '/buyer/authorization',
 			data,
 			isLoading: false,
-			isStatus: true
+			isStatus: false
 		})
 	}
 	/*维沙邀请码绑定*/
@@ -23,7 +23,7 @@ export default class UserService {
 			url: '/buyer/invitation/code',
 			data,
 			isLoading: false,
-			isStatus: true
+			isStatus: false
 		})
 	}
 	/* 供应商注册 */