Browse Source

Merge branch 'master' into dev

# Conflicts:
#	utils/functions.js
master
喵喵喵1234 1 year ago
parent
commit
c79ed914cc
  1. 15
      pages/Address/edit.vue
  2. 1
      pages/Index/index.vue
  3. 10
      pages/Service/index.vue
  4. 154
      utils/functions.js

15
pages/Address/edit.vue

@ -292,7 +292,20 @@ export default {
success: (res) => {
that.lat = res.latitude;
that.lng = res.longitude;
that.model.address.area = res.address;
console.log(res)
// that.model.address.area = res.address;
api.getloction({activedeta:{
city:res.address,
address:res.name
}}).then(data => {
let address = data.address_components;
console.log('address',address)
// that.address.province = address.province;
// that.address.city = address.city;
// that.address.district = address.district;
that.model.address.area = address.province+address.city+address.district;
console.log()
});
},
fail: (err) => {
console.log(err)

1
pages/Index/index.vue

@ -50,6 +50,7 @@
</view>
</view>
</uv-popup>
<uv-parse content="<div></div>"></uv-parse>
</template>
<script>

10
pages/Service/index.vue

@ -101,7 +101,7 @@
<u-text :text="mapData.address" color="#AFB5BE" size="28"></u-text>
</view>
<view class="button" style="width:50rpx;height:50rpx;">
<u-image mode="widthFix" width="=50" height="50" :src="staticImage.position" @click="callPostion"></u-image>
<u-image mode="widthFix" width="=50" height="50" :src="staticImage.position" @click="callPosition"></u-image>
</view>
</view>
<view class="pop-add"></view>
@ -138,7 +138,7 @@
<view class="icon" style="margin-right:20rpx;">
<u-image mode="widthFix" width="32" height="32" :src="staticImage.listPosition"></u-image>
</view>
<view class="value col " @click="callLocal(item.lat,item.lng)">
<view class="value col " @click="callLocal(item.lat,item.lng,item.name)">
<u-text :text="item.address" color="#AFB5BE" size="28" custom-style="display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; overflow: hidden; "></u-text>
</view>
</view>
@ -507,7 +507,7 @@ export default {
afterCreateMap(){
this.getServiceList(true);
},
callPostion(){
callPosition(){
const latitude=parseFloat(this.mapData.lat);
const longitude=parseFloat(this.mapData.lng);
uni.openLocation({
@ -516,13 +516,13 @@ export default {
name:this.mapData.name,
})
},
callLocal(lat,lng){
callLocal(lat,lng,name = ''){
const latitude=parseFloat(lat);
const longitude=parseFloat(lng);
uni.openLocation({
latitude:latitude,
longitude:longitude,
name:this.mapData.name,
name:name,
})
},
callPhone(phone){

154
utils/functions.js

@ -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: () => {

Loading…
Cancel
Save