|
|
|
@ -1,44 +1,42 @@
|
|
|
|
|
// import qq from '@/utils/qqmap-wx-jssdk.min.js'
|
|
|
|
|
// import QQMapWX from './qqmap-wx-jssdk.min.js';
|
|
|
|
|
// import QQMapWX from './qqmap-wx-jssdk.min.js';=
|
|
|
|
|
// import QQMapWX from './qqmap-wx-jssdk.min.js';
|
|
|
|
|
// import OSS from "ali-oss/lib/browser";
|
|
|
|
|
|
|
|
|
|
const QQMapWX=require('./qqmap-wx-jssdk.min.js') |
|
|
|
|
import * as QQMapwx from '@/utils/qqmap-wx-jssdk.min.js' |
|
|
|
|
var qqmapsdk;
|
|
|
|
|
import { imghost,host,oss } from '@/config/host.js' |
|
|
|
|
import {getSTS} from "@/api/other"; |
|
|
|
|
var qqmapsdk; |
|
|
|
|
import {imghost, host, oss } from '@/config/host.js' |
|
|
|
|
import store from "@/store"; |
|
|
|
|
const api = { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
loginModalState: true, |
|
|
|
|
mapLocation:()=>{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new Promise((relove, reject) => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wx.authorize({ |
|
|
|
|
scope: 'scope.userFuzzyLocation', |
|
|
|
|
success(res) { |
|
|
|
|
if(res.errMsg == 'authorize:ok'){ |
|
|
|
|
wx.getFuzzyLocation({ |
|
|
|
|
type: 'wgs84', |
|
|
|
|
success(re) { |
|
|
|
|
console.log(re); |
|
|
|
|
type: 'wgs84', |
|
|
|
|
success(re) { |
|
|
|
|
uni.chooseLocation({ |
|
|
|
|
latitude:re.latitude, |
|
|
|
|
longitude:re.longitude, |
|
|
|
|
success: function (data) { |
|
|
|
|
console.log(data); |
|
|
|
|
let obj={ |
|
|
|
|
latitude:data.latitude, |
|
|
|
|
longitude: data.longitude, |
|
|
|
|
address:data.address |
|
|
|
|
} |
|
|
|
|
}
|
|
|
|
|
if(data.errMsg=='chooseLocation:ok'){ |
|
|
|
|
qqmapsdk=new QQMapWX({ |
|
|
|
|
key:'K65BZ-LULE4-744UV-X4EIA-27RA5-A4FWT' |
|
|
|
|
key:'SUUBZ-MIX6C-Y7U2B-AXT6O-NZ2W5-D6F2B' |
|
|
|
|
}) |
|
|
|
|
qqmapsdk.reverseGeocoder({ |
|
|
|
|
location:{ |
|
|
|
|
location:{
|
|
|
|
|
latitude:data.latitude , |
|
|
|
|
longitude: data.longitude |
|
|
|
|
}, |
|
|
|
@ -58,12 +56,12 @@ const api = {
|
|
|
|
|
// console.log('经度:' + data.longitude);
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
fail(err) { |
|
|
|
|
console.log(err) |
|
|
|
|
console.log(err)
|
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
@ -71,53 +69,99 @@ const api = {
|
|
|
|
|
getloction(details){ |
|
|
|
|
return new Promise((relove, reject)=>{ |
|
|
|
|
qqmapsdk=new QQMapWX({ |
|
|
|
|
key:'K65BZ-LULE4-744UV-X4EIA-27RA5-A4FWT' |
|
|
|
|
key:'SUUBZ-MIX6C-Y7U2B-AXT6O-NZ2W5-D6F2B' |
|
|
|
|
}) |
|
|
|
|
qqmapsdk.geocoder({ |
|
|
|
|
//获取表单传入地址
|
|
|
|
|
address: details.activedeta.city+details.activedeta.address, //地址参数,例:固定地址,address: '北京市海淀区彩和坊路海淀西大街74号'
|
|
|
|
|
success: function(res) {//成功后的回调
|
|
|
|
|
//获取表单传入地址
|
|
|
|
|
address: details.activedeta.city+details.activedeta.address, //地址参数,例:固定地址,address: '北京市海淀区彩和坊路海淀西大街74号'
|
|
|
|
|
success: function(res) {//成功后的回调
|
|
|
|
|
console.log(res); |
|
|
|
|
relove(res.result) |
|
|
|
|
}, |
|
|
|
|
fail: function(error) { |
|
|
|
|
console.error(error); |
|
|
|
|
}, |
|
|
|
|
complete: function(res) { |
|
|
|
|
console.log(res); |
|
|
|
|
} |
|
|
|
|
relove(res.result.location) |
|
|
|
|
}, |
|
|
|
|
fail: function(error) { |
|
|
|
|
console.error(error); |
|
|
|
|
}, |
|
|
|
|
complete: function(res) { |
|
|
|
|
console.log(res); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
urlToObj:(url)=>{ |
|
|
|
|
let obj = {} |
|
|
|
|
let str = url.slice(url.indexOf('?') + 1) |
|
|
|
|
let arr = str.split('&') |
|
|
|
|
for (let j = arr.length, i = 0; i < j; i++) { |
|
|
|
|
let arr_temp = arr[i].split('=') |
|
|
|
|
obj[arr_temp[0]] = arr_temp[1] |
|
|
|
|
} |
|
|
|
|
return obj |
|
|
|
|
let str = url.slice(url.indexOf('?') + 1) |
|
|
|
|
let arr = str.split('&') |
|
|
|
|
for (let j = arr.length, i = 0; i < j; i++) { |
|
|
|
|
let arr_temp = arr[i].split('=') |
|
|
|
|
obj[arr_temp[0]] = arr_temp[1] |
|
|
|
|
} |
|
|
|
|
return obj |
|
|
|
|
}, |
|
|
|
|
upfile:(file)=>{ |
|
|
|
|
let token=uni.getStorageSync('token') |
|
|
|
|
// console.log(file);
|
|
|
|
|
return new Promise((relove, reject) => { |
|
|
|
|
// console.log(file);
|
|
|
|
|
uni.showLoading({ |
|
|
|
|
title:'上传中' |
|
|
|
|
}) |
|
|
|
|
uni.uploadFile({ |
|
|
|
|
url: `${host}/other/upload`, //仅为示例,非真实的接口地址
|
|
|
|
|
filePath:file, |
|
|
|
|
name: 'file', |
|
|
|
|
success: (uploadFileRes) => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
relove(JSON.parse(uploadFileRes.data).data) |
|
|
|
|
// console.log(JSON.parse(uploadFileRes.data).data);
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
uni.uploadFile({ |
|
|
|
|
url: `${host}/other/upload`, //仅为示例,非真实的接口地址
|
|
|
|
|
filePath:file, |
|
|
|
|
name: 'file', |
|
|
|
|
header: { |
|
|
|
|
"content-type": "application/json;charset=utf-8", |
|
|
|
|
"Authorization":"Bearer "+ token.token |
|
|
|
|
}, |
|
|
|
|
success: (uploadFileRes) => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
relove(JSON.parse(uploadFileRes.data).data) |
|
|
|
|
// console.log(JSON.parse(uploadFileRes.data).data);
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
uploadOssFile:(file)=>{ |
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
getSTS({}).then(res => { |
|
|
|
|
// const client = new OSS(res.data);
|
|
|
|
|
// console.log(file);
|
|
|
|
|
uni.showLoading({ |
|
|
|
|
title:'上传中' |
|
|
|
|
}) |
|
|
|
|
let timer = new Date(); |
|
|
|
|
let address = timer.getFullYear() + '' + (timer.getMonth() + 1) + '' + timer.getDate(); |
|
|
|
|
address = 'upload/' + address + '/'; |
|
|
|
|
var imageSrc = file; |
|
|
|
|
let str = file.substr(file.lastIndexOf('.')); |
|
|
|
|
let nameStr = address + timer.getTime() + str; |
|
|
|
|
uni.uploadFile({ |
|
|
|
|
url: `${oss}`, //仅为示例,非真实的接口地址
|
|
|
|
|
filePath:file, |
|
|
|
|
name: 'file', |
|
|
|
|
header: { |
|
|
|
|
"content-type": "application/json;charset=utf-8", |
|
|
|
|
}, |
|
|
|
|
formData:Object.assign({ |
|
|
|
|
name:nameStr, |
|
|
|
|
key:nameStr, |
|
|
|
|
success_action_status: '200', |
|
|
|
|
},res.data), |
|
|
|
|
success: (uploadFileRes) => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
resolve ({show_path:oss+'/' + nameStr}); |
|
|
|
|
// relove(JSON.parse(uploadFileRes.data).data)
|
|
|
|
|
// console.log(JSON.parse(uploadFileRes.data).data);
|
|
|
|
|
}, |
|
|
|
|
fail:(res) =>{ |
|
|
|
|
uni.hideLoading() |
|
|
|
|
console.log(res) |
|
|
|
|
return {}; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
imgurl:(url)=>{ |
|
|
|
|
if(url){ |
|
|
|
|
if(url.indexOf('http')==-1){ |
|
|
|
@ -229,16 +273,15 @@ const api = {
|
|
|
|
|
this.system = res |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
// log('res',this.system);
|
|
|
|
|
//获取胶囊信息
|
|
|
|
|
this.menu = wx.getMenuButtonBoundingClientRect() |
|
|
|
|
this.systemBar = this.system.statusBarHeight //状态栏高度
|
|
|
|
|
this.navigationBar = (this.menu.top - this.system.statusBarHeight) * 2 + this.menu.height //胶囊高度
|
|
|
|
|
this.navPaddingTop = this.systemBar; |
|
|
|
|
this.navHeight = this.menu.height; |
|
|
|
|
this.headerPadding = (this.menu.top - this.systemBar); |
|
|
|
|
|
|
|
|
|
this.systemBarHeight = (this.navPaddingTop+this.navHeight + (this.headerPadding *2)) |
|
|
|
|
//获取胶囊信息
|
|
|
|
|
this.menu = wx.getMenuButtonBoundingClientRect() |
|
|
|
|
this.systemBar = this.system.statusBarHeight //状态栏高度
|
|
|
|
|
this.navigationBar = (this.menu.top - this.system.statusBarHeight) * 2 + this.menu.height //胶囊高度
|
|
|
|
|
this.navPaddingTop = this.systemBar; |
|
|
|
|
this.navHeight = this.menu.height; |
|
|
|
|
this.headerPadding = (this.menu.top - this.systemBar); |
|
|
|
|
this.systemBarHeight = (this.navPaddingTop + this.navigationBar) |
|
|
|
|
}catch(e){ |
|
|
|
|
//默认高度,刘海屏
|
|
|
|
|
this.navPaddingTop = 43; |
|
|
|
@ -250,7 +293,8 @@ const api = {
|
|
|
|
|
navHeight:this.navHeight, |
|
|
|
|
headerPadding:this.headerPadding, |
|
|
|
|
systemBarHeight:this.systemBarHeight, |
|
|
|
|
windowHeihgt:(this.system.windowHeight - this.systemBarHeight) |
|
|
|
|
windowHeight:(this.system.windowHeight - this.navigationBar - this.systemBar), |
|
|
|
|
menu:this.menu |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
wxSystemInfo: () => { |
|
|
|
|