12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- const APP = getApp();
- Page({
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.login();
- },
- /**
- * 登录
- */
- login: function () {
- const that = this;
- wx.login({
- success: res => {
- const params = {
- code: res.code
- }
- //登录
- APP.Post(APP.Url.login, params).then(res => {
- APP.globalData.openId = res.data;
- //请求设备集合
- that.getDeviceList(res.data);
- })
- }
- })
- },
- /**
- * 获取设备列表
- */
- getDeviceList: function (userId) {
- const params = {
- userId: userId,
- }
- APP.Get(APP.Url.getListByUserId, params).then(res => {
- APP.globalData.deviceList = res.data;
- wx.switchTab({
- url: '/pages/index/index',
- })
- })
- }
- })
|