houwei vor 3 Jahren
Ursprung
Commit
4c4a6627c0

+ 0 - 5
pages/activeDetail/activeDetail.js

@@ -13,11 +13,6 @@ Page({
         loginStatus: true
       })
     })
-    // .catch(err => {
-    //   this.setData({
-    //     loginStatus: false
-    //   })
-    // });
     tool.isFinishInfo().then(result2 => {
       this.setData({
         infoStatus: true

+ 29 - 12
pages/index/index.js

@@ -113,16 +113,16 @@ Page({
       method: "get",
       success: (res) => {
         if (res.data.code == 0) {
-          let config='ysf.config';
+          let config = 'ysf.config';
           let sex1 = '';
-          if(res.data.info.sex==0){
-            sex1='女'
-          }else{
-            sex1='男'
+          if (res.data.info.sex == 0) {
+            sex1 = '女'
+          } else {
+            sex1 = '男'
           }
           this.setData({
             myInfo: res.data.info,
-            [config]:JSON.stringify({
+            [config]: JSON.stringify({
               "uid": res.data.id, // 用户唯一标识
               "level": 1, // vip等级
               "data": JSON.stringify([{
@@ -174,12 +174,29 @@ Page({
     this.getletterStauts();
     this.getInfos()
     this.getActivies();
-    tool.isLogin().then(res => {
-      this.setData({
-        userInfo:JSON.parse(res.rawData)
-      })
-    }).catch(err => {
-      console.log(err)
+    wx.getSetting({
+      success: res => {
+        console.log(res)
+        if (res.authSetting['scope.userInfo']) {
+          wx.getUserInfo({
+            success: res => {
+              console.log(res)
+              this.setData({
+                userInfo:JSON.parse(res.rawData)
+              })
+              console.log(this.data.userInfo,'000000000000')
+            }
+          })
+        }
+      }
     })
+    // tool.isLogin().then(res => {
+    //   this.setData({
+    //     userInfo:JSON.parse(res.rawData)
+    //   })
+    //   console.log(this.data.userInfo,'000000000000')
+    // }).catch(err => {
+    //   console.log(err)
+    // })
   }
 })

+ 1 - 0
pages/index/index.wxml

@@ -6,6 +6,7 @@
 			</swiper-item>
 		</block>
 	</swiper>
+	<!-- <button open-type="openSetting" bindopensetting="callback">打开设置页</button> -->
 	<!-- <view style="width:100%;height:100rpx;border:1px solid red">
 	<view>{{userInfo}}</view>
 	<view>{{ysf}}</view>

+ 56 - 46
pages/personInfo/personInfo.js

@@ -495,50 +495,49 @@ Page({
     })
   },
   getPhoneNumber(e) {
-    tool.isLogin().then(res => {
-      console.log(res)
-      if (e.detail.errMsg == "getPhoneNumber:ok") {
-        wx.request({
-          url: app.globalData.publicUrl + '/wx/user/wxbfa171fdd4000e03/phone',
-          header: {
-            'content-type': 'application/x-www-form-urlencoded',
-          },
-          data: {
-            sessionKey: this.data.sessionkey,
-            signature: res.signature,
-            rawData: res.rawData,
-            encryptedData: e.detail.encryptedData,
-            iv: e.detail.iv
-          },
-          method: "POST",
-          success: (res) => {
-            console.log(res, '我是解析的手号');
-            let tel = 'form.tel'
-            if (res.data.phoneNumber) {
-              this.setData({
-                [tel]: res.data.phoneNumber
-              })
-            } else {
-              this.setData({
-                [tel]: 0
-              })
-            }
-          }
-        })
-      }
-    }).catch(err => {
-      wx.showModal({
-        title: '您还未登录',
-        showCancel: false,
-        success(res) {
-          if (res.confirm) {
-            wx.redirectTo({
-              url: '/pages/personal/personal',
+    console.log(e,'000000000')
+    if (e.detail.errMsg == "getPhoneNumber:ok") {
+      wx.getSetting({
+        success: res => {
+          console.log(res,'111111')
+          if (res.authSetting['scope.userInfo']) {
+            wx.getUserInfo({
+              success: res2 => {
+                console.log(JSON.parse(res2.rawData),'222222222222')
+                  wx.request({
+                    url: app.globalData.publicUrl + '/wx/user/wxbfa171fdd4000e03/phone',
+                    header: {
+                      'content-type': 'application/x-www-form-urlencoded',
+                    },
+                    data: {
+                      sessionKey: this.data.sessionkey,
+                      signature: res2.signature,
+                      rawData: res2.rawData,
+                      encryptedData: e.detail.encryptedData,
+                      iv: e.detail.iv
+                    },
+                    method: "POST",
+                    success: (res) => {
+                      console.log(res, '我是解析的手号');
+                      let tel = 'form.tel'
+                      if (res.data.phoneNumber) {
+                        this.setData({
+                          [tel]: res.data.phoneNumber
+                        })
+                      } else {
+                        this.setData({
+                          [tel]: 0
+                        })
+                      }
+                    }
+                  })
+                // }
+              }
             })
           }
         }
-      });
-    })
+      })
+    }
   },
   // 表单提交事件
   formSubmit(e) {
@@ -623,11 +622,22 @@ Page({
   },
   onShow() {
     tool.isLogin().then(res => {
-      console.log(res,'7777777777777')
-      this.setData({
-        userInfo: JSON.parse(res.rawData)
-      })
-      // this.getInfos()
+      // this.setData({
+      //   userInfo: JSON.parse(res.rawData)
+      // })
+      // wx.getSetting({
+      //   success: res => {
+      //     if (res.authSetting['scope.userInfo']) {
+      //       wx.getUserInfo({
+      //         success: res => {
+      //           this.setData({
+      //             userInfo:JSON.parse(res.rawData)
+      //           })
+      //         }
+      //       })
+      //     }
+      //   }
+      // })
     }).catch(err => {
       wx.showModal({
         title: '您还未登录',

+ 46 - 46
pages/personInfoDetail/personInfoDetail.js

@@ -299,52 +299,52 @@ Page({
     })
   },
   // 获取手机号
-  getPhoneNumber(e) {
-    tool.isLogin().then(res => {
-      console.log(res)
-      if (e.detail.errMsg == "getPhoneNumber:ok") {
-        wx.request({
-          url: app.globalData.publicUrl + '/wx/user/wxbfa171fdd4000e03/phone',
-          header: {
-            'content-type': 'application/x-www-form-urlencoded',
-          },
-          data: {
-            sessionKey: this.data.sessionkey,
-            signature: res.signature,
-            rawData: res.rawData,
-            encryptedData: e.detail.encryptedData,
-            iv: e.detail.iv
-          },
-          method: "POST",
-          success: (res) => {
-            console.log(res, '我是解析的手号');
-            let tel = 'form.tel'
-            if (res.data.phoneNumber) {
-              this.setData({
-                [tel]: res.data.phoneNumber
-              })
-            } else {
-              this.setData({
-                [tel]: 0
-              })
-            }
-          }
-        })
-      }
-    }).catch(err => {
-      wx.showModal({
-        title: '您还未登录',
-        showCancel: false,
-        success(res) {
-          if (res.confirm) {
-            wx.redirectTo({
-              url: '/pages/personal/personal',
-            })
-          }
-        }
-      });
-    })
-  },
+  // getPhoneNumber(e) {
+  //   tool.isLogin().then(res => {
+  //     console.log(res)
+  //     if (e.detail.errMsg == "getPhoneNumber:ok") {
+  //       wx.request({
+  //         url: app.globalData.publicUrl + '/wx/user/wxbfa171fdd4000e03/phone',
+  //         header: {
+  //           'content-type': 'application/x-www-form-urlencoded',
+  //         },
+  //         data: {
+  //           sessionKey: this.data.sessionkey,
+  //           signature: res.signature,
+  //           rawData: res.rawData,
+  //           encryptedData: e.detail.encryptedData,
+  //           iv: e.detail.iv
+  //         },
+  //         method: "POST",
+  //         success: (res) => {
+  //           console.log(res, '我是解析的手号');
+  //           let tel = 'form.tel'
+  //           if (res.data.phoneNumber) {
+  //             this.setData({
+  //               [tel]: res.data.phoneNumber
+  //             })
+  //           } else {
+  //             this.setData({
+  //               [tel]: 0
+  //             })
+  //           }
+  //         }
+  //       })
+  //     }
+  //   }).catch(err => {
+  //     wx.showModal({
+  //       title: '您还未登录',
+  //       showCancel: false,
+  //       success(res) {
+  //         if (res.confirm) {
+  //           wx.redirectTo({
+  //             url: '/pages/personal/personal',
+  //           })
+  //         }
+  //       }
+  //     });
+  //   })
+  // },
   getInfos() {
     wx.showLoading();
     wx.request({

+ 0 - 7
pages/personInfoDetail/personInfoDetail.wxml

@@ -1,12 +1,5 @@
 	<view class="container">
 		<form bindsubmit='formSubmit'>
-			<view class="block" style="display:none">
-				<view class='left' style="width:40%">咋联系你呢</view>
-				<view class='right' style="width:60%">
-					<input name="tel" wx:if="{{form.tel}}" value="{{form.tel}}" bindblur="phoneChange" placeholder="未填写" placeholder-class="iconfont icon-jianjiaohao1 icon-tubiaozhizuo-1"></input>
-					<button wx:else open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" id="photo_btn">未填写</button>
-				</view>
-			</view>
 			<view class="block">
 				<view class='left' style="width:50%">你得有一米八吧</view>
 				<view class='right' style="width:50%">

+ 1 - 1
pages/personal/personal.js

@@ -65,7 +65,7 @@ Page({
     })
   },
   bindGetUserInfo: function (e) {
-    console.log(e.detail.userInfo)
+    console.log(e)
     this.setData({
       nick: e.detail.userInfo.nickName,
       avatarUrl: e.detail.userInfo.avatarUrl,

+ 23 - 10
utils/tool.js

@@ -61,18 +61,31 @@ const formDetails = (type) => {
 };
 // 判断是否登录
 const isLogin = () => {
+  // return new Promise((resolve, reject) => {
+  //   wx.getSetting({
+  //     success: res => {
+  //       console.log(res)
+  //       if (res.authSetting['scope.userInfo']) {
+  //         wx.getUserInfo({
+  //           success: res => {
+  //             resolve(res)
+  //           }
+  //         })
+  //       } else {
+  //        reject(false)
+  //       }
+  //     }
+  //   })
+  // })
   return new Promise((resolve, reject) => {
-    wx.getSetting({
-      success: res => {
-        console.log(res)
-        if (res.authSetting['scope.userInfo']) {
-          wx.getUserInfo({
-            success: res => {
-              resolve(res)
-            }
-          })
+    wx.request({
+      url: util.globalData.publicUrl + '/wx/member/' + wx.getStorageSync('openId') + '/info',
+      method: "get",
+      success: (res) => {
+        if (res.data.code == 0&&res.data.info.avatar&&res.data.info.nickName) {
+          resolve(true)
         } else {
-         reject(false)
+          reject(false)
         }
       }
     })