// pages/index/index.js import cloudApi from "../../apis/cloudApi" import { wxSetSessionKey, } from "../../utils/wxUtils" import { postApi } from "../../apis/api" Page({ /** * 页面的初始数据 */ data: { loginStatus: false }, async login() { let res1 = await postApi("/user/wx/login", { openId: wx.getStorageSync('openId') }) if (res1.data.status == 0) { let data = { ...res1.data.result.userInfo, ...res1.data.result.shipInfo, } Object.keys(data).forEach(function (key) { wx.setStorageSync(key, data[key]) }) wx.navigateTo({ url: '/pages/takePhoto/takePhoto', }) } else { let session_key = wx.getStorageSync('session_key') let openId = wx.getStorageSync('openId') wx.navigateTo({ url: '/pages/takePhoto/takePhoto', }) wx.clearStorage({ success: (res) => { wx.setStorageSync('session_key', session_key) wx.setStorageSync('openId', openId) }, }) } }, onLoad: function (options) { if (wx.getStorageSync('userId') && wx.getStorageSync('shipName')) { this.setData({ loginStatus: true }) } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })