You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
2.6 KiB
94 lines
2.6 KiB
import config from '../../config.js';
|
|
import request from '../request.js';
|
|
import common from '../common.js';
|
|
let app = new Object()
|
|
|
|
/**
|
|
* 获取APP基本信息
|
|
* 2021-02-20
|
|
*/
|
|
app.getInfo = function() {
|
|
let device_id = uni.getStorageSync('device_id')
|
|
let user_id = uni.getStorageSync('user_id')
|
|
let access_token = uni.getStorageSync('access_token')
|
|
|
|
return new Promise((resolve, reject) => {
|
|
if (!device_id) {
|
|
uni.getSystemInfo({
|
|
success: (res) => {
|
|
// 获取客户端推送标识信息
|
|
let client_info = plus.push.getClientInfo()
|
|
|
|
// console.log(client_info)
|
|
// console.log({
|
|
// device_id: res.deviceId,
|
|
// brand: res.brand,
|
|
// model: res.model,
|
|
// pixel_ratio: res.pixelRatio,
|
|
// language: res.language,
|
|
// version: res.version,
|
|
// system: res.system,
|
|
// platform: res.platform,
|
|
// client_id: client_info.clientid ? client_info.clientid : ''
|
|
// })
|
|
|
|
request.getData('base/app/api/User/user', {
|
|
// 设备 id 。由 uni-app 框架生成并存储,清空 Storage 会导致改变
|
|
device_id: res.deviceId,
|
|
brand: res.brand,
|
|
model: res.model,
|
|
pixel_ratio: res.pixelRatio,
|
|
language: res.language,
|
|
version: res.version,
|
|
system: res.system,
|
|
platform: res.platform,
|
|
client_id: client_info.clientid ? client_info.clientid : ''
|
|
}).then(res => {
|
|
if (res.code === 0) {
|
|
uni.setStorageSync('device_id', res
|
|
.data.device_id)
|
|
uni.setStorageSync('user_id', res
|
|
.data.user_id)
|
|
uni.setStorageSync('access_token',
|
|
res.data.access_token)
|
|
uni.setStorageSync('access_token_expire_time', res.data
|
|
.access_token_expire_time)
|
|
|
|
resolve({
|
|
device_id: uni
|
|
.getStorageSync(
|
|
'device_id'),
|
|
user_id: uni
|
|
.getStorageSync(
|
|
'user_id')
|
|
})
|
|
console.log(
|
|
'生产环境刚获得: device_id = ' +
|
|
uni.getStorageSync(
|
|
'device_id') +
|
|
' user_id = ' + uni
|
|
.getStorageSync(
|
|
'user_id') + ' access_token = ' + uni
|
|
.getStorageSync('access_token'))
|
|
} else {
|
|
reject()
|
|
}
|
|
})
|
|
},
|
|
fail: (res) => {
|
|
reject()
|
|
}
|
|
});
|
|
} else {
|
|
resolve({
|
|
device_id: uni.getStorageSync('device_id'),
|
|
user_id: uni.getStorageSync('user_id')
|
|
})
|
|
// console.log('生产环境缓存: device_id = ' + uni.getStorageSync('device_id') + ' user_id = ' + uni
|
|
// .getStorageSync('user_id') + ' access_token = ' + uni.getStorageSync('access_token'))
|
|
}
|
|
})
|
|
}
|
|
|
|
export default app
|