Commit 8179316a authored by ly's avatar ly

获取设备信息

parent a6afa57e
......@@ -4,8 +4,22 @@
import { SelectLocation } from "./utils/authPerission";
export default {
onLaunch: function() {
const common = uni.getStorageSync("m-headers")
if (!common) {
const common = uni.getStorageSync("m-header-device")
let versionNumber
plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo){
if(wgtinfo.version){
versionNumber = wgtinfo.version;
}else{
versionNumber = plus.runtime.version;
}
uni.setStorageSync('version',versionNumber)
})
console.log(plus.os.name,'8')
if (!common && plus.os.name=='iOS') {
console.log(plus.os.name,'9')
this.loadDevice();
this.loadNetwork();
this.loadLocation();
......@@ -24,6 +38,7 @@
plus.runtime.getProperty(plus.runtime.appid,function(widgetInfo){
let currentVersion = widgetInfo.version.replace(/\./g, ""); //获取当前版本号
self.$request('/app/v1/checkVersions','GET').then(res=>{
console.log(res,'appvue')
const { versionInfo }=res.result
const { version,updateUrl,updateMsg,update,forceUpdate}=versionInfo
if(update==true && currentVersion<version){
......@@ -100,9 +115,9 @@
convertPromise('getSystemInfo').then(result => {
const deviceInfo = {
// token:uuidObtain,
// token:uuidObtain, result.appName
deviceType: result.deviceType,
appName: result.appName,
appName: 'DDH',
deviceId: result.deviceId,
device: result.osName,
deviceName: result.platform,
......@@ -111,9 +126,9 @@
mobileType: result.model,
screenHeight: result.screenHeight,
screenWidth: result.screenWidth,
resolution: result.windowWidth + '*' + result.screenHeight
resolution: result.windowWidth + '*' + result.screenHeight,
appSourceId: "1"
};
// 本地存储
uni.setStorage({
key: 'm-device-info',
......@@ -207,6 +222,14 @@
},
onShow: function() {
this.checkVersion()
const common = uni.getStorageSync("m-header-device")
if (!common && plus.os.name=='iOS') {
console.log(plus.os.name,'9')
this.loadDevice();
this.loadNetwork();
this.loadLocation();
this.loadUuid()
}
},
onHide: function() {
......
......@@ -101,6 +101,7 @@
* 点击确定
* */
bindPickerChange(e) {
console.log(e.target.value,'change')
this.$emit('change', {
index: selectCode,
data: selectVal
......
......@@ -14,7 +14,7 @@ const BASE = {
baseUrl: "https://dell-buyer-l.meimeiyouxin.com",
},
prod: {
baseUrl: "https://dell-buyer.meimeiyouxin.com",
baseUrl: "https://api.yyhock.com",
}
}
let env = process.env.VUE_APP_BASE_NODE_ENV
......
......@@ -175,7 +175,7 @@
// }else{
// self.getOss(tempFilePaths,type)
// }
uni.setStorageSync('authVals','1')
self.getOss(tempFilePaths,type)
},
fail: (err) => {
......
......@@ -607,6 +607,7 @@
this.showmarriage=true
},
changeLive(data) {
console.log(data,'现居城市')
this.liveCity = data.data.join('')
this.liveCode=data.index.join(',')
},
......@@ -622,9 +623,10 @@
this.cityAddress=e.detail.value
},
changeWork(data) {
console.log(data,'工作城市')
this.workCity = data.data.join('')
this.workCode=data.index.join(',')
// console.log(data)
},
workChange(e){
this.workAddress=e.target.value
......
......@@ -51,6 +51,7 @@
<script>
import moment from "moment";
import {loadDevice,loadNetwork,loadUuid,loadLocation} from '../../utils/deviceInfo.js'
export default {
data() {
return {
......@@ -60,7 +61,18 @@
}
},
onLoad() {
const token=uni.getStorageSync('token')
const common = uni.getStorageSync("m-header-device")
if(!common && plus.os.name!='iOS' && token){
loadDevice()
loadNetwork()
loadUuid()
loadLocation()
this.init()
}else{
this.init()
}
},
methods: {
init(){
......@@ -105,8 +117,19 @@
},
onShow() {
const token=uni.getStorageSync('token')
const common = uni.getStorageSync("m-header-device")
if(!common && plus.os.name!='iOS' && token){
loadDevice()
loadNetwork()
loadUuid()
loadLocation()
this.init()
}else{
this.init()
}
}
}
</script>
......
......@@ -72,6 +72,7 @@
</template>
<script>
import {loadDevice,loadNetwork,loadUuid,loadLocation} from '../../utils/deviceInfo.js'
export default {
data() {
return {
......@@ -121,15 +122,22 @@
},
onLoad() {
const token=uni.getStorageSync('token')
const common = uni.getStorageSync("m-header-device")
this.token=token
// 获取头部的高度
// const query = uni.createSelectorQuery().in(this);
// query.select('.i-header').boundingClientRect(data => {
// console.log(data.height,'98767')
// this.headerHeight = data.height;
// }).exec();
if(!common && plus.os.name!='iOS' && token){
loadDevice()
loadNetwork()
loadUuid()
loadLocation()
this.init()
this.searchGood()
}else{
this.init()
this.searchGood()
}
},
methods:{
init(){
......@@ -234,9 +242,8 @@
"size":pageSize,
"sort":sort
}
console.log(params,'查询商品')
self.$request('/pawn/category/getGoodsPage','POST',params).then(res => {
console.log(res,'查询商品')
const {current,total,size,records }=res.result
const hasNextPage=total-self.pageSize*self.pageNum>0?true:false //是否有下一页
if(self.loadFlag){
......@@ -274,9 +281,22 @@
},
onShow() {
const token=uni.getStorageSync('token')
const common = uni.getStorageSync("m-header-device")
this.token=token
if(!common && plus.os.name!='iOS' && token){
loadDevice()
loadNetwork()
loadUuid()
loadLocation()
this.init()
this.searchGood()
}else{
this.init()
this.searchGood()
}
}
}
</script>
......
......@@ -57,6 +57,7 @@
<script>
//1、使用插件
import moduleCard from '../../components/moduleCard/index.vue'
import {loadDevice,loadNetwork,loadUuid,loadLocation} from '../../utils/deviceInfo.js'
export default {
//2、使用插件
components:{
......@@ -73,8 +74,17 @@
}
},
onLoad() {
const token=uni.getStorageSync('token')
const common = uni.getStorageSync("m-header-device")
if(!common && plus.os.name!='iOS' && token){
loadDevice()
loadNetwork()
loadUuid()
loadLocation()
this.init()
}else{
this.init()
}
},
onPullDownRefresh(){
......@@ -82,16 +92,6 @@
this.init()
uni.stopPullDownRefresh();
},
// onReady() {
// const isAgree = uni.getStorageSync('m-agreement')
// if (!isAgree) {
// console.log(isAgree,'isAgree')
// uni.navigateTo({
// url: '/pages/agreement/index'
// })
// }
// },
methods: {
refushMy(){
console.log('emit2')
......@@ -141,8 +141,19 @@
}
},
onShow(){
const token=uni.getStorageSync('token')
const common = uni.getStorageSync("m-header-device")
if(!common && plus.os.name!='iOS' && token){
loadDevice()
loadNetwork()
loadUuid()
loadLocation()
this.init()
}else{
this.init()
// this.initMy()
}
}
}
</script>
......
......@@ -56,6 +56,7 @@
</template>
<script>
import {loadDevice,loadNetwork,loadUuid,loadLocation} from '../../utils/deviceInfo.js'
export default {
data() {
return {
......@@ -69,15 +70,22 @@
},
onLoad(){
const token=uni.getStorageSync('token')
console.log(token,'token')
const common = uni.getStorageSync("m-header-device")
if(!common && plus.os.name!='iOS' && token){
loadDevice()
loadNetwork()
loadUuid()
loadLocation()
this.initMy()
this.initTels()
}else{
if(token==''){
this.userTel=''
this.Go('uni:/pages/login/login')
return false
}else{
}
this.initMy()
this.initTels()
}
},
......@@ -158,12 +166,20 @@
},
onShow(){
const token=uni.getStorageSync('token')
console.log(token,'token')
const common = uni.getStorageSync("m-header-device")
if(!common && plus.os.name!='iOS' && token){
loadDevice()
loadNetwork()
loadUuid()
loadLocation()
this.initMy()
this.initTels()
}else{
if(token==''){
this.userTel=''
this.Go('uni:/pages/login/login')
return false
}else{
}
this.initMy()
this.initTels()
}
......
.single-pages{
width: 100%;
height: 100vh;
min-height: 1634rpx;
min-height: 100vh;
background: #F7FAFF;
.single-header{
padding:15rpx 0 15rpx 30rpx;
......@@ -13,7 +13,7 @@
line-height: 33rpx;
}
.single-boxs{
margin-bottom:220rpx;
padding-bottom:90rpx;
.single-main{
margin: 0 30rpx;
height: 120rpx;
......
This diff is collapsed.
This diff is collapsed.
/*
* URL分为3中类型
* 1. 以uni://开头的地址是uni-app原生的页面
* 2. 以http或者https开头的地址是H5
* 3. 跳转到其它APP的地址
* */
import { convertPromise } from '../utils/header.js'
import Permission from '../js_sdk/wa-permission/permission.js'
import { SelectLocation } from "../utils/authPerission.js";
// 获取common当中的设备信息
export const loadDevice=function() {
const that = this
convertPromise('getSystemInfo').then(result => {
const deviceInfo = {
// token:uuidObtain, result.appName
deviceType: result.deviceType,
appName: 'DDH',
deviceId: result.deviceId,
device: result.osName,
deviceName: result.platform,
appVersion: result.appWgtVersion,
osVersion: result.osVersion ? result.osVersion : result.system,
mobileType: result.model,
screenHeight: result.screenHeight,
screenWidth: result.screenWidth,
resolution: result.windowWidth + '*' + result.screenHeight,
appSourceId: "1"
};
// 本地存储
uni.setStorage({
key: 'm-device-info',
data: JSON.stringify(deviceInfo),
success: function() {
console.log('m-device-info存储成功');
}
});
}).catch(err => {
//that.toast('获取设备信息失败')
uni.showModal({
title: '"多典花"想访问您的设备信息',
content: '通过访问您的设备信息,提高您授信通过率。',
showCancel: false,
confirmText: '去设置',
success: function(res) {
if (res.confirm) {
Permission.gotoAppPermissionSetting()
}
}
});
})
}
// 获取common当中的网络信息
export const loadNetwork=function() {
const that = this;
convertPromise('getNetworkType').then(result => {
const networkInfo = {
networkStatus: result.networkType
};
// 网络信息存储
uni.setStorage({
key: 'm-network-info',
data: JSON.stringify(networkInfo),
success: function() {
console.log('m-network-info存储成功');
}
});
}).catch(err => {
that.toast('获取网络信息失败')
})
}
// 获取common当中的网络信息
export const loadUuid=function() {
plus.device.getInfo({
success: function(e) {
const deviceInfo = {
token: e.uuid,
};
uni.setStorage({
key: 'm-load-udid',
data: JSON.stringify(deviceInfo),
success: function() {
console.log('uuid存储成功');
}
})
},
fail: function(e) {
console.log('getDeviceInfo failed: ' + JSON.stringify(e));
}
});
}
// 获取common当中的网络信息
export const loadLocation=function() {
const that = this;
// 苹果测试手机如果没有插入手机卡,获取定位之后会解析失败,报错
SelectLocation(() => {
convertPromise('getLocation', {
type: 'wgs84',
geocode: true
}).then(result => {
const locationInfo = {
lat: String(result.latitude),
lng: String(result.longitude)
};
uni.setStorage({
key: 'm-location-info',
data: JSON.stringify(locationInfo),
success: function() {
console.log('m-location-info存储成功');
}
});
}).catch(err => {
console.log(err, '错误了')
// that.toast('获取位置信息失败')
})
})
}
export default {
loadDevice,
loadNetwork,
loadUuid,
loadLocation
}
......@@ -33,24 +33,6 @@ export const initHeaderInfo = function (){
}
// 初始化请求头的device参数信息
export const initHeaderDevice = function () {
const common = {
appName: 'DDH',
appSourceId: "1",
token: "c695fa285b9dc46a", // 设备令牌(device_token) 设备udid
device:'',//设备是安卓还是ios
appVersion:'',//版本号
idfa: "", // IOS设备则为:IDFA 广告标识
imei: "", //安卓设备为:imei
mac: "", // mac
wifiMac: "", // wifimac
clientIp: "",
carrierOperator: 'OperatorName', //运营商
pushType: "1", //设备push接入类型(1. 小米PUSH,2. 极光PUSH)
electricQuantity: "", //电量
totalStorage: "", //存储总空间
availableStorage: "" //可用存储空间
};
console.log(common,'common')
const deviceInfo = uni.getStorageSync('m-device-info')
const networkInfo = uni.getStorageSync('m-network-info')
const locationInfo = uni.getStorageSync('m-location-info')
......@@ -58,27 +40,26 @@ export const initHeaderDevice = function () {
let device = {};
if (deviceInfo) {
device = Object.assign(device, common, JSON.parse(deviceInfo))
device = Object.assign(device, JSON.parse(deviceInfo))
}
if (networkInfo) {
device = Object.assign(device, common, JSON.parse(networkInfo))
device = Object.assign(device, JSON.parse(networkInfo))
}
if (locationInfo) {
device = Object.assign(device, common, JSON.parse(locationInfo))
device = Object.assign(device, JSON.parse(locationInfo))
}
if(loadUuid){
device = Object.assign(device, common, JSON.parse(loadUuid))
device = Object.assign(device, JSON.parse(loadUuid))
}
if (deviceInfo && networkInfo && loadUuid) {
const headerDeviceInfo = {
if (deviceInfo && networkInfo && locationInfo && loadUuid) {
let headerDeviceInfo = {
...JSON.parse(deviceInfo),
...JSON.parse(networkInfo),
...JSON.parse(locationInfo),
...JSON.parse(loadUuid),
...common
}
// 存储所有请求的头部信息
uni.setStorage({
key: 'm-header-device',
......
import {initHeaderDevice} from './header.js'
import {initHeaderDevice,initHeaderInfo} from './header.js'
import api from '../config/api.js'
const request=async(url,type,data)=>{
// const baseUrl='http://portal.cloudsmake.cn' //测试
// const baseUrl='https://api.yyhock.com'//线上
const baseUrl=api.baseUrl
// 这里确保一定是可以获取得到的
console.log(baseUrl,'rd3333')
const headerDevice = uni.getStorageSync('m-header-device')
let rd = null;
const versionNew=uni.getStorageSync('version')
// 根据当前时间戳生成一个随机整数
var randomNum = new Date().getTime();
let rd
const tokenF=uni.getStorageSync('tokenFinance')
if(tokenF=='' && plus.os.name!='iOS'){
rd=initHeaderInfo()
}else{
if (headerDevice) {
rd = headerDevice
} else {
const common = initHeaderDevice()
}else{
const common = initHeaderDevice()
rd = JSON.stringify(common)
// console.log(rd,'rd3333')
}
}
return new Promise((resolve,reject)=>{
const token=uni.getStorageSync('token')
const tokenFinance=uni.getStorageSync('tokenFinance')
console.log(token,'token')
console.log(tokenFinance,'tokenFinance')
uni.request({
url: baseUrl+url,
method:type,
......
......@@ -5,7 +5,6 @@
* 3. 跳转到其它APP的地址
* */
export const Jump = function (url, type='navigate') {
console.log(url,type,'路径1')
if (!url) return;
......@@ -58,6 +57,8 @@ export const Jump = function (url, type='navigate') {
}
export default {
Jump
Jump,
}
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