// pages/welcome/welcome.js var api = require('../../utils/service-api.js'); var util = require('../../utils/util.js') Page({ /** * 页面的初始数据 */ data: { artId: '', loadding: true, jumpUrl: '', }, onLoad: function(option) { var _this = this if (option.url != undefined) { _this.setData({ jumpUrl: decodeURIComponent(option.url) }) } }, /** * 用户授权登录 */ userAuthorization: function(options) { var _this = this; _this.setData({ loadding: false }) if (options.detail.errMsg == 'getUserInfo:fail auth deny') { wx.showToast({ title: "为了您能正常使用小程序,请先同意授权", icon: "none" }); _this.setData({ loadding: true }) return; } var userInfo = options.detail.userInfo //更新用戶信息 util.request({ api: "/wxapi/user/saveUserInfo", checkLogin: true, data: userInfo, callback: function(data) { getApp().userInfo = data.rows[0]; //跳转页面 _this.setData({ loadding: true }) if (_this.data.jumpUrl == '' || _this.data.jumpUrl == undefined) { wx.reLaunch({ url: '/pages/index/index' }) } else if (_this.data.jumpUrl == 'back') { //后退一页 wx.navigateBack({ delta: 1 }) } else { wx.reLaunch({ url: _this.data.jumpUrl }) } } }); }, agreement(e) { wx.navigateTo({ url: '../shopType/shopType', }) }, // 进入内容页面 intoContent() { wx.navigateTo({ url: '/pages/article/article?id=12', }) }, })