wechat-address.js
993 Bytes
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
function choose(callback) {
wx.chooseAddress({
success(res) {
if (callback && typeof callback === 'function') {
return callback(res);
}
}
});
}
function beforeChoose(callback) {
if (wx.getSetting) {
wx.getSetting({
success(res) {
if (!res.authSetting['scope.address']) {
wx.authorize({
scope: 'scope.address',
success() {
choose(callback);
},
fail() {
wx.showModal({
content: '获取微信地址授权失败,请重新授权',
showCancel: false,
confirmText: '好的'
});
}
});
} else {
choose(callback);
}
}
});
} else {
wx.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
});
}
}
export default {
choose: beforeChoose
};