Compare commits
4 Commits
main
...
feat/app-a
| Author | SHA1 | Date | |
|---|---|---|---|
| a0f710c1a8 | |||
| 237320c7a1 | |||
| e9b85e9e61 | |||
| a6340250f2 |
@@ -1,28 +1,28 @@
|
||||
{
|
||||
"version" : "1",
|
||||
"prompt" : "template",
|
||||
"title" : "用户协议与隐私政策",
|
||||
"message" : "\t请务必审慎阅读、充分理解“用户协议与 隐私政策”各条款,包括但不限于:为了 向你提供即时通讯、内容分享等服务,我 们需要收集你的设备信息、操作日志等个 人信息。你可以在“设置”中查看、变更、删除个人信息并管理你的授权。<br/>
|
||||
你可以阅读 <a href=\"pages/columnGoods/static/yhxy.html\">《用户协议》</a>与 <a href=\"pages/columnGoods/static/yszc.html\">《隐私政策》</a>了解详细信息。如你同意,请点击“我同意”开始接受我们的服务。",
|
||||
"buttonAccept" : "同意并接受",
|
||||
"buttonRefuse" : "暂不同意",
|
||||
"second" : {
|
||||
"title" : "确认提示",
|
||||
"message" : "进入应用前,你需先同意<a href=\"pages/columnGoods/static/yhxy.html\">《用户协议》</a>与<a href=\"pages/columnGoods/static/yszc.html\">《隐私政策》</a>,否则将退出应用。",
|
||||
"buttonAccept" : "同意并继续",
|
||||
"buttonRefuse" : "退出应用"
|
||||
"version": "1",
|
||||
"prompt": "template",
|
||||
"title": "用户协议与隐私政策",
|
||||
"message": "\t请务必审慎阅读、充分理解“用户协议与 隐私政策”各条款,包括但不限于:为了 向你提供即时通讯、内容分享等服务,我 们需要收集你的设备信息、操作日志等个 人信息。你可以在“设置”中查看、变更、删除个人信息并管理你的授权。<br/>你可以阅读 <a href=\"pages/columnGoods/static/yhxy.html\">《用户协议》</a>与 <a href=\"pages/columnGoods/static/yszc.html\">《隐私政策》</a>了解详细信息。如你同意,请点击“我同意”开始接受我们的服务。",
|
||||
"buttonAccept": "同意并接受",
|
||||
"buttonRefuse": "暂不同意",
|
||||
"backToExit": "true",
|
||||
"second": {
|
||||
"title": "确认提示",
|
||||
"message": "进入应用前,你需先同意<a href=\"pages/columnGoods/static/yhxy.html\">《用户协议》</a>与<a href=\"pages/columnGoods/static/yszc.html\">《隐私政策》</a>,否则将退出应用。",
|
||||
"buttonAccept": "同意并继续",
|
||||
"buttonRefuse": "退出应用"
|
||||
},
|
||||
"styles" : {
|
||||
"backgroundColor" : "#fff",
|
||||
"borderRadius" : "5px",
|
||||
"title" : {
|
||||
"color" : "#000"
|
||||
"styles": {
|
||||
"backgroundColor": "#fff",
|
||||
"borderRadius": "5px",
|
||||
"title": {
|
||||
"color": "#000"
|
||||
},
|
||||
"buttonAccept" : {
|
||||
"color" : "#fff"
|
||||
"buttonAccept": {
|
||||
"color": "#fff"
|
||||
},
|
||||
"buttonRefuse" : {
|
||||
"color" : "#ccc"
|
||||
"buttonRefuse": {
|
||||
"color": "#ccc"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
13
api/user.js
13
api/user.js
@@ -900,4 +900,17 @@ export function channelApplyInfoApi() {
|
||||
// 采购商切换身份
|
||||
export function checkIdentityApi(data) {
|
||||
return request.post(`user/switch_identity`, data);
|
||||
}
|
||||
|
||||
/* ---------- App 身份(2026-10-26,Android 一期) ----------
|
||||
宿主在短信登录后调用:
|
||||
appIdentity() 取规范 openid(routine 优先 → app → unionid 反查)
|
||||
appBind({ code }) 新用户:uni.login 拿 code → 绑定到当前 uid
|
||||
两个接口都要求登录态(request 自动带 Authori-zation)。 */
|
||||
export function appIdentity() {
|
||||
return request.get('wechat/app_identity');
|
||||
}
|
||||
|
||||
export function appBind(data) {
|
||||
return request.post('wechat/app_bind', data);
|
||||
}
|
||||
30
config/legal.js
Normal file
30
config/legal.js
Normal file
@@ -0,0 +1,30 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | 合规展示信息(主体 / 备案号)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 用途:小米、华为等商店硬性要求「应用内可见 APP 备案号」(截图要体现),
|
||||
// | 而备案号在开发期还不存在 —— 统一收在这一个文件,号下来只改这里。
|
||||
// |
|
||||
// | 为什么不放 config/app.js:那个文件在 .gitignore 里(本地私有配置),
|
||||
// | 放进去等于不进仓库、换个环境就丢;也不写死在页面里:同一个号要出现在
|
||||
// | 设置页与登录页两处,写死两份必然不同步。
|
||||
// |
|
||||
// | 使用位置:
|
||||
// | pages/users/user_set/index.vue 「我的 → 设置」底部的关于区块
|
||||
// | pages/users/login/index.vue 登录页页脚(未登录也能看到)
|
||||
// | ⚠️ 两处展示都包在 #ifdef APP-PLUS 里:小程序 / H5 的界面与行为不受影响。
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* APP 备案号:ICP 备案号 + 「-序号A」后缀,例:京ICP备17065521号-3A
|
||||
* 空字符串 = 不展示该行(备案号下发前保持为空,避免截图里出现占位文案被商店挑刺)
|
||||
* ⚠️ 号码下发后填这里 → 重新出包;不要去改页面。
|
||||
*/
|
||||
APP_BEIAN_NO: '',
|
||||
|
||||
/** 网站/主体 ICP 备案号(已有,官网与小程序在用) */
|
||||
WEBSITE_ICP_NO: '京ICP备17065521号',
|
||||
|
||||
/** 备案主体 = 软著著作权人(北京臻惠网络科技有限公司)—— 三处必须一致,改名要同步软著与备案 */
|
||||
SUBJECT: '北京臻惠网络科技有限公司'
|
||||
};
|
||||
@@ -8,6 +8,11 @@
|
||||
"sassImplementationName" : "node-sass",
|
||||
/* 5+App特有相关 */
|
||||
"app-plus" : {
|
||||
/* 隐私政策提示框开关:template = 启动时在 splash 层弹原生隐私框(上架硬性要求)。
|
||||
提示框内容/样式在同目录 androidPrivacy.json,两者必须同时存在且 JSON 合法。 */
|
||||
"privacy" : {
|
||||
"prompt" : "template"
|
||||
},
|
||||
"usingComponents" : true,
|
||||
"nvueCompiler" : "uni-app",
|
||||
"nvueStyleCompiler" : "uni-app",
|
||||
@@ -19,6 +24,11 @@
|
||||
"distribute" : {
|
||||
/* android打包配置 */
|
||||
"android" : {
|
||||
"packagename" : "com.yizhezhe.douba",
|
||||
"keystore" : "keystore/douba-shop.keystore",
|
||||
"password" : "douba@2026",
|
||||
"aliasname" : "douba",
|
||||
"schemes" : "douba",
|
||||
"permissions" : [
|
||||
"<uses-feature android:name=\"android.hardware.camera\"/>",
|
||||
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
|
||||
@@ -26,24 +36,18 @@
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
|
||||
"<uses-permission android:name=\"android.permission.CAPTURE_AUDIO_OUTPUT\"/>",
|
||||
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
|
||||
"<uses-permission android:name=\"android.permission.INTERNET\"/>",
|
||||
"<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
|
||||
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
|
||||
"<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
|
||||
"<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>"
|
||||
],
|
||||
"abiFilters" : [ "armeabi-v7a" ],
|
||||
"abiFilters" : [ "armeabi-v7a", "arm64-v8a" ],
|
||||
"permissionExternalStorage" : {
|
||||
"request" : "none",
|
||||
"prompt" : "应用保存运行状态等信息,需要获取读写手机存储(系统提示为访问设备上的照片、媒体内容和文件)权限,请允许。"
|
||||
@@ -53,8 +57,8 @@
|
||||
"prompt" : "为保证您正常、安全地使用,需要获取设备识别码(部分手机提示为获取手机号码)使用权限,请允许"
|
||||
},
|
||||
"minSdkVersion" : 21,
|
||||
"targetSdkVersion" : 30, // 建议设置为 30 或更高
|
||||
"compileSdkVersion" : 30
|
||||
"targetSdkVersion" : 34, // 商店普遍要求 30+,34 为稳妥档(36 需同步验证);API 34 起前台服务/权限更严
|
||||
"compileSdkVersion" : 36 // HBuilderX 4.81+ 适配 16KB page size 要求 36
|
||||
},
|
||||
/* ios打包配置 */
|
||||
"ios" : {
|
||||
@@ -82,8 +86,8 @@
|
||||
"payment" : {
|
||||
"weixin" : {
|
||||
"__platform__" : [ "ios", "android" ],
|
||||
"appid" : "wx3e14a895971fbea6",
|
||||
"UniversalLinks" : "https://pro.crmeb.net/uni-universallinks/__UNI__7E0054B/"
|
||||
"appid" : "wxbe5081d4835af21b",
|
||||
"UniversalLinks" : "https://mp.yizhezhe.com/uni-universallinks/__UNI__52BA861/"
|
||||
},
|
||||
"alipay" : {
|
||||
"__platform__" : [ "ios", "android" ]
|
||||
@@ -91,8 +95,8 @@
|
||||
},
|
||||
"share" : {
|
||||
"weixin" : {
|
||||
"appid" : "wx3e14a895971fbea6",
|
||||
"UniversalLinks" : "https://pro.crmeb.net/uni-universallinks/__UNI__7E0054B/"
|
||||
"appid" : "wxbe5081d4835af21b",
|
||||
"UniversalLinks" : "https://mp.yizhezhe.com/uni-universallinks/__UNI__52BA861/"
|
||||
}
|
||||
},
|
||||
"push" : {},
|
||||
@@ -104,9 +108,9 @@
|
||||
},
|
||||
"oauth" : {
|
||||
"weixin" : {
|
||||
"appid" : "wx3e14a895971fbea6",
|
||||
"appsecret" : "ee83a6c94edbc5dd7a5b4614316d85a7",
|
||||
"UniversalLinks" : "https://pro.crmeb.net/uni-universallinks/__UNI__7E0054B/"
|
||||
"appid" : "wxbe5081d4835af21b",
|
||||
"appsecret" : "5dafb0ed5b106eb8f56f70824893f7ec",
|
||||
"UniversalLinks" : "https://mp.yizhezhe.com/uni-universallinks/__UNI__52BA861/"
|
||||
},
|
||||
"apple" : {}
|
||||
},
|
||||
|
||||
@@ -132,7 +132,78 @@ export default {
|
||||
{auth_login:1, openid, unionid}(新用户,无 token)或 {token, ...}(老用户)
|
||||
两端都算成功,只要拿到 openid 就落到 store + 缓存。
|
||||
返回 Promise<{openid, unionid}>;拿不到就 resolve 空串,由调用方决定是否匿名加载。 */
|
||||
/* ============================================================
|
||||
App(Android 一期)身份链路 —— 2026-10-26
|
||||
------------------------------------------------------------
|
||||
App 没有 wx.login / openid;本地身份来源是「短信登录后的 uid」:
|
||||
① 有 token → GET /api/wechat/app_identity(routine openid 优先)
|
||||
② 没有 openid(全新用户)→ uni.login({provider:'weixin'}) 拿 code
|
||||
→ POST /api/wechat/app_bind 绑定到当前 uid → 再取 app_identity
|
||||
③ 没装微信/拒绝授权 → 返回空,页面给「登录后继续 / 重试」
|
||||
⚠️ 不在启动时弹微信:只有走到这里(且确实没有 openid)才授权。
|
||||
============================================================ */
|
||||
_appIdentityFlow() {
|
||||
const needLogin = { openid: '', unionid: '', needLogin: true };
|
||||
const empty = { openid: '', unionid: '', needLogin: false };
|
||||
let hasToken = false;
|
||||
try { hasToken = !!(store.state.app.token || uni.getStorageSync(LOGIN_STATUS)); } catch (e) { hasToken = !!store.state.app.token; }
|
||||
if (!hasToken) return Promise.resolve(needLogin);
|
||||
|
||||
const save = (openid, unionid) => {
|
||||
if (!openid) return empty;
|
||||
try { store.commit('SET_OPENID', openid); uni.setStorageSync('OPENID', openid); } catch (e) {}
|
||||
if (unionid) {
|
||||
try { store.commit('SET_UNIONID', unionid); uni.setStorageSync('UNIONID', unionid); } catch (e) {}
|
||||
}
|
||||
return { openid: openid, unionid: unionid || '', needLogin: false };
|
||||
};
|
||||
const read = (res) => {
|
||||
const d = (res && res.data) || {};
|
||||
return { openid: d.openid || '', unionid: d.unionid || '', source: d.source || '' };
|
||||
};
|
||||
return import('@/api/user.js').then((api) => {
|
||||
return api.appIdentity().then((res) => {
|
||||
const id = read(res);
|
||||
console.log('[auth-flow] App app_identity: openid=' + (id.openid ? '有' : '无') + ' source=' + (id.source || '?'));
|
||||
if (id.openid) return save(id.openid, id.unionid);
|
||||
return this._weixinLoginCode().then((code) => {
|
||||
if (!code) {
|
||||
console.warn('[auth-flow] App:未拿到微信 code(未安装微信/拒绝授权)');
|
||||
return empty;
|
||||
}
|
||||
return api.appBind({ code: code }).then(() => {
|
||||
return api.appIdentity().then((r2) => {
|
||||
const id2 = read(r2);
|
||||
console.log('[auth-flow] App app_bind 后身份: openid=' + (id2.openid ? '有' : '无'));
|
||||
return save(id2.openid, id2.unionid);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}).catch((err) => {
|
||||
console.warn('[auth-flow] App 身份解析失败:', err && (err.message || err));
|
||||
return empty;
|
||||
});
|
||||
},
|
||||
_weixinLoginCode() {
|
||||
return new Promise((resolve) => {
|
||||
// #ifdef APP-PLUS
|
||||
uni.login({
|
||||
provider: 'weixin',
|
||||
success: (r) => resolve((r && r.code) || ''),
|
||||
fail: (e) => { console.warn('[auth-flow] uni.login(weixin) 失败:', e); resolve(''); }
|
||||
});
|
||||
// #endif
|
||||
// #ifndef APP-PLUS
|
||||
resolve('');
|
||||
// #endif
|
||||
});
|
||||
},
|
||||
_silenceAuthOpenid() {
|
||||
// #ifdef APP-PLUS
|
||||
/* App:走短信登录 + app_identity / app_bind(不碰 wx.login) */
|
||||
return this._appIdentityFlow();
|
||||
// #endif
|
||||
const empty = { openid: '', unionid: '' };
|
||||
return new Promise((resolve) => {
|
||||
/* ⚠️ 保险丝:wx.login / 接口有可能长时间不回调(弱网、域名没配好)。
|
||||
@@ -253,11 +324,18 @@ export default {
|
||||
break;
|
||||
}
|
||||
case 'requestProfile':
|
||||
/* App:没有小程序授权页,也不该弹页内面板(web-view 是原生组件、会盖住)。
|
||||
直接用当前 openid 查共享资料,把 hash 写回 web-view 即可。 */
|
||||
// #ifdef APP-PLUS
|
||||
this._pushAppProfile(m.href);
|
||||
// #endif
|
||||
// #ifndef APP-PLUS
|
||||
this.showAuth = true;
|
||||
/* 面板回传基址:H5 在消息里带 href(发起面板时的当前地址)→ 提交后
|
||||
按它回传。消息送达=面板弹出,href 同一条消息到达,确定性强于
|
||||
赌 shareHref 的 postMessage 派发时机(宫格换应用后可能还是旧地址)。 */
|
||||
if (m.href) this._panelBaseUrl = m.href;
|
||||
// #endif
|
||||
break;
|
||||
case 'setTitle':
|
||||
if (m.title) {
|
||||
@@ -312,6 +390,42 @@ export default {
|
||||
'&avatar=' + encodeURIComponent(r.avatar || '');
|
||||
},
|
||||
|
||||
/* App:H5 发 requestProfile 时,直接用当前 openid 查共享资料并回传 hash。
|
||||
—— 不弹面板、不调 getPhoneNumber(短信登录已验证手机号);
|
||||
—— 也绕开「App 的 web-view 是原生组件、页内面板会被盖住」的问题。 */
|
||||
_pushAppProfile(href) {
|
||||
const openid = this._hostOpenid();
|
||||
if (!openid) return uni.showToast({ title: '未获得 openid,请先登录', icon: 'none' });
|
||||
const current = (typeof this._hostCurrentUrl === 'function') ? this._hostCurrentUrl() : '';
|
||||
const base = String(href || this.shareHref || current || '').split('#')[0];
|
||||
if (!base) return;
|
||||
uni.showLoading({ title: '获取资料中', mask: true });
|
||||
uni.request({
|
||||
url: SHARED_AUTH_API + '?openid=' + encodeURIComponent(openid),
|
||||
method: 'GET',
|
||||
timeout: 10000,
|
||||
success: (r) => {
|
||||
uni.hideLoading();
|
||||
const d = r.data || {};
|
||||
if (d.code === 200) {
|
||||
const res = d.result || {};
|
||||
this._hostSetWebviewUrl(this.hostAuthUrl(base, {
|
||||
openid: openid,
|
||||
phone: res.phone || '',
|
||||
nickname: res.userName || '',
|
||||
avatar: res.avatar || ''
|
||||
}));
|
||||
} else {
|
||||
uni.showToast({ title: d.message || '资料获取失败', icon: 'none' });
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: '资料请求失败,请检查网络', icon: 'none' });
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 读取独立授权页(pages/annex/auth/index)写下的 __AUTH_RESULT__。
|
||||
* 该页成功后 navigateBack 回到宿主页 —— 两个宿主页都必须在 onShow 调用本方法,
|
||||
|
||||
@@ -8,10 +8,11 @@
|
||||
以前 url 为空时这里是白屏(没有任何占位),所以必须给一块可见的屏,
|
||||
否则「不加载」会变成「白屏 + 用户不知道该干嘛」。 -->
|
||||
<view v-else class="wv-fallback">
|
||||
<view class="wv-emoji">{{ identityFail ? '🥲' : '🍼' }}</view>
|
||||
<view class="wv-title">{{ identityFail ? '未获取到微信身份' : '正在获取微信身份' }}</view>
|
||||
<view class="wv-desc">{{ identityFail ? '请检查网络后点下方重试,或退出小程序重新进入' : '马上就好,请稍候(不会加载空数据的页面)' }}</view>
|
||||
<button v-if="identityFail" class="wv-retry" hover-class="wv-retry-hover" @tap="retryIdentity">重新获取身份</button>
|
||||
<view class="wv-emoji">{{ appNeedLogin ? '🔐' : (identityFail ? '🥲' : '🍼') }}</view>
|
||||
<view class="wv-title">{{ appNeedLogin ? '登录后继续' : (identityFail ? '未获取到微信身份' : '正在获取微信身份') }}</view>
|
||||
<view class="wv-desc">{{ appNeedLogin ? '使用手机号验证码登录;登录后会获取微信身份并自动打开该应用' : (identityFail ? '请检查网络后点下方重试,或退出小程序重新进入' : '马上就好,请稍候(不会加载空数据的页面)') }}</view>
|
||||
<button v-if="appNeedLogin" class="wv-retry" hover-class="wv-retry-hover" @tap="goAppLogin">登录后继续</button>
|
||||
<button v-else-if="identityFail" class="wv-retry" hover-class="wv-retry-hover" @tap="retryIdentity">重新获取身份</button>
|
||||
</view>
|
||||
|
||||
<!-- 共享原生授权面板(任意 H5 应用 postMessage({action:'requestProfile'}) 后显示) -->
|
||||
@@ -156,6 +157,7 @@ export default {
|
||||
savedUrl: '',
|
||||
identityPending: false, // 正在获取 openid(此期间**不加载 H5**)
|
||||
identityFail: false, // 多次仍未拿到 openid → 停在兜底屏,给「重新获取身份」入口
|
||||
appNeedLogin: false, // App:未登录 → 兜底屏给「登录后继续」
|
||||
_idAttempts: 0, // 自动重试计数
|
||||
_pendingTarget: '' // 重试时要加载的目标 URL(重试按钮用)
|
||||
}
|
||||
@@ -378,9 +380,23 @@ export default {
|
||||
console.log('[auth-flow] 🔑 容器页取 openid(第 ' + this._idAttempts + '/' + MAX + ' 次),此期间不加载 H5');
|
||||
/* 2) 第 1 次先等 App.vue onLaunch 那次静默登录(同一次 exchange,别重复换 code);
|
||||
之后的重试才自己 wx.login + 换 openid。理由与首页壳一致,见 mixins 的 _awaitHostLogin。 */
|
||||
const task = (seq === 0) ? this._awaitHostLogin(1500) : this._silenceAuthOpenid();
|
||||
task.then(() => {
|
||||
let task;
|
||||
// #ifdef APP-PLUS
|
||||
task = this._silenceAuthOpenid();
|
||||
// #endif
|
||||
// #ifndef APP-PLUS
|
||||
task = (seq === 0) ? this._awaitHostLogin(1500) : this._silenceAuthOpenid();
|
||||
// #endif
|
||||
task.then((r) => {
|
||||
if (this._loadWithCachedIdentity(t)) return;
|
||||
/* App 未登录:停止自动重试,兜底屏给「登录后继续」 */
|
||||
if (r && r.needLogin) {
|
||||
this.identityPending = false;
|
||||
this.identityFail = false;
|
||||
this.appNeedLogin = true;
|
||||
console.log('[auth-flow] App 未登录(容器页)→ 等待用户登录');
|
||||
return;
|
||||
}
|
||||
if (this._idAttempts < MAX) {
|
||||
setTimeout(() => this._ensureIdentityThenLoad(t), 500); // 退避固定 500ms(原 600×n)
|
||||
return;
|
||||
@@ -396,6 +412,7 @@ export default {
|
||||
if (!cached.openid) return false;
|
||||
this.identityPending = false;
|
||||
this.identityFail = false;
|
||||
this.appNeedLogin = false;
|
||||
this._idAttempts = 0;
|
||||
this._applyIdentity(t, cached.openid, cached.unionid, getUrlParam(t, 'openid'));
|
||||
return true;
|
||||
@@ -404,9 +421,21 @@ export default {
|
||||
retryIdentity() {
|
||||
this._idAttempts = 0;
|
||||
this.identityFail = false;
|
||||
this.appNeedLogin = false;
|
||||
this._ensureIdentityThenLoad(this._pendingTarget || this.savedUrl || this.url);
|
||||
},
|
||||
|
||||
/* App:去登录;登录成功 reLaunch 回容器页(带原目标 URL) */
|
||||
goAppLogin() {
|
||||
const back = this._pendingTarget || this.savedUrl || this.url || '';
|
||||
try {
|
||||
/* 必须走 $Cache.set(loginMobile 读的是 $Cache.get(BACK_URL)) */
|
||||
this.$Cache.set('login_back_url',
|
||||
back ? '/pages/annex/web_view/index?url=' + encodeURIComponent(back) : '/pages/index/index');
|
||||
} catch (e) {}
|
||||
uni.navigateTo({ url: '/pages/users/login/index' });
|
||||
},
|
||||
|
||||
_applyIdentity(targetUrl, openid, unionid, urlOpenid) {
|
||||
console.log('[auth-flow] _applyIdentity: openid=' + (openid || '(空)') + ', unionid=' + (unionid || '(空)') + ', urlOpenid=' + (urlOpenid || '(无)'));
|
||||
if (urlOpenid && urlOpenid !== openid) {
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
<view class="mamabox-title">{{ fallbackTitle }}</view>
|
||||
<view class="mamabox-desc">{{ fallbackDesc }}</view>
|
||||
</view>
|
||||
<button v-if="loadError || identityFail" class="mamabox-retry" hover-class="mamabox-retry-hover" @tap="retryLoad">{{ loadError ? '重新加载' : '重新获取身份' }}</button>
|
||||
<button v-if="appNeedLogin" class="mamabox-retry" hover-class="mamabox-retry-hover" @tap="goAppLogin">登录后继续</button>
|
||||
<button v-else-if="loadError || identityFail" class="mamabox-retry" hover-class="mamabox-retry-hover" @tap="retryLoad">{{ loadError ? '重新加载' : '重新获取身份' }}</button>
|
||||
</view>
|
||||
|
||||
<!-- 小程序原生授权面板(H5 postMessage 请求后显示):手机号/昵称/头像 -->
|
||||
@@ -122,19 +123,21 @@
|
||||
别让用户对着「正在加载」干等却不知道在等什么。 */
|
||||
fallbackTitle() {
|
||||
if (this.loadError) return '页面加载失败';
|
||||
if (this.appNeedLogin) return '登录后继续';
|
||||
if (this.identityFail) return '未获取到微信身份';
|
||||
if (this.identityPending) return '正在获取微信身份';
|
||||
return '正在加载';
|
||||
},
|
||||
fallbackDesc() {
|
||||
if (this.loadError) return '请检查网络后重试';
|
||||
if (this.appNeedLogin) return '使用手机号验证码登录;登录后会获取微信身份并自动进入首页';
|
||||
if (this.identityFail) return '请检查网络后点下方重试,或退出小程序重新进入';
|
||||
if (this.identityPending) return '马上就好,请稍候(不会加载空数据的页面)';
|
||||
if (this.restoring) return '正在回到你上次使用的应用';
|
||||
return '正在为你打开「兜爸心选」';
|
||||
},
|
||||
fallbackEmoji() {
|
||||
return (this.loadError || this.identityFail) ? '🥲' : '🍼';
|
||||
return this.appNeedLogin ? '🔐' : ((this.loadError || this.identityFail) ? '🥲' : '🍼');
|
||||
},
|
||||
},
|
||||
data() {
|
||||
@@ -150,6 +153,7 @@
|
||||
_noRestore: false, // 本次加载 mama-box 是否要带 #norestore=1(禁止 H5 兜底再把用户送回应用)
|
||||
identityPending: false, // 正在获取 openid(此期间**不加载 H5**,见 fetchIdentityThenLoad)
|
||||
identityFail: false, // 多次仍未拿到 openid → 停在兜底屏,给「重新获取身份」入口
|
||||
appNeedLogin: false, // App:没登录(或登录后仍无身份)→ 兜底屏给「登录后继续」
|
||||
shareInfo: {}, // CRMEB 后台「分享设置」(标题/图,无 App 匹配时兜底)
|
||||
// 授权面板字段由 mixins/webviewHost.js 提供:
|
||||
// showAuth / authNickname / authAvatar / _authCode
|
||||
@@ -620,9 +624,25 @@
|
||||
它先落地就直接加载 —— 避免两边各换一次 code 白花 200–300ms
|
||||
(微信 code 一次性;实测 code2session 约 200–300ms)。
|
||||
之后的重试才自己 wx.login + 换 openid(_silenceAuthOpenid)。 */
|
||||
const task = (seq === 0) ? this._awaitHostLogin(1500) : this._silenceAuthOpenid();
|
||||
task.then(() => {
|
||||
let task;
|
||||
// #ifdef APP-PLUS
|
||||
/* App:没有并行的 wx.login,直接走「短信登录态 + app_identity/app_bind」 */
|
||||
task = this._silenceAuthOpenid();
|
||||
// #endif
|
||||
// #ifndef APP-PLUS
|
||||
task = (seq === 0) ? this._awaitHostLogin(1500) : this._silenceAuthOpenid();
|
||||
// #endif
|
||||
task.then((r) => {
|
||||
if (this._loadWithCachedIdentity(base)) return;
|
||||
/* App 未登录:**停止自动重试**,兜底屏给「登录后继续」按钮 ——
|
||||
没有 token 时重试多少次都拿不到身份,继续循环只是让用户干等。 */
|
||||
if (r && r.needLogin) {
|
||||
this.identityPending = false;
|
||||
this.identityFail = false;
|
||||
this.appNeedLogin = true;
|
||||
console.log('[auth-flow] App 未登录 → 等待用户登录(不自动重试)');
|
||||
return;
|
||||
}
|
||||
if (this._idAttempts < MAX) {
|
||||
/* 退避固定 500ms(原来 600×n,最坏 3 次 + 1.8s 退避 ≈ 3.5s 才出失败屏;
|
||||
现在 2 次 + 0.5s ≈ 1.5s 量级) */
|
||||
@@ -639,6 +659,7 @@
|
||||
if (!this._hostOpenid()) return false;
|
||||
this.identityPending = false;
|
||||
this.identityFail = false;
|
||||
this.appNeedLogin = false;
|
||||
this._idAttempts = 0;
|
||||
this._shownOnce = true;
|
||||
// 沿用本次的 _noRestore(见 loadMamaBox 注释):本轮加载是否需要禁止 mama-box 兜底恢复
|
||||
@@ -697,6 +718,7 @@
|
||||
this.requesting = false;
|
||||
this._shownOnce = true;
|
||||
this.identityFail = false;
|
||||
this.appNeedLogin = false;
|
||||
/* 有身份直接重载;没有就再走一遍「取到才加载」(重置尝试次数,自动重试 3 次)
|
||||
⚠️ 沿用 this._noRestore:重试首页时同样不许首页 H5 兜底恢复(见 loadMamaBox)。 */
|
||||
const homeUrl = this._homeBase();
|
||||
@@ -709,6 +731,15 @@
|
||||
this.fetchIdentityThenLoad(homeUrl);
|
||||
},
|
||||
|
||||
/* App:去登录。登录页成功后会 reLaunch 回 login_back_url(这里显式设成本页),
|
||||
回到首页再走一遍「短信登录态 → app_identity → app_bind」。 */
|
||||
goAppLogin() {
|
||||
/* ⚠️ 必须走 $Cache.set:loginMobile 用 $Cache.get(BACK_URL) 读,
|
||||
裸 uni.setStorageSync 会因缺少过期标记被当成「无值」覆盖掉。 */
|
||||
try { this.$Cache.set('login_back_url', '/pages/index/index'); } catch (e) {}
|
||||
uni.navigateTo({ url: '/pages/users/login/index' });
|
||||
},
|
||||
|
||||
/* 授权完善资料(postMessage → 原生面板 → 共享授权接口 → hash 回传)与
|
||||
pages/annex/web_view 共用 mixins/webviewHost.js:
|
||||
handleHostMessage / onChooseHostAvatar / onHostGetPhone /
|
||||
|
||||
@@ -78,6 +78,10 @@
|
||||
<text class="main-color" @click.stop="privacy('user')">《用户协议》</text>
|
||||
与<text class="main-color" @click.stop="privacy('privacy')">《隐私协议》</text>
|
||||
</checkbox-group>
|
||||
<!-- #ifdef APP-PLUS -->
|
||||
<!-- 备案号:商店审核要求应用内可见(未登录也能看到);号未下发时该行不渲染,取值见 config/legal.js -->
|
||||
<view class="beian" v-if="beianNo">APP 备案号:{{ beianNo }}</view>
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
<Verify v-if="!disabled" @success="success" :captchaType="captchaType" :imgSize="{ width: '330px', height: '155px' }"
|
||||
ref="verify"></Verify>
|
||||
@@ -116,6 +120,7 @@
|
||||
import colors from '@/mixins/color.js';
|
||||
import Verify from '../components/verify/verify.vue';
|
||||
import { HTTP_REQUEST_URL, CAPTCHA_TYPE } from '@/config/app';
|
||||
import legal from '@/config/legal.js';
|
||||
export default {
|
||||
name: "Login",
|
||||
components: {
|
||||
@@ -147,6 +152,8 @@
|
||||
appleShow: false, // 苹果登录版本必须要求ios13以上的
|
||||
keyLock: true,
|
||||
copyrightContext:'',
|
||||
// App 备案号(商店要求应用内可见):号未下发时为空 → 该行不渲染
|
||||
beianNo: legal.APP_BEIAN_NO,
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
@@ -798,6 +805,14 @@
|
||||
color: var(--view-theme);
|
||||
}
|
||||
|
||||
/* App 备案号:字号比协议再小一档,避免抢协议勾选的视觉重心 */
|
||||
.beian {
|
||||
margin-top: 14rpx;
|
||||
font-size: 20rpx;
|
||||
line-height: 28rpx;
|
||||
color: #b5b5b5;
|
||||
}
|
||||
|
||||
.trembling {
|
||||
animation: shake 0.6s;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { mapGetters, mapMutations } from 'vuex';
|
||||
import colors from '@/mixins/color.js';
|
||||
import tuiModal from '@/components/tui-modal/index.vue';
|
||||
import NavBar from '@/components/NavBar.vue';
|
||||
import legal from '@/config/legal.js';
|
||||
export default {
|
||||
computed: mapGetters(['isLogin']),
|
||||
data() {
|
||||
@@ -15,7 +16,11 @@ export default {
|
||||
loginType: 'h5',
|
||||
showModal: false,
|
||||
version: '',
|
||||
fileSizeString: ''
|
||||
fileSizeString: '',
|
||||
// 关于区块的合规信息(App 内必须可见备案号):统一取 config/legal.js
|
||||
beianNo: legal.APP_BEIAN_NO,
|
||||
icpNo: legal.WEBSITE_ICP_NO,
|
||||
subject: legal.SUBJECT
|
||||
};
|
||||
},
|
||||
mixins: [colors],
|
||||
@@ -149,6 +154,28 @@ export default {
|
||||
</view>
|
||||
</navigator>
|
||||
</view>
|
||||
<!-- #ifdef APP-PLUS -->
|
||||
<!-- 关于:版本 + 备案信息。小米/华为等商店硬性要求应用内可见备案号(截图要体现),
|
||||
取值全部在 config/legal.js;备案号未下发时该行自动隐藏。 -->
|
||||
<view class="list rd-24rpx mx-20">
|
||||
<view class="item acea-row row-between-wrapper">
|
||||
<view>当前版本</view>
|
||||
<view class="grab value">{{ version || '—' }}</view>
|
||||
</view>
|
||||
<view class="item acea-row row-between-wrapper" v-if="beianNo">
|
||||
<view>APP 备案号</view>
|
||||
<view class="grab value">{{ beianNo }}</view>
|
||||
</view>
|
||||
<view class="item acea-row row-between-wrapper">
|
||||
<view>ICP 备案号</view>
|
||||
<view class="grab value">{{ icpNo }}</view>
|
||||
</view>
|
||||
<view class="item acea-row row-between-wrapper">
|
||||
<view>开发者</view>
|
||||
<view class="grab value">{{ subject }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef MP -->
|
||||
<view class="list rd-24rpx mx-20">
|
||||
<view class="item acea-row row-between-wrapper" @click="outLogin">
|
||||
@@ -230,6 +257,15 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
/* 右侧纯文本值(版本号 / 备案号 / 主体):备案号可能较长,允许换行 */
|
||||
.value {
|
||||
color: #999;
|
||||
font-size: 26rpx;
|
||||
max-width: 60%;
|
||||
text-align: right;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/deep/.uni-switch-input {
|
||||
width: 84rpx;
|
||||
height: 48rpx;
|
||||
|
||||
Reference in New Issue
Block a user