feat(user): 后台用户管理增加重置密码功能,并将部署流程默认调整为纯代码部署(不同步数据库)
这个提交包含在:
@@ -647,7 +647,6 @@
|
||||
import GoodsPickerDrawer from '@/components/GoodsPickerDrawer.vue';
|
||||
import api from '@/utils/api.js';
|
||||
import { isLogin, toLogin } from '@/utils/request.js';
|
||||
import { ensureSilentLogin } from '@/utils/wxlogin.js';
|
||||
import { getNavBarMetrics } from '@/utils/system.js';
|
||||
import YjyfRefreshScroll from '@/components/YjyfRefreshScroll.vue';
|
||||
|
||||
@@ -1088,11 +1087,6 @@
|
||||
feedError.value = '';
|
||||
|
||||
homeLoadingPromise = (async () => {
|
||||
const wasLoggedIn = isLogin();
|
||||
const silentLoginTask = wasLoggedIn
|
||||
? Promise.resolve(true)
|
||||
: ensureSilentLogin().catch(() => false);
|
||||
|
||||
const homeTask = (async () => {
|
||||
try {
|
||||
const res = await api.home();
|
||||
@@ -1107,19 +1101,6 @@
|
||||
const feedTask = loadFeed(true, hasExistingList);
|
||||
|
||||
await Promise.all([homeTask, feedTask]);
|
||||
|
||||
// 若首次冷启动刚完成静默登录,后台无感补拉一次角标,不阻塞首屏渲染
|
||||
if (!wasLoggedIn) {
|
||||
const loggedNow = await silentLoginTask;
|
||||
if (loggedNow && isLogin()) {
|
||||
try {
|
||||
const fresh = await api.home();
|
||||
if (fresh && fresh.badge) badge.value = fresh.badge;
|
||||
} catch (e) {
|
||||
console.warn('[Home] badge refresh failed:', e);
|
||||
}
|
||||
}
|
||||
}
|
||||
})().finally(() => {
|
||||
homeBooting.value = false;
|
||||
homeLoadingPromise = null;
|
||||
|
||||
@@ -38,21 +38,13 @@
|
||||
<input v-if="status.has_login_password" v-model="oldPassword" class="input" password placeholder="请输入原登录密码" />
|
||||
<input v-model="newPassword" class="input" password maxlength="30" placeholder="新登录密码(6至30位)" />
|
||||
<input v-model="confirmPassword" class="input" password maxlength="30" placeholder="再次输入新登录密码" />
|
||||
<text v-if="!status.has_login_password" class="hint">请使用绑定的微信手机号验证身份。</text>
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<button v-if="!status.has_login_password" class="primary" open-type="getPhoneNumber" :disabled="busy" @getphonenumber="onPhoneVerify">验证手机号并设置</button>
|
||||
<!-- #endif -->
|
||||
<!-- #ifndef MP-WEIXIN -->
|
||||
<text v-if="!status.has_login_password" class="hint">请在微信小程序中完成手机号验证后设置。</text>
|
||||
<!-- #endif -->
|
||||
<button v-if="status.has_login_password" class="primary" :disabled="busy" @tap="savePassword">确认修改</button>
|
||||
<button class="primary" :disabled="busy" @tap="savePassword">{{ status.has_login_password ? '确认修改' : '确认设置' }}</button>
|
||||
</template>
|
||||
<template v-else-if="mode === 'payment'">
|
||||
<input v-if="status.has_payment_password" v-model="oldPassword" class="input" type="number" password maxlength="6" placeholder="请输入原支付密码" />
|
||||
<input v-else-if="!status.has_payment_password" v-model="oldPassword" class="input" password placeholder="请输入登录密码以验证身份" />
|
||||
<input v-model="newPassword" class="input" type="number" password maxlength="6" placeholder="设置6位支付密码" />
|
||||
<input v-model="newPassword" class="input" type="number" password maxlength="6" placeholder="设置6位数字支付密码" />
|
||||
<input v-model="confirmPassword" class="input" type="number" password maxlength="6" placeholder="再次输入支付密码" />
|
||||
<button class="primary" :disabled="busy" @tap="savePassword">确认</button>
|
||||
<button class="primary" :disabled="busy" @tap="savePassword">{{ status.has_payment_password ? '确认修改' : '确认设置' }}</button>
|
||||
</template>
|
||||
|
||||
</view>
|
||||
@@ -88,24 +80,26 @@
|
||||
if (!valid || newPassword.value !== confirmPassword.value) { uni.showToast({ title: '请检查两次输入的密码', icon: 'none' }); return false; }
|
||||
return true;
|
||||
}
|
||||
async function onPhoneVerify(event) {
|
||||
const code = event.detail && event.detail.code;
|
||||
if (!code) { uni.showToast({ title: '未完成手机号验证', icon: 'none' }); return; }
|
||||
await savePassword(code);
|
||||
}
|
||||
async function savePassword(phoneCode = '') {
|
||||
if (typeof phoneCode !== 'string') phoneCode = '';
|
||||
async function savePassword() {
|
||||
if (busy.value || !validPassword()) return;
|
||||
if (mode.value === 'login' && status.value.has_login_password && !oldPassword.value) {
|
||||
uni.showToast({ title: '请输入原登录密码', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (mode.value === 'payment' && status.value.has_payment_password && !/^\d{6}$/.test(oldPassword.value)) {
|
||||
uni.showToast({ title: '请输入6位原支付密码', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
busy.value = true;
|
||||
try {
|
||||
if (mode.value === 'login') {
|
||||
await api.changeLoginPassword({ old_password: oldPassword.value, new_password: newPassword.value, phone_code: phoneCode });
|
||||
await api.changeLoginPassword({ old_password: oldPassword.value, new_password: newPassword.value });
|
||||
clearAuth(); uni.showToast({ title: '请重新登录', icon: 'none' });
|
||||
setTimeout(() => uni.reLaunch({ url: '/pages/login/login' }), 700); return;
|
||||
}
|
||||
const firstSetup = !status.value.has_payment_password;
|
||||
if (!firstSetup) await api.changePaymentPassword({ old_password: oldPassword.value, new_password: newPassword.value });
|
||||
else await api.setPaymentPassword({ login_password: oldPassword.value, new_password: newPassword.value });
|
||||
else await api.setPaymentPassword({ new_password: newPassword.value });
|
||||
busy.value = false; close(); uni.showToast({ title: '保存成功' });
|
||||
if (setupFromPayment.value && firstSetup) {
|
||||
try { await finishPaymentSetup(uni, returnOrder.value); } catch (e) { uni.showToast({ title: e.message, icon: 'none' }); }
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* → 自动用全新 code 重试一次
|
||||
*/
|
||||
import api from './api.js';
|
||||
import { getToken, setToken, setUser } from './request.js';
|
||||
import { setToken, setUser } from './request.js';
|
||||
|
||||
let inflight = null;
|
||||
|
||||
@@ -46,22 +46,6 @@ async function exchange(payload, retry) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 静默登录(进主页时调用):已登录直接返回,失败不抛错
|
||||
*/
|
||||
export function ensureSilentLogin() {
|
||||
if (getToken()) return Promise.resolve(null);
|
||||
if (inflight) return inflight;
|
||||
|
||||
inflight = exchange({}, true)
|
||||
.catch(() => null)
|
||||
.then((data) => {
|
||||
inflight = null;
|
||||
return data;
|
||||
});
|
||||
return inflight;
|
||||
}
|
||||
|
||||
/**
|
||||
* 主动授权登录(点击「微信一键登录」)
|
||||
*/
|
||||
|
||||
在新工单中引用
屏蔽一个用户