|
@@ -30,6 +30,8 @@ Page({
|
|
|
this.setData({
|
|
|
openid: app.globalData.openid
|
|
|
})
|
|
|
+ console.log(this.data.openid)
|
|
|
+ this.getNotice()
|
|
|
wx.getStorage({
|
|
|
key: 'userInfo',
|
|
|
success: res=> {
|
|
@@ -38,8 +40,6 @@ Page({
|
|
|
}
|
|
|
},
|
|
|
})
|
|
|
-
|
|
|
-
|
|
|
var animation = wx.createAnimation({
|
|
|
duration: 1000,
|
|
|
timingFunction: 'ease',
|
|
@@ -102,5 +102,56 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
+ },
|
|
|
+ getNotice:function(){
|
|
|
+ wx.showLoading({
|
|
|
+ title: '',
|
|
|
+ })
|
|
|
+ wx.request({
|
|
|
+ url: host+'/api/wx/notice',
|
|
|
+ header: {
|
|
|
+ openid: this.data.openid
|
|
|
+ },
|
|
|
+ success:res=>{
|
|
|
+ if (res.statusCode == 403) {
|
|
|
+ this.save()
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ list:res.data.data.list
|
|
|
+ })
|
|
|
+ if(res.data.data.new > 0){
|
|
|
+ wx.setTabBarBadge({
|
|
|
+ index: 2,
|
|
|
+ text: String(res.data.data.new)
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ save: function () {
|
|
|
+ var _this = this
|
|
|
+ wx.showLoading({
|
|
|
+ title: '正在登录',
|
|
|
+ })
|
|
|
+ wx.getStorage({
|
|
|
+ key: 'userInfo',
|
|
|
+ success: function (res) {
|
|
|
+ console.log(res)
|
|
|
+ wx.request({
|
|
|
+ url: host + '/api/wx/auth',
|
|
|
+ method: 'POST',
|
|
|
+ data: {
|
|
|
+ nickname: res.data.nickName,
|
|
|
+ avatar: res.data.avatarUrl,
|
|
|
+ openid: app.globalData.openid,
|
|
|
+ },
|
|
|
+ success: res => {
|
|
|
+ wx.hideLoading()
|
|
|
+ _this.getData();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ })
|
|
|
}
|
|
|
})
|