|
@@ -1,12 +1,63 @@
|
|
import http from '../../base/httputil'
|
|
import http from '../../base/httputil'
|
|
|
|
+const app = getApp()
|
|
Page({
|
|
Page({
|
|
|
|
|
|
/**
|
|
/**
|
|
* 页面的初始数据
|
|
* 页面的初始数据
|
|
*/
|
|
*/
|
|
data: {
|
|
data: {
|
|
-
|
|
|
|
|
|
+ isShowAccoutDialog : false
|
|
|
|
+ },
|
|
|
|
+ init_userInfo() {
|
|
|
|
+ let that = this
|
|
|
|
+ if (app.globalToken == null) {
|
|
|
|
+ http.showLoading()
|
|
|
|
+ wx.getUserProfile({
|
|
|
|
+ desc: 'desc',
|
|
|
|
+ success: (res) => {
|
|
|
|
+ this.getSysUserInfo(res.userInfo)
|
|
|
|
+ },
|
|
|
|
+ fail: res => {
|
|
|
|
+ console.log(res)
|
|
|
|
+ },
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ getSysUserInfo(info) {
|
|
|
|
+ let that = this
|
|
|
|
+ wx.login({
|
|
|
|
+ success(res) {
|
|
|
|
+ var code = res.code
|
|
|
|
+ var data = {
|
|
|
|
+ wxCode: code,
|
|
|
|
+ wxNickName: info.nickName,
|
|
|
|
+ wxAvatarUrl: info.avatarUrl
|
|
|
|
+ }
|
|
|
|
+ http.send_post("/auth/applogin", data, that.loginSuccess)
|
|
|
|
+ },
|
|
|
|
+ fail(res) {
|
|
|
|
+ console.log("ffff", res)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
},
|
|
},
|
|
|
|
+ loginSuccess(res) {
|
|
|
|
+ console.log("rrrr",res)
|
|
|
|
+ if (res.data.code != 200) {
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: res.data.msg,
|
|
|
|
+ icon: "none"
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ app.globalToken = res.data.data.access_token
|
|
|
|
+ console.log("我的令牌:",app.globalToken )
|
|
|
|
+ //登录成功,获取首页数据
|
|
|
|
+ http.hideLoading()
|
|
|
|
+ this.setData({
|
|
|
|
+ isShowAccoutDialog : true
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
*/
|