he2802 3 سال پیش
والد
کامیت
5f119ef2a2
4فایلهای تغییر یافته به همراه81 افزوده شده و 18 حذف شده
  1. 41 0
      common/methodTool.js
  2. 2 2
      pages.json
  3. 11 5
      pages/login/login.vue
  4. 27 11
      pages2/wd/info.vue

+ 41 - 0
common/methodTool.js

@@ -100,5 +100,46 @@ export default {
 		var tmp = Date.parse(new Date()).toString();
 		tmp = tmp.substr(0, 10);
 		return tmp;
+	},
+	getYears(strBirthday) {
+		
+		if (!strBirthday) {
+			return '未知';
+		}
+		var returnAge;
+		var strBirthdayArr = strBirthday.split('-');
+		var birthYear = strBirthdayArr[0];
+		var birthMonth = strBirthdayArr[1];
+		var birthDay = strBirthdayArr[2];
+		var d = new Date();
+		var nowYear = d.getFullYear();
+		var nowMonth = d.getMonth() + 1;
+		var nowDay = d.getDate();
+	
+		if (nowYear == birthYear) {
+			returnAge = 0; //同年 则为0岁
+		} else {
+			var ageDiff = nowYear - birthYear; //年之差
+			if (ageDiff > 0) {
+				if (nowMonth == birthMonth) {
+					var dayDiff = nowDay - birthDay; //日之差
+					if (dayDiff < 0) {
+						returnAge = ageDiff - 1;
+					} else {
+						returnAge = ageDiff;
+					}
+				} else {
+					var monthDiff = nowMonth - birthMonth; //月之差
+					if (monthDiff < 0) {
+						returnAge = ageDiff - 1;
+					} else {
+						returnAge = ageDiff;
+					}
+				}
+			} else {
+				returnAge = -1; //返回-1 表示出生日期输入错误 晚于今天
+			}
+		}
+		return returnAge; //返回周岁年龄
 	}
 }

+ 2 - 2
pages.json

@@ -295,12 +295,12 @@
 			}
 		}
 	}],
-	"preloadRule": {
+	/* "preloadRule": {
 		"pages/index/index": {
 			"network": "all",
 			"packages": ["pages2"]
 		}
-	},
+	}, */
 	"globalStyle": {
 		"navigationBarTextStyle": "black",
 		"navigationBarTitleText": "WeChat",

+ 11 - 5
pages/login/login.vue

@@ -134,8 +134,8 @@ export default {
 				return 
 			}
 			//虚拟登录
-			that.fakeLogin()
-			return
+			/* that.fakeLogin()
+			return */
 			that.isUse = true
 			that.$api.accountLogin(this.form).then(
 				res => {
@@ -145,9 +145,15 @@ export default {
 							//信息完善,直接进入页面
 							uni.setStorageSync('user_account', res.data.data.user_account);
 							uni.setStorageSync('token', res.data.data.token);
-							uni.switchTab({
-								url:'/pages/index/index'
-							})
+							that.$api.getInfo().then(resdata => {
+								if(resdata.data.code == 200){
+									uni.switchTab({
+										url:'/pages/index/index'
+									})
+									that.$store.state.userInfo = resdata.data.data;
+								}
+								
+							});
 						}else{
 							//未完善信息,存为临时信息
 							uni.setStorageSync('user_account_temp', res.data.data.user_account);

+ 27 - 11
pages2/wd/info.vue

@@ -8,32 +8,37 @@
 	<view  class="loginBox">
 		<view style="display: flex;height: 160rpx;justify-content: center;" >
 			<view style="text-align: center;">
-				<image  src="https://file-dev.xyyxt.net/oss/images/avatar/20210623/1624414559368_44562477.png" class="avatar"></image>
-				<view class="nick">倪虹洁</view>
+				<image  :src="$method.splitImgHost(form.avatar, true)" class="avatar"></image>
+				<view class="nick">{{form.realname}}</view>
 				<view>
 					<view class="item">
 						<view>我的昵称</view>
-						<view>倪虹洁<u-icon name="arrow-right" color="#999999" size="28"></u-icon></view>
+						<view>{{form.nickname}}<u-icon name="arrow-right" color="#999999" size="28"></u-icon></view>
 					</view>
 					<view class="item">
 						<view>性别</view>
-						<view>请选择性别<u-icon name="arrow-right" color="#999999" size="28"></u-icon></view>
+						<view>{{ array_sex[form.sex] }}<u-icon name="arrow-right" color="#999999" size="28"></u-icon></view>
 					</view>
 					<view class="item">
 						<view>年龄</view>
-						<view>请填写年龄<u-icon name="arrow-right" color="#999999" size="28"></u-icon></view>
+						<view>{{ $method.getYears(form.userBirth) }}<u-icon name="arrow-right" color="#999999" size="28"></u-icon></view>
 					</view>
 					<view class="item">
 						<view>关联学员身份</view>
-						<view>012345678987654321<u-icon name="arrow-right" color="#999999" size="28"></u-icon></view>
+						<view style="display: flex;">
+							<view style="text-align: right;">
+								<view>{{ form.realname }}</view>
+								<view>{{ form.idCard }}</view>
+							</view>
+							<u-icon name="arrow-right" color="#999999" size="28"></u-icon></view>
 					</view>
 					<view class="item">
 						<view>所在城市</view>
-						<view>广东省广州市天河区<u-icon name="arrow-right" color="#999999" size="28"></u-icon></view>
+						<view>{{ form.province }}-{{ form.city }}-{{ form.district }}<u-icon name="arrow-right" color="#999999" size="28"></u-icon></view>
 					</view>
 					<view class="item">
 						<view>手机号码</view>
-						<view>13800138000<u-icon name="arrow-right" color="#999999" size="28"></u-icon></view>
+						<view>{{ form.telphone }}<u-icon name="arrow-right" color="#999999" size="28"></u-icon></view>
 					</view>
 					<view class="item">
 						<view>微信绑定</view>
@@ -53,18 +58,28 @@
 export default {
 	data() {
 		return {
-			
+			form:{},
+			array_sex: ['男', '女'],
 			
 		};
 	},
-	onReady() {
-		
+	onShow(){
+		this.form = this.userInfo
+		console.log(this.form)
 	},
 	onLoad(option) {
 		
 	},
 	methods: {
 		
+	},
+	computed: {...mapGetters(['userInfo'])},
+	watch:{
+		userInfo(val, oldVal){//普通的watch监听
+		     if(val){
+				 this.form = this.userInfo
+			 }
+		 },
 	}
 	
 };
@@ -88,6 +103,7 @@ export default {
 		justify-content: space-between;
 		padding: 0 20rpx;
 		margin-top: 30rpx;
+		font-size: 24rpx;
 	}
 	.nick{
 		font-size: 36rpx;