index.js
3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// packageEquity/pages/road/index/index.js
import mapApi from '~/utils/mapapi/mapapi'
import { IMG_URL } from '~/config';
Page({
/**
* 页面的初始数据
*/
data: {
IMGURL:IMG_URL,
scale: 16,
flag: false,
editForm: {
rescueType: 0,
rescueTypeName: '紧急脱困'
},
rescueTypeList: [
{
confId: 0,
confName: '紧急脱困'
},
{
confId: 1,
confName: '拖车'
},
{
confId: 2,
confName: '换胎'
},
{
confId: 3,
confName: '送油'
},
{
confId: 4,
confName: '搭电'
},
{
confId: 5,
confName: '事故救援'
}
]
},
// onLoad: function (options) {},
onLoad(options) {
let { editForm } = this.data
if (options.confId + 1) {
editForm.rescueType = options.confId
editForm.rescueTypeName = options.name
}
if(options&&options.source=='GH'){
this.source = 'GH'
}
this.setData({
editForm
})
},
init() {
// this.getLocation()
},
/**授权位置成功 */
authSuccess() {
this.setData({
showAuth: false,
flag: true,
unauthorized: false
})
this.getLocation()
},
/**授权失败 */
authFail() {
this.setData({
showAuth: true,
unauthorized: true
})
},
/**授权弹窗取消 */
authCancel() {
wx.p.router.back()
},
// 切换线索
handleRescueType(e) {
var targetItem = e.currentTarget.dataset.item
this.setData({
'editForm.rescueType': targetItem.confId,
'editForm.rescueTypeName': targetItem.confName
})
},
// 下一步
handleNextStep() {
let otherParams = {}
if(this.source=='GH'){
otherParams.source='GH'
}
wx.p.router.go('/packageEquity/pages/road/roadInfo/roadInfo', {
editForm: this.data.editForm,
addressObj: this.data.addressObj,
isActivity: true,
notIntercept: true,
...otherParams
})
},
getLocation() {
wx.getLocation({
type: 'gcj02',
success: res => {
this.getCarPosition(res.latitude, res.longitude)
}
})
},
obtain(e) {
let { latitude, longitude } = e.detail
this.getCarPosition(latitude, longitude)
},
getCarPosition(latitude, longitude) {
mapApi.detailedAdrress([latitude, longitude]).then(data => {
this.setData({
addressObj: data,
latitude,
longitude
})
this.getControlHeight(map => {
map.addMarkers({
markers: [
{
id: 1,
iconPath: IMG_URL + 'equity/' + 'position.png' + `?v=${wx.$version}`,
latitude,
longitude,
width: 28,
height: 41,
callout: {
content: this.data.addressObj.formatted_addresses.recommend,
color: '#282829',
bgColor: '#FFFFFF',
borderRadius: 10,
padding: 14,
anchorY: -13,
borderWidth: 1,
borderColor: 'rgba(0, 0, 0, 0.1)',
display: 'ALWAYS'
}
}
],
clear: true,
success(res) {
console.log(res)
}
})
})
})
},
getControlHeight(callBack) {
wx.p.wxApi.getViewInfo('.control-box', ({ height }) => {
this.setData({
controlHeight: height
})
callBack(wx.createMapContext('map'))
})
}
})