2024-01-25 13:47:25 +08:00

49 lines
1.0 KiB
JavaScript

import { httpRequest, cloud } from './utils/httpRequest';
// import { getUserInfo, getSystemInfoSync } from '../../utils/obtainInfo'
// const { httpRequest } = getApp();
import { storageUid } from './utils/utils'
App({
cloud,
httpRequest,
globalData: {
userInfo: {},
systemInfo: {}
},
onLaunch(options) {
},
onShow() {
this.globalData.systemInfo = my.getSystemInfoSync();
this.testLogin();
},
async testLogin() {
const paramenter = {
path: '/reg',
method: 'POST',
}
const res = await httpRequest(paramenter)
// console.log(res, "regregreg")
if (res && res.status == 1) {
storageUid(res.data.uid);
const userParamenter = {
path: '/user',
method: 'POST',
}
const userRes = await httpRequest(userParamenter);
if (userRes.status == 1) {
getApp().globalData.userInfo = userRes.data.info;
my.setStorageSync({
key: 'userInfo',
data: {
userInfo: userRes.data.info
}
})
}
}
},
});