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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<script>
import "./../.env.js";
import { AnalysysAgent } from "@/utils/analysys_paas.js";
import util from "@/utils/util.js";
import login from "@/utils/login.js";
import upload from '@/components/upload/task.js'
export default {
globalData: {
// 开发环境
uniEnv: process.uniEnv,
// 微信小程序平台编号,空--家维广场,1--自营平台
wxAppNo: 1,
// 服务规范教程视频
service_standard: {
course1: {
url: process.uniEnv.qn_base_url + "course/Section1.mp4",
title: "第一节 师傅考核规则",
desc:
"接单操作须知有助你快速了解充电桩安装业务,提高接单效率,请认真查看及学习。",
},
course2: {
url: process.uniEnv.qn_base_url + "course/Section2.mp4",
title: "第二节 安装材料及工具",
desc:
"接单操作须知有助你快速了解充电桩安装业务,提高接单效率,请认真查看及学习。",
},
course3: {
url: process.uniEnv.qn_base_url + "course/Section3.mp4",
title: "第三节 安装施工规范",
desc:
"接单操作须知有助你快速了解充电桩安装业务,提高接单效率,请认真查看及学习。",
},
course4: {
url: "https://qn-static.banshouhui.com/self-support/videoen.mp4",
title: "第四节 录单上传要求",
desc:
"接单操作须知有助你快速了解充电桩安装业务,提高接单效率,请认真查看及学习。",
},
},
// 退出登录
logout: false,
navHeight: 0, //导航栏高度
rpxScreenHeight: 0, // 照相视框高度
safeHeight: 0, // 安全高度
//拍照相关数据
photo: {
product: {
brandId: "", // 品牌id
brandName: "", // 品牌名称
classifyId: "", // 分类id
systemId: "", // 系统id
},
topIndex: 0,
itemIndex: 0,
currentItemLength: 0, //已拍摄照片张数
productList: [],
currentItem: null, // 选择的某一项
setting: null, //自定义设置
waterSetting: null, // 水印设置
allImages: [],
tempPath: {
origin: "", // 缓存拍照图片
mixWater: "", // 缓存水印拍照图片
},
},
fileList: {} // 文件地址缓存 {url最后一段: tmpPath}
},
onLaunch: async function () {
// 应用初始化(全局只触发一次)
AnalysysAgent.registerSuperProperty("platform", "self-support");
// 版本更新
await this.updateApp();
this.getSystemInfo();
// 系统自动登录::每次运行小程序重新获取用户信息
await this.autoLogin();
//this.deleteTempImg()
},
onShow: function () {
// 应用启动,或从后台进入前台显示
if (this.uploadTask.length > 0) {
upload.uploadImageTask(this)
}
},
onHide: function () {
// 应用从前台进入后台
},
watch: {
uploadTask: function(newValue, oldValue) {
if(newValue.length > 0) upload.uploadImageTask(this)
}
},
methods: {
// 处理已上传完成的图片
deleteTempImg() {
const result = uni.getStorageSync('delImg')
if (result.length > 0) {
for (let i of result) {
uni.removeSavedFile({
filePath: i
})
}
uni.setStorageSync('delImg', [])
}
},
getSystemInfo() {
try {
let a = this.$u.sys();
this.globalData.navHeight =
(a.statusBarHeight / a.screenWidth) * 750 + 90;
this.globalData.rpxScreenHeight =
(a.screenHeight / a.screenWidth) * 750;
this.globalData.screenHeight = a.screenHeight;
this.globalData.safeHeight = a.safeArea.bottom;
} catch (a) {}
},
async getBaseInfo(vm, callBack) {
const res = await vm.$u.api.getSettleBaseInfo();
if (res.code !== 200) {
return false;
}
vm.$u.vuex("vuex_settled", res.data || null);
if (!res.data) {
return;
}
if (typeof callBack == "function") {
callBack(vm, res.data);
}
return res.data;
},
/**
* 微信用户自动登录
*/
async autoLogin() {
let that = this;
// 如果token不为空,则跳过自动登录
if(that.vuex_token) {
return false
}
await login.oauth().then(async (res) => {
if (res.code) {
let params = {
code: res.code,
wxAppNo: that.globalData.wxAppNo, // 自营平台小程序
};
let result = await that.$u.api.loginWechatAuth(params);
if (result && result.code == 200 && result.data && result.data.token) {
login.setUserData(result.data, this);
this.profileSet(this)
this.profileAppend(this)
} else {
uni.navigateTo({
url: "pages/login/index",
});
}
} else {
uni.showModal({
title: "登录失败",
content: "未获取到code",
});
}
});
},
/* 版本更新 */
async updateApp(type) {
if (uni.canIUse('getUpdateManager')) {
// 版本更新
const updateManager = uni.getUpdateManager();
updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调
if (!res.hasUpdate && type === 1) {
uni.showModal({
title: '提示',
content: '当前版本已经是最新版本',
showCancel: false
})
}
});
updateManager.onUpdateReady(function (res) {
uni.showModal({
title: "更新提示",
content: "新版本已经准备好,是否重启应用?",
success(res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
} else if (res.cancel) {
//如果需要强制更新,则给出二次弹窗
uni.showModal({
title: '温馨提示~',
content: '本次版本更新涉及到新的功能添加,旧版本无法正常访问的哦~',
showCancel: false,
success: function (result) {
if (result.confirm) updateManager.applyUpdate()
}
})
}
},
});
});
updateManager.onUpdateFailed(function (res) {
// 新的版本下载失败
uni.showModal({
title: '已经有新版本了哟~',
content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~',
showCancel: false
})
});
} else {
uni.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。',
showCancel: false
})
}
},
/* ------------------------- 数据埋点begin ------------------------------ */
track(event, properties) {
if (AnalysysAgent) {
// 易观添加事件
let AnalysysAgent = wx.AnalysysAgent;
AnalysysAgent.track("self_support_" + event, properties);
}
},
profileSet(vm) {
// 设备身份标识
if (AnalysysAgent) {
let user = vm.$u.deepClone(vm.vuex_user);
let profile = vm.$u.deepClone(vm.vuex_auth_user);
profile.openid = user.wxopenid || profile.openid
profile.unionid = user.unionid || profile.unionid || null
AnalysysAgent.profileSet(profile);
}
},
profileAppend(vm) {
if (AnalysysAgent) {
let user = vm.$u.deepClone(vm.vuex_user);
// 用户id设置
AnalysysAgent.alias(user.id + "");
// 用户附加属性
let profile = {
userfrom: "自营平台",
id: user.id,
mobile: user.mobile,
loginName: user.loginName,
source: user.score,
};
Object.keys(profile).map((key) => {
if (key && profile[key]) {
AnalysysAgent.profileAppend(key, profile[key]);
}
});
}
},
share(toShareProperties, trackProperties) {
if (AnalysysAgent) {
AnalysysAgent.share(toShareProperties, trackProperties);
}
},
trackPage(pageName, properties) {
if (AnalysysAgent) {
AnalysysAgent.pageView(pageName, properties);
}
},
initShare(option) {
option = option || {};
if (AnalysysAgent && option.user_id) {
let shareUserInfo = {
share_from_id: option.user_id || "",
share_from_nickname: option.user_name || "",
};
AnalysysAgent.registerSuperProperties(shareUserInfo);
}
},
/* ------------------------- 数据埋点end ------------------------------ */
},
};
</script>
<style>
/*每个页面公共css */
@import "@/common/iconfont.css";
</style>
<style lang="scss">
/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
@import "uview-ui/index.scss";
@import "@/common/index.scss";
</style>