12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- //index.js
- //获取应用实例
- const app = getApp()
- Page({
- data: {
- userInfo: {},
- },
- onLoad: function () {
- this.initInfo();
- },
- initInfo () {
- var token = wx.getStorageSync('user').token, data = {}, that = this;
- console.log(token);
- if (token) {
- that.getInfo(token)
- }else{
- app.login(that.getInfo);
- }
- },
- getInfo (token) {
- var that = this, token = token || wx.getStorageSync('user').token, data = null;
- console.log(token);
- wx.request({
- url: app.globalData.HOST + '/user/wx/personalCenter',
- method: 'POST',
- data: {token: token},
- success: function (res) {
- if (res.data.errno == '0'){
- data = res.data.rst
- that.setData({userInfo: data})
- }else if(res.data.errno == '90001'){
- }
- }
- });
- },
- goApplication () {
- var tel = wx.getStorageSync('tel') || '0', user_id = wx.getStorageSync('user').user_id || '0';
- console.log(user_id);
- console.log(tel);
- if (tel != '0' || user_id != '0') {
- wx.navigateTo({
- url: "/pages/application/application"
- })
- }else{
- wx.navigateTo({
- url: "/pages/getPhone/getPhone?from=mine"
- })
- }
- }
- })
|