tanyanfei 4 years ago
parent
commit
b0d0c51f6a

+ 2 - 0
pages/collect/collect.js

@@ -30,6 +30,8 @@ Page({
               })
             }
           })
+        }else{
+          wx.hideNavigationBarLoading()
         }
       },
     })

+ 5 - 0
pages/conference/conference.js

@@ -67,6 +67,11 @@ Page({
           })
         }
       },
+      fail:err=>{
+        wx.switchTab({
+          url: '../mine/mine',
+        })
+      }
     })
   },
   close: function () {

+ 58 - 46
pages/eventDetail/eventDetail.js

@@ -9,6 +9,7 @@ Page({
   data: {
     text:'发送验证码',
     info: {},
+    id:'',
     uid: '',
     show1:1,
     show2: 1,
@@ -23,7 +24,7 @@ Page({
     index:[0,0,0],
     page:1,
     proof_img:'',
-    user_id:'',   //用户id
+    user_id:0,   //用户id
     apply_id:'',   //报名ID
     phone:''
   },
@@ -40,7 +41,9 @@ Page({
         apply_id: options.apply_id
       })
     }
-    
+    this.setData({
+      id: options.id
+    })
     var that = this;
     wx.showNavigationBarLoading()
     var that = this;
@@ -51,52 +54,14 @@ Page({
           this.setData({
             user_id: res.data
           })
-          wx.request({
-            url: host + '/api/detail',
-            method: 'GET',
-            data: {
-              type: 'conference',
-              id: options.id,
-              uid: res.data
-            },
-            success: function (res) {
-              wx.hideNavigationBarLoading();
-              const info = res.data.data
-              if (info.sign_note) { info.sign_note = info.sign_note.replace(/\\n/, '\n') }
-              that.setData({
-                info: info
-              })
-              setTimeout(()=>{
-                const query = wx.createSelectorQuery()
-                query.select('#content').boundingClientRect(rect => {
-                  let height = rect.height;
-                  console.log(height)
-                  if(height<60){
-                      that.setData({
-                          show1:0
-                      })
-                  }
-                }).exec()
-                query.select('#content1').boundingClientRect(rect => {
-                  let height = rect.height;
-                  if (height < 60) {
-                    that.setData({
-                      show2: 0
-                    })
-                  }
-                }).exec()
-              },100)
-            },
-            fail: function () {
-              wx.hideLoading();
-              wx.showToast({
-                title: '服务器开小差啦!',
-                icon: 'none'
-              })
-            }
-          })
+          this.getData()
         }
       },
+      fail:err=>{
+        wx.switchTab({
+          url: '../mine/mine',
+        })
+      }
     })
     
     //中科院单位
@@ -116,6 +81,53 @@ Page({
       },
     })
   },
+  getData(){
+    var that = this;
+    wx.request({
+      url: host + '/api/detail',
+      method: 'GET',
+      data: {
+        type: 'conference',
+        id: this.data.id,
+        uid: this.data.user_id
+      },
+      success: function (res) {
+        wx.hideNavigationBarLoading();
+        const info = res.data.data
+        if (info.sign_note) { info.sign_note = info.sign_note.replace(/\\n/, '\n') }
+        that.setData({
+          info: info
+        })
+        setTimeout(() => {
+          const query = wx.createSelectorQuery()
+          query.select('#content').boundingClientRect(rect => {
+            let height = rect.height;
+            console.log(height)
+            if (height < 60) {
+              that.setData({
+                show1: 0
+              })
+            }
+          }).exec()
+          query.select('#content1').boundingClientRect(rect => {
+            let height = rect.height;
+            if (height < 60) {
+              that.setData({
+                show2: 0
+              })
+            }
+          }).exec()
+        }, 100)
+      },
+      fail: function () {
+        wx.hideLoading();
+        wx.showToast({
+          title: '服务器开小差啦!',
+          icon: 'none'
+        })
+      }
+    })
+  },
   map:function(){
     const latitude = Number(this.data.info.hotel.latitude);
     const longitude = Number(this.data.info.hotel.longitude);

+ 5 - 1
pages/index/index.js

@@ -74,8 +74,12 @@ Page({
           if (res.data) {
             this.setData({ show: 0, uid: res.data })
           }
-          
         },
+        fail:err=>{
+          wx.switchTab({
+            url: '../mine/mine',
+          })
+        }
       })
     }  
     

+ 47 - 0
pages/mine/mine.js

@@ -1,4 +1,6 @@
 // pages/mine/mine.js
+const app = getApp()
+var host = app.globalData.host;
 Page({
 
   /**
@@ -22,6 +24,51 @@ Page({
       },
     })
   },
+  onGotUserInfo: function () {
+    wx.getUserProfile({
+      desc: '用于完善会员资料',
+      success: res => {
+        //获取基本信息
+        var data = {
+          nickName: res.userInfo.nickName,
+          avatarUrl: res.userInfo.avatarUrl
+        }
+        wx.showLoading({
+          title: '正在登陆',
+        })
+        wx.setStorage({
+          key: 'userInfo',
+          data: data,
+        })
+        this.setData({
+          userinfo: data
+        })
+        wx.request({
+          url: host + '/api/auth',
+          method: 'POST',
+          data: {
+            nickname: data.nickName,
+            avatar: data.avatarUrl,
+            openid: app.globalData.openid,
+          },
+          success: res => {
+            wx.hideLoading()
+            wx.setStorage({
+              key: 'uid',
+              data: res.data.data.uid,
+            })
+          },
+          fail: error => {
+            wx.hideLoading()
+            wx.showLoading({
+              title: '登陆失败',
+            })
+          }
+        })
+      }
+    })
+
+  },
 
   /**
    * 生命周期函数--监听页面初次渲染完成

+ 1 - 1
pages/mine/mine.wxml

@@ -11,7 +11,7 @@
   </view>
 </view>
 <view wx:else  style="margin:50rpx 0;"> 
-    <button bindgetuserinfo="onGotUserInfo" open-type="getUserInfo">登录</button>
+    <button bindtap="onGotUserInfo" >登录</button>
 </view>
 <view class="list">
   <navigator  url="../order/order"  class="list-item">