修改bug

This commit is contained in:
Mr.jiang 2024-08-05 19:05:50 +08:00
parent e68bf29cdf
commit 9545c533da
7 changed files with 156 additions and 802 deletions

View File

@ -123,6 +123,10 @@
"spotlight@3x" : "static/logo.png"
}
}
},
"splashscreen" : {
"androidStyle" : "default",
"iosStyle" : "storyboard"
}
}
},

View File

@ -119,7 +119,7 @@
</view>
</view>
</view>
<view class="header-view header-padd header-margin">
<view class="header-view header-padd header-margin" style="margin-bottom: 100px;">
<view class="d-title title-font">
<span>给技师捎句话</span>
<span style="color: rgb(9, 111, 75);" @click="kuaijie">快捷输入</span>
@ -527,12 +527,14 @@
let massageTypeId = this.orderXm.massageTypeId;
let longitude = this.longitude;
let latitude = this.latitude;
let classifyId= this.orderXm.classifyId
let city=this.orderXm.city
uni.setStorage({
key: 'taocanDd',
data: '支付',
success: function () {
uni.navigateTo({
url: '/pages/therapist/therapistDingdan?massageTypeId='+massageTypeId+'&latitude='+latitude+'&longitude='+longitude
url: '/pages/therapist/therapistDingdan?massageTypeId='+massageTypeId+'&latitude='+latitude+'&longitude='+longitude+'&classifyId='+classifyId+'&city='+city
})
}
});

View File

@ -98,7 +98,7 @@
<span v-if="jishiName">{{jishiName.technicianTypeName}}</span>
</view>
<view class="liliao-bottom" style="margin-right: 6px;">
<span v-if="jishiName">{{jishiName.artificerName}}</span>
<span v-if="jishiName">{{jishiName.artificerName?jishiName.artificerName:jishiName.artificer.artificerName}}</span>
<span v-else>选择不同技师价格可能不一样哦~</span>
<span class="view-more"></span>
</view>
@ -143,11 +143,14 @@
</view>
</view>
</view>
<view class="margin-top-xl pay-ding">
<view class="d-title">备注</view>
<view class="header-view header-padd" style="margin-bottom: 100px;">
<view class="d-title">
<span>给技师捎句话</span>
<span style="color: rgb(9, 111, 75);" @click="kuaijie">快捷输入</span>
</view>
<view class="list-pay">
<view class="textarea-pay-list">
<textarea @input="textareaChange" class="textarea-pay" v-model="orderXm.remark" placeholder="请输入备注" name="" maxlength="100"></textarea>
<textarea @input="textareaChange" class="textarea-pay" v-model="textareaData" placeholder="请输入备注" name="" maxlength="100"></textarea>
</view>
</view>
@ -242,6 +245,20 @@
</scroll-view>
</view>
</u-popup>
<!-- 快捷输入 -->
<u-popup v-model="popupKj" mode="bottom">
<view>
<scroll-view scroll-y="true" style="background: #f7f7f7;">
<view class="guke-list">
<view class="guke-btn huiBtn" :class="{ lanBtn: selected.includes(item) }"
@click="gukeBtn(item)" v-for="(item,index) in fuwuBtn" :key="index">
{{item.title}}
</view>
</view>
<view class="kuaijie-btn" @click="quxiaoKj">取消</view>
</scroll-view>
</view>
</u-popup>
</view>
</template>
@ -250,6 +267,14 @@
export default {
data() {
return {
fuwuBtn: [
{'title':'请速回电确认服务时间地点'},
{'title':'到达后请先电话联系,切勿大声敲门'},
{'title':'时间紧张,请尽快到达服务位置'},
{'title':'直接来即可'},
],
selected:[],
popupKj:false,
number:1,
startTime: '',
msTimeList: [],
@ -357,6 +382,7 @@
this.youhuiF(this.couponId)
}
if(this.jishiName){
console.log('this.jishiName===',this.jishiName)
this.getMsTime(Time);
this.technicianRate=Math.ceil(this.orderXm.price+(this.orderXm.price*(this.jishiName.technicianTypeRate/100)))
}else{
@ -406,6 +432,27 @@
// #endif
},
methods: {
quxiaoKj(){//
this.textareaData='';
this.selected=[];
this.popupKj=false;
},
kuaijie(){//
this.popupKj=true;
},
gukeBtn(item) {
var index = this.selected.indexOf(item);
if (index === -1) {
this.selected.push(item);
} else {
this.selected.splice(index, 1);
}
var data = [];
for (var i = 0; i < this.selected.length; i++) {
data.push(this.selected[i].title)
}
this.textareaData = data.join(",")
},
goOrder() {//orderId
let that = this
let data = {
@ -724,13 +771,18 @@
});
},
liliaoshi(){
let massageTypeId = this.orderXm.massageTypeId?this.orderXm.massageTypeId:this.orderXm.ordersMassageList[0].massageType.massageTypeId;
let longitude = this.longitude;
let latitude = this.latitude;
let classifyId= this.orderXm.classifyId?this.orderXm.classifyId:this.orderXm.ordersMassageList[0].massageType.classifyId;
let city=this.orderXm.city?this.orderXm.city:this.orderXm.ordersMassageList[0].massageType.city;
uni.setStorage({
key: 'taocanDd',
data: '修改',
success: function () {
uni.navigateTo({
url: '/pages/therapist/therapistDingdan'
})
uni.navigateTo({
url: '/pages/therapist/therapistDingdan?massageTypeId='+massageTypeId+'&latitude='+latitude+'&longitude='+longitude+'&classifyId='+classifyId+'&city='+city
})
}
});
},
@ -1369,6 +1421,63 @@
</script>
<style lang="scss" scoped>
.header-view-text{
width: 170rpx;
font-size: 29rpx;
color: #222222;
}
.header-view{
background-color: #fff;
border-radius: 11px;
}
.header-padd{
padding:30rpx;
}
.header-margin{
margin:20rpx;
}
.kuaijie-btn{
width: 100%;
height: 40px;
text-align: center;
line-height: 40px;
font-weight: bold;
font-size: 14px;
margin-top: 10px;
background: #fff;
// color: #049F89;
}
.huiBtn {
color: #333333;
}
.lanBtn {
color: #049F89;
}
.guke-btn {
width: 100%;
height: 40px;
line-height: 40px;
margin-left: 5px;
text-align: center;
line-height: 40px;
font-weight: bold;
font-size: 12px;
border-radius: 6px;
border-bottom: 1px solid #ccc;
}
.guke-list {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
flex-wrap: wrap;
box-sizing: border-box;
background-color: #fff;
}
.title-font{
font-size:30rpx;
color: #333333;
}
.head-bottom{
width: 68%;
display: flex;
@ -1720,6 +1829,9 @@
font-weight: bold;
font-size: 32rpx;
color: #333333;
display: flex;
flex-direction: row;
justify-content: space-between;
}
.checkbox-data{
padding: 0px 11px;
@ -1739,7 +1851,7 @@
}
.list-pay{
width: 100%;
padding: 0px 29rpx;
// padding: 0px 29rpx;
}
.pay-ding-top{
width: 100%;

View File

@ -108,7 +108,7 @@
</view>
</view>
</view>
<view class="header-view header-padd header-margin">
<view class="header-view header-padd header-margin" style="margin-bottom: 100px;">
<view class="d-title">
<span>给技师捎句话</span>
<span style="color: rgb(9, 111, 75);" @click="kuaijie">快捷输入</span>

View File

@ -94,7 +94,7 @@
</view>
</view>
</view>
<view class="header-view header-padd header-margin">
<view class="header-view header-padd header-margin" style="margin-bottom: 100px;">
<view class="d-title title-font">
<span>给技师捎句话</span>
<span style="color: rgb(9, 111, 75);" @click="kuaijie">快捷输入</span>
@ -544,13 +544,15 @@
let massageTypeId = that.orderXm.massageTypeId;
let longitude = that.longitude;
let latitude = that.latitude;
let classifyId= this.orderXm.classifyId
let city=this.orderXm.city
uni.setStorage({
key: 'taocanDd',
data: '我的套餐',
success: function () {
uni.navigateTo({
url: '/pages/therapist/therapistDingdan?technicianType='+that.orderXm.level+'&massageTypeId='+massageTypeId+'&latitude='+latitude+'&longitude='+longitude
})
uni.navigateTo({
url: '/pages/therapist/therapistDingdan?massageTypeId='+massageTypeId+'&latitude='+latitude+'&longitude='+longitude+'&classifyId='+classifyId+'&city='+city
})
}
});
},

View File

@ -89,10 +89,7 @@
</view>
</view> -->
<!-- <view class="flex justify-around margin-top " v-if="jsczSel != '否'">
<view @click="goNav('/pages/therapist/therapistList?index=2')">为TA充值</view>
<view @click="goNav('/pages/therapist/therapistList?index=3')">我的技师</view>
</view> -->
<view class="push-button">
<view class="detail-btn" @click="pay">
确定充值</view>

View File

@ -2,17 +2,12 @@
<view class="content">
<view class="content-head">
<view class="padding-top-sm flex align-center" style="padding-bottom: 9px;">
<!-- <view v-if="XCXIsSelect != ''" class="flex align-center justify-between margin-right-sm"
@tap="showCityList" style="line-height: 68rpx;">
<image src="../../static/liliao-1.png" class="dingwei-img"></image>
<view class="localName">{{ city }}</view>
</view> -->
<u-search class="flex-sub" placeholder="请输入技师名字" :focus="false" shape="square" v-model="artificerName"
:show-action="true" :animation="true" bg-color="#f5f5f5" color="#1A1A1A" @search="onSearch()"
action-text="搜索" @custom="onSearch()"></u-search>
</view>
</view>
<view class="liebiao" v-show="current === 0">
<view class="liebiao">
<view v-if="orderList.length" class="flex text-center flex-wrap list-view">
<view class="margin-bottom-sm radius touxiang-left">
<view class="flex align-center touxiang-left-view" v-if="item.status=='1'" v-for="(item, index) in orderList" :key='index'
@ -98,90 +93,23 @@
<empty v-if="orderList.length == 0"></empty>
</view>
<!-- 经验筛选 -->
<u-select v-model="Cityshow" :list="cityList" @confirm="getCity"></u-select>
</view>
</template>
<script>
import selectSwitchDitu from "@/components/xuan-switch/xuan-switch-ditu.vue";
import meTabs from "@/components/mescroll-uni/me-tabs/me-tabs.vue";
import empty from '@/components/empty.vue'
import RenDropdownFilter from '@/components/ren-dropdown-filter/ren-dropdown-filter.vue'
import commonConfig from 'common/config.js';
import * as webMap from 'utils/webMap.js';
import permision from "@/components/permission.js";
//
// #ifdef APP-PLUS
// import permision from "@/components/permission.js";
// #endif
export default {
components: {
meTabs,
empty,
RenDropdownFilter,
selectSwitchDitu
},
data() {
return {
artificerName: '',
tpSel: 0,
tpCount: 0,
showTP: false,
Cityshow: false,
loading: true, //
defaultSelected: [],
value1: '',
value2: '',
value3: '',
game: [],
defaultIndex: [0, 0, 0],
filterData: [
[{
label: '推荐',
value: '',
}],
[{
label: '服务热度',
value: '0',
},
{
label: '从高到低',
value: '1',
},
{
label: '从低到高',
value: '2',
}
],
[{
label: '距离',
value: '0',
},
{
label: '从远到近',
value: '2',
},
{
label: '从近到远',
value: '1',
}
],
],
list: [{
name: '综合',
id: 1
}, {
name: '距离',
id: 2
}, {
name: '销量',
id: 3
}, {
name: '好评',
id: 4
}],
listIndex: 0,
city: '请选择城市',
orderList: [],
@ -204,147 +132,34 @@
latitude: '43.86487',
longitude: '',
address: '',
mapScale: 16, //
markers: [], // markers
cmap: null, //map
amap: null,
infoWindow: null,
marker: null,
socketConnect: null,
pointMap: {}, //map
pointThread: null,
currentMarkerIndex: -1,
showPopup: false,
dataIndex:'',
technicianType:''
technicianType:'',
classifyId:''
}
},
onLoad(e) {
let that = this
that.technicianType=e.technicianType
that.massageTypeId=e.massageTypeId
that.longitude=e.longitude
that.latitude=e.latitude
// that.getLocation();//
// that.getLocation(true);//
that.classifyId=e.classifyId
that.city=e.city
uni.getStorage({
key: 'taocanDd',
success: (res) => {
that.dataIndex = res.data;
}
});
that.getTypeList();
if(that.latitude!='' && that.longitude!=''){
uni.setStorageSync('latitude', that.latitude)
uni.setStorageSync('longitude', that.longitude)
if (that.amap) {
that.amap.setCenter(new AMap.LngLat(that.latitude, that.longitude));
}
if (that.infoWindow) {
that.infoWindow.setPosition(new TMap.LatLng(that.latitude, that.longitude));
}
that.page = 1
that.getTypeList();
}else{
uni.getLocation({
type: 'gcj02',
geocode: true, //true
highAccuracyExpireTime: 500,
success: function(res) {
console.log(res, '地理位置-----------------------》')
that.latitude = res.latitude
that.longitude = res.longitude
uni.setStorageSync('latitude', res.latitude)
uni.setStorageSync('longitude', res.longitude)
if (that.amap) {
that.amap.setCenter(new AMap.LngLat(res.latitude, res.longitude));
}
if (that.infoWindow) {
that.infoWindow.setPosition(new TMap.LatLng(res.latitude, res.longitude));
}
that.page = 1
that.getTypeList();
},
fail: function(e) {
console.log('获取地址失败1', e)
// #ifdef APP-PLUS
that.checkPermission();
// #endif
}
})
}
//
if (e.invitation) {
that.$queue.setData('inviterCode', e.invitation);
}
if (this.myId) {
that.$Request.getT('/app/common/type/235').then(res => { //
if (res.code == 0) {
if (res.data && res.data.value) {
that.arr.push(res.data.value)
}
}
})
that.$Request.getT('/app/common/type/236').then(res => { //
if (res.code == 0) {
if (res.data && res.data.value) {
that.arr.push(res.data.value)
}
}
})
}
that.getlist()
},
onShow() {
let that = this
that.getKTCityList();
that.XCXIsSelect = this.$queue.getData("XCXIsSelect");
that.city = uni.getStorageSync('city') ? uni.getStorageSync('city') : '请选择城市'
that.getTpCount();
that.getTpMy();
that.token = uni.getStorageSync('token')
if (uni.getStorageSync('token')) {
if (that.latitude && that.longitude) {
that.page = 1
that.getlist()
} else {
uni.getLocation({
type: 'gcj02',
highAccuracyExpireTime: 500,
geocode: true, //true
success: function(res) {
console.log(res, '地理位置')
that.latitude = res.latitude
that.longitude = res.longitude
that.page = 1
that.getTypeList();
that.getlist()
},
fail: function() {
console.log('获取地址失败2')
}
})
}
}
that.myId = uni.getStorageSync('userId')
// console.log(that.showModal, '------', that.myId)
// #ifdef MP-WEIXIN
//
if (that.myId) {
that.getIsVip()
if (this.showModal) {
// this.openMsg()
}
}
// #endif
},
onReady() {
console.log('this ->', this, uni);
this.initMap();
//this.initMapPointThread();
},
methods: {
//
@ -401,65 +216,6 @@
})
}
},
switch1Change: function (e) {//
var num= Number(e)
if(e==false){
this.current = 1;
}else{
this.current = 0;
}
console.log('switch1 发生 change 事件,携带值为', Number(e),e)
},
showTips() {
uni.showToast({
title: '技师已下线',
icon: 'none'
})
},
onClickItem(e) {
if (this.current != e) {
this.current = e;
}
},
showCityList() {
// #ifdef APP-PLUS
if (this.latitude === '' || this.longitude === '') {
this.checkPermission();
return;
}
// #endif
this.Cityshow = true;
},
async checkPermission() {
let status = permision.isIOS ? await permision.requestIOS('location') : await permision.requestAndroid(
'android.permission.ACCESS_FINE_LOCATION');
if (status === null || status === 1) {
status = 1;
} else if (status === 2) {
uni.showModal({
content: "系统定位已关闭",
confirmText: "确定",
showCancel: false,
success: function(res) {}
})
} else if (status.code) {
uni.showModal({
content: status.message
})
} else {
uni.showModal({
title: '定位服务已关闭',
content: "您需要打开定位权限,否则我们将无法获得到您附近的项目服务,导致我们无法为您提供服务,请到>设置>隐私>定位服务>中开启【盛安到家】定位权限",
confirmText: "设置",
success: function(res) {
if (res.confirm) {
permision.gotoAppSetting();
}
}
})
}
return status;
},
saveImgss(imgs, index) {
console.log(imgs, index)
// let that = this
@ -481,100 +237,6 @@
current: 0
});
},
saveTP() {
if (!this.token) {
uni.navigateTo({
url: '/pages/public/login'
});
return;
}
let userId = this.$queue.getData('userId');
let userName = this.$queue.getData('userName');
this.$queue.showLoading('投票中...');
this.$Request.postJson('/app/message/insertMessage', {
state: 11,
content: this.city,
userName: userName,
userId: userId
})
.then(res => {
if (res.code === 0) {
uni.showToast({
title: '投票成功!'
});
this.getTpCount();
this.getTpMy();
} else {
uni.hideLoading();
uni.showModal({
showCancel: false,
title: '投票失败',
content: res.msg
});
}
});
},
getTpMy() {
this.$Request.getT('/app/message/selectMessageByUserId?page=1&limit=1&state=11').then(res => {
if (res.code == 0) {
if (res.data && res.data.list && res.data.list.length > 0) {
this.tpSel = 1;
} else {
this.tpSel = 2;
}
}
});
},
getTpCount() {
this.$Request.getT('/app/message/selectCityCount?city=' + this.city).then(res => {
if (res.code == 0) {
this.tpCount = res.data ? res.data : 0;
}
});
},
getCity(e) {
console.log("得到的城市-------------》",e[0].label);
this.city = e[0].label;
uni.setStorageSync('city', this.city)
this.getKTCityList();
this.page = 1
this.getlist()
},
getKTCityList() {
let cityName;
// let cityName = uni.getStorageSync('city') ? uni.getStorageSync('city') : ''
// if (cityName === '') {
// return;
// }
this.$Request.getT('/app/trip/selectTripList').then(res => {
if (res.code == 0) {
this.cityList = [];
let isOpen = false
res.data.forEach((d, index) => {
if (cityName === d.city) {
isOpen = true;
}
let data = {}
data.label = d.city
data.value = index
this.cityList.push(data);
});
console.log("请求-----------------请求>",this.cityList)
if (!isOpen) {
// debugger;
this.orderList = []
this.showTP = true;
// uni.showToast({
// title: '',
// duration: 2000,
// icon: 'none'
// });
} else {
this.showTP = false;
}
}
});
},
getTypeList() {
this.$Request.get("/app/dict/list", {
type: '服务类型'
@ -584,73 +246,12 @@
this.tablist = res.data
this.tabIndex = res.data[0].id;
this.page = 1;
this.getlist()
// this.getlist()
//线
this.initMapPointThread();
}
}
});
},
//
openMsg() {
console.log('订阅消息')
var that = this
uni.getSetting({
withSubscriptions: true, //false
success(ret) {
if (ret.subscriptionsSetting.itemSettings) {
uni.setStorageSync('sendMsg', true)
uni.openSetting({ //
success(rea) {
console.log(rea.authSetting)
}
});
} else { //
console.log(99999)
uni.setStorageSync('sendMsg', false)
uni.showModal({
title: '提示',
content: '为了更好的体验,请绑定消息推送',
confirmText: '确定',
cancelText: '取消',
success: function(res) {
if (res.confirm) {
wx.requestSubscribeMessage({
tmplIds: that.arr,
success(re) {
var datas = JSON.stringify(re);
if (datas.indexOf("accept") != -1) {
console.log(re)
// uni.setStorageSync('sendMsg', true)
}
},
fail: (res) => {
console.log(res)
}
})
// uni.setStorageSync('sendMsg', true)
console.log('确认')
that.showModal = false
} else if (res.cancel) {
console.log('取消')
// uni.setStorageSync('sendMsg', false)
that.showModal = true
}
}
})
}
}
})
},
getIsVip() {
this.$Request.get("/app/UserVip/isUserVip").then(res => {
if (res.code == 0) {
this.isVip = res.data
uni.setStorageSync('isVIP', res.data)
}
});
},
onSearch(e) {
// this.artificerName = e;
this.page = 1;
@ -661,7 +262,7 @@
let data = {
// id: curTab,
artificerName: this.artificerName,
classifyId: this.tabIndex,
classifyId: this.classifyId,
page: this.page,
limit: this.limit,
massageTypeId: this.massageTypeId,
@ -673,7 +274,6 @@
city: this.city,
technicianType:this.technicianType
}
console.log(data)
this.$Request.get("/app/artificer/selectArtificerList", data).then(res => {
this.loading = false;
if (res.code == 0) {
@ -694,397 +294,34 @@
} else {
this.orderList = [...this.orderList, ...res.data.list]
}
// for (var i = 0; i < this.orderList.length; i++) {
// if (this.orderList[i].status!='1') {
// this.orderList=[]
// }
// }
}
uni.stopPullDownRefresh();
})
},
//
tabChange() {
if (uni.getStorageSync('sendMsg')) {
console.log('授权+1')
wx.requestSubscribeMessage({
tmplIds: this.arr,
success(re) {
console.log(JSON.stringify(re), 111111111111)
var datas = JSON.stringify(re);
if (datas.indexOf("accept") != -1) {
// console.log(re)
}
},
fail: (res) => {
// console.log(res)
}
})
}
this.defaultIndex = [0, 0, 0]
// this.$refs.uDropdown.close();
this.page = 1
this.getlist()
},
//
change(index) {
// this.value1 = e[0][0].value
// this.value2 = e[1][0].value
// this.value3 = e[2][0].value
this.listIndex = index
this.page = 1
this.getlist()
},
//
goSelectCity() {
// uni.navigateTo({
// url: '/pages/index/citys/citys'
// });
let that = this
uni.chooseLocation({
success: function(res) {
console.log('位置名称:' + res.name);
console.log('详细地址:' + res.address);
console.log('纬度:' + res.latitude);
console.log('经度:' + res.longitude);
that.latitude = res.latitude
that.longitude = res.longitude
uni.setStorageSync('latitude', res.latitude)
uni.setStorageSync('longitude', res.longitude)
that.selectCity(that.longitude, that.latitude);
}
});
},
selectCity(longitude, latitude) {
this.$Request.get('/app/Login/selectCity?lat=' + latitude + '&lng=' + longitude).then(res => {
if (res.code == 0) {
this.city = res.data.city ? res.data.city : '未知'
uni.setStorageSync('city', res.data.city)
this.page = 1
this.getlist()
}
});
},
//
goLowTaking() {
uni.navigateTo({
url: '/pages/index/order/lowTaking'
});
},
//
goNav(url) {
if (uni.getStorageSync('sendMsg')) {
console.log('授权+1')
wx.requestSubscribeMessage({
tmplIds: this.arr,
success(re) {
console.log(JSON.stringify(re), 111111111111)
var datas = JSON.stringify(re);
if (datas.indexOf("accept") != -1) {
console.log(re)
}
},
fail: (res) => {
console.log(res)
}
})
}
if (url.indexOf('/pages/') !== -1) {
uni.navigateTo({
url
});
} else {
//#ifndef H5
uni.navigateTo({
url: '/pages/index/webView?url=' + url
});
//#endif
//#ifdef H5
window.location.href = url;
//#endif
}
},
//
goSearch(index) {
if (uni.getStorageSync('sendMsg')) {
console.log('授权+1')
wx.requestSubscribeMessage({
tmplIds: this.arr,
success(re) {
// console.log(JSON.stringify(re), 111111111111)
var datas = JSON.stringify(re);
if (datas.indexOf("accept") != -1) {
console.log(re)
}
},
fail: (res) => {
console.log(res)
}
})
}
uni.navigateTo({
url: '/pages/index/search/index?index=' + index
});
},
//
getLocation(isHighAccuracy = false) {
console.log('获取地理位置,精度:', isHighAccuracy);
let that = this;
//
uni.getLocation({
// type: 'wgs84',
type: 'gcj02',
highAccuracyExpireTime: isHighAccuracy ? 5000 : 500,
isHighAccuracy,
success: function(res) {
let longitude = res.longitude;
let latitude = res.latitude;
console.log('当前位置的经度:' + longitude);
console.log('当前位置的纬度:' + latitude);
getApp().globalData['longitude'] = longitude;
getApp().globalData['latitude'] = latitude;
console.log('定位成功', latitude, longitude);
if (that.amap) {
uni.amap.setCenter([longitude, latitude])
}
},
fail(res) {
console.log('定位失败!', res);
}
});
//
let longitude = getApp().globalData['longitude'] || 0;
let latitude = getApp().globalData['latitude'] || 0;
return {
latitude,
longitude
};
},
initMap() {
let amap = webMap.creatAMap('txMapContainer');
uni.amap = amap;
this.amap = amap;
let that = this;
setTimeout(() => {
uni.hideLoading();
this.current = 0;
uni.getLocation({
// type: 'wgs84',
type: 'gcj02',
highAccuracyExpireTime: 3000,
isHighAccuracy: true,
success: function(res) {
let longitude = res.longitude;
let latitude = res.latitude;
console.log('当前位置的经度:' + longitude);
console.log('当前位置的纬度:' + latitude);
console.log('定位成功', latitude, longitude);
if (amap) {
uni.amap.setCenter([longitude, latitude])
}
},
fail(res) {
console.log('定位失败!', res);
}
});
if (that.orderList.length > 0) {
let rmap = {};
let onLineArtificerList = this.orderList.filter((item) => item.status == 1);
onLineArtificerList.forEach(x => {
rmap[x.userId] = x.latitude + ',' + x.longitude; //
});
console.log('在initMap初始化', JSON.parse(JSON.stringify(rmap)));
this.pointMap = rmap;
that.creatMarker(rmap);
}
}, 500);
},
creatMarker(map) {
let that = this;
webMap.addMarker(uni.amap, map, this.orderList, (e, udata) => {
that.currentMarkerIndex = udata.userId;
that.showPopup = true;
});
},
updateMarker(map) {
this.creatMarker(map);
},
getUserId() {
return this.myId;
},
getBusinessId() {
// return '12345678900987654321';
//return this.massageTypeId;
return this.tabIndex;
// return '98';
},
getOrderByCurrentMarkerIndex(key = this.currentMarkerIndex) {
return ((this.orderList || []).find(x => x.userId == key) || {});
},
creatSocket() {
let deviceId = this.getBusinessId();
let socketConnect = uni.connectSocket({
url: commonConfig.WS_UPLOAD_MAP_PATH + deviceId,
data() {
return {
msg: ''
}
},
header: {
'content-type': 'application/json',
// 'token': token
},
method: 'GET',
success(res) {
//
// uni.showLoading({
// title: ''
// });
},
fail(err) {
//
// uni.showLoading({
// title: ''
// });
}
});
uni.onSocketOpen((res) => {
// uni.hideLoading()
// uni.showToast({
// icon: 'none',
// title: ''
// })
console.log('onOpen', res);
});
uni.onSocketError((err) => {
// this.connecting = false
// this.connected = false
// uni.hideLoading()
// uni.showModal({
// content: '',
// showCancel: false
// })
console.log('onError', err);
});
uni.onSocketMessage((res) => {
let that = this;
console.log('onMessage', res)
let datas = JSON.parse(res.data)
// let data = {
// chat: {
// userHead: '../../static/logo.png'
// },
// content: datas.content,
// type: datas.type,
// sendType: datas.sendType
// }
// that.ListItem.push(data);
//
this.pointMap = {};
switch (datas.type) {
case 'getCoordinate': {
console.log('坐标包:', JSON.parse(JSON.stringify(datas.data)));
let map = {};
let rmap = {};
let onLineArtificerList = this.orderList.filter((item) => item.status == 1);
onLineArtificerList.forEach(x => {
map[x.userId] = x;
let zb = datas.data[x.userId];
if (!zb) {
//datas.data[x.userId] = x.latitude + ',' + x.longitude; //
rmap[x.userId] = x.latitude + ',' + x.longitude; //
} else {
rmap[x.userId] = zb;
}
});
// let data = datas.data;
// let rdata = {};
// data.forEach(x => rdata[x.userId]);
//rmap = datas.data; //debug
console.log('坐标最终结果:', JSON.parse(JSON.stringify(rmap)));
this.pointMap = rmap;
that.creatMarker(rmap);
break;
}
default: {
}
}
});
uni.onSocketClose((res) => {
console.log('onClose', res)
console.log('2 - 关闭触发', uni.pointThread)
//this.closeSocket();
this.socketConnect = null;
this.pointThread = null;
uni.pointThread = null;
uni.userSocketConnect = null;
});
this.socketConnect = socketConnect;
uni.userSocketConnect = socketConnect;
},
sendMsg(msg) {
uni.sendSocketMessage({
data: JSON.stringify(msg),
success: (...e) => {
console.log('发送成功!', ...e);
},
fail: (...e) => {
console.log('发送失败!', ...e);
},
});
},
closeSocket() {
console.log('2-关闭 - closeSocket')
uni.closeSocket();
//temp1.pointThread
clearInterval(uni.pointThread);
},
initMapPointThread() {
let that = this;
//
if (!that.socketConnect) {
this.closeSocket();
//that.socketConnect = uni.userSocketConnect;
}
if (uni.userSocketConnect) {
this.closeSocket()
//that.socketConnect = uni.userSocketConnect;
}
setTimeout(x => {
console.log('重新开始');
that.creatSocket();
//
setTimeout(x => {
that.forSendMsg();
}, 500);
}, 500)
},
forSendMsg() {
let that = this;
if (!that.mapPointThreadIsRun) {
that.sendMsgFn();
let pointThread = setInterval(() => {
that.sendMsgFn();
}, 3 * 60 * 1000); //3 * 60 * 1000
this.pointThread = pointThread;
uni.pointThread = pointThread;
}
},
sendMsgFn() {
let that = this;
let userId = that.getUserId();
let businessId = that.getBusinessId();
let msg = {
sendType: "getCoordinate",
userId,
businessId,
rkey: `map:location:${businessId}:*`
}
that.sendMsg(msg);
},
},
onReachBottom: function() {
this.page = this.page + 1;