Commit b054c69c authored by caimeng's avatar caimeng

1

parent 1c164044
No preview for this file type
...@@ -129,6 +129,7 @@ export const loadNetwork = () => { ...@@ -129,6 +129,7 @@ export const loadNetwork = () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.getNetworkType({ uni.getNetworkType({
success: (res) => { success: (res) => {
console.log(res,'往222')
// 网络信息存储 // 网络信息存储
uni.setStorage({ uni.setStorage({
key: "m-network-info", key: "m-network-info",
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -10,112 +10,112 @@ import Permission from '../js_sdk/wa-permission/permission.js' ...@@ -10,112 +10,112 @@ import Permission from '../js_sdk/wa-permission/permission.js'
import { SelectLocation } from "../utils/authPerission.js"; import { SelectLocation } from "../utils/authPerission.js";
// import { getAppVersion } from "@/api/api.js"; // import { getAppVersion } from "@/api/api.js";
// 获取common当中的设备信息 // 获取common当中的设备信息
export const loadDevice=function() { export const loadDevice = function () {
const that = this const that = this
convertPromise('getSystemInfo').then(result => { convertPromise('getSystemInfo').then(result => {
const deviceInfo = { const deviceInfo = {
// token:uuidObtain, result.appName // token:uuidObtain, result.appName
deviceType: result.deviceType, deviceType: result.deviceType,
appName: 'DDH', appName: 'DDH',
deviceId: result.deviceId, deviceId: result.deviceId,
device: result.osName, device: result.osName,
deviceName: result.platform, deviceName: result.platform,
appVersion: result.appWgtVersion, appVersion: result.appWgtVersion,
osVersion: result.osVersion ? result.osVersion : result.system, osVersion: result.osVersion ? result.osVersion : result.system,
mobileType: result.model, mobileType: result.model,
screenHeight: result.screenHeight, screenHeight: result.screenHeight,
screenWidth: result.screenWidth, screenWidth: result.screenWidth,
resolution: result.windowWidth + '*' + result.screenHeight, resolution: result.windowWidth + '*' + result.screenHeight,
appSourceId: "1" appSourceId: "1"
}; };
// 本地存储 // 本地存储
uni.setStorage({ uni.setStorage({
key: 'm-device-info', key: 'm-device-info',
data: JSON.stringify(deviceInfo), data: JSON.stringify(deviceInfo),
success: function() { success: function () {
console.log('m-device-info存储成功'); console.log('m-device-info存储成功');
} }
}); });
}).catch(err => { }).catch(err => {
//that.toast('获取设备信息失败') //that.toast('获取设备信息失败')
uni.showModal({ uni.showModal({
title: '"多典花"想访问您的设备信息', title: '"多典花"想访问您的设备信息',
content: '通过访问您的设备信息,提高您授信通过率。', content: '通过访问您的设备信息,提高您授信通过率。',
showCancel: false, showCancel: false,
confirmText: '去设置', confirmText: '去设置',
success: function(res) { success: function (res) {
if (res.confirm) { if (res.confirm) {
Permission.gotoAppPermissionSetting() Permission.gotoAppPermissionSetting()
} }
} }
}); });
}) })
} }
// 获取common当中的网络信息 // 获取common当中的网络信息
export const loadNetwork=function() { export const loadNetwork = function () {
const that = this; const that = this;
convertPromise('getNetworkType').then(result => { convertPromise('getNetworkType').then(result => {
const networkInfo = { const networkInfo = {
networkStatus: result.networkType networkStatus: result.networkType
}; };
// 网络信息存储 // 网络信息存储
uni.setStorage({ uni.setStorage({
key: 'm-network-info', key: 'm-network-info',
data: JSON.stringify(networkInfo), data: JSON.stringify(networkInfo),
success: function() { success: function () {
console.log('m-network-info存储成功'); console.log('m-network-info存储成功');
} }
}); });
}).catch(err => { }).catch(err => {
that.toast('获取网络信息失败') that.toast('获取网络信息失败')
}) })
} }
// 获取common当中的网络信息 // 获取common当中的网络信息
export const loadUuid=function() { export const loadUuid = function () {
plus.device.getInfo({ plus.device.getInfo({
success: function(e) { success: function (e) {
const deviceInfo = { const deviceInfo = {
token: e.uuid, token: e.uuid,
}; };
uni.setStorage({ uni.setStorage({
key: 'm-load-udid', key: 'm-load-udid',
data: JSON.stringify(deviceInfo), data: JSON.stringify(deviceInfo),
success: function() { success: function () {
console.log('uuid存储成功'); console.log('uuid存储成功');
} }
}) })
}, },
fail: function(e) { fail: function (e) {
console.log('getDeviceInfo failed: ' + JSON.stringify(e)); console.log('getDeviceInfo failed: ' + JSON.stringify(e));
} }
}); });
} }
// 获取common当中的网络信息 // 获取common当中的网络信息
export const loadLocation=function() { export const loadLocation = function () {
const that = this; const that = this;
// 苹果测试手机如果没有插入手机卡,获取定位之后会解析失败,报错 // 苹果测试手机如果没有插入手机卡,获取定位之后会解析失败,报错
SelectLocation(() => { SelectLocation(() => {
convertPromise('getLocation', { convertPromise('getLocation', {
type: 'wgs84', type: 'wgs84',
geocode: true geocode: true
}).then(result => { }).then(result => {
const locationInfo = { const locationInfo = {
lat: String(result.latitude), lat: String(result.latitude),
lng: String(result.longitude) lng: String(result.longitude)
}; };
uni.setStorage({ uni.setStorage({
key: 'm-location-info', key: 'm-location-info',
data: JSON.stringify(locationInfo), data: JSON.stringify(locationInfo),
success: function() { success: function () {
console.log('m-location-info存储成功'); console.log('m-location-info存储成功');
} }
}); });
}).catch(err => { }).catch(err => {
console.log(err, '错误了') console.log(err, '错误了')
// that.toast('获取位置信息失败') // that.toast('获取位置信息失败')
})
}) })
})
} }
export default { export default {
loadDevice, loadDevice,
......
...@@ -60,6 +60,9 @@ export const initHeaderDevice = function () { ...@@ -60,6 +60,9 @@ export const initHeaderDevice = function () {
const networkInfo = uni.getStorageSync('m-network-info') const networkInfo = uni.getStorageSync('m-network-info')
const locationInfo = uni.getStorageSync('m-location-info') const locationInfo = uni.getStorageSync('m-location-info')
const loadUuid = uni.getStorageSync('m-load-udid') const loadUuid = uni.getStorageSync('m-load-udid')
console.log(networkInfo,loadUuid,'===================')
let device = {}; let device = {};
if (deviceInfo) { if (deviceInfo) {
device = Object.assign(device, common, JSON.parse(deviceInfo)) device = Object.assign(device, common, JSON.parse(deviceInfo))
...@@ -87,10 +90,7 @@ export const initHeaderDevice = function () { ...@@ -87,10 +90,7 @@ export const initHeaderDevice = function () {
// 存储所有请求的头部信息 // 存储所有请求的头部信息
uni.setStorage({ uni.setStorage({
key: 'm-header-device', key: 'm-header-device',
data: JSON.stringify(headerDeviceInfo), data: JSON.stringify(headerDeviceInfo)
success: function () {
// console.log('m-header-device存储成功4');
}
}); });
return headerDeviceInfo return headerDeviceInfo
......
...@@ -113,6 +113,7 @@ export const loadNetwork = () => { ...@@ -113,6 +113,7 @@ export const loadNetwork = () => {
const networkInfo = { const networkInfo = {
networkStatus: result.networkType networkStatus: result.networkType
}; };
// 网络信息存储 // 网络信息存储
uni.setStorage({ uni.setStorage({
key: 'm-network-info', key: 'm-network-info',
......
...@@ -4,23 +4,11 @@ const request = async (url, type, data) => { ...@@ -4,23 +4,11 @@ const request = async (url, type, data) => {
const baseUrl = api.common const baseUrl = api.common
// 这里确保一定是可以获取得到的 // 这里确保一定是可以获取得到的
const headerDevice = uni.getStorageSync('m-header-device') const headerDevice = uni.getStorageSync('m-header-device')
const deviceInfo = uni.getStorageSync('m-device-info')
const tokenF = uni.getStorageSync('tokenFinance')
let rd = null
if (!deviceInfo || tokenF == '' && plus.os.name != 'iOS') { let rd = initHeaderInfo()
rd = initHeaderInfo() if (headerDevice) rd = headerDevice
} else { else rd = initHeaderDevice()
if (headerDevice) { rd = JSON.stringify(rd)
rd = headerDevice
} else {
const common = initHeaderDevice()
console.log(common, '日===')
if (common) {
rd = JSON.stringify(common)
}
}
}
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const token = uni.getStorageSync('token') const token = uni.getStorageSync('token')
......
...@@ -127,10 +127,11 @@ export const loadNetwork = () => { ...@@ -127,10 +127,11 @@ export const loadNetwork = () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.getNetworkType({ uni.getNetworkType({
success: (res) => { success: (res) => {
console.log(res,'哈哈====')
// 网络信息存储 // 网络信息存储
uni.setStorage({ uni.setStorage({
key: "m-network-info", key: "m-network-info",
data: res.networkType, data: JSON.stringify(res),
success: function() { success: function() {
console.log("m-network-info存储成功"); console.log("m-network-info存储成功");
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment