1. 新增多语言文件覆盖组件、页面、公共模块的翻译文案 2. 修复多处动态拼接lang key的调用,增加兜底逻辑避免空值或原始key暴露 3. 补全DIY组件、业务页面的国际化适配 4. 新增P2动态key国际化处理方案文档
113 lines
2.5 KiB
JavaScript
113 lines
2.5 KiB
JavaScript
export default {
|
|
data() {
|
|
return {
|
|
authInfo: {}
|
|
}
|
|
},
|
|
methods: {
|
|
/**
|
|
* 获取用户登录凭证code
|
|
*/
|
|
getCode(callback, fallbackFunc) {
|
|
console.log(`-----> auth.js getCode`)
|
|
// 微信小程序
|
|
// #ifdef MP-WEIXIN
|
|
console.log(`微信小程序登录`)
|
|
uni.login({
|
|
provider: 'weixin',
|
|
timeout: 3000,
|
|
success: res => {
|
|
if (res.code) {
|
|
this.$api.sendRequest({
|
|
url: '/weapp/api/weapp/authcodetoopenid',
|
|
data: {
|
|
code: res.code
|
|
},
|
|
success: res => {
|
|
if (res.code >= 0) {
|
|
if (res.data.openid) this.authInfo.weapp_openid = res.data
|
|
.openid;
|
|
if (res.data.unionid) this.authInfo.wx_unionid = res.data
|
|
.unionid;
|
|
typeof callback == 'function' && callback(this.authInfo);
|
|
} else {
|
|
fallbackFunc && fallbackFunc(res);
|
|
this.$util.showToast({
|
|
title: res.message ? res.message : this.$lang('common.auth.miniProgramConfigError')
|
|
});
|
|
}
|
|
}
|
|
})
|
|
} else {
|
|
fallbackFunc && fallbackFunc(res);
|
|
}
|
|
},
|
|
fail: (res) => {
|
|
// #ifdef MP-WEIXIN
|
|
let scene = wx.getLaunchOptionsSync().scene;
|
|
if ([1154, 1155].indexOf(scene) == -1) {
|
|
this.$util.showToast({
|
|
title: res.errMsg
|
|
});
|
|
}
|
|
// #endif
|
|
fallbackFunc && fallbackFunc(res);
|
|
}
|
|
})
|
|
// #endif
|
|
|
|
// #ifdef MP-ALIPAY
|
|
uni.login({
|
|
timeout: 3000,
|
|
success: res => {
|
|
if (res.code) {
|
|
this.$api.sendRequest({
|
|
url: '/aliapp/api/aliapp/authcodetouserid',
|
|
data: {
|
|
code: res.code
|
|
},
|
|
success: res => {
|
|
if (res.code >= 0) {
|
|
if (res.data.user_id) this.authInfo.ali_openid = res.data
|
|
.user_id;
|
|
typeof callback == 'function' && callback(this.authInfo);
|
|
} else {
|
|
fallbackFunc && fallbackFunc(res);
|
|
this.$util.showToast({
|
|
title: res.message ? res.message : this.$lang('common.auth.miniProgramConfigError')
|
|
});
|
|
}
|
|
}
|
|
})
|
|
}
|
|
},
|
|
fail: (err) => {
|
|
this.$util.showToast({
|
|
title: res.errMsg
|
|
});
|
|
}
|
|
})
|
|
// #endif
|
|
|
|
// #ifdef H5
|
|
if (this.$util.isWeiXin()) {
|
|
this.$api.sendRequest({
|
|
url: '/wechat/api/wechat/authcode',
|
|
data: {
|
|
redirect_url: location.href,
|
|
scopes: 'snsapi_userinfo'
|
|
},
|
|
success: res => {
|
|
if (res.code >= 0) {
|
|
location.href = res.data;
|
|
}
|
|
},
|
|
fail: err => {
|
|
fallbackFunc && fallbackFunc(err);
|
|
}
|
|
});
|
|
}
|
|
// #endif
|
|
}
|
|
}
|
|
} |