主要更新uniapp相关功能
This commit is contained in:
1 parent
aa92ca40a2
commit
5b4dbb2b46
65 files changed
+8532
-1921
No files matched your search
@@ -141,3 +141,24 @@ export function pushWechatMpTest(data) {
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
* 微信小程序:一键登录配置(AppID / AppSecret / 启用)
|
||||
*************************************************/
|
||||
|
||||
/** 获取小程序配置(AppSecret 返回掩码) */
|
||||
export function getWechatMiniConfig() {
|
||||
return request({
|
||||
url: "/platform/wechatMini/config",
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
|
||||
/** 保存小程序配置(掩码 / 空串表示不修改原值) */
|
||||
export function saveWechatMiniConfig(data) {
|
||||
return request({
|
||||
url: "/platform/wechatMini/config",
|
||||
method: "post",
|
||||
data,
|
||||
});
|
||||
}
|
||||
@@ -410,6 +410,44 @@
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<!-- 小程序一键登录配置 -->
|
||||
<el-card shadow="never" class="settings-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>微信小程序(一键登录)配置</span>
|
||||
<el-tag v-if="Number(miniCfg.enabled) === 1 && miniCfg.configured" type="success" size="small">已启用</el-tag>
|
||||
<el-tag v-else type="info" size="small" class="ml8">未启用:小程序端仅账号密码登录</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
<el-form label-width="140px" label-position="right">
|
||||
<el-form-item label="启用状态">
|
||||
<el-switch v-model="miniCfg.enabled" :active-value="1" :inactive-value="0" />
|
||||
<span class="form-tip-inline">开启后 uniapp 小程序端登录页展示「微信手机号一键登录」主入口</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="AppID" required>
|
||||
<el-input v-model="miniCfg.app_id" placeholder="小程序后台「开发管理 → 开发设置」中的 AppID" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="AppSecret">
|
||||
<el-input v-model="miniCfg.app_secret" type="password" show-password placeholder="已保存时显示掩码,保持不变则无需修改" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="自动绑定">
|
||||
<el-switch v-model="miniCfg.auto_bind" :active-value="1" :inactive-value="0" />
|
||||
<span class="form-tip-inline">开启后未通过手机号验证的 openid 也会自动绑定账号;关闭时仅在手机号验证通过后建立绑定</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="miniCfg.remark" placeholder="仅后台可见" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :loading="miniSaving" @click="saveMiniConfig">保存配置</el-button>
|
||||
<div class="form-tip">
|
||||
① 此处 AppID 必须与 uniapp manifest.json「mp-weixin.appid」一致,否则 code 换 openid 会报 40029;<br />
|
||||
② 「手机号一键登录」需小程序为已认证企业主体,并在小程序后台开通「手机号快速验证」能力;<br />
|
||||
③ 保存并启用后,小程序端登录页自动切换为微信认证登录优先、账号密码其次。
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<!-- 绑定我的微信 -->
|
||||
<!-- <el-card shadow="never" class="settings-card bind-card">
|
||||
<template #header>
|
||||
@@ -623,6 +661,8 @@ import { formatTime } from "@/utils/datetime";
|
||||
import {
|
||||
getWechatMpConfig,
|
||||
saveWechatMpConfig,
|
||||
getWechatMiniConfig,
|
||||
saveWechatMiniConfig,
|
||||
testWechatMpConnection,
|
||||
publishWechatMpMenu,
|
||||
uploadWechatFollowQrcode,
|
||||
@@ -1049,6 +1089,56 @@ const saveWechatConfig = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
/* ==================== 微信小程序(一键登录) ==================== */
|
||||
|
||||
const miniCfg = reactive({
|
||||
app_id: "",
|
||||
app_secret: "",
|
||||
enabled: 0,
|
||||
auto_bind: 1,
|
||||
remark: "",
|
||||
configured: false,
|
||||
});
|
||||
const miniSaving = ref(false);
|
||||
|
||||
const loadMiniConfig = async () => {
|
||||
try {
|
||||
const res = await getWechatMiniConfig();
|
||||
if (res.code === 200 && res.data) {
|
||||
Object.assign(miniCfg, res.data);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("加载小程序配置失败:", e);
|
||||
}
|
||||
};
|
||||
|
||||
const saveMiniConfig = async () => {
|
||||
if (!miniCfg.app_id) {
|
||||
ElMessage.warning("请先填写 AppID");
|
||||
return;
|
||||
}
|
||||
miniSaving.value = true;
|
||||
try {
|
||||
const res = await saveWechatMiniConfig({
|
||||
app_id: miniCfg.app_id,
|
||||
app_secret: miniCfg.app_secret,
|
||||
enabled: Number(miniCfg.enabled) === 1 ? 1 : 0,
|
||||
auto_bind: Number(miniCfg.auto_bind) === 1 ? 1 : 0,
|
||||
remark: miniCfg.remark,
|
||||
});
|
||||
if (res.code === 200) {
|
||||
ElMessage.success("小程序配置保存成功");
|
||||
await loadMiniConfig();
|
||||
} else {
|
||||
ElMessage.error(res.msg || "保存失败");
|
||||
}
|
||||
} catch (e) {
|
||||
ElMessage.error(e?.message || "保存失败");
|
||||
} finally {
|
||||
miniSaving.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 关注二维码上传/删除(存 data URL,供租户端「绑定微信」页展示扫码)
|
||||
const followQrcodeUploading = ref(false);
|
||||
const handleFollowQrcodeUpload = async ({ file }) => {
|
||||
@@ -1344,6 +1434,7 @@ onMounted(() => {
|
||||
loadSiteReminderConfig();
|
||||
loadBarkConfig();
|
||||
loadWechatConfig();
|
||||
loadMiniConfig();
|
||||
loadWechatBinding();
|
||||
});
|
||||
|
||||
@@ -1351,6 +1442,7 @@ onMounted(() => {
|
||||
watch(activeSubTab, (tab) => {
|
||||
if (tab === "wechat") {
|
||||
loadWechatConfig();
|
||||
loadMiniConfig();
|
||||
loadWechatBinding();
|
||||
loadFollowers();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user