// pages/home/home.js
|
var touchStartX = 0; //触摸时的原点
|
var touchStartY = 0; //触摸时的原点
|
var time = 0; // 时间记录,用于滑动时且时间小于1s则执行左右滑动
|
var interval = ""; // 记录/清理时间记录
|
var touchMoveX = 0; // x轴方向移动的距离
|
var touchMoveY = 0; // y轴方向移动的距离
|
const app = getApp()
|
const unit = require('../../utils/util')
|
const BaiduMap = require('../../utils/bmap-wx.min')
|
var latitude = app.globalData.userLatitude
|
var longitude = app.globalData.userLongitude
|
const {
|
queryServerCarMo,
|
saveOrderPrivateCar,
|
queryLines,
|
orderCharteredCar,
|
queryLogisticsNumber
|
} = require('../../utils/ajax')
|
Page({
|
/**
|
* 页面的初始数据
|
*/
|
data: {
|
showBlack: false,
|
showNotice: false,
|
noticeInfo: {},
|
// 当前选择的协议(协议弹窗)
|
agreementSelect: 1,
|
// 是否定位成功
|
isLocation: true,
|
// 老年模式一键叫车弹窗
|
confirmPopupShow: false,
|
showPop: false,
|
mapId: 'map4select',
|
nowOrder: false,
|
latitude: wx.getStorageSync('latitude'),
|
longitude: wx.getStorageSync('longitude'),
|
nextLatitude: '', //选择位置后的坐标
|
nextLongitude: '', //选择位置后的坐标
|
nextCityName: '您要去哪儿',
|
nextBoolean: false, //判断是否选择终点位置
|
showLocationIcon: true, //是否展示中心图片
|
polyline: [],
|
// changeWay:[{id:1,name:'现在'},{id:2,name:'预约'},{id:3,name:'代叫'}],
|
cityName: wx.getStorageSync('cityName') || '',
|
cityNameStart: wx.getStorageSync('cityNameStart') || '正在获取位置信息',
|
busStyle: [], //当地出租车类型
|
busId: 2, //出租车类型 id.
|
height: 0, //屏幕高度
|
width: 0, //宽度
|
changeWayId: 1, //出行方式ID
|
carNum: 0, //默认附近车辆为0
|
selecttime: false,
|
selecttimeBc: false,
|
goTime: '选择时间',
|
adcode: 0, //滑动地图是判断当前城市的code
|
mapCode: wx.createMapContext("map4select"),
|
openMessage: false,
|
startChangeCar: true, //没有选择之前底部样式
|
endChangeCar: false, //选择起始点以后底部样式
|
taxiCode: [{
|
id: 1,
|
name: '现在'
|
}, {
|
id: 2,
|
name: '预约'
|
}, {
|
id: 3,
|
name: '代老人叫车'
|
}],
|
changeWayIdDown: 1,
|
checkDown: 1,
|
selecttip: false,
|
substitute: 0, //是否代叫
|
isDj: 1,
|
tip: '0元',
|
changePeople: "选乘车人",
|
changeModel: '线上计费',
|
payModel: '线上计费',
|
yyTime: '现在',
|
btnDisabled: false, //呼叫车按钮,
|
multiArray: [
|
[],
|
[],
|
[]
|
],
|
changephone: "",
|
btuBottom: 0,
|
newTime: "现在",
|
formLocation: true,
|
changeStartName: "",
|
// 顶部模式选择列表
|
modoList: [{
|
id: 1,
|
name: '普通模式'
|
}, {
|
id: 2,
|
name: '老年人模式'
|
}],
|
// 当前选择的模式
|
modeSelectId: wx.getStorageSync('modeId') || 1,
|
show_block: false,
|
//左侧个人中心
|
personalList: [{
|
name: "我的订单",
|
imgSrc: "../../img/icon_me_order.png",
|
},
|
{
|
name: "优惠券",
|
imgSrc: "../../img/icon_me_coupons.png",
|
},
|
{
|
name: "安全",
|
imgSrc: "../../img/icon_me_safety.png",
|
},
|
// {
|
// name: "钱包",
|
// imgSrc: "../../img/icon_me_wallet.png",
|
// },
|
// {
|
// name: "开发票",
|
// imgSrc: "../../img/icon_me_invoice.png",
|
// },
|
{
|
name: "意见反馈",
|
imgSrc: "../../img/icon_me_opinion.png",
|
},
|
{
|
name: "客服",
|
imgSrc: "../../img/icon_me_service.png",
|
},
|
{
|
name: "设置",
|
imgSrc: "../../img/icon_me_set.png",
|
},
|
],
|
showSwiperTop: false,
|
showFrist: true,
|
showCover: false,
|
//专车以后.........
|
special: [], //专车类型
|
specialId: 0, //专车默认id
|
haveQueryServerCarLodaing: true, //专车默认转圈
|
carName: "呼叫出租车",
|
orderTypeIng: "",
|
//跨城出行
|
abvoadStartLocation: "请选择起点",
|
abvoadEndLocation: "请选择终点",
|
abovadStartId: null, //选择起点ID
|
abovadEndId: null, //终点ID
|
selectdayNum: false,
|
bcPeopleNum: '', //用车人数
|
bcUseInfoNum: "", //联系人
|
bcUsePhoneNum: "", //联系人电话
|
useTime: '选择用车时间',
|
useTimeInfo: "", //用车时间
|
useHours: "选择用车时长",
|
dayNum: "", //用车时长
|
useCarTypeText: "选择车型要求",
|
useCarType: "", //用车类型
|
useCarTypeId: "", //用车类型ID
|
useCarTypePrice: "", //用车类型价格,
|
useHow: "选择车辆用途",
|
useHowdo: "", //用车用途
|
allPrice: "",
|
content: "", // 协议内容
|
BcSuccess: false,
|
showQueryLogisticsNumber: false,
|
sameUserInfo: true, //
|
sameUserInfoObj: {}, //小件物流个人信息
|
// 协议痰喘显示隐藏
|
agreementShow: wx.getStorageSync('token') ? false : !wx.getStorageSync('isAgreement') && true,
|
showModel: false,
|
jumpUrl: '',
|
priceObj:{},
|
},
|
|
|
//选择计费方式
|
changeModel() {
|
this.setData({
|
showModel: true
|
})
|
},
|
|
//关闭弹窗
|
onClose() {
|
this.setData({
|
showModel: false
|
})
|
},
|
|
bindTap(e) {
|
console.log('shuju', e);
|
},
|
|
|
//切换计费方式
|
changeTab1() {
|
this.setData({
|
changeModel: '线上计费'
|
})
|
},
|
|
//切换计费方式
|
changeTab2() {
|
console.log(2222222222);
|
this.setData({
|
changeModel: '打表计费'
|
})
|
},
|
|
changePayModel() {
|
this.setData({
|
payModel: this.data.changeModel,
|
showModel: false,
|
})
|
},
|
|
|
//邀请有礼跳转
|
shareGift() {
|
wx.navigateTo({
|
url: '/pages/invite/invite',
|
})
|
},
|
|
|
|
|
|
|
|
// 同意协议
|
agree() {
|
wx.setStorageSync('isAgreement', 1)
|
this.setData({
|
agreementShow: false
|
})
|
},
|
closeNotice() {
|
this.setData({
|
showNotice: false
|
})
|
},
|
// 不同意协议
|
disagree() {
|
if (wx.exitMiniProgram) {
|
wx.exitMiniProgram()
|
} else {
|
wx.navigateBack({
|
delta: 999,
|
})
|
}
|
|
},
|
// 协议弹窗切换
|
agreementChange(e) {
|
this.setData({
|
agreementSelect: e.currentTarget.dataset.id
|
})
|
this.getAgreement()
|
},
|
// 一键叫车
|
confirmClickCall() {
|
this.clickCall()
|
this.btnCar()
|
},
|
// 控制老年模式下一键叫车弹窗显示隐藏
|
clickCall() {
|
this.setData({
|
confirmPopupShow: !this.data.confirmPopupShow
|
})
|
},
|
callPhone() {
|
this.getIsBlack().then(res => {
|
if (res) {
|
const phone = this.data.homePhone.filter(item => item.type == 3 && item.platform == 1)
|
if (phone.length) {
|
wx.makePhoneCall({
|
phoneNumber: phone[0].phone //仅为示例,并非真实的电话号码
|
})
|
} else {
|
wx.showToast({
|
title: '助老模式暂未配置电话号码',
|
icon: 'none'
|
})
|
}
|
}
|
})
|
},
|
// 普通与老年模式切换
|
modeChange(e) {
|
this.setData({
|
modeSelectId: e.currentTarget.dataset.id
|
})
|
|
wx.setStorageSync('modeId', e.currentTarget.dataset.id)
|
},
|
//包车
|
clickPhone(e) {
|
console.log(e)
|
let phone = e.currentTarget.dataset.phone
|
wx.makePhoneCall({
|
phoneNumber: phone,
|
})
|
},
|
clickWeb() {
|
wx.navigateTo({
|
url: "/pages/setting/userHelp/userHelp?type=" + 14,
|
});
|
},
|
clickCarStyleBc() {
|
wx.navigateTo({
|
url: '/pages/bc-pages/bc-style/bc-style?day=' + this.data.dayNum,
|
})
|
},
|
clickCarTypeBc() {
|
console.log(this.data.dayNum)
|
wx.navigateTo({
|
url: '/pages/bc-pages/bc-type/bc-type',
|
})
|
},
|
clickCarDay() {
|
this.setData({
|
selectdayNum: true
|
})
|
},
|
onParentEventDayNum(e) {
|
console.log(e)
|
this.setData({
|
dayNum: e.detail
|
}, () => {
|
let useCarTypePrice = this.data.useCarTypePrice
|
if (useCarTypePrice !== '') {
|
let startPrice = useCarTypePrice.split('-')[0]
|
let endPrice = useCarTypePrice.split('-')[1]
|
if (e.detail !== undefined) {
|
let day = e.detail.substring(0, e.detail.length - 1);
|
this.setData({
|
allPrice: "¥" + startPrice * day + ' - ' + "¥" + endPrice * day
|
})
|
}
|
}
|
})
|
},
|
//包车乘车人数
|
bcPeople(e) {
|
console.log(e)
|
let bcPeopleNum = e.detail.value
|
this.setData({
|
bcPeopleNum
|
})
|
},
|
bcUseInfo(e) {
|
let bcUseInfoNum = e.detail.value
|
this.setData({
|
bcUseInfoNum
|
})
|
},
|
bcUsePhone(e) {
|
let bcUsePhoneNum = e.detail.value
|
this.setData({
|
bcUsePhoneNum
|
})
|
},
|
//提交
|
pushBcClick() {
|
this.orderCharteredCar()
|
},
|
async orderCharteredCar() {
|
let placeLonLat = wx.getStorageSync('userLocation')
|
let {
|
useTimeInfo,
|
dayNum,
|
useCarTypeId,
|
useHowdo,
|
bcPeopleNum, //用车人数
|
bcUseInfoNum, //联系人
|
bcUsePhoneNum, //联系人电话
|
} = this.data
|
console.log(bcPeopleNum)
|
let myreg = /^[1][3,4,5,7,8,9][0-9]{9}$/;
|
if (useTimeInfo == '') {
|
app.showToastSuccess('请选择用车时间', null, 'none', 1500)
|
return false
|
} else if (dayNum == '') {
|
app.showToastSuccess('请选择用车时长', null, 'none', 1500)
|
return false
|
} else if (useCarTypeId == '') {
|
app.showToastSuccess('请选择车型', null, 'none', 1500)
|
return false
|
} else if (useHowdo == '') {
|
app.showToastSuccess('请选择用车用途', null, 'none', 1500)
|
return false
|
} else if (bcPeopleNum == '' || bcPeopleNum == '0') {
|
app.showToastSuccess('请输入乘车人数', null, 'none', 1500)
|
return false
|
} else if (bcUseInfoNum == '') {
|
app.showToastSuccess('请填写联系人姓名', null, 'none', 1500)
|
return false
|
} else if (bcUsePhoneNum == '') {
|
app.showToastSuccess('请填写联系人电话', null, 'none', 1500)
|
return false
|
} else if (!myreg.test(bcUsePhoneNum)) {
|
app.showToastSuccess('请填写正确的手机号', null, 'none', 1500)
|
return false
|
}
|
let data = {
|
carTime: Number(dayNum.substring(0, dayNum.length - 1)),
|
contactPerson: bcUseInfoNum,
|
contactPhone: bcUsePhoneNum,
|
modelUse: useHowdo,
|
peopleNumber: bcPeopleNum,
|
placeLonLat,
|
serverCarModelId: useCarTypeId,
|
travelTime: useTimeInfo
|
}
|
let res = await orderCharteredCar(data)
|
console.log(res)
|
if (res.data.code == 200) {
|
this.setData({
|
BcSuccess: true,
|
useTimeInfo: "",
|
dayNum: "",
|
useCarTypeId: "",
|
useHowdo: "",
|
bcPeopleNum: "", //用车人数
|
bcUseInfoNum: "", //联系人
|
bcUsePhoneNum: "", //联系人电话
|
useCarType: "", //用车类型
|
})
|
} else {
|
app.showToastSuccess(res.data.msg, null, 'none', 1500)
|
this.setData({
|
BcSuccess: false
|
})
|
}
|
},
|
handelcloseOrder() {
|
this.setData({
|
BcSuccess: false
|
})
|
},
|
//同城小件物流
|
toTip() {
|
if (wx.getStorageSync('token') == '') {
|
wx.redirectTo({
|
url: '/pages/index/index',
|
})
|
return
|
}
|
wx.reLaunch({
|
url: '/pages/myTrip/myTrip?where=sameCity',
|
})
|
},
|
startChangeMap(e) {
|
console.log(e)
|
// 地图发生变化的时候,获取中间点
|
if (e.type == 'end' && (e.causedBy == 'scale' || e.causedBy == 'drag') && this.data.nextBoolean == false) {
|
var that = this;
|
this.mapCtx = wx.createMapContext("someCityMap");
|
//获取中心坐标 api
|
this.mapCtx.getCenterLocation({
|
// type: 'bd09ll',
|
success: function (res) {
|
that.setData({
|
latitude: this.transformFromGCJToBaidu(res.latitude, res.longitude).latitude,
|
longitude: this.transformFromGCJToBaidu(res.latitude, res.longitude).longitude,
|
})
|
that.getLocal(res.latitude, res.longitude)
|
console.log('2222222222222222222222222222222222');
|
that.getCarNum(res.latitude, res.longitude, that.data.busId)
|
}
|
})
|
}
|
},
|
|
transformFromGCJToBaidu(latitude, longitude) {
|
var pi = 3.14159265358979324 * 3000.0 / 180.0;
|
var z = Math.sqrt(longitude * longitude + latitude * latitude) + 0.00002 * Math.sin(latitude * pi);
|
var theta = Math.atan2(latitude, longitude) + 0.000003 * Math.cos(longitude * pi);
|
var a_latitude = (z * Math.sin(theta) + 0.006);
|
var a_longitude = (z * Math.cos(theta) + 0.0065);
|
|
return {
|
latitude: a_latitude,
|
longitude: a_longitude
|
};
|
},
|
//queryLogisticsNumber 获取首页小件物流订单数量
|
async queryLogisticsNumber() {
|
let res = await queryLogisticsNumber()
|
console.log(res)
|
if (res.data.code == 200) {
|
this.setData({
|
queryLogisticsNumber: res.data.data.number,
|
showQueryLogisticsNumber: true
|
})
|
}
|
},
|
//编辑个人信息
|
sameCityInfo() {
|
let sameUserInfoObj = this.data.sameUserInfoObj
|
wx.navigateTo({
|
url: '/pages/home/same-city-info/same-city-info?sameUserInfoObj=' + JSON.stringify(sameUserInfoObj),
|
})
|
},
|
//我的积分
|
handelClickintegral() {
|
wx.navigateTo({
|
url: '/pages/home/integral/integral?integral=' + this.data.userInfo.integral,
|
})
|
this.setData({
|
openMessage: false
|
})
|
},
|
//选择听成小件物流的类型
|
changeCityTypeStyle() {
|
let sameUserInfoObj = this.data.sameUserInfoObj
|
if (wx.getStorageSync('token') == '') {
|
wx.navigateTo({
|
url: '/pages/index/index',
|
})
|
return false
|
}
|
if (sameUserInfoObj.name == undefined) {
|
app.showToastSuccess('请完善收货人信息', null, 'none', 1500)
|
return false
|
}
|
let {
|
longitude,
|
latitude,
|
changeStartName,
|
cityNameStart,
|
busId
|
} = this.data
|
let dataInfo = {
|
longitude,
|
latitude,
|
changeStartName,
|
cityNameStart,
|
busId,
|
...this.data.sameUserInfoObj
|
}
|
wx.navigateTo({
|
url: '/pages/home/type-style/type-style?dataInfo=' + JSON.stringify(dataInfo),
|
})
|
},
|
//专车板块开始
|
//获取专车类型
|
queryServerCarMo() {
|
let endLonLat = this.data.nextLongitude + ',' + this.data.nextLatitude
|
let startLonLat = (this.data.startLon || this.data.longitude) + ',' + (this.data.startLat || this.data.latitude)
|
let type = 1
|
queryServerCarMo(endLonLat, startLonLat, type).then((res) => {
|
console.log(res)
|
if (res.data.code == 200) {
|
if (res.data.data.length > 0) {
|
this.setData({
|
special: res.data.data.map(x => {
|
x.amount = x.amount.toFixed(2)
|
return x
|
}),
|
haveQueryServerCarLodaing: false
|
})
|
} else {
|
this.setData({
|
btnDisabled: true
|
})
|
}
|
} else {
|
this.setData({
|
haveQueryServerCarLodaing: true
|
})
|
app.showToastSuccess(res.data.msg, null, 'none', 1500)
|
}
|
})
|
},
|
|
//点击专车
|
getSpecial(e) {
|
console.log(e)
|
let id = e.currentTarget.dataset.id
|
this.setData({
|
specialId: id
|
})
|
},
|
|
//专车下单
|
saveOrderPrivateCarAjax(
|
driverId,
|
endAddress,
|
endLat,
|
endLon,
|
orderSource,
|
orderType,
|
passengers,
|
passengersPhone,
|
placementLat,
|
placementLon,
|
serverCarModelId,
|
startAddress,
|
startLat,
|
startLon,
|
substitute,
|
travelTime,
|
type
|
) {
|
saveOrderPrivateCar(
|
driverId,
|
endAddress,
|
endLat,
|
endLon,
|
orderSource,
|
orderType,
|
passengers,
|
passengersPhone,
|
placementLat,
|
placementLon,
|
serverCarModelId,
|
startAddress,
|
startLat,
|
startLon,
|
substitute,
|
travelTime,
|
type
|
).then((res) => {
|
console.log(res)
|
if (res.data.code == 200) {
|
console.log(startAddress)
|
this.setData({
|
btnDisabled: false,
|
startChangeCar: true, //没有选择之前底部样式
|
endChangeCar: false, //选择起始点以后底部样式
|
nextCityName: "您要去哪儿",
|
yyTime: "现在",
|
tip: "0元",
|
markers: "",
|
points: "",
|
polyline: [],
|
showLocationIcon: true,
|
changephone: "",
|
changePeople: "更换乘车人",
|
startLon: "",
|
startLat: "",
|
specialId: 0,
|
nextBoolean: false
|
})
|
wx.setStorageSync('orderID', res.data.data.id)
|
wx.navigateTo({
|
url: '../../pages/waiting/waiting?startAddress=' +
|
startAddress + '&startLat=' +
|
startLat + '&startLon=' +
|
startLon + '&endAddress=' +
|
endAddress + '&endLat=' +
|
endLat + '&endLon=' +
|
endLon + '&time=' +
|
travelTime + '&orderType=' +
|
1,
|
})
|
} else if (res.data.code == 600) {
|
wx.navigateTo({
|
url: '/pages/index/index',
|
})
|
|
} else {
|
app.showToastSuccess(res.data.msg, null, 'none', 1500)
|
}
|
})
|
},
|
//专车板块结束
|
setSosPeople() {
|
wx.navigateTo({
|
url: '/pages/safe/urgent/urgent',
|
})
|
},
|
//跨城出行 选择起点
|
abvoadStartLocation() {
|
wx.navigateTo({
|
url: "/pages/advoad-start-location/index?where=statrLocation&abovadEndId=" + this.data.abovadEndId || ''
|
})
|
},
|
//跨域出行 选择终点
|
abvoadEndLocationClick() {
|
let {
|
abvoadStartLocation
|
} = this.data
|
if (abvoadStartLocation == '请选择起点') {
|
app.showToastSuccess('请先选择上车地点', null, 'none', 1500)
|
return false
|
}
|
wx.navigateTo({
|
url: "/pages/advoad-start-location/index?where=endLocation" + "&abovadStartId=" + this.data.abovadStartId
|
})
|
},
|
//跨城出行 城市切换
|
abovadCityChange() {
|
let {
|
abvoadStartLocation,
|
abvoadEndLocation,
|
abovadStartId, //选择起点ID
|
abovadEndId, //终点ID
|
} = this.data
|
this.setData({
|
abvoadStartLocation: abvoadEndLocation,
|
abvoadEndLocation: abvoadStartLocation,
|
abovadStartId: abovadEndId,
|
abovadEndId: abovadStartId,
|
})
|
},
|
//跨域出行 查询车辆CLICK
|
async queryLinesAjax(abovadEndId, abovadStartId) {
|
let {
|
abvoadStartLocation,
|
abvoadEndLocation,
|
orderType
|
} = this.data
|
if (abovadEndId == abovadStartId) {
|
app.showToastSuccess('起始点不能相同', null, 'none', 1500)
|
return false
|
}
|
let res1 = await queryLines(abovadEndId, abovadStartId)
|
console.log(res1)
|
let resData = res1.data.data
|
if (wx.getStorageSync('token') == '') {
|
wx.navigateTo({
|
url: '/pages/index/index',
|
})
|
return false
|
}
|
if (res1.data.code == 200) {
|
|
let resDataInfo = {
|
abovadStartId,
|
abovadEndId
|
}
|
if (resData.length > 1) {
|
wx.navigateTo({
|
url: `/pages/advoad-city-search/advoad-line/advoad-line?dataInfoAllin=${JSON.stringify(resData)}&ids=${JSON.stringify(resDataInfo)}`,
|
})
|
} else if (resData.length == 1) {
|
let resDataInfo = res1.data.data[0].id
|
wx.navigateTo({
|
url: `/pages/advoad-city-search/advoad-city-search?abovadEndId=${abovadEndId}&abovadStartId=${abovadStartId}&abvoadStartLocation=${abvoadStartLocation}&abvoadEndLocation=${abvoadEndLocation}&orderType=${orderType}&lineId=${resDataInfo}`,
|
})
|
} else if (resData.length == 0) {
|
app.showToastSuccess('暂无线路', null, 'none', 1500)
|
return false
|
}
|
this.setData({
|
abvoadStartLocation: "请选择起点",
|
abvoadEndLocation: "请选择终点",
|
abovadStartId: null, //选择起点ID
|
abovadEndId: null, //终点ID
|
})
|
} else {
|
app.showToastSuccess(res1.data.msg, null, 'none', 1500)
|
}
|
},
|
searchAbovad() {
|
let {
|
abovadStartId, //选择起点ID
|
abovadEndId, //终点ID
|
|
} = this.data
|
if (abovadStartId !== null && abovadEndId !== null) {
|
this.queryLinesAjax(abovadEndId, abovadStartId)
|
// if(dataInfoAllin.length == 1) {
|
// wx.navigateTo({
|
// url: `/pages/advoad-city-search/advoad-line/advoad-line?dataInfoAllin=${JSON.stringify(dataInfoAllin)}`,
|
// })
|
// return false
|
// }
|
// wx.navigateTo({
|
// url: `/pages/advoad-city-search/advoad-city-search?abovadEndId=${abovadEndId}&abovadStartId=${abovadStartId}&abvoadStartLocation=${abvoadStartLocation}&abvoadEndLocation=${abvoadEndLocation}&orderType=${orderType}`,
|
// })
|
|
} else {
|
app.showToastSuccess('查询失败', null, 'none', 1500)
|
}
|
},
|
|
preventD() {
|
|
|
|
},
|
//导航栏高度
|
onMyEvent: function (e) {
|
this.setData({
|
sendHeight: e.detail.sendHeight
|
});
|
},
|
setContainerHeight() {
|
let that = this;
|
//设置容器高度
|
that.setData({
|
containersHeight: wx.getSystemInfoSync().windowHeight - this.data.sendHeight
|
});
|
},
|
getMylocation() {
|
let mapCtx = wx.createMapContext('map4select');
|
mapCtx.moveToLocation({
|
success: (res) => {
|
console.log('adsadsad', res);
|
// this.getLocal(wx.getStorageSync('latitude'), wx.getStorageSync('longitude'),true)
|
this.getLocationApi()
|
|
this.setData({
|
newCityName: "",
|
cityName: wx.getStorageSync('cityName')
|
})
|
},
|
fail: (res) => {
|
console.log(res)
|
}
|
});
|
},
|
onCloseTop() {
|
this.setData({
|
showSwiperTop: false
|
})
|
},
|
|
//获取广告
|
getadver(adcode) {
|
if (wx.getStorageSync('adcode') !== "") {
|
unit.post(app.globalData.Url + "/base/advertisement/queryByType", {
|
type: 1,
|
code: adcode
|
})
|
.then((res) => {
|
if (Object.keys(res.data.data).length > 0) {
|
this.setData({
|
swiperTop: res.data.data,
|
showSwiperTop: true
|
})
|
}
|
})
|
}
|
},
|
//获取广告
|
getadver2(adcode) {
|
if (wx.getStorageSync('adcode') !== "") {
|
unit.post(app.globalData.Url + "/base/advertisement/queryByType", {
|
type: 2,
|
code: adcode
|
})
|
.then((res) => {
|
this.setData({
|
swiperBottom: res.data.data,
|
})
|
})
|
}
|
|
},
|
//扫一扫
|
scan() {
|
if (wx.getStorageSync('token') !== "") {
|
wx.scanCode({
|
success: (res) => {
|
var result = res.result.split(":")[1];
|
this.setData({
|
driverId: result,
|
})
|
wx.navigateTo({
|
url: '/pages/home/scanPage/scanPage?driverId=' + result,
|
})
|
}
|
})
|
} else {
|
wx.navigateTo({
|
url: '/pages/index/index',
|
})
|
}
|
},
|
changeInfo() {
|
wx.navigateTo({
|
url: '../../pages/myinfo/myinfo'
|
})
|
this.setData({
|
openMessage: false
|
})
|
},
|
//点击个人中心 跳转
|
clickPersonal(e) {
|
var name = e.currentTarget.dataset.name
|
this.setData({
|
openMessage: false
|
})
|
switch (name) {
|
case "我的订单":
|
wx.navigateTo({
|
url: '../../pages/myTrip/myTrip',
|
})
|
break;
|
case "优惠券":
|
wx.navigateTo({
|
url: '../../pages/coupon/coupon',
|
})
|
break;
|
case "安全":
|
wx.navigateTo({
|
url: '../../pages/safe/safe',
|
})
|
break;
|
case "钱包":
|
wx.navigateTo({
|
url: '../../pages/wallet/wallet',
|
})
|
break;
|
case "开发票":
|
|
break;
|
case "意见反馈":
|
|
wx.navigateTo({
|
url: '../../pages/feedback/feedback',
|
})
|
break
|
case "客服":
|
wx.navigateTo({
|
url: '../../pages/customer/customer',
|
})
|
break
|
case "设置":
|
wx.navigateTo({
|
url: '../../pages/setting/setting',
|
})
|
break
|
default:
|
}
|
},
|
/**
|
* 生命周期函数--监听页面加载
|
*/
|
setNavSize: function () {
|
var that = this,
|
sysinfo = wx.getSystemInfoSync(),
|
statusHeight = sysinfo.statusBarHeight,
|
isiOS = sysinfo.system.indexOf("iOS") > -1,
|
navHeight;
|
if (!isiOS) {
|
navHeight = 48;
|
} else {
|
navHeight = 44;
|
}
|
that.setData({
|
status: statusHeight,
|
navHeight: navHeight,
|
sendHeight: navHeight + statusHeight,
|
});
|
},
|
setStyle: function () {
|
var that = this,
|
containerStyle,
|
textStyle,
|
iconStyle;
|
containerStyle = ["background:" + that.data.background].join(";");
|
textStyle = [
|
"color:" + '#000000',
|
"font-size:" + that.data.fontSize + "px",
|
"font-weight:" + 500,
|
].join(";");
|
iconStyle = [
|
"width: " + that.data.iconWidth + "px",
|
"height: " + that.data.iconHeight + "px",
|
].join(";");
|
that.setData({
|
containerStyle: containerStyle,
|
textStyle: textStyle,
|
iconStyle: iconStyle,
|
});
|
},
|
homeBack() {
|
this.setData({
|
endChangeCar: false,
|
startChangeCar: true,
|
nextCityName: "您要去哪儿",
|
yyTime: "现在",
|
tip: "0元",
|
markers: "",
|
points: "",
|
polyline: [],
|
showLocationIcon: true,
|
changephone: '',
|
changePeople: "更换乘车人",
|
nextBoolean: false,
|
endAddress: '',
|
endLat: '',
|
endLon: '',
|
})
|
// this.getLocal(wx.getStorageSync('latitude'), wx.getStorageSync('longitude'))
|
// this.getLocal(wx.getStorageSync('userLocation').split(",")[1], wx.getStorageSync('userLocation').split(",")[0])
|
this.getLocal(wx.getStorageSync('latitude'), wx.getStorageSync('longitude'))
|
},
|
// 获取隐私协议和用户协议
|
getAgreement() {
|
wx.showLoading({
|
mask: true
|
})
|
var data = {
|
type: +this.data.agreementSelect
|
}
|
wx.request({
|
url: app.globalData.Url + '/base/agreement/queryByType?type=' + this.data.agreementSelect,
|
method: "POST",
|
data: data,
|
success: (res) => {
|
this.setData({
|
content: res.data.data.content
|
})
|
wx.hideLoading()
|
},
|
fail() {
|
wx.hideLoading()
|
}
|
})
|
},
|
onLoad: function (options) {
|
//swiper
|
// app.getFloatStr(5)
|
// this.show()
|
|
console.log('shuju1111111111', options);
|
|
if (options.scene) {
|
console.log(1111111111, );
|
const uidMatch = options.scene.match(/uid%3D(\d+)/);
|
const userTypeMatch = options.scene.match(/userType%3D(\d+)/);
|
// 提取匹配到的值
|
const uid = uidMatch ? uidMatch[1] : null;
|
const userType = userTypeMatch ? userTypeMatch[1] : null;
|
wx.setStorageSync('uid', uid)
|
wx.setStorageSync('userType', userType)
|
}
|
|
|
|
this.getAgreement()
|
this.getSwiper()
|
this.getHomePhone()
|
this.getNotice()
|
if (Object.keys(options).length == 0) {
|
this.getadver(wx.getStorageSync('adcode') || this.data.adcode)
|
}
|
this.setNavSize()
|
this.setStyle()
|
let isPhone = app.globalData.isIphoneX;
|
if (isPhone) {
|
this.setData({
|
btuBottom: 68,
|
})
|
}
|
if (options.where == 'index') {
|
this.setData({
|
latitude: options.latitude,
|
longitude: options.longitude,
|
cityNameStart: options.cityNameStart
|
})
|
}
|
this.setData({
|
height: wx.getSystemInfoSync().windowHeight,
|
width: wx.getSystemInfoSync().windowWidth,
|
})
|
},
|
|
// 获取是否进入黑名单
|
async getIsBlack() {
|
let res = await unit.post(app.globalData.Url + '/api/checkBlack')
|
if (res.data.code == -1) {
|
//已经进入黑名单
|
this.setData({
|
showBlack: true
|
})
|
return false
|
} else {
|
return true
|
}
|
},
|
//获取最新通知
|
getNotice() {
|
unit.post(app.globalData.Url + '/base/notice/allert').then(res => {
|
if (res.data.data[0]?.id) {
|
// let regex = /<a[^>]*\shref="([^"]+)"[^>]*>([^<]+)<\/a>/gi;
|
// let url = regex.exec(res.data.data[0].content)[1]
|
// console.log('shuju45645648488464',url);
|
this.setData({
|
noticeInfo: res.data.data[0],
|
showNotice: true,
|
// jumpUrl: url
|
})
|
unit.post(app.globalData.Url + '/api/systemNotice/delSystemNotice', {
|
id: res.data.data[0].id
|
})
|
}
|
})
|
},
|
//跳转广告配置的h5
|
|
goWebView() {
|
// if(this.data.jumpUrl){
|
// let idStr = this.data.jumpUrl.split('?')[1].split('=')[1]
|
// // let urlStr = `/pages/home/webh5/webh5?act=1&url=${this.data.jumpUrl}&${idStr}`
|
// console.log('//////////',idStr);
|
// wx.navigateTo({
|
// url: `/pages/home/webh5/webh5?act=1&id=${idStr}&url=` + this.data.jumpUrl,
|
// })
|
// }
|
wx.navigateTo({
|
url: '/pages/setting/userHelp/userHelp?type=5',
|
})
|
},
|
getSetting() {
|
var that = this
|
wx.getSetting({
|
success: (res) => {
|
if (res.authSetting['scope.userLocation'] == false) {
|
wx.showModal({
|
content: '检测到您没打开定位权限,是否去设置打开?',
|
confirmText: "确认",
|
cancelText: "取消",
|
success: (res) => {
|
if (res.confirm) {
|
wx.openSetting({
|
success: (res) => {
|
if (res.authSetting['scope.userLocation'] == true) {
|
wx.showToast({
|
title: '授权成功',
|
icon: 'success',
|
duration: 1000
|
})
|
//接入百度地图方法
|
var bmap = new BaiduMap.BMapWX({
|
ak: 'fi3HGJjW153NCNsaTb9FekxeX1Lj3auo' // 必填,您的key
|
})
|
|
// bmap.regeocoding({
|
// success: (res) => {
|
// that.setData({
|
// cityName:res[0].regeocodeData.addressComponent.city,
|
// latitude: res[0].latitude,
|
// longitude:res[0].longitude,
|
// adcode:res[0].regeocodeData.addressComponent.adcode,
|
// cityNameStart:res[0].name,
|
// district:res[0].regeocodeData.addressComponent.province,
|
// formatted_address:res[0].regeocodeData.formatted_address
|
// })
|
// wx.setStorageSync('latitude', res.originalData.result.location.lat)
|
// wx.setStorageSync('longitude', res.originalData.result.location.lng)
|
// wx.setStorageSync('adcode', res.originalData.result.addressComponent.adcode)
|
// wx.setStorageSync('cityName', res.originalData.result.addressComponent.city)
|
// wx.setStorageSync('cityNameStart', res.originalData.result.formatted_address)
|
// wx.setStorageSync('district', res.originalData.result.addressComponent.district)
|
// wx.setStorageSync('province', res.originalData.result.addressComponent.province)
|
// wx.setStorageSync('formatted_address', res.originalData.result.formatted_address)
|
// that.queryBusiness(res.originalData.result.addressComponent.city, res.originalData.result.addressComponent.district, res.originalData.result.addressComponent.province)
|
// that.getCarNum(res.originalData.result.location.lat, res.originalData.result.location.lng, that.data.busId)
|
// that.openCity(res.originalData.result.addressComponent.adcode)
|
// that.getadver2(wx.getStorageSync('adcode') || res.originalData.result.addressComponent.adcode)
|
// }
|
// })
|
wx.getLocation({
|
// isHighAccuracy:true,
|
type: 'gcj02',
|
success: res => {
|
that.setData({
|
latitude: res.latitude,
|
longitude: res.longitude
|
})
|
wx.setStorageSync('latitude', res.latitude)
|
wx.setStorageSync('longitude', res.longitude)
|
wx.request({
|
url: `https://api.map.baidu.com/geoconv/v2/?coords=${res.longitude},${res.latitude}&model=1&ak=3mHKIXMArjgIkgADzOlTYp4XssNSNkwr`,
|
success: function (res) {
|
bmap.regeocoding({
|
coordtype: 'bd09ll',
|
location: res.data.result[0].y + ',' + res.data.result[0].x,
|
success: function (res) {
|
// that.setData({
|
// cityName: res.originalData.result.addressComponent.city,
|
// // latitude: res.originalData.result.location.lat,
|
// // longitude: res.originalData.result.location.lng,
|
// adcode: res.originalData.result.addressComponent.adcode,
|
// cityNameStart: res.originalData.result.formatted_address,
|
// district: res.originalData.result.addressComponent.district,
|
// province: res.originalData.result.addressComponent.province,
|
// formatted_address: res.originalData.result.formatted_address
|
// })
|
|
wx.setStorageSync('adcode', res.originalData.result.addressComponent.adcode)
|
wx.setStorageSync('cityName', res.originalData.result.addressComponent.city)
|
wx.setStorageSync('cityNameStart', res.originalData.result.formatted_address)
|
wx.setStorageSync('district', res.originalData.result.addressComponent.district)
|
wx.setStorageSync('province', res.originalData.result.addressComponent.province)
|
wx.setStorageSync('formatted_address', res.originalData.result.formatted_address)
|
that.queryBusiness(res.originalData.result.addressComponent.city, res.originalData.result.addressComponent.district, res.originalData.result.addressComponent.province)
|
that.getCarNum(res.originalData.result.location.lat, res.originalData.result.location.lng, that.data.busId)
|
that.openCity(res.originalData.result.addressComponent.adcode)
|
that.getadver2(wx.getStorageSync('adcode') || res.originalData.result.addressComponent.adcode)
|
},
|
fail: function (res) {
|
that.setData({
|
cityNameStart: "正在定位中"
|
})
|
},
|
})
|
}
|
})
|
}
|
})
|
}
|
},
|
})
|
}
|
}
|
})
|
} else {
|
this.getLocationApi()
|
}
|
},
|
})
|
},
|
// 选择服务城市
|
selectCity() {
|
wx.navigateTo({
|
url: '/pages/changeCity/changeCity',
|
})
|
},
|
//getLocation函数封装
|
getLocationApi() {
|
var that = this
|
// this.getMylocation()
|
// wx.onLocationChange(() => {})
|
|
wx.getLocation({
|
// altitude: 'altitude',00
|
type: 'gcj02',
|
success: (res) => {
|
wx.getSetting({
|
success: (res) => {
|
this.setData({
|
isLocation: true
|
})
|
console.log(res.authSetting['scope.userLocation'], res.authSetting['scope.userLocation'])
|
if (res.authSetting['scope.userLocation'] != undefined && res.authSetting['scope.userLocation'] !== true) {
|
wx.showModal({
|
cancelColor: 'cancelColor',
|
title: '请求获取位置信息',
|
confirmText: "确认",
|
cancelText: "取消",
|
success: (res) => {
|
wx.showModal({
|
cancelColor: res,
|
})
|
if (res.confirm) {
|
var bmap = new BaiduMap.BMapWX({
|
ak: 'fi3HGJjW153NCNsaTb9FekxeX1Lj3auo' // 必填,您的key
|
})
|
|
wx.getLocation({
|
// isHighAccuracy:true,
|
type: 'gcj02',
|
success: res => {
|
that.setData({
|
latitude: res.latitude,
|
longitude: res.longitude
|
})
|
wx.setStorageSync('latitude', res.latitude)
|
wx.setStorageSync('longitude', res.longitude)
|
wx.request({
|
url: `https://api.map.baidu.com/geoconv/v2/?coords=${res.longitude},${res.latitude}&model=1&ak=3mHKIXMArjgIkgADzOlTYp4XssNSNkwr`,
|
success: function (res) {
|
bmap.regeocoding({
|
coordtype: 'bd09ll',
|
location: res.data.result[0].y + ',' + res.data.result[0].x,
|
success: function (res) {
|
that.setData({
|
cityName: res.originalData.result.addressComponent.city,
|
// latitude: res.originalData.result.location.lat,
|
// longitude: res.originalData.result.location.lng,
|
adcode: res.originalData.result.addressComponent.adcode,
|
cityNameStart: res.originalData.result.formatted_address,
|
district: res.originalData.result.addressComponent.district,
|
province: res.originalData.result.addressComponent.province,
|
formatted_address: res.originalData.result.formatted_address
|
})
|
|
wx.setStorageSync('adcode', res.originalData.result.addressComponent.adcode)
|
wx.setStorageSync('cityName', res.originalData.result.addressComponent.city)
|
wx.setStorageSync('cityNameStart', res.originalData.result.formatted_address)
|
wx.setStorageSync('district', res.originalData.result.addressComponent.district)
|
wx.setStorageSync('province', res.originalData.result.addressComponent.province)
|
wx.setStorageSync('formatted_address', res.originalData.result.formatted_address)
|
that.queryBusiness(res.originalData.result.addressComponent.city, res.originalData.result.addressComponent.district, res.originalData.result.addressComponent.province)
|
that.getCarNum(res.originalData.result.location.lat, res.originalData.result.location.lng, that.data.busId)
|
that.openCity(res.originalData.result.addressComponent.adcode)
|
that.getadver2(wx.getStorageSync('adcode') || res.originalData.result.addressComponent.adcode)
|
},
|
fail: function (res) {
|
that.setData({
|
cityNameStart: "正在定位中"
|
})
|
},
|
})
|
}
|
})
|
}
|
})
|
} else {
|
wx.showToast({
|
title: '拒绝授权',
|
})
|
}
|
}
|
})
|
} else if (res.authSetting['scope.userLocation'] == undefined) {
|
wx.showModal({
|
content: '检测到您没打开定位权限,是否去设置打开?',
|
confirmText: "确认",
|
cancelText: "取消",
|
success: function (res) {
|
//点击“确认”时打开设置页面
|
if (res.confirm) {
|
console.log('用户点击确认')
|
wx.openSetting({
|
success: (res) => {
|
if (res.authSetting['scope.userLocation'] == true) {
|
wx.showToast({
|
title: '授权成功',
|
icon: 'success',
|
duration: 1000
|
})
|
//接入高地地图调用.....
|
var bmap = new BaiduMap.BMapWX({
|
ak: 'fi3HGJjW153NCNsaTb9FekxeX1Lj3auo' // 必填,您的key
|
})
|
|
wx.getLocation({
|
// isHighAccuracy:true,
|
type: 'gcj02',
|
success: res => {
|
that.setData({
|
latitude: res.latitude,
|
longitude: res.longitude
|
})
|
console.log('7878787878787////////////////');
|
wx.setStorageSync('latitude', res.latitude)
|
wx.setStorageSync('longitude', res.longitude)
|
wx.request({
|
url: `https://api.map.baidu.com/geoconv/v2/?coords=${res.longitude},${res.latitude}&model=1&ak=3mHKIXMArjgIkgADzOlTYp4XssNSNkwr`,
|
success: function (res) {
|
bmap.regeocoding({
|
coordtype: 'bd09ll',
|
location: res.data.result[0].y + ',' + res.data.result[0].x,
|
success: function (res) {
|
that.setData({
|
cityName: res.originalData.result.addressComponent.city,
|
// latitude: res.originalData.result.location.lat,
|
// longitude: res.originalData.result.location.lng,
|
adcode: res.originalData.result.addressComponent.adcode,
|
cityNameStart: res.originalData.result.formatted_address,
|
district: res.originalData.result.addressComponent.district,
|
province: res.originalData.result.addressComponent.province,
|
formatted_address: res.originalData.result.formatted_address
|
})
|
|
wx.setStorageSync('adcode', res.originalData.result.addressComponent.adcode)
|
wx.setStorageSync('cityName', res.originalData.result.addressComponent.city)
|
wx.setStorageSync('cityNameStart', res.originalData.result.formatted_address)
|
wx.setStorageSync('district', res.originalData.result.addressComponent.district)
|
wx.setStorageSync('province', res.originalData.result.addressComponent.province)
|
wx.setStorageSync('formatted_address', res.originalData.result.formatted_address)
|
that.queryBusiness(res.originalData.result.addressComponent.city, res.originalData.result.addressComponent.district, res.originalData.result.addressComponent.province)
|
that.getCarNum(res.originalData.result.location.lat, res.originalData.result.location.lng, that.data.busId)
|
that.openCity(res.originalData.result.addressComponent.adcode)
|
that.getadver2(wx.getStorageSync('adcode') || res.originalData.result.addressComponent.adcode)
|
},
|
fail: function (res) {
|
that.setData({
|
cityNameStart: "正在定位中"
|
})
|
},
|
})
|
}
|
})
|
}
|
})
|
}
|
},
|
})
|
} else {
|
console.log('用户点击取消')
|
}
|
}
|
});
|
} else if (res.authSetting['scope.userLocation'] == true) {
|
var bmap = new BaiduMap.BMapWX({
|
ak: 'fi3HGJjW153NCNsaTb9FekxeX1Lj3auo' // 必填,您的key
|
})
|
wx.getLocation({
|
// isHighAccuracy:true,
|
type: 'gcj02',
|
success: res => {
|
that.setData({
|
latitude: res.latitude,
|
longitude: res.longitude
|
})
|
console.log('wewaeawewaq2e12', res);
|
wx.setStorageSync('latitude', res.latitude)
|
wx.setStorageSync('longitude', res.longitude)
|
wx.request({
|
url: `https://api.map.baidu.com/geoconv/v2/?coords=${res.longitude},${res.latitude}&model=1&ak=3mHKIXMArjgIkgADzOlTYp4XssNSNkwr`,
|
success: function (res) {
|
console.log('weqwewqeqwe41545454545545445', res);
|
bmap.regeocoding({
|
coordtype: 'bd09ll',
|
location: res.data.result[0].y + ',' + res.data.result[0].x,
|
success: (res) => {
|
console.log('shuju//////////////////', res);
|
that.setData({
|
cityName: res.originalData.result.addressComponent.city,
|
// latitude: res.originalData.result.location.lat,
|
// longitude: res.originalData.result.location.lng,
|
adcode: res.originalData.result.addressComponent.adcode,
|
cityNameStart: res.originalData.result.formatted_address,
|
changeStartName: res.originalData.result.formatted_address,
|
district: res.originalData.result.addressComponent.district,
|
province: res.originalData.result.addressComponent.province,
|
formatted_address: res.originalData.result.formatted_address
|
})
|
|
wx.setStorageSync('adcode', res.originalData.result.addressComponent.adcode)
|
wx.setStorageSync('cityName', res.originalData.result.addressComponent.city)
|
wx.setStorageSync('cityNameStart', res.originalData.result.formatted_address)
|
wx.setStorageSync('district', res.originalData.result.addressComponent.district)
|
wx.setStorageSync('province', res.originalData.result.addressComponent.province)
|
wx.setStorageSync('formatted_address', res.originalData.result.formatted_address)
|
that.queryBusiness(res.originalData.result.addressComponent.city, res.originalData.result.addressComponent.district, res.originalData.result.addressComponent.province)
|
that.getCarNum(res.originalData.result.location.lat, res.originalData.result.location.lng, that.data.busId)
|
that.openCity(res.originalData.result.addressComponent.adcode)
|
that.getadver2(wx.getStorageSync('adcode') || res.originalData.result.addressComponent.adcode)
|
},
|
fail: function (res) {
|
that.setData({
|
cityNameStart: "正在定位中"
|
})
|
},
|
})
|
}
|
})
|
}
|
})
|
|
}
|
},
|
})
|
},
|
fail(err) {
|
console.log(err, this.data.isLocation)
|
this.setData({
|
isLocation: false
|
})
|
}
|
})
|
},
|
get() {
|
wx.makePhoneCall({
|
phoneNumber: this.data.homePhone[0].phone,
|
success: (res) => {},
|
fail: (res) => {}
|
})
|
},
|
serverPhone() {
|
this.setData({
|
showBlack: false
|
})
|
wx.makePhoneCall({
|
phoneNumber: this.data.homePhone[1].phone,
|
success: (res) => {},
|
fail: (res) => {}
|
})
|
},
|
getHomePhone() {
|
unit.post(app.globalData.Url + "/base/phone/queryPhones", {
|
code: wx.getStorageSync('adcode')
|
})
|
.then((res) => {
|
this.setData({
|
homePhone: res.data.data
|
})
|
})
|
},
|
//获取消息个数
|
getInfoMessage() {
|
unit.post(app.globalData.Url + "/api/systemNotice/queryNoReadNoticeNum")
|
.then((res) => {
|
if (res.data.code == 200) {
|
if (res.data.data.number > 0) {
|
this.setData({
|
show_block: true
|
})
|
}
|
} else if (res.data.code == 600 || res.data.code == 700) {
|
|
}
|
})
|
},
|
|
//呼叫出租车
|
taxiBtnFun(index, mode) {
|
if (wx.getStorageSync('userId') == "") {
|
wx.navigateTo({
|
url: '/pages/index/index',
|
})
|
return false
|
}
|
console.log(this.data.changePeople, 78778)
|
// if ((this.data.changePeople == "选乘车人" || !this.data.changePeople) && this.data.modeSelectId != 2) {
|
// wx.showToast({
|
// title: '请选择乘车人',
|
// icon: "none",
|
// duration: 1500,
|
// })
|
// return
|
// }
|
if (this.data.checkDown == 3) {
|
if (this.data.changePeople == "更换乘车人") {
|
wx.showToast({
|
title: '请选择乘车人',
|
icon: "none",
|
duration: 1500,
|
})
|
return
|
}
|
}
|
if (wx.getStorageSync('stepName') == "") {
|
wx.navigateTo({
|
url: '/pages/safe/urgent/urgent',
|
})
|
return false
|
}
|
this.setData({
|
btnDisabled: true
|
})
|
var DATE = unit.formatTimeUser(new Date());
|
|
if (this.data.checkDown == 2) {
|
if (this.data.yyTime == "现在") {
|
this.setData({
|
date: DATE,
|
})
|
} else {
|
this.setData({
|
date: this.data.newTime || DATE,
|
})
|
}
|
if (this.data.changePeople !== "更换乘车人") {
|
this.setData({
|
substitute: 1
|
})
|
}
|
this.setData({
|
isDj: 2
|
})
|
} else {
|
if (this.data.changePeople !== "更换乘车人") {
|
this.setData({
|
substitute: 1
|
})
|
}
|
this.setData({
|
date: DATE,
|
isDj: 1
|
})
|
}
|
if (this.data.checkDown !== 3) {} else {
|
this.setData({
|
substitute: 1
|
})
|
}
|
if (this.data.changePeople == "更换乘车人") {
|
this.data.changePeople = ''
|
}
|
let startLat = this.data.startLat || this.data.latitude
|
let startLon = this.data.startLon || this.data.longitude
|
let token = wx.getStorageSync('token')
|
var header = {
|
"content-type": "application/x-www-form-urlencoded",
|
Authorization: "Bearer" + " " + token,
|
}
|
if (!this.data.changePeople) this.data.changePeople = '选乘车人'
|
let btnCarData = {
|
endAddress: this.data.endAddress || '',
|
endLat: JSON.parse(JSON.stringify(this.data.nextLatitude || '')),
|
endLon: JSON.parse(JSON.stringify(this.data.nextLongitude || '')),
|
orderSource: 3,
|
orderType: this.data.isDj,
|
passengers: this.data.changePeople,
|
passengersPhone: this.data.changephone || wx.getStorageSync('phone'),
|
placementLat: this.data.latitude,
|
placementLon: this.data.longitude,
|
startAddress: this.data.changeStartName || this.data.cityNameStart,
|
startLat: JSON.parse(JSON.stringify(startLat)),
|
startLon: JSON.parse(JSON.stringify(startLon)),
|
areaCode: wx.getStorageSync('adcode'),
|
substitute: this.data.substitute, //代下单
|
tipMoney: +this.data.tip.substr(0, this.data.tip.length - 1),
|
travelTime: this.data.date,
|
payManner: this.data.modeSelectId == 2 ? 3 : this.data.payModel == '线上计费' ? 1 : 2
|
}
|
if (btnCarData.endLon) {
|
wx.request({
|
url: `https://api.map.baidu.com/geoconv/v2/?coords=${btnCarData.startLon},${btnCarData.startLat};${btnCarData.endLon},${btnCarData.endLat}&model=1&ak=3mHKIXMArjgIkgADzOlTYp4XssNSNkwr`,
|
success: (res) => {
|
btnCarData.startLon = res.data.result[0].x
|
btnCarData.startLat = res.data.result[0].y
|
// btnCarData.endLon = res.data.result[1]?.x
|
// btnCarData.endLat = res.data.result[1]?.y
|
if (Object.keys(btnCarData).length == 17) {
|
btnCarData.oldPeople = Number(!mode)
|
if (Number(!mode)) {
|
btnCarData.endAddress = ''
|
btnCarData.endLat = ''
|
btnCarData.endLon = ''
|
this.setData({
|
endAddress: '',
|
nextLatitude: '',
|
nextLongitude: '',
|
})
|
}
|
unit.post(app.globalData.Url + '/api/taxi/taxiOrder',
|
btnCarData,
|
)
|
.then((res) => {
|
if (res.data.code == 200) {
|
wx.setStorageSync('orderID', res.data.data.id)
|
wx.navigateTo({
|
url: '../../pages/waiting/waiting?startAddress=' +
|
(this.data.changeStartName || this.data.cityNameStart) + '&startLat=' +
|
startLat + '&startLon=' +
|
startLon + '&endAddress=' +
|
this.data.endAddress + '&endLat=' +
|
this.data.nextLatitude + '&endLon=' +
|
this.data.nextLongitude + '&time=' +
|
this.data.date + '&orderType=' + 2 + "&onekey=" +
|
index
|
|
})
|
this.setData({
|
btnDisabled: false,
|
startChangeCar: true, //没有选择之前底部样式
|
endChangeCar: false, //选择起始点以后底部样式
|
nextCityName: "您要去哪儿",
|
yyTime: "现在",
|
tip: "0元",
|
markers: "",
|
points: "",
|
polyline: [],
|
showLocationIcon: true,
|
changephone: "",
|
changePeople: "更换乘车人",
|
startLon: "",
|
startLat: "",
|
nextBoolean: false,
|
|
endAddress: '',
|
endLat: '',
|
endLon: '',
|
|
})
|
} else if (res.data.code == 600 || res.data.code == 700) {
|
// 清空本地token
|
wx.navigateTo({
|
url: '/pages/index/index',
|
})
|
setTimeout(() => {
|
this.setData({
|
btnDisabled: false
|
})
|
})
|
} else if (res.data.code == 500) {
|
if (res.data.msg == '有未完成的订单') {
|
this.getNowOrder()
|
} else {
|
app.showToastSuccess(res.data.msg, null, 'none', 1500)
|
}
|
|
setTimeout(() => {
|
this.setData({
|
btnDisabled: false
|
})
|
}, 2000)
|
} else {
|
setTimeout(() => {
|
this.setData({
|
btnDisabled: false
|
})
|
}, 2000)
|
app.showToastSuccess(res.data.msg, null, 'none', 1500)
|
}
|
})
|
} else {
|
setTimeout(() => {
|
this.setData({
|
btnDisabled: false
|
})
|
}, 2000)
|
app.showToastSuccess('参数错误', null, 'none', 1500)
|
}
|
},
|
})
|
} else {
|
wx.request({
|
url: `https://api.map.baidu.com/geoconv/v2/?coords=${btnCarData.startLon},${btnCarData.startLat}&model=1&ak=3mHKIXMArjgIkgADzOlTYp4XssNSNkwr`,
|
success: (res) => {
|
btnCarData.startLon = res.data.result[0].x
|
btnCarData.startLat = res.data.result[0].y
|
// btnCarData.endLon = res.data.result[1]?.x
|
// btnCarData.endLat = res.data.result[1]?.y
|
if (Object.keys(btnCarData).length == 17) {
|
btnCarData.oldPeople = Number(!mode)
|
if (Number(!mode)) {
|
btnCarData.endAddress = ''
|
btnCarData.endLat = ''
|
btnCarData.endLon = ''
|
this.setData({
|
endAddress: '',
|
nextLatitude: '',
|
nextLongitude: '',
|
})
|
}
|
unit.post(app.globalData.Url + '/api/taxi/taxiOrder',
|
btnCarData,
|
)
|
.then((res) => {
|
if (res.data.code == 200) {
|
wx.setStorageSync('orderID', res.data.data.id)
|
wx.navigateTo({
|
url: '../../pages/waiting/waiting?startAddress=' +
|
(this.data.changeStartName || this.data.cityNameStart) + '&startLat=' +
|
startLat + '&startLon=' +
|
startLon + '&endAddress=' +
|
this.data.endAddress + '&endLat=' +
|
this.data.nextLatitude + '&endLon=' +
|
this.data.nextLongitude + '&time=' +
|
this.data.date + '&orderType=' + 2 + "&onekey=" +
|
index
|
|
})
|
this.setData({
|
btnDisabled: false,
|
startChangeCar: true, //没有选择之前底部样式
|
endChangeCar: false, //选择起始点以后底部样式
|
nextCityName: "您要去哪儿",
|
yyTime: "现在",
|
tip: "0元",
|
markers: "",
|
points: "",
|
polyline: [],
|
showLocationIcon: true,
|
changephone: "",
|
changePeople: "更换乘车人",
|
startLon: "",
|
startLat: "",
|
nextBoolean: false,
|
|
endAddress: '',
|
endLat: '',
|
endLon: '',
|
|
})
|
} else if (res.data.code == 600 || res.data.code == 700) {
|
// 清空本地token
|
wx.navigateTo({
|
url: '/pages/index/index',
|
})
|
setTimeout(() => {
|
this.setData({
|
btnDisabled: false
|
})
|
})
|
} else if (res.data.code == 500) {
|
if (res.data.msg == '有未完成的订单') {
|
this.getNowOrder()
|
} else {
|
app.showToastSuccess(res.data.msg, null, 'none', 1500)
|
}
|
|
setTimeout(() => {
|
this.setData({
|
btnDisabled: false
|
})
|
}, 2000)
|
} else {
|
setTimeout(() => {
|
this.setData({
|
btnDisabled: false
|
})
|
}, 2000)
|
app.showToastSuccess(res.data.msg, null, 'none', 1500)
|
}
|
})
|
} else {
|
setTimeout(() => {
|
this.setData({
|
btnDisabled: false
|
})
|
}, 2000)
|
app.showToastSuccess('参数错误', null, 'none', 1500)
|
}
|
},
|
})
|
}
|
|
|
console.log('wdawdad', btnCarData);
|
|
},
|
//下单按钮
|
btnCar(e) {
|
// this.getIsBlack()
|
let token = wx.getStorageSync('token')
|
let index = e ? e.currentTarget.dataset.index : 0
|
let havePhone = wx.getStorageSync("havePhone")
|
let header = {
|
"Content-Type": "application/json;charset=UTF-8,",
|
Authorization: "Bearer" + " " + token,
|
};
|
wx.request({
|
url: app.globalData.Url + '/api/checkBlack',
|
header,
|
method: 'POST',
|
success: (res) => {
|
if (res.data.code == -1) {
|
this.setData({
|
showBlack: true
|
})
|
} else {
|
if (this.data.cityNameStart == '正在获取位置信息') {
|
wx.showToast({
|
title: '请选择起点',
|
icon: 'none'
|
})
|
return false
|
}
|
if (!token || token == '') {
|
wx.navigateTo({
|
url: '/pages/index/index',
|
})
|
return false
|
}
|
if (!havePhone) {
|
wx.navigateTo({
|
url: '/pages/wxChatPhone/wxChatPhone',
|
})
|
return false
|
}
|
|
let busId = this.data.busId
|
if (busId == 2) {
|
this.taxiBtnFun(index, Boolean(e))
|
} else if (busId == 1) {
|
let startLat = this.data.startLat || this.data.latitude
|
let startLon = this.data.startLon || this.data.longitude
|
let DATE = unit.formatTimeUser(new Date());
|
let travelTime
|
let orderType
|
let {
|
endAddress,
|
nextLatitude,
|
nextLongitude,
|
isDj,
|
changePeople,
|
changephone,
|
latitude,
|
longitude,
|
cityNameStart,
|
substitute,
|
yyTime,
|
newTime,
|
specialId
|
} = this.data
|
console.log(changePeople)
|
if (yyTime == '现在') {
|
travelTime = DATE
|
orderType = 1
|
} else {
|
travelTime = newTime
|
orderType = 2
|
}
|
if (changePeople == '更换乘车人') {
|
substitute = 0
|
changePeople = ''
|
} else {
|
substitute = 1
|
}
|
if (specialId == '') {
|
app.showToastSuccess('请选择车型', null, 'none', 1500)
|
return
|
}
|
if (wx.getStorageSync('userId') == "") {
|
wx.navigateTo({
|
url: '/pages/index/index',
|
})
|
return false
|
}
|
if (wx.getStorageSync('stepName') == "") {
|
wx.navigateTo({
|
url: '/pages/safe/urgent/urgent',
|
})
|
return false
|
}
|
this.saveOrderPrivateCarAjax('', endAddress, nextLatitude, nextLongitude, 3, orderType, changePeople, changephone, latitude, longitude, specialId, cityNameStart, startLat, startLon, substitute, travelTime, 1)
|
}
|
}
|
}
|
})
|
},
|
//获取滚动消息
|
getSwiper() {
|
unit.post(app.globalData.Url + "/base/notice/queryNotices", {
|
type: 1
|
})
|
.then((res) => {
|
console.log(res)
|
this.setData({
|
swiper: res.data.data
|
})
|
})
|
},
|
//获取正在进行中的订单
|
getNowOrder() {
|
unit.post(app.globalData.Url + '/api/order/queryServingOrder')
|
.then((res) => {
|
console.log(res)
|
if (res.data.code == 200) {
|
wx.setStorageSync('orderID', res.data.data[0].orderId)
|
wx.showModal({
|
title: "您有正在进行中的订单!",
|
content: "",
|
showCancel: true,
|
cancelText: "取消",
|
cancelColor: "#000000",
|
confirmText: "确定",
|
confirmColor: "#F07207",
|
success: result => {
|
if (result.confirm) {
|
wx.navigateTo({
|
url: "/pages/myTrip/myTrip",
|
});
|
}
|
},
|
});
|
}
|
})
|
},
|
//openMessage
|
openMessage() {
|
this.getUserInfo()
|
},
|
close() {
|
this.setData({
|
openMessage: false
|
})
|
},
|
//跳转到消息 info
|
info() {
|
if (wx.getStorageSync('token') == "") {
|
wx.navigateTo({
|
url: '../../pages/index/index',
|
})
|
} else {
|
wx.navigateTo({
|
url: '../../pages/info/info',
|
})
|
}
|
},
|
|
//获取个人用户信息
|
getUserInfo() {
|
unit.post(app.globalData.Url + '/api/user/queryUserInfo')
|
.then((res) => {
|
console.log(res)
|
if (res.data.code == 200) {
|
this.setData({
|
openMessage: !this.data.openMessage,
|
userInfo: res.data.data,
|
})
|
wx.setStorageSync('myPhone', res.data.data.phone)
|
wx.setStorageSync('userInfo', res.data.data)
|
if (res.data.data.emergencyContactNumber !== '') {
|
wx.setStorageSync('stepName', {
|
emergencyContact: res.data.data.emergencyContact,
|
emergencyContactPhone: res.data.data.emergencyContactNumber
|
})
|
wx.setStorageSync('step', 2)
|
}
|
}
|
})
|
},
|
//出租车更换乘车人跳转
|
|
//弹出小费弹窗
|
selecttip() {
|
console.log("1")
|
this.setData({
|
selecttip: true
|
})
|
},
|
//选择出发地跳转
|
from() {
|
console.log(this.data.cityName)
|
let busId = this.data.busId
|
wx.navigateTo({
|
url: '../../pages/getLocation/getLocation?cityName=' + this.data.cityName + '&busId=' + busId,
|
})
|
},
|
//选择时间
|
selecttime() {
|
this.setData({
|
selecttime: true
|
})
|
},
|
clickCarTime() {
|
this.setData({
|
selecttimeBc: true
|
})
|
},
|
onParentEventBcTime(e) {
|
console.log(e)
|
let useTimeInfo = e.detail.split(' ')[0]
|
this.setData({
|
useTimeInfo
|
})
|
},
|
//传时间
|
onParentEvent(e) {
|
console.log(e)
|
this.setData({
|
goTime: e.detail,
|
yyTime: e.detail.serverStartTime,
|
newTime: e.detail.newTime
|
})
|
},
|
//传小费
|
onParentEventTip(e) {
|
console.log(e.detail)
|
if (e.detail !== undefined) {
|
this.setData({
|
tip: e.detail
|
})
|
}
|
},
|
//选择乘车人时间
|
changePeople: function () {
|
wx.navigateTo({
|
url: '../../pages/changePeople/changePeople?name=' + this.data.changePeople + "&phone=" + this.data.changephone,
|
})
|
},
|
//叫车方式changeWayApi api
|
changeWayApiDown: function (e) {
|
console.log(e)
|
let wayId = e.currentTarget.dataset.id
|
if (e.currentTarget.dataset.id == 3) {
|
this.setData({
|
substitute: 1,
|
checkDown: wayId
|
})
|
} else {
|
this.setData({
|
checkDown: wayId,
|
changeWayIdDown: wayId,
|
substitute: 0
|
})
|
}
|
|
},
|
//获取抽屉高度
|
calculateScrollViewHeight() {
|
let that = this;
|
let query = wx.createSelectorQuery().in(this)
|
//根据节点id查询节点部分的高度(px单位)
|
query.select('#top').boundingClientRect();
|
query.exec((res) => {
|
// 分别取出节点的高度
|
let imageHeight = res[0].height;
|
// 然后窗口高度(wx.getSystemInfoSync().windowHeight)减去其他不滑动界面的高度
|
let scrollViewHeight = wx.getSystemInfoSync().windowHeight -
|
imageHeight
|
// 算出来之后存到data对象里面
|
that.setData({
|
scrollHeight: scrollViewHeight
|
});
|
})
|
},
|
//获取附近空闲司机
|
getCarNum(lat, lon, type) {
|
wx.request({
|
url: `https://api.map.baidu.com/geoconv/v2/?coords=${lon},${lat}&model=1&ak=3mHKIXMArjgIkgADzOlTYp4XssNSNkwr`,
|
success: (res) => {
|
unit.post(app.globalData.Url + '/base/driver/queryIdleDriver', {
|
lat: res.data.result[0].y,
|
lon: res.data.result[0].x,
|
type: type
|
})
|
.then((res) => {
|
this.setData({
|
carNum: res.data.data.number
|
})
|
})
|
},
|
})
|
|
},
|
//选择车的类型 /base/openCity/queryBusiness
|
queryBusiness(city, district, province) {
|
unit.post(app.globalData.Url + '/base/openCity/queryBusiness', {
|
city: city,
|
district: district,
|
province: province
|
})
|
.then((res) => {
|
console.log(res)
|
this.setData({
|
busStyle: res.data.data
|
})
|
})
|
.catch((res) => {})
|
},
|
closeBlack() {
|
this.setData({
|
showBlack: false
|
})
|
},
|
|
//改变出租车状态
|
changCarID: function (e) {
|
let id = e.currentTarget.dataset.id
|
this.setData({
|
busId: id,
|
btnDisabled: false,
|
orderType: id
|
}, () => {
|
if (id == 1) {
|
this.setData({
|
carName: '呼叫专车'
|
}, () => {
|
if (this.data.endChangeCar) {
|
this.queryServerCarMo()
|
}
|
})
|
this.getCarNum(latitude, longitude, id)
|
} else if (id == 2) {
|
this.setData({
|
carName: '呼叫出租车'
|
})
|
this.getCarNum(latitude, longitude, id)
|
} else if (id == 4 || id == 5) {
|
this.queryLogisticsNumber()
|
}
|
})
|
},
|
|
|
|
|
//选择城市跳转
|
changeCity: function (e) {
|
console.log(e)
|
wx.navigateTo({
|
url: '../../pages/changeCity/changeCity?name=' + e.currentTarget.dataset.value,
|
})
|
|
},
|
go_share(e) {
|
wx.navigateTo({
|
url: '../../pages/changeCity/changeCity?name=' + e.currentTarget.dataset.value,
|
})
|
},
|
//判断当前城市是否开通业务
|
openCity(adcode) {
|
// qqmapsdk = new QQMapWX({
|
// key: 'SVIBZ-4RN6J-LPRF2-XZOZF-EAZKF-USFTD' //这里自己的key秘钥进行填充
|
// });
|
unit.post(app.globalData.Url + '/base/openCity/openCity', {
|
code: adcode
|
})
|
.then((res) => {
|
if (res.data.code == 200) {
|
if (res.data.data.open == 1) {
|
this.setData({
|
showPop: false
|
})
|
} else {
|
this.setData({
|
showPop: true
|
})
|
}
|
} else {
|
app.showToastSuccess(res.data.msg, null, "none", 1500)
|
}
|
})
|
.catch((res) => {
|
console.log(res)
|
})
|
},
|
//用户滑动地图获取中心位置
|
regionchange: function (e) {
|
// 地图发生变化的时候,获取中间点
|
if (e.type == 'end' && (e.causedBy == 'scale' || e.causedBy == 'drag') && this.data.nextBoolean == false) {
|
var that = this;
|
this.mapCtx = wx.createMapContext("map4select");
|
//获取中心坐标 api
|
this.mapCtx.getCenterLocation({
|
type: 'gcj02',
|
success: function (res) {
|
that.setData({
|
latitude: res.latitude,
|
longitude: res.longitude,
|
})
|
that.getLocal(res.latitude, res.longitude, true)
|
that.getCarNum(res.latitude, res.longitude, that.data.busId)
|
}
|
})
|
}
|
if (e.causedBy == "gesture") {
|
this.setData({
|
showCover: true
|
})
|
} else if (e.causedBy == "drag") {
|
this.setData({
|
showCover: false
|
})
|
}
|
},
|
// 获取当前地理位置
|
getLocal: function (latitude, longitude, move) {
|
var bmap = new BaiduMap.BMapWX({
|
ak: 'fi3HGJjW153NCNsaTb9FekxeX1Lj3auo' // 必填,您的key
|
})
|
let that = this;
|
wx.request({
|
url: `https://api.map.baidu.com/geoconv/v2/?coords=${longitude},${latitude}&model=5&ak=3mHKIXMArjgIkgADzOlTYp4XssNSNkwr`,
|
success: (resp) => {
|
console.log('获取当前地理位置 获取当前地理位置', resp, 'longitude', longitude, 'latitude', latitude, 'move move move', move)
|
bmap.regeocoding({
|
location: move ? (latitude + ',' + longitude) : (resp.data.result[0].y + ',' + resp.data.result[0].x),
|
// location:latitude+ ',' +longitude,
|
// location: '30.657469'+','+'104.06669',
|
success: (res) => {
|
//这里的res参数里有具体的城市数据
|
console.log('这里的res参数里有具体的城市数据', res)
|
var name = res.originalData.result.addressComponent
|
that.setData({
|
changeStartName: res.originalData.result.formatted_address,
|
startLat: move ? '' : resp.data.result[0].y,
|
startLon: move ? '' : resp.data.result[0].x,
|
cityNameStart: res.originalData.result.formatted_address,
|
adcode: res.originalData.result.addressComponent.adcode,
|
latitude: move ? latitude : resp.data.result[0].y,
|
longitude: move ? longitude : resp.data.result[0].x
|
// latitude:'30.657469',
|
// longitude:"104.06669"
|
})
|
that.queryBusiness(name.city, name.district, name.province)
|
that.openCity(res.originalData.result.addressComponent.adcode)
|
},
|
fail: function (res) {
|
that.setData({
|
cityNameStart: "正在定位中"
|
})
|
},
|
})
|
}
|
})
|
},
|
|
//选择要去的位置跳转
|
goWhere: function () {
|
wx.navigateTo({
|
url: '../../pages/setLocation/setLocation?cityName=' + this.data.cityName + '&busId=' + this.data.busId
|
})
|
},
|
|
//选择目的地后开始对地图绘制信息
|
pointAddress() {
|
var that = this;
|
// 标注起点终点
|
if (that.data.nextBoolean) {
|
var points = [{
|
latitude: that.data.startLat || that.data.latitude,
|
longitude: that.data.startLon || that.data.longitude,
|
},
|
{
|
latitude: that.data.nextLatitude,
|
longitude: that.data.nextLongitude,
|
},
|
|
]
|
let startLat = that.data.startLat || that.data.latitude
|
let startLon = that.data.startLon || that.data.longitude
|
wx.request({
|
url: `https://api.map.baidu.com/geoconv/v2/?coords=${startLon},${startLat};${that.data.nextLongitude},${that.data.nextLatitude}&model=1&ak=3mHKIXMArjgIkgADzOlTYp4XssNSNkwr`,
|
success: (resp) => {
|
console.log('that.data.nextLongitud,that.data.nextLongitudee', that.data.nextLongitude)
|
// wx.request({
|
// url: `https://api.map.baidu.com/directionlite/v1/driving?origin=${resp.data.result[0].y},${resp.data.result[0].x}&destination=${that.data.nextLatitude},${that.data.nextLongitude}&ak=WQhfsluNzEeUHUxoH4jc4JiCQOXw4Mnx&ret_coordtype=gcj02`,
|
// success: (res) => {
|
// var coors = res.data.result.routes[0].steps
|
// var polyline = [];
|
// coors.forEach(function (step, index) {
|
// // if (index == 0) {
|
// // polyline.push({
|
// // latitude: step.end_location.lat,
|
// // longitude: step.end_location.lng
|
// // });
|
// // } else {
|
// // polyline.push({
|
// // latitude: step.start_location.lat,
|
// // longitude: step.start_location.lng
|
// // });
|
// // }
|
// // return
|
// let list = step.path.split(';')
|
// if (index == 0) {
|
// polyline.push({
|
// latitude: step.start_location.lat,
|
// longitude: step.start_location.lng
|
// });
|
// }
|
// list.forEach(function (item, ind) {
|
// if (item) {
|
// let lng = item.split(',')[0]
|
// let lat = item.split(',')[1]
|
// polyline.push({
|
// latitude: lat,
|
// longitude: lng
|
// });
|
// }
|
// })
|
// // }
|
// if (coors.length == index + 1) {
|
// unit.post(app.globalData.Url + '/base/taxi/queryExpectedTime', {
|
// // slat:that.data.latitude,
|
// // slon:that.data.longitude,
|
// slat: that.data.startLat || that.data.latitude,
|
// slon: that.data.startLon || that.data.longitude,
|
// elat: that.data.nextLatitude,
|
// elon: that.data.nextLongitude
|
// })
|
// .then((res) => {
|
// if (res.data.code == 200) {
|
// // let markers1 = that.data.markers[0]
|
// // let markers2 =
|
// // that.data.markers[1]+ that.data.markers[1][callout]
|
|
// // this.setData({
|
// // markers:[markers1,markers2]
|
// // })
|
// console.log(list, '2222222222222222222222');
|
|
// var markers = [{
|
// iconPath: "../../img/start_icon.png",
|
// id: 1,
|
// latitude: that.data.startLat || that.data.latitude,
|
// longitude: that.data.startLon || that.data.longitude,
|
// width: 26,
|
// height: 34,
|
// },
|
// {
|
// iconPath: "../../img/end_icon.png",
|
// id: 2,
|
// latitude: list[list.length - 2].split(',')[1],
|
// longitude: list[list.length - 2].split(',')[0],
|
// width: 26,
|
// height: 34,
|
// callout: {
|
// content: '大约行驶' + res.data.data.minute + '分钟',
|
// color: '#333333',
|
// fontSize: 13,
|
// borderRadius: 1,
|
// display: 'ALWAYS',
|
// borderRadius: 13,
|
// padding: 10,
|
// textAlign: 'center'
|
// }
|
// },
|
// ]
|
// that.setData({
|
// markers,
|
// points
|
// })
|
// }
|
// })
|
// }
|
// });
|
// that.setData({
|
// polyline: [{
|
// points: polyline,
|
// arrowLine: true,
|
// color: '#00C47A',
|
// width: 4,
|
// borderWidth: 1,
|
// borderColor: '#00C47A'
|
// }],
|
// });
|
|
// }
|
// })
|
// return
|
unit.post(app.globalData.Url + '/base/loadLine', {
|
startLat: resp.data.result[0].y,
|
startLon: resp.data.result[0].x,
|
nextLatitude: that.data.nextLatitude,
|
nextLongitude: that.data.nextLongitude,
|
})
|
.then((res) => {
|
|
unit.post(app.globalData.Url + '/api/taxi/getAllForecastPrice', {
|
payManner: that.data.changeModel == '线上计费' ? 1 : 2,
|
startLat:resp.data.result[0].y,
|
startLon:resp.data.result[0].x,
|
endLat: that.data.nextLatitude,
|
endLon: that.data.nextLongitude
|
})
|
.then((res) => {
|
console.log(res)
|
if (res.data.code == 200) {
|
res.data.data.online = res.data.data.online.toFixed(2)
|
res.data.data.offline = res.data.data.offline.toFixed(2)
|
|
this.setData({
|
priceObj:res.data.data
|
})
|
}
|
})
|
|
var coors = res.data.data
|
var polyline = [];
|
coors.forEach(function (step, index) {
|
// if (index == 0) {
|
// polyline.push({
|
// latitude: step.end_location.lat,
|
// longitude: step.end_location.lng
|
// });
|
// } else {
|
// polyline.push({
|
// latitude: step.start_location.lat,
|
// longitude: step.start_location.lng
|
// });
|
// }
|
// return
|
let list = step.path.split(';')
|
if (index == 0) {
|
polyline.push({
|
latitude: step.start_location.lat,
|
longitude: step.start_location.lng
|
});
|
}
|
list.forEach(function (item, ind) {
|
if (item) {
|
let lng = item.split(',')[0]
|
let lat = item.split(',')[1]
|
polyline.push({
|
latitude: lat,
|
longitude: lng
|
});
|
|
if (coors.length == index + 1 && list.length == ind + 1) {
|
unit.post(app.globalData.Url + '/base/taxi/queryExpectedTime', {
|
// slat:that.data.latitude,
|
// slon:that.data.longitude,
|
slat: that.data.startLat || that.data.latitude,
|
slon: that.data.startLon || that.data.longitude,
|
elat: that.data.nextLatitude,
|
elon: that.data.nextLongitude
|
})
|
.then((res) => {
|
if (res.data.code == 200) {
|
// let markers1 = that.data.markers[0]
|
// let markers2 =
|
// that.data.markers[1]+ that.data.markers[1][callout]
|
|
// this.setData({
|
// markers:[markers1,markers2]
|
// })
|
console.log(list, '2222222222222222222222');
|
|
var markers = [{
|
iconPath: "../../img/start_icon.png",
|
id: 1,
|
latitude: that.data.startLat || that.data.latitude,
|
longitude: that.data.startLon || that.data.longitude,
|
width: 26,
|
height: 34,
|
},
|
{
|
iconPath: "../../img/end_icon.png",
|
id: 2,
|
latitude: lat,
|
longitude: lng,
|
width: 26,
|
height: 34,
|
callout: {
|
content: '大约行驶' + res.data.data.minute + '分钟',
|
color: '#333333',
|
fontSize: 13,
|
borderRadius: 1,
|
display: 'ALWAYS',
|
borderRadius: 13,
|
padding: 10,
|
textAlign: 'center'
|
}
|
},
|
]
|
that.setData({
|
markers,
|
points
|
})
|
}
|
})
|
}
|
}
|
})
|
// }
|
|
});
|
that.setData({
|
polyline: [{
|
points: polyline,
|
arrowLine: true,
|
color: '#00C47A',
|
width: 4,
|
borderWidth: 1,
|
borderColor: '#00C47A'
|
}],
|
});
|
})
|
}
|
})
|
// unit.get('https://apis.map.qq.com/ws/direction/v1/driving/?from=' +
|
// startLat + ',' +
|
// startLon + '&to=' + that.data.nextLatitude + ',' +
|
// that.data.nextLongitude + '&output=json&callback=cb&key=SVIBZ-4RN6J-LPRF2-XZOZF-EAZKF-USFTD', {})
|
// .then((res) => {
|
// if (res.data.message == 'Success') {
|
// var coors = res.data.result.routes[0].polyline
|
// for (var i = 2; i < coors.length; i++) {
|
// coors[i] = coors[i - 2] + coors[i] / 1000000
|
// }
|
// // coors.forEach((element,index) => {
|
// // coors[index] =coors[index - 2]+ coors[index]/ 1000000
|
// // });
|
// //划线
|
// var b = [];
|
// for (var i = 0; i < coors.length; i = i + 2) {
|
// b[i / 2] = {
|
// latitude: coors[i],
|
// longitude: coors[i + 1]
|
// };
|
// }
|
|
// that.setData({
|
// polyline: [{
|
// points: b,
|
// arrowLine: true,
|
// color: '#00C47A',
|
// width: 4,
|
// borderWidth: 1,
|
// borderColor: '#00C47A'
|
// }],
|
// })
|
// } else {
|
// app.showToastSuccess('路线规划失败', null, "none", 1500)
|
// }
|
// })
|
// wx.request({
|
// url: `https://api.map.baidu.com/directionlite/v1/driving?origin=${startLat},${startLon}&destination=${ that.data.nextLatitude},${that.data.nextLongitude}&ak=WQhfsluNzEeUHUxoH4jc4JiCQOXw4Mnx`,
|
// success: function (res) {
|
// if (res.data.status == 0) {
|
|
// }
|
// },
|
// fail: function (res) {
|
// app.showToastSuccess('路线规划失败', null, "none", 1500)
|
// }
|
// })
|
|
|
|
// var polyline =[{
|
// points:[
|
// {
|
// latitude: that.data.latitude,
|
// longitude: that.data.longitude,
|
// },
|
// {
|
// latitude: that.data.nextLatitude,
|
// longitude: that.data.nextLongitude,
|
// },
|
// ],
|
// color:'#00C47A',
|
// width:4,
|
// borderWidth:1,
|
// borderColor:'#00C47A'
|
// }]
|
|
that.setData({
|
centerHidden: false,
|
points,
|
showLocationIcon: false
|
});
|
}
|
|
//缩放地图显示起点终点缩放地图显示起点终点
|
|
},
|
/**
|
* 生命周期函数--监听页面初次渲染完成
|
*/
|
onReady: function (options) {
|
|
let that = this;
|
setTimeout(function () {
|
that.calculateScrollViewHeight()
|
}, 100)
|
},
|
|
/**
|
* 生命周期函数--监听页面显示
|
*/
|
//获取正在进行中的订单
|
getOriding() {
|
unit.post(app.globalData.Url + '/api/order/queryServingOrder')
|
.then((res) => {
|
if (res.data.code == 200 && res.data.data.length > 0) {
|
if (res.data.data[0].state <= 7) {
|
wx.setStorageSync('orderID', res.data.data[0].orderId)
|
this.setData({
|
nowOrder: true,
|
orderIdIng: res.data.data[0].orderId,
|
stateInd: res.data.data[0].state,
|
orderTypeIng: res.data.data[0].orderType,
|
selfOrder: res.data.data[0]
|
})
|
} else if (res.data.data[0].state == 12 || res.data.data[0].state == 11) {
|
wx.setStorageSync('orderID', res.data.data[0].orderId)
|
this.setData({
|
nowOrder: true,
|
orderIdIng: res.data.data[0].orderId,
|
stateInd: res.data.data[0].state,
|
orderTypeIng: res.data.data[0].orderType
|
})
|
}
|
} else {
|
this.setData({
|
nowOrder: false,
|
})
|
}
|
})
|
},
|
goWaiting(e) {
|
if (e.currentTarget.dataset.state <= 6) {
|
wx.navigateTo({
|
url: '../../pages/waiting/waiting?where=' + "myTrip" + "&orderID=" + e.currentTarget.dataset.orderid + "&state=" + e.currentTarget.dataset.state + '&orderType=' + e.currentTarget.dataset.ordertype + "&onekey=" + '0'
|
})
|
} else if (e.currentTarget.dataset.state == 12) {
|
wx.navigateTo({
|
url: '../../pages/closeTip/closeTip?id=' + e.currentTarget.dataset.orderid + '&orderType=' + e.currentTarget.dataset.ordertype + "&onekey=" + '0',
|
})
|
} else if (e.currentTarget.dataset.state == 11) {
|
wx.navigateTo({
|
url: '../../pages/waiting/waiting?where=' + "myTrip" + "&orderID=" + e.currentTarget.dataset.orderid + "&state=" + e.currentTarget.dataset.state + '&orderType=' + e.currentTarget.dataset.ordertype + "&onekey=" + '0'
|
})
|
} else if (e.currentTarget.dataset.state == 7 && e.currentTarget.dataset.ordertype == 3) {
|
wx.navigateTo({
|
url: '/pages/advoad-city-search/advoad-message/electronic-wait-pay/electronic-wait-pay?paypaydata=' + JSON.stringify(e.currentTarget.dataset.self) + "&onekey=" + '0',
|
})
|
} else {
|
wx.navigateTo({
|
url: '../../pages/carDown/carDown?id=' + e.currentTarget.dataset.orderid + '&orderType=' + e.currentTarget.dataset.ordertype + "&onekey=" + '0'
|
})
|
}
|
},
|
show() {
|
let pages = getCurrentPages();
|
this.setContainerHeight()
|
|
if (wx.getStorageSync('token') !== '' && wx.getStorageSync('token') !== 'quit') {
|
this.getInfoMessage()
|
this.getOriding()
|
}
|
|
this.setData({
|
cityName: wx.getStorageSync('cityName') || '正在定位中',
|
})
|
|
let {
|
abvoadEndLocation
|
} = this.data
|
this.data.formLocation
|
//用户拒绝后的函数
|
this.setData({
|
avatarUrl: wx.getStorageSync('avatarUrl'),
|
nickName: wx.getStorageSync('nickName')
|
})
|
if (this.data.formLocation) {
|
this.getLocationApi()
|
this.setData({
|
startLat: "",
|
startLon: "",
|
newCityName: ""
|
})
|
}
|
setTimeout(() => {
|
if (this.data.showFrist) {
|
this.getSetting()
|
}
|
}, 2000)
|
|
// this.getLocal(wx.getStorageSync('latitude'),wx.getStorageSync('longitude'))
|
|
if (this.data.sameUserInfoObj.name !== undefined) {
|
this.setData({
|
sameUserInfo: false,
|
|
})
|
}
|
},
|
onShow: function () {
|
this.setData({
|
agreementShow: wx.getStorageSync('token') ? false : !wx.getStorageSync('isAgreement') && true,
|
})
|
this.show()
|
this.setData({
|
modeSelectId: wx.getStorageSync('modeId') || 1
|
})
|
},
|
/**
|
* 生命周期函数--监听页面隐藏
|
*/
|
onHide: function () {
|
this.setData({
|
showFrist: false,
|
formLocation: true
|
})
|
},
|
|
/**
|
* 生命周期函数--监听页面卸载
|
*/
|
onUnload: function () {
|
|
},
|
|
/**
|
* 页面相关事件处理函数--监听用户下拉动作
|
*/
|
onPullDownRefresh: function () {
|
|
},
|
|
/**
|
* 页面上拉触底事件的处理函数
|
*/
|
onReachBottom: function () {
|
|
},
|
|
/**
|
* 用户点击右上角分享
|
*/
|
onShareAppMessage: function (e) {
|
if (e.from === 'button') {
|
|
}
|
return {
|
title: '新版“咸宁出租车”隆重上线,下载注册即送打车券。',
|
imageUrl: "",
|
// imageUrl: "/img/share_img.png",
|
path: '/pages/home/home',
|
success: function (res) {}
|
}
|
}
|
})
|