Prechádzať zdrojové kódy

Merge branch 'master' of http://code.xiudo.cn/yty/uni-xiudoyou

ltx529596 4 rokov pred
rodič
commit
66611e8565
3 zmenil súbory, kde vykonal 42 pridanie a 9 odobranie
  1. 1 1
      src/pages.json
  2. 8 3
      src/pages/index/index.vue
  3. 33 5
      src/pages/public/login.vue

+ 1 - 1
src/pages.json

@@ -3,7 +3,7 @@
     {
       "path": "pages/public/login",
       "style":{
-        "navigationBarTitleText": "登",
+        "navigationBarTitleText": "登",
         "navigationBarTextStyle": "black",
         "navigationBarBackgroundColor":"#ffffff",
         "enablePullDownRefresh":true

+ 8 - 3
src/pages/index/index.vue

@@ -22,10 +22,10 @@
 				</view>
 				<view class="user">
 					<view class="user-left">
-						<image src="" mode="" class="usericon"></image>
+						<image :src="userInfo.avatarUrl" mode="" class="usericon"></image>
 						<view class="message">
-							<view class="name">猪猪虾</view>
-							<view class="tele">151123165441</view>
+							<view class="name">{{userInfo.nickName}}</view>
+							<view class="tele"></view>
 						</view>
 					</view>
 					<view class="user-right" @tap="scanCode">
@@ -277,6 +277,8 @@ export default {
   },
   data() {
     return {
+      //用户信息
+      userInfo:uni.getStorageSync('wechatUserInfo'),
       loading: true,
       
       // 遮罩层
@@ -353,6 +355,7 @@ export default {
   // 页面生命周期 监听页面加载
   onLoad() {
     _self = this;
+    console.log(this.userInfo)
     this.cWidth = uni.upx2px(690); // upx2px 转换为px
     this.cHeight = uni.upx2px(300);
     this.bWidth = uni.upx2px(690);
@@ -367,6 +370,8 @@ export default {
     this.shopSellData();
 
     this.loading = false;
+
+    
   },
   methods: {
     // 监听遮罩层行为

+ 33 - 5
src/pages/public/login.vue

@@ -78,7 +78,7 @@ export default {
       codeSeconds: 0, // 验证码发送时间间隔
       loginByPass: true,
       smsCodeBtnDisabled: true,
-      userInfo: null,
+      userInfo: null
     };
   },
 
@@ -103,8 +103,36 @@ export default {
     this.userInfo = uni.getStorageSync('wechatUserInfo');
 
     this.getCaptchaImage();
+     this.changeLogin(); 
   },
-  methods: {
+  methods: { 
+    //获取用户信息
+  changeLogin(){
+    let that = this  
+	// 授权
+	// 获取用户详细信息, 可以获取到说明已经授权过, 直接拿到用户信息
+      uni.getUserInfo({
+        provider: 'weixin',
+        //授权成功的回调
+        success(res) {          
+          uni.showToast({
+              title:'授权成功',
+            icon:'none'
+          })
+          // that.wechatuserinfo = res.userInfo    
+          console.log(res)
+          uni.setStorageSync('wechatUserInfo',res.userInfo )     
+        },
+        //第一次进入小程序
+        fail() {
+          uni.showToast({
+            title: '请点击授权进行登录',
+            icon: 'none'
+          });
+        }
+      });
+    },
+  
     loginTest(mobile, password) {
       this.loginParams.mobile = mobile;
       this.loginParams.password = password;
@@ -184,7 +212,7 @@ export default {
         });
     },
     // 提交表单
-    async toLogin() {
+    async toLogin() {  
       let cheRes, loginApi;
       if (this.loginByPass) {
         loginApi = loginByPass;
@@ -214,7 +242,7 @@ export default {
     },
     // 登录
     async handleLogin(params, loginApi) {
-      this.btnLoading = true;
+      this.btnLoading = true;  
       await this.$http
         .post(loginApi, params)
         .then((r) => {
@@ -235,7 +263,7 @@ export default {
             }
             uni.removeStorageSync('backToPage');
             uni.removeStorageSync('wechatUserInfo');
-          } else {
+          } else {            
             this.$mRouter.reLaunch({ route: '/pages/index/index' });
           }
         })