"__usePrivacyCheck__": true,
uni.getLocation({
type: 'gcj02', //返回可以用于wx.openLocation的经纬度
success (res) {
console.log(res);
if (res.errMsg == "getLocation:ok") {
const latitude = res.latitude;
const longitude = res.longitude;
uni.chooseLocation({
latitude,
longitude,
success(res) {
console.log(res,'chooseLocation');
if (res.errMsg =="chooseLocation:ok") {
this.detailAddres = res.address; //将解析后的地址进行存储
console.log(this.detailAddres);
uni.setStorageSync("publishAddres",res.address);
}
},
fail: function() {},
complete: function() {}
})
}},uni.getLocation不执行,将代码"__usePrivacyCheck__": true,去除后就可以有人知道啥原因嘛;还有使用uni.getPrivacySetting是微信开发工具报错了不知啥原因 WAServiceMainContext.js?t=wechat&s=1693886790044&v=3.0.0:1 TypeError: Cannot read property '0' of undefined
at vendor.js? [sm]:19235(env: Windows,mp,1.06.2307260; lib: 3.0.0);
报错代码:uni.addInterceptor({
returnValue: function returnValue(res) {
if (!(!!res && (_typeof(res) === "object" || typeof res === "function") && typeof res.then === "function")) {
return res;
}
return new Promise(function (resolve, reject) {
res.then(function (res) {
return res[0] ? reject(res[0]) : resolve(res[1]);
});
});
}
});
不执行 是因为 被隐私协议弹窗拦住了。你需要开发个隐私协议弹窗。
https://developers.weixin.qq.com/community/develop/article/doc/000a0af85d4160ed2c40a1bb966413
<u-popup mode="center" :show="yisishow">
<view class="popup-box">
<view class="weui-half-screen-dialog__hd">
{{privacytitle}}
</view>
<view class="weui-half-screen-dialog__bd">
<text class="weui-half-screen-dialog__tips">{{desc1}}</text>
<text class="weui-half-screen-dialog__tips color-8BC21F" @click="openPrivacyContract">
{{urlTitle}}
</text>
<text class="weui-half-screen-dialog__tips">{{desc2}}</text>
</view>
<view class="weui-half-screen-dialog__ft">
<button class="weui-btn" @click="handleDisagree">拒绝</button>
<button id="agree-btn" type="default" open-type="agreePrivacyAuthorization" class="weui-btn agree"
@agreeprivacyauthorization="handleAgreePrivacyAuthorization">同意</button>
</view>
</view>
</u-popup>,
在onShow调用的
//隐私是否授权
uni.getPrivacySetting({
success: res => {
console.log(res, '小程序隐私协议开发');
if (res.errMsg == 'getPrivacySetting:ok') {
if (res.needAuthorization) {
// 用户未授权
this.yisishow = true;
this.urlTitle = res.privacyContractName;
console.log(this.yisishow, 'this.yisishow');
console.log(this.urlTitle, 'this.urlTitle');
} else {
this.yisishow = false;
console.log(this.yisishow, 'this.yisishow');
uni.getUserInfo({
success: (res) => {
console.log(res, "res");
uni.login({
provider: 'weixin',
success: (res) => {
console.log(res, "登录login");
let code = res.code;
//登录微信获取sessionId
uni.request({
url: config.BASE_URL +
"/app-api/szyServiceUser/getSessionId",
data: {
code: code
},
header: {
'tenant-id': tenantid
},
success: (res) => {
console.log(res, res.data
.data)
uni.setStorageSync(
"sessionId", res
.data.data);
}
})
}
})
}
})
}
}
}
});
https://developers.weixin.qq.com/community/develop/article/doc/0002aac6d6ce70522140e35ae6b813