| @@ -23,9 +23,43 @@ App({ | |||||
| // // 发送 res.code 到后台换取 openId, sessionKey, unionId | // // 发送 res.code 到后台换取 openId, sessionKey, unionId | ||||
| // } | // } | ||||
| // }) | // }) | ||||
| this.loginGettoken() | |||||
| }, | }, | ||||
| globalData: { | globalData: { | ||||
| userInfo: null, | userInfo: null, | ||||
| token: '1212121212' | |||||
| } | |||||
| token: '2222' | |||||
| }, | |||||
| //登录-获取token | |||||
| loginGettoken(){ | |||||
| let that = this | |||||
| wx.login({ | |||||
| success (res) { | |||||
| if (res.code) { | |||||
| //发起网络请求 | |||||
| wx.request({ | |||||
| url:'https://cktest.2weisou.com/meta/auth/mobile/token/social?grant_type=mobil&mobile=MINI_C@'+res.code+'@'+'', | |||||
| method: "POST", | |||||
| data: { | |||||
| }, | |||||
| header: { | |||||
| Authorization: "Basic YXBwbGV0OmFwcGxldA==", | |||||
| }, | |||||
| success(res1) { | |||||
| if (res1.statusCode == 200) { | |||||
| let userInfo = res1.data.user_info | |||||
| that.globalData.token = res1.data.access_token | |||||
| that.globalData.userInfo = res1.data.user_info | |||||
| // console.log(that.globalData.token) | |||||
| // console.log(that.globalData.userInfo) | |||||
| wx.setStorageSync('token', res1.data.access_token) | |||||
| wx.setStorageSync('userInfo', res1.data.user_info) | |||||
| } | |||||
| } | |||||
| }) | |||||
| } else { | |||||
| console.log('登录失败!' + res.errMsg) | |||||
| } | |||||
| } | |||||
| }) | |||||
| }, | |||||
| }) | }) | ||||
| @@ -8,10 +8,12 @@ Page({ | |||||
| }, | }, | ||||
| onLoad() { | onLoad() { | ||||
| }, | }, | ||||
| tabindex(e) { | |||||
| let index= e.currentTarget.dataset.index | |||||
| tabindex() { | |||||
| let userInfo = getApp().globalData.userInfo | |||||
| console.log(userInfo) | |||||
| wx.navigateTo({ | wx.navigateTo({ | ||||
| url: '../out/index?index=' +index, | |||||
| url: '/pages/out/index?index=1&userid=' + userInfo.id + '&gameid=1'+ '&type=' + 1 | |||||
| }) | }) | ||||
| }, | }, | ||||
| tabsaoma() { | tabsaoma() { | ||||
| @@ -1,7 +1,9 @@ | |||||
| // index.js | // index.js | ||||
| // 获取应用实例 | // 获取应用实例 | ||||
| const app = getApp() | const app = getApp() | ||||
| let userInfo = getApp().globalData.userInfo | |||||
| let token = getApp().globalData.token | |||||
| console.log(userInfo) | |||||
| Page({ | Page({ | ||||
| data: { | data: { | ||||
| avatarModal: false, | avatarModal: false, | ||||
| @@ -16,7 +18,37 @@ Page({ | |||||
| token: '' | token: '' | ||||
| }, | }, | ||||
| onLoad() { | onLoad() { | ||||
| this.loginGettoken() | |||||
| if (userInfo) { | |||||
| this.setData({ | |||||
| token: token, | |||||
| userid: userInfo.id, | |||||
| userInfo: userInfo | |||||
| }) | |||||
| if(!!userInfo.userWxName&&!!userInfo.phone){ | |||||
| this.leave() | |||||
| return; | |||||
| } | |||||
| if(!userInfo.userWxName||!userInfo.phone){ | |||||
| this.setData({ | |||||
| showBg: true | |||||
| }) | |||||
| }else{ | |||||
| this.setData({ | |||||
| showBg: false | |||||
| }) | |||||
| } | |||||
| this.setData({ | |||||
| avatarModal: !!userInfo.userWxName?false:true, | |||||
| phoneModal1: !!userInfo.phone?false:true, | |||||
| step: 1 | |||||
| }) | |||||
| if(!this.data.avatarModal){ | |||||
| this.setData({ | |||||
| step: 2, | |||||
| phoneModal: this.data.phoneModal1 | |||||
| }) | |||||
| } | |||||
| } | |||||
| }, | }, | ||||
| backhome(){ | backhome(){ | ||||
| wx.navigateTo({ | wx.navigateTo({ | ||||
| @@ -1,4 +1,4 @@ | |||||
| // pages/out/index.js | |||||
| Page({ | Page({ | ||||
| /** | /** | ||||
| @@ -10,17 +10,11 @@ Page({ | |||||
| * 生命周期函数--监听页面加载 | * 生命周期函数--监听页面加载 | ||||
| */ | */ | ||||
| onLoad: function (options) { | onLoad: function (options) { | ||||
| // wx.navigateTo({ | |||||
| // url: '/pages/login/index' | |||||
| // }) | |||||
| wx.showModal({ | wx.showModal({ | ||||
| title: '温馨提示', | title: '温馨提示', | ||||
| content: '确定进入该小程序吗', | content: '确定进入该小程序吗', | ||||
| showCancel: false,//是否显示取消按钮 | showCancel: false,//是否显示取消按钮 | ||||
| // cancelText: "取消",//默认是“取消” | |||||
| // cancelColor: '#000000',//取消文字的颜色 | |||||
| // confirmText: "确定",//默认是“确定” | |||||
| // confirmColor: '#3cc51f',//确定文字的颜色 | |||||
| success: function (res) { | success: function (res) { | ||||
| if (res.cancel) { | if (res.cancel) { | ||||
| //点击取消,wx.navigateBack | //点击取消,wx.navigateBack | ||||
| @@ -12,13 +12,13 @@ Page({ | |||||
| onLoad: function (options) { | onLoad: function (options) { | ||||
| }, | }, | ||||
| backGame(){ | |||||
| closeShare(){ | |||||
| // wx.navigateBack({ | // wx.navigateBack({ | ||||
| // delta: 1 | // delta: 1 | ||||
| // }) | // }) | ||||
| let userInfo = wx.getStorageSync('userInfo') | let userInfo = wx.getStorageSync('userInfo') | ||||
| wx.navigateTo({ | wx.navigateTo({ | ||||
| url: `/pages/login/index?index=1&userid=${userInfo.id}&gameid=1&type=2`, | |||||
| url: `/pages/out/index?index=1&userid=${userInfo.id}&gameid=1&type=2`, | |||||
| }) | }) | ||||
| }, | }, | ||||
| /** | /** | ||||
| @@ -70,7 +70,7 @@ Page({ | |||||
| console.log(e) | console.log(e) | ||||
| this.shareFun() | this.shareFun() | ||||
| return { | return { | ||||
| title: '5.5元购新房万份好礼免费兑', | |||||
| title: '万套特惠房源5折起iPhone13 Pro Max免费赢', | |||||
| imageUrl: 'https://static.quhouse.com/468340e3a1374decb4fa51a172aa4f52.png', | imageUrl: 'https://static.quhouse.com/468340e3a1374decb4fa51a172aa4f52.png', | ||||
| path: '/pages/index/index' | path: '/pages/index/index' | ||||
| } | } | ||||
| @@ -10,6 +10,6 @@ | |||||
| <!-- <image class="btn" src="https://static.quhouse.com/cbbbda43ce244fe39c235f59c2b1e8fa.png"></image> --> | <!-- <image class="btn" src="https://static.quhouse.com/cbbbda43ce244fe39c235f59c2b1e8fa.png"></image> --> | ||||
| <button class="btn" open-type="share"></button> | <button class="btn" open-type="share"></button> | ||||
| </view> | </view> | ||||
| <image class="close" bindtap="backGame" src="https://static.quhouse.com/643b05904e17410aa568557328cf7dc1.png"></image> | |||||
| <image class="close" bindtap="closeShare" src="https://static.quhouse.com/643b05904e17410aa568557328cf7dc1.png"></image> | |||||
| </view> | </view> | ||||
| </view> | </view> | ||||