fix:最新版本
This commit is contained in:
@@ -7,8 +7,7 @@
|
||||
}
|
||||
|
||||
.add-device-page__scroll {
|
||||
flex: 1;
|
||||
height: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.add-device-page__body {
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
}
|
||||
|
||||
.complete-page__scroll {
|
||||
flex: 1;
|
||||
height: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.complete-page__body {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view class="complete-page">
|
||||
<app-navbar title="设备配置" />
|
||||
<scroll-view class="complete-page__scroll" scroll-y>
|
||||
<page-scroll-view class="complete-page__scroll">
|
||||
<view class="complete-page__body">
|
||||
<bind-steps :steps="BIND_STEPS" :current="currentStep" />
|
||||
<complete-success-hero />
|
||||
@@ -107,7 +107,7 @@
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</page-scroll-view>
|
||||
<view class="complete-page__footer">
|
||||
<view
|
||||
class="complete-page__submit"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view class="add-device-page">
|
||||
<app-navbar title="添加设备" />
|
||||
<scroll-view class="add-device-page__scroll" scroll-y>
|
||||
<page-scroll-view class="add-device-page__scroll">
|
||||
<view class="add-device-page__body">
|
||||
<bind-steps :steps="BIND_STEPS" :current="currentStep" />
|
||||
<bind-bluetooth-hero />
|
||||
@@ -25,7 +25,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</page-scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view class="pair-page">
|
||||
<app-navbar title="设备配置" />
|
||||
<scroll-view class="pair-page__scroll" scroll-y>
|
||||
<page-scroll-view class="pair-page__scroll">
|
||||
<view class="pair-page__body">
|
||||
<bind-steps :steps="BIND_STEPS" :current="currentStep" />
|
||||
<pair-hero />
|
||||
@@ -33,7 +33,7 @@
|
||||
<pair-check-list :items="checkItems" />
|
||||
<pair-device-summary :device="device" :connect-status="connectStatus" />
|
||||
</view>
|
||||
</scroll-view>
|
||||
</page-scroll-view>
|
||||
<view class="pair-page__footer">
|
||||
<view
|
||||
v-if="connectStatus === 'failed'"
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
}
|
||||
|
||||
.pair-page__scroll {
|
||||
flex: 1;
|
||||
height: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pair-page__body {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view class="scan-page">
|
||||
<app-navbar title="扫描设备" />
|
||||
<scroll-view class="scan-page__scroll" scroll-y>
|
||||
<page-scroll-view class="scan-page__scroll">
|
||||
<view class="scan-page__body">
|
||||
<bind-steps :steps="BIND_STEPS" :current="currentStep" />
|
||||
<scan-hero />
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
<scan-help-tip />
|
||||
</view>
|
||||
</scroll-view>
|
||||
</page-scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
}
|
||||
|
||||
.scan-page__scroll {
|
||||
flex: 1;
|
||||
height: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.scan-page__body {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<template>
|
||||
<view class="agreement-page">
|
||||
<app-navbar :title="title" />
|
||||
<scroll-view class="agreement-page__scroll" scroll-y>
|
||||
<page-scroll-view class="agreement-page__scroll">
|
||||
<view class="agreement-page__content">
|
||||
<view v-if="loading" class="agreement-page__loading">
|
||||
<text>加载中...</text>
|
||||
</view>
|
||||
<text v-else class="agreement-page__text">{{ content }}</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</page-scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -27,8 +27,7 @@ const { title, content, loading } = useAgreement()
|
||||
}
|
||||
|
||||
.agreement-page__scroll {
|
||||
flex: 1;
|
||||
height: calc(100vh - 88rpx);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.agreement-page__content {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<base-input v-model="password" icon="lock" type="password" placeholder="请输入密码" />
|
||||
<base-input v-model="confirmPassword" icon="lock" type="password" placeholder="确认密码" />
|
||||
|
||||
<text class="auth-form-page__hint">8-20位字符,须包含字母、数字、符号中的至少2种。</text>
|
||||
<text class="auth-form-page__hint">{{ passwordRuleHint }}</text>
|
||||
|
||||
<view class="auth-form-page__btn">
|
||||
<primary-button text="确认修改" @click="submit" />
|
||||
@@ -17,8 +17,11 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PASSWORD_RULE_HINT } from '@/utils/validate'
|
||||
import { useChangePassword } from './use-change-password'
|
||||
|
||||
const passwordRuleHint = `${PASSWORD_RULE_HINT}。`
|
||||
|
||||
const { password, confirmPassword, submit } = useChangePassword()
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { ref } from 'vue'
|
||||
import { getErrorMessage } from '@/utils/api-error'
|
||||
import { isValidStrongPassword } from '@/utils/validate'
|
||||
import { isValidStrongPassword, PASSWORD_INVALID_TOAST } from '@/utils/validate'
|
||||
import { resetPasswordByToken } from './change-password.api'
|
||||
|
||||
export function useChangePassword() {
|
||||
@@ -27,10 +27,7 @@ export function useChangePassword() {
|
||||
return
|
||||
}
|
||||
if (!isValidStrongPassword(password.value)) {
|
||||
uni.showToast({
|
||||
title: '密码需8-20位,且包含字母、数字、符号中至少2种',
|
||||
icon: 'none',
|
||||
})
|
||||
uni.showToast({ title: PASSWORD_INVALID_TOAST, icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (password.value !== confirmPassword.value) {
|
||||
|
||||
@@ -163,8 +163,7 @@
|
||||
.device-detail-page__scroll {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
flex: 1;
|
||||
height: 0;
|
||||
width: 100%;
|
||||
margin-top: -40rpx;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<text class="device-detail-hero__sync">{{ syncText }}</text>
|
||||
</view>
|
||||
|
||||
<scroll-view class="device-detail-page__scroll" scroll-y>
|
||||
<page-scroll-view class="device-detail-page__scroll" :scroll-style="detailScrollStyle">
|
||||
<view class="device-detail-panel">
|
||||
<view class="device-detail-panel__dash" aria-hidden="true" />
|
||||
|
||||
@@ -140,7 +140,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</page-scroll-view>
|
||||
|
||||
<filter-replace-dialog
|
||||
v-model:visible="filterReplaceDialogVisible"
|
||||
@@ -152,12 +152,16 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { usePageScrollHeight } from '@/hooks/use-page-scroll-height'
|
||||
import { staticAssets } from '@/utils/static-assets'
|
||||
import FilterReplaceDialog from './components/filter-replace-dialog/index.vue'
|
||||
import RunModeExplainDialog from './components/run-mode-explain-dialog/index.vue'
|
||||
import { useDeviceDetail } from './use-device-detail'
|
||||
|
||||
const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight ?? 0)
|
||||
const { scrollStyle: detailScrollStyle } = usePageScrollHeight({
|
||||
topSelector: '.device-detail-hero',
|
||||
})
|
||||
const runModeExplainVisible = ref(false)
|
||||
|
||||
function onOpenRunModeExplain() {
|
||||
|
||||
@@ -4,3 +4,16 @@
|
||||
padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.device-page__loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 360rpx;
|
||||
padding: 48rpx 32rpx;
|
||||
}
|
||||
|
||||
.device-page__loading-text {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<view class="home-manage-page">
|
||||
<app-navbar title="家庭管理" />
|
||||
|
||||
<scroll-view class="home-manage-page__scroll" scroll-y>
|
||||
<page-scroll-view class="home-manage-page__scroll">
|
||||
<view class="home-manage-page__body">
|
||||
<text class="home-manage-page__summary">{{ summaryText }}</text>
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</page-scroll-view>
|
||||
|
||||
<home-name-dialog
|
||||
v-model:visible="nameDialogVisible"
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
}
|
||||
|
||||
.home-manage-page__scroll {
|
||||
flex: 1;
|
||||
height: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.home-manage-page__body {
|
||||
@@ -73,11 +72,18 @@
|
||||
margin-left: 32rpx;
|
||||
}
|
||||
|
||||
.home-manage-page__loading,
|
||||
.home-manage-page__empty {
|
||||
padding: 120rpx 32rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.home-manage-page__loading-text {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.home-manage-page__empty-text {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<view class="home-manage-page">
|
||||
<app-navbar title="家庭管理" />
|
||||
|
||||
<scroll-view class="home-manage-page__scroll" scroll-y>
|
||||
<page-scroll-view class="home-manage-page__scroll">
|
||||
<view class="home-manage-page__body">
|
||||
<view v-if="homes.length" class="home-manage-page__list">
|
||||
<view
|
||||
@@ -20,11 +20,14 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-else-if="!loading" class="home-manage-page__empty">
|
||||
<view v-else-if="loading" class="home-manage-page__loading">
|
||||
<text class="home-manage-page__loading-text">加载中...</text>
|
||||
</view>
|
||||
<view v-else class="home-manage-page__empty">
|
||||
<text class="home-manage-page__empty-text">暂无家庭</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</page-scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { ref } from 'vue'
|
||||
import {
|
||||
buildUpdateHomeBody,
|
||||
isValidHomeName,
|
||||
updateHome,
|
||||
} from '@/api/home'
|
||||
import { getErrorMessage } from '@/utils/api-error'
|
||||
import { parseId } from '@/utils/device-id'
|
||||
import { formatCoordinateAddress, reverseGeocode } from '@/utils/map-geocode'
|
||||
import { loadHomeGeo, saveHomeGeo } from '../use-home-manage'
|
||||
@@ -21,6 +27,8 @@ function requestUserLocation(): Promise<UniApp.GetLocationSuccess> {
|
||||
|
||||
export function useHomeLocation() {
|
||||
const homeId = ref('')
|
||||
const homeName = ref('我的家')
|
||||
const saving = ref(false)
|
||||
const latitude = ref(DEFAULT_LATITUDE)
|
||||
const longitude = ref(DEFAULT_LONGITUDE)
|
||||
const searchKeyword = ref('')
|
||||
@@ -136,11 +144,17 @@ export function useHomeLocation() {
|
||||
}
|
||||
}
|
||||
|
||||
function onConfirm() {
|
||||
async function onConfirm() {
|
||||
if (!homeId.value) {
|
||||
uni.navigateBack()
|
||||
return
|
||||
}
|
||||
if (!isValidHomeName(homeName.value)) {
|
||||
uni.showToast({ title: '家庭名称需 2-10 个字符', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (saving.value) return
|
||||
|
||||
const address = addressText.value.trim()
|
||||
|| formatCoordinateAddress(latitude.value, longitude.value)
|
||||
const geo: HomeGeoInfo = {
|
||||
@@ -148,15 +162,30 @@ export function useHomeLocation() {
|
||||
latitude: latitude.value,
|
||||
longitude: longitude.value,
|
||||
}
|
||||
saveHomeGeo(homeId.value, geo)
|
||||
uni.showToast({ title: '保存成功', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 300)
|
||||
|
||||
saving.value = true
|
||||
try {
|
||||
await updateHome(
|
||||
homeId.value,
|
||||
buildUpdateHomeBody(homeName.value, { geo }),
|
||||
)
|
||||
saveHomeGeo(homeId.value, geo)
|
||||
uni.showToast({ title: '保存成功', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 300)
|
||||
} catch (err) {
|
||||
uni.showToast({ title: getErrorMessage(err, '保存家庭位置失败'), icon: 'none' })
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onLoad((query?: Record<string, string | undefined>) => {
|
||||
homeId.value = parseId(query?.homeId)
|
||||
if (query?.homeName) {
|
||||
homeName.value = decodeURIComponent(String(query.homeName))
|
||||
}
|
||||
const saved = homeId.value ? loadHomeGeo(homeId.value) : undefined
|
||||
if (query?.address) {
|
||||
addressText.value = decodeURIComponent(String(query.address))
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||
import { computed, ref } from 'vue'
|
||||
import { resolveValidHomeId } from '@/api/home'
|
||||
import {
|
||||
buildUpdateHomeBody,
|
||||
isValidHomeName,
|
||||
resolveValidHomeId,
|
||||
updateHome,
|
||||
} from '@/api/home'
|
||||
import type { AppHomeVo } from '@/types/location'
|
||||
import { fetchRoomList } from '@/api/location'
|
||||
import { getErrorMessage } from '@/utils/api-error'
|
||||
import { fetchHomeManageStats } from './home-manage.api'
|
||||
@@ -31,6 +37,8 @@ export function useHomeManage() {
|
||||
const homeAddress = ref('')
|
||||
const loading = ref(false)
|
||||
const nameDialogVisible = ref(false)
|
||||
const currentHome = ref<AppHomeVo>()
|
||||
const savingName = ref(false)
|
||||
|
||||
const summaryText = computed(
|
||||
() => `共${roomCount.value}个房间,${deviceCount.value}个设备`,
|
||||
@@ -44,11 +52,22 @@ export function useHomeManage() {
|
||||
fetchHomeManageStats(homeId.value),
|
||||
fetchRoomList(homeId.value),
|
||||
])
|
||||
currentHome.value = stats.home
|
||||
if (stats.home?.homeName) homeName.value = stats.home.homeName
|
||||
roomCount.value = rooms.length || stats.roomCount
|
||||
deviceCount.value = stats.deviceCount
|
||||
const geo = loadHomeGeo(homeId.value)
|
||||
homeAddress.value = geo?.address ?? ''
|
||||
homeAddress.value =
|
||||
stats.home?.homeLocationAddress?.trim()
|
||||
|| geo?.address
|
||||
|| ''
|
||||
if (stats.home?.homeLocationAddress && stats.home.homeLocationLatitude != null) {
|
||||
saveHomeGeo(homeId.value, {
|
||||
address: stats.home.homeLocationAddress,
|
||||
latitude: stats.home.homeLocationLatitude,
|
||||
longitude: stats.home.homeLocationLongitude ?? 116.4074,
|
||||
})
|
||||
}
|
||||
} catch (err) {
|
||||
uni.showToast({ title: getErrorMessage(err, '加载家庭信息失败'), icon: 'none' })
|
||||
} finally {
|
||||
@@ -68,14 +87,31 @@ export function useHomeManage() {
|
||||
nameDialogVisible.value = true
|
||||
}
|
||||
|
||||
function onConfirmHomeName(name: string) {
|
||||
async function onConfirmHomeName(name: string) {
|
||||
const trimmed = name.trim()
|
||||
if (!trimmed) {
|
||||
uni.showToast({ title: '请输入家庭名称', icon: 'none' })
|
||||
if (!isValidHomeName(trimmed)) {
|
||||
uni.showToast({ title: '家庭名称需 2-10 个字符', icon: 'none' })
|
||||
return
|
||||
}
|
||||
homeName.value = trimmed
|
||||
uni.showToast({ title: '家庭名称修改接口待对接', icon: 'none' })
|
||||
if (!homeId.value || savingName.value) return
|
||||
|
||||
savingName.value = true
|
||||
try {
|
||||
const geo = loadHomeGeo(homeId.value)
|
||||
await updateHome(
|
||||
homeId.value,
|
||||
buildUpdateHomeBody(trimmed, { geo, home: currentHome.value }),
|
||||
)
|
||||
homeName.value = trimmed
|
||||
if (currentHome.value) {
|
||||
currentHome.value = { ...currentHome.value, homeName: trimmed }
|
||||
}
|
||||
uni.showToast({ title: '修改成功', icon: 'success' })
|
||||
} catch (err) {
|
||||
uni.showToast({ title: getErrorMessage(err, '修改家庭名称失败'), icon: 'none' })
|
||||
} finally {
|
||||
savingName.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onOpenLocation() {
|
||||
|
||||
@@ -21,7 +21,10 @@
|
||||
@manage="onManageDevices"
|
||||
@select="onSelectDevice"
|
||||
/>
|
||||
<template v-else-if="!loading">
|
||||
<view v-else-if="loading" class="device-page__loading">
|
||||
<text class="device-page__loading-text">加载中...</text>
|
||||
</view>
|
||||
<template v-else>
|
||||
<device-empty :step-hint="bindStepHint" @bind="onStartBind" />
|
||||
<hot-devices :items="hotDevices" @mall="onGoMall" />
|
||||
</template>
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
}
|
||||
|
||||
.device-settings-page__scroll {
|
||||
flex: 1;
|
||||
height: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.device-settings-page__body {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<view class="device-settings-page">
|
||||
<app-navbar title="设备设置" />
|
||||
|
||||
<scroll-view class="device-settings-page__scroll" scroll-y>
|
||||
<page-scroll-view class="device-settings-page__scroll">
|
||||
<view class="device-settings-page__body">
|
||||
<view class="device-settings-card">
|
||||
<view class="device-settings-card__top">
|
||||
@@ -74,7 +74,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</page-scroll-view>
|
||||
|
||||
<device-name-dialog
|
||||
v-model:visible="nameDialogVisible"
|
||||
|
||||
@@ -2,6 +2,7 @@ import { onHide, onShow } from '@dcloudio/uni-app'
|
||||
import { computed, ref } from 'vue'
|
||||
import { refreshUnreadMessageCount } from '@/hooks/use-message-inbox'
|
||||
import { fetchHomeList, resolveValidHomeId } from '@/api/home'
|
||||
import { getStoredToken } from '@/utils/auth-token'
|
||||
import { parseId, sameId } from '@/utils/device-id'
|
||||
import { createLocation } from '@/api/location'
|
||||
import { getErrorMessage } from '@/utils/api-error'
|
||||
@@ -131,6 +132,10 @@ export function useDevice() {
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
if (!getStoredToken()) {
|
||||
uni.reLaunch({ url: '/pages/login/index' })
|
||||
return
|
||||
}
|
||||
void loadDevices()
|
||||
void refreshUnreadMessageCount()
|
||||
startPresencePolling()
|
||||
|
||||
@@ -8,7 +8,16 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<template v-if="mode === 'code'">
|
||||
<template v-if="mode === 'password'">
|
||||
<base-input v-model="account" icon="phone" placeholder="请输入账号" />
|
||||
<base-input v-model="password" icon="lock" type="password" placeholder="请输入密码" />
|
||||
<view class="login-page__links">
|
||||
<text class="login-page__link" @tap="switchMode('code')">验证码登录</text>
|
||||
<text class="login-page__link" @tap="goForgotPassword">忘记密码?</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<base-input v-model="phone" icon="phone" type="number" placeholder="请输入手机号" :maxlength="11" />
|
||||
<base-input v-model="code" icon="shield" type="number" placeholder="请输入验证码" :maxlength="6">
|
||||
<template #suffix>
|
||||
@@ -20,15 +29,6 @@
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<base-input v-model="account" icon="phone" placeholder="请输入账号" />
|
||||
<base-input v-model="password" icon="lock" type="password" placeholder="请输入密码" />
|
||||
<view class="login-page__links">
|
||||
<text class="login-page__link" @tap="switchMode('code')">验证码登录</text>
|
||||
<text class="login-page__link" @tap="goForgotPassword">忘记密码?</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<view class="login-page__footer">
|
||||
<view class="login-page__agreement">
|
||||
<agreement-checkbox v-model="agreed" />
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { ref } from 'vue'
|
||||
import { useSmsCode } from '@/hooks/use-sms-code'
|
||||
import { isValidPassword, isValidPhone, isValidSmsCode } from '@/utils/validate'
|
||||
@@ -10,8 +11,8 @@ import { loginByPassword, loginBySms } from './login.api'
|
||||
import type { LoginMode } from './login.types'
|
||||
|
||||
export function useLogin() {
|
||||
const mode = ref<LoginMode>('code')
|
||||
const agreed = ref(true)
|
||||
const mode = ref<LoginMode>('password')
|
||||
const agreed = ref(false)
|
||||
const phone = ref('')
|
||||
const code = ref('')
|
||||
const account = ref('')
|
||||
@@ -85,6 +86,12 @@ export function useLogin() {
|
||||
uni.navigateTo({ url: '/pages/forgot-password/index' })
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
if (!getStoredToken()) return
|
||||
setupMessageInbox()
|
||||
uni.reLaunch({ url: '/pages/device/index' })
|
||||
})
|
||||
|
||||
return {
|
||||
mode,
|
||||
agreed,
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
}
|
||||
|
||||
.edit-profile-page__scroll {
|
||||
flex: 1;
|
||||
height: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.edit-profile-page__body {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<app-navbar title="编辑资料" />
|
||||
</view>
|
||||
|
||||
<scroll-view class="edit-profile-page__scroll" scroll-y>
|
||||
<page-scroll-view class="edit-profile-page__scroll">
|
||||
<view class="edit-profile-page__body">
|
||||
<view class="edit-profile-page__avatar-section">
|
||||
<view class="edit-profile-page__avatar-wrap">
|
||||
@@ -118,7 +118,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</page-scroll-view>
|
||||
|
||||
<view class="edit-profile-page__footer">
|
||||
<view
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||
import { computed, ref } from 'vue'
|
||||
import { fetchProfile, updateProfile, uploadProfileAvatar } from '@/api/profile'
|
||||
import { getErrorMessage } from '@/utils/api-error'
|
||||
@@ -56,22 +56,25 @@ export function useEditProfile() {
|
||||
const locationText = computed(() =>
|
||||
formatLocation(form.value.province, form.value.city, form.value.district),
|
||||
)
|
||||
function applyProfile(profile: Awaited<ReturnType<typeof fetchProfile>>) {
|
||||
form.value = {
|
||||
nickName: profile.nickName || profile.userName || '',
|
||||
gender: profile.gender || '0',
|
||||
birthday: profile.birthday || '',
|
||||
province: profile.province || '',
|
||||
city: profile.city || '',
|
||||
district: profile.district || '',
|
||||
phonenumber: profile.phonenumber || profile.userName || '',
|
||||
avatarUrl: profile.avatarUrl || '',
|
||||
avatarOssId: profile.avatarOssId ? String(profile.avatarOssId) : '',
|
||||
}
|
||||
}
|
||||
|
||||
async function loadProfile() {
|
||||
if (loading.value) return
|
||||
loading.value = true
|
||||
try {
|
||||
const profile = await fetchProfile()
|
||||
form.value = {
|
||||
nickName: profile.nickName || profile.userName || '',
|
||||
gender: profile.gender || '0',
|
||||
birthday: profile.birthday || '',
|
||||
province: profile.province || '',
|
||||
city: profile.city || '',
|
||||
district: profile.district || '',
|
||||
phonenumber: profile.phonenumber || profile.userName || '',
|
||||
avatarUrl: profile.avatarUrl || '',
|
||||
avatarOssId: profile.avatarOssId ? String(profile.avatarOssId) : '',
|
||||
}
|
||||
applyProfile(await fetchProfile())
|
||||
} catch (err) {
|
||||
uni.showToast({ title: getErrorMessage(err, '加载资料失败'), icon: 'none' })
|
||||
} finally {
|
||||
@@ -79,6 +82,16 @@ export function useEditProfile() {
|
||||
}
|
||||
}
|
||||
|
||||
/** 从换绑手机号等子页返回时只刷新手机号,避免覆盖未保存的头像等编辑 */
|
||||
async function refreshPhoneFromServer() {
|
||||
try {
|
||||
const profile = await fetchProfile()
|
||||
form.value.phonenumber = profile.phonenumber || profile.userName || ''
|
||||
} catch {
|
||||
// 静默失败,保留当前表单
|
||||
}
|
||||
}
|
||||
|
||||
function onOpenAvatarSheet() {
|
||||
avatarSheetVisible.value = true
|
||||
}
|
||||
@@ -105,6 +118,7 @@ export function useEditProfile() {
|
||||
const filePath = res.tempFilePaths[0]
|
||||
if (!filePath) return
|
||||
|
||||
form.value.avatarUrl = filePath
|
||||
uploadingAvatar.value = true
|
||||
uni.showLoading({ title: '上传中...', mask: true })
|
||||
const uploaded = await uploadProfileAvatar(filePath)
|
||||
@@ -200,10 +214,14 @@ export function useEditProfile() {
|
||||
}
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
onLoad(() => {
|
||||
void loadProfile()
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
void refreshPhoneFromServer()
|
||||
})
|
||||
|
||||
return {
|
||||
loading,
|
||||
saving,
|
||||
|
||||
@@ -8,9 +8,8 @@
|
||||
</template>
|
||||
</app-navbar>
|
||||
|
||||
<scroll-view
|
||||
<page-scroll-view
|
||||
class="notify-page__scroll"
|
||||
scroll-y
|
||||
refresher-enabled
|
||||
:refresher-triggered="loading"
|
||||
@refresherrefresh="onRefresh"
|
||||
@@ -50,7 +49,7 @@
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</scroll-view>
|
||||
</page-scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
}
|
||||
|
||||
.notify-page__scroll {
|
||||
flex: 1;
|
||||
height: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.notify-page__body {
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
<template>
|
||||
<view v-if="visible" class="cancel-account-dialog">
|
||||
<view class="cancel-account-dialog__mask" @tap="onCancel" />
|
||||
<view class="cancel-account-dialog__panel" @tap.stop>
|
||||
<text class="cancel-account-dialog__title">注销账号</text>
|
||||
<view class="cancel-account-dialog__body">
|
||||
<text class="cancel-account-dialog__warn">
|
||||
注销后账号及所有数据将被永久删除,且无法恢复,请谨慎操作。
|
||||
</text>
|
||||
<text class="cancel-account-dialog__item">· 已绑定的智能设备将全部解绑</text>
|
||||
<text class="cancel-account-dialog__item">· 家庭、订单及客服记录将无法找回</text>
|
||||
<text class="cancel-account-dialog__item">· 注销完成后需重新注册才能使用</text>
|
||||
</view>
|
||||
<view class="cancel-account-dialog__footer">
|
||||
<view class="cancel-account-dialog__btn" @tap.stop="onCancel">
|
||||
<text class="cancel-account-dialog__btn-text">我再想想</text>
|
||||
</view>
|
||||
<view class="cancel-account-dialog__divider-v" />
|
||||
<view
|
||||
class="cancel-account-dialog__btn"
|
||||
:class="{ 'cancel-account-dialog__btn--disabled': !canConfirm }"
|
||||
@tap.stop="onConfirm"
|
||||
>
|
||||
<text
|
||||
class="cancel-account-dialog__btn-text cancel-account-dialog__btn-text--danger"
|
||||
:class="{ 'cancel-account-dialog__btn-text--disabled': !canConfirm }"
|
||||
>
|
||||
{{ confirmText }}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onUnmounted, ref, watch } from 'vue'
|
||||
|
||||
const COUNTDOWN_SECONDS = 10
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:visible': [value: boolean]
|
||||
confirm: []
|
||||
}>()
|
||||
|
||||
const countdown = ref(COUNTDOWN_SECONDS)
|
||||
let timer: ReturnType<typeof setInterval> | undefined
|
||||
|
||||
const canConfirm = computed(() => countdown.value <= 0)
|
||||
|
||||
const confirmText = computed(() =>
|
||||
canConfirm.value ? '确认注销' : `确认注销(${countdown.value}s)`,
|
||||
)
|
||||
|
||||
function clearTimer() {
|
||||
if (timer) clearInterval(timer)
|
||||
timer = undefined
|
||||
}
|
||||
|
||||
function startCountdown() {
|
||||
clearTimer()
|
||||
countdown.value = COUNTDOWN_SECONDS
|
||||
timer = setInterval(() => {
|
||||
if (countdown.value <= 1) {
|
||||
countdown.value = 0
|
||||
clearTimer()
|
||||
return
|
||||
}
|
||||
countdown.value -= 1
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) startCountdown()
|
||||
else clearTimer()
|
||||
},
|
||||
)
|
||||
|
||||
onUnmounted(clearTimer)
|
||||
|
||||
function onCancel() {
|
||||
emit('update:visible', false)
|
||||
}
|
||||
|
||||
function onConfirm() {
|
||||
if (!canConfirm.value) return
|
||||
emit('confirm')
|
||||
emit('update:visible', false)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.cancel-account-dialog {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 500;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.cancel-account-dialog__mask {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.55);
|
||||
}
|
||||
|
||||
.cancel-account-dialog__panel {
|
||||
position: relative;
|
||||
width: 600rpx;
|
||||
background: #fff;
|
||||
border-radius: 24rpx;
|
||||
overflow: hidden;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.cancel-account-dialog__title {
|
||||
display: block;
|
||||
padding: 48rpx 40rpx 24rpx;
|
||||
font-size: 34rpx;
|
||||
font-weight: 600;
|
||||
color: $color-text;
|
||||
text-align: center;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.cancel-account-dialog__body {
|
||||
padding: 0 40rpx 40rpx;
|
||||
}
|
||||
|
||||
.cancel-account-dialog__warn {
|
||||
display: block;
|
||||
margin-bottom: 20rpx;
|
||||
font-size: 28rpx;
|
||||
color: #f04438;
|
||||
line-height: 1.6;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.cancel-account-dialog__item {
|
||||
display: block;
|
||||
font-size: 26rpx;
|
||||
color: $color-text-secondary;
|
||||
line-height: 1.65;
|
||||
text-align: left;
|
||||
margin-bottom: 10rpx;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.cancel-account-dialog__footer {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
border-top: 1rpx solid #ebedf0;
|
||||
}
|
||||
|
||||
.cancel-account-dialog__btn {
|
||||
flex: 1;
|
||||
height: 96rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&--disabled {
|
||||
opacity: 0.45;
|
||||
}
|
||||
}
|
||||
|
||||
.cancel-account-dialog__divider-v {
|
||||
width: 1rpx;
|
||||
background: #ebedf0;
|
||||
}
|
||||
|
||||
.cancel-account-dialog__btn-text {
|
||||
font-size: 30rpx;
|
||||
color: $color-text;
|
||||
line-height: 1;
|
||||
|
||||
&--danger {
|
||||
color: #f04438;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
&--disabled {
|
||||
color: #98a2b3;
|
||||
font-weight: 400;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -2,7 +2,7 @@
|
||||
<view class="privacy-page">
|
||||
<app-navbar title="账号与安全" />
|
||||
|
||||
<scroll-view class="privacy-page__scroll" scroll-y>
|
||||
<page-scroll-view class="privacy-page__scroll">
|
||||
<view class="privacy-page__body">
|
||||
<view
|
||||
v-for="section in sections"
|
||||
@@ -54,15 +54,27 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</page-scroll-view>
|
||||
|
||||
<cancel-account-dialog
|
||||
v-model:visible="cancelAccountDialogVisible"
|
||||
@confirm="onConfirmCancelAccount"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { staticAssets } from '@/utils/static-assets'
|
||||
import CancelAccountDialog from './components/cancel-account-dialog/index.vue'
|
||||
import { usePrivacy } from './use-privacy'
|
||||
|
||||
const { sections, onItemTap, onLogout } = usePrivacy()
|
||||
const {
|
||||
sections,
|
||||
cancelAccountDialogVisible,
|
||||
onItemTap,
|
||||
onLogout,
|
||||
onConfirmCancelAccount,
|
||||
} = usePrivacy()
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
}
|
||||
|
||||
.privacy-page__scroll {
|
||||
flex: 1;
|
||||
height: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.privacy-page__body {
|
||||
|
||||
@@ -15,6 +15,8 @@ function maskPhone(phone?: string): string {
|
||||
|
||||
export function usePrivacy() {
|
||||
const phone = ref('')
|
||||
const cancelAccountDialogVisible = ref(false)
|
||||
const cancelingAccount = ref(false)
|
||||
|
||||
const sections = computed<PrivacySection[]>(() => [
|
||||
{
|
||||
@@ -66,25 +68,23 @@ export function usePrivacy() {
|
||||
return
|
||||
}
|
||||
if (itemId === 'delete-account') {
|
||||
uni.showModal({
|
||||
title: '注销账号',
|
||||
content: '注销后账号及所有数据将被永久删除,且无法恢复。确定继续吗?',
|
||||
confirmColor: '#f04438',
|
||||
success: (res) => {
|
||||
if (!res.confirm) return
|
||||
void (async () => {
|
||||
try {
|
||||
await cancelAccount()
|
||||
teardownMessageInbox()
|
||||
clearStoredToken()
|
||||
uni.showToast({ title: '账号已注销', icon: 'success' })
|
||||
uni.reLaunch({ url: '/pages/login/index' })
|
||||
} catch (err) {
|
||||
uni.showToast({ title: getErrorMessage(err, '注销失败'), icon: 'none' })
|
||||
}
|
||||
})()
|
||||
},
|
||||
})
|
||||
cancelAccountDialogVisible.value = true
|
||||
}
|
||||
}
|
||||
|
||||
async function onConfirmCancelAccount() {
|
||||
if (cancelingAccount.value) return
|
||||
cancelingAccount.value = true
|
||||
try {
|
||||
await cancelAccount()
|
||||
teardownMessageInbox()
|
||||
clearStoredToken()
|
||||
uni.showToast({ title: '账号已注销', icon: 'success' })
|
||||
uni.reLaunch({ url: '/pages/login/index' })
|
||||
} catch (err) {
|
||||
uni.showToast({ title: getErrorMessage(err, '注销失败'), icon: 'none' })
|
||||
} finally {
|
||||
cancelingAccount.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,9 @@ export function usePrivacy() {
|
||||
|
||||
return {
|
||||
sections,
|
||||
cancelAccountDialogVisible,
|
||||
onItemTap,
|
||||
onLogout,
|
||||
onConfirmCancelAccount,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<base-input v-model="confirmPassword" icon="lock" type="password" placeholder="确认密码" />
|
||||
</view>
|
||||
|
||||
<text class="set-password-page__hint">8-20位字符,须包含字母、数字、符号中的至少2种。</text>
|
||||
<text class="set-password-page__hint">{{ passwordRuleHint }}</text>
|
||||
|
||||
<view class="set-password-page__btn">
|
||||
<primary-button text="确认修改" @click="submit" />
|
||||
@@ -23,8 +23,11 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PASSWORD_RULE_HINT } from '@/utils/validate'
|
||||
import { useSetPassword } from './use-set-password'
|
||||
|
||||
const passwordRuleHint = `${PASSWORD_RULE_HINT}。`
|
||||
|
||||
const { password, confirmPassword, onForgotPassword, submit } = useSetPassword()
|
||||
</script>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<view class="storage-page">
|
||||
<app-navbar title="储存空间" />
|
||||
|
||||
<scroll-view class="storage-page__scroll" scroll-y>
|
||||
<page-scroll-view class="storage-page__scroll">
|
||||
<view class="storage-page__body">
|
||||
<text class="storage-page__section-label">储存空间</text>
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</page-scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
}
|
||||
|
||||
.storage-page__scroll {
|
||||
flex: 1;
|
||||
height: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.storage-page__body {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { resolveCsAppToken } from '@/api/request'
|
||||
import { getApiBaseUrl } from '@/config/app-env'
|
||||
import { getStoredToken } from '@/utils/auth-token'
|
||||
import type { CsChatWsPayload, CsMessageVo, CsSessionVo } from './support.types'
|
||||
|
||||
/** 断线后首次重连等待(非轮询;连接成功后会保持长连接) */
|
||||
@@ -28,26 +29,18 @@ function resolveCsChatWsBase(): string {
|
||||
|
||||
if (isH5Dev() && !forceDirect) {
|
||||
const proto = window.location.protocol === 'https:' ? 'wss:' : 'ws:'
|
||||
const useCsHost = !!import.meta.env.VITE_CS_API_BASE_URL?.trim()
|
||||
const path = useCsHost ? '/cs-app/cs/chat' : '/app/cs/chat'
|
||||
return `${proto}//${window.location.host}${path}`
|
||||
return `${proto}//${window.location.host}/app/cs/chat`
|
||||
}
|
||||
|
||||
if (configured) {
|
||||
return configured.replace(/[?#].*$/, '').replace(/\/$/, '')
|
||||
}
|
||||
|
||||
const csBase = import.meta.env.VITE_CS_API_BASE_URL?.trim()
|
||||
if (csBase) {
|
||||
const wsBase = csBase.replace(/^https/i, 'wss').replace(/^http/i, 'ws').replace(/\/$/, '')
|
||||
return `${wsBase}/app/cs/chat`
|
||||
}
|
||||
|
||||
const envBase = import.meta.env.VITE_API_BASE_URL?.trim() || ''
|
||||
const fallback =
|
||||
import.meta.env.VITE_API_PROXY_TARGET?.trim() || 'http://192.168.0.222:8082'
|
||||
const httpBase = envBase || fallback
|
||||
const wsBase = httpBase.replace(/^https/i, 'wss').replace(/^http/i, 'ws')
|
||||
const httpBase =
|
||||
getApiBaseUrl()
|
||||
|| import.meta.env.VITE_API_PROXY_TARGET?.trim()
|
||||
|| 'http://192.168.0.222:8082'
|
||||
const wsBase = httpBase.replace(/^https/i, 'wss').replace(/^http/i, 'ws').replace(/\/$/, '')
|
||||
return `${wsBase}/app/cs/chat`
|
||||
}
|
||||
|
||||
@@ -79,7 +72,7 @@ function clearReconnectTimer() {
|
||||
}
|
||||
|
||||
function scheduleReconnect() {
|
||||
if (manualClosed || !resolveCsAppToken() || !activeSessionId) return
|
||||
if (manualClosed || !getStoredToken() || !activeSessionId) return
|
||||
clearReconnectTimer()
|
||||
const delay = Math.min(
|
||||
RECONNECT_BASE_MS * Math.pow(1.5, reconnectAttempt),
|
||||
@@ -209,7 +202,7 @@ function bindSocketTask(task: UniApp.SocketTask, seq: number) {
|
||||
}
|
||||
|
||||
export function connectCsChatSocket(sessionId: string) {
|
||||
const token = resolveCsAppToken()
|
||||
const token = getStoredToken()
|
||||
if (!token || !sessionId) return
|
||||
if (connecting) return
|
||||
if (socketOpened && socketTask && activeSessionId === sessionId) return
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { resolveCsAppBaseUrl, request, requestCsApp, uploadAppFile } from '@/api/request'
|
||||
import { assertCsUploadToken, ensureCsUploadReady } from '@/api/cs-auth'
|
||||
import { isCsAuthError, request, uploadAppFile } from '@/api/request'
|
||||
import { getCsApiBaseUrl } from '@/config/app-env'
|
||||
import { ApiError } from '@/utils/api-error'
|
||||
import {
|
||||
isSessionEnded,
|
||||
@@ -27,15 +27,20 @@ function buildSessionPath(sessionId: string, suffix = '') {
|
||||
return `/app/cs/session/${encodeURIComponent(sessionId)}${suffix}`
|
||||
}
|
||||
|
||||
/** 客服会话相关接口统一走 212(与 upload / 图片 message 同服,保证 ossId、url 一致) */
|
||||
function csRequest<T>(options: Parameters<typeof request>[0]): Promise<T> {
|
||||
return resolveCsAppBaseUrl() ? requestCsApp<T>(options) : request<T>(options)
|
||||
/**
|
||||
* 客服会话 / 消息 / 转人工等走主站(222),与设备列表等同套 token + clientId。
|
||||
* 仅图片上传走 212(有 cs_token 用 clientId=app,否则主站 token + 主站 clientId)。
|
||||
*/
|
||||
function csSessionRequest<T>(options: Parameters<typeof request>[0]): Promise<T> {
|
||||
return request<T>(options)
|
||||
}
|
||||
|
||||
function resolveCsUploadUrl(): string {
|
||||
const csBase = resolveCsAppBaseUrl()
|
||||
if (csBase) return `${csBase}/cs/upload`
|
||||
return '/app/cs/upload'
|
||||
// #ifdef H5
|
||||
if (import.meta.env.DEV) return '/cs-app/cs/upload'
|
||||
// #endif
|
||||
const csBase = getCsApiBaseUrl()
|
||||
return csBase ? `${csBase}/app/cs/upload` : '/app/cs/upload'
|
||||
}
|
||||
|
||||
function normalizeCsUploadVo(data: unknown): CzCsUploadVo {
|
||||
@@ -66,7 +71,7 @@ function unwrapRows<T>(data: T[] | CsTableData<T> | undefined): T[] {
|
||||
|
||||
/** POST /app/cs/session — 创建客服会话;已有未结束会话时返回原会话 */
|
||||
export function createCsSession(data: CsCreateSessionBody = {}) {
|
||||
return csRequest<CsAppActionVo | CsSessionVo | string | null>({
|
||||
return csSessionRequest<CsAppActionVo | CsSessionVo | string | null>({
|
||||
url: '/app/cs/session',
|
||||
method: 'POST',
|
||||
data,
|
||||
@@ -113,7 +118,7 @@ export async function resolveCsSession(): Promise<CsResolvedSession> {
|
||||
|
||||
/** GET /app/cs/session/list — 查询自己的会话 */
|
||||
export function fetchCsSessionList(query: CsSessionListQuery = {}) {
|
||||
return csRequest<CsSessionVo[] | CsTableData<CsSessionVo>>({
|
||||
return csSessionRequest<CsSessionVo[] | CsTableData<CsSessionVo>>({
|
||||
url: '/app/cs/session/list',
|
||||
method: 'GET',
|
||||
data: query,
|
||||
@@ -122,7 +127,7 @@ export function fetchCsSessionList(query: CsSessionListQuery = {}) {
|
||||
|
||||
/** GET /app/cs/session/{sessionId} — 查询会话详情 */
|
||||
export function fetchCsSessionDetail(sessionId: string) {
|
||||
return csRequest<CsAppActionVo | CsSessionVo | string | null>({
|
||||
return csSessionRequest<CsAppActionVo | CsSessionVo | string | null>({
|
||||
url: buildSessionPath(sessionId),
|
||||
method: 'GET',
|
||||
}).then((data) => normalizeSessionResponse(unwrapCsActionResponse(data).session))
|
||||
@@ -130,19 +135,23 @@ export function fetchCsSessionDetail(sessionId: string) {
|
||||
|
||||
/** GET /app/cs/session/{sessionId}/messages — 拉取会话消息 */
|
||||
export function fetchCsMessages(sessionId: string, afterSeq = 0) {
|
||||
return csRequest<CsMessageVo[] | CsTableData<CsMessageVo>>({
|
||||
return csSessionRequest<CsMessageVo[] | CsTableData<CsMessageVo>>({
|
||||
url: buildSessionPath(sessionId, '/messages'),
|
||||
method: 'GET',
|
||||
data: { afterSeq },
|
||||
}).then(unwrapRows)
|
||||
}
|
||||
|
||||
/** POST /app/cs/upload — 212 上传(clientId=app + cs_token) */
|
||||
export function uploadCsChatImage(filePath: string): Promise<CzCsUploadVo> {
|
||||
assertCsUploadToken()
|
||||
return uploadAppFile<CzCsUploadVo>(resolveCsUploadUrl(), filePath, 'file', 'cs').then((data) =>
|
||||
normalizeCsUploadVo(data),
|
||||
)
|
||||
/** POST /app/cs/upload — 优先 212;鉴权失败时回退主站 222 */
|
||||
export async function uploadCsChatImage(filePath: string): Promise<CzCsUploadVo> {
|
||||
try {
|
||||
const data = await uploadAppFile<CzCsUploadVo>(resolveCsUploadUrl(), filePath, 'file', 'cs')
|
||||
return normalizeCsUploadVo(data)
|
||||
} catch (err) {
|
||||
if (!isCsAuthError(err)) throw err
|
||||
const data = await uploadAppFile<CzCsUploadVo>('/app/cs/upload', filePath, 'file', 'default')
|
||||
return normalizeCsUploadVo(data)
|
||||
}
|
||||
}
|
||||
|
||||
/** 图片消息体:msgType + ossId + clientMsgId */
|
||||
@@ -161,8 +170,7 @@ export function buildCsImageMessageBody(
|
||||
|
||||
/** POST /app/cs/session/{sessionId}/message — 发送消息 */
|
||||
export function sendCsMessage(sessionId: string, data: CsSendMessageBody) {
|
||||
if (resolveCsAppBaseUrl()) ensureCsUploadReady()
|
||||
return csRequest<CsAppActionVo>({
|
||||
return csSessionRequest<CsAppActionVo>({
|
||||
url: buildSessionPath(sessionId, '/message'),
|
||||
method: 'POST',
|
||||
data,
|
||||
@@ -171,7 +179,7 @@ export function sendCsMessage(sessionId: string, data: CsSendMessageBody) {
|
||||
|
||||
/** POST /app/cs/session/{sessionId}/transfer — 转人工 */
|
||||
export function transferCsSession(sessionId: string) {
|
||||
return csRequest<CsAppActionVo | CsSessionVo | null>({
|
||||
return csSessionRequest<CsAppActionVo | CsSessionVo | null>({
|
||||
url: buildSessionPath(sessionId, '/transfer'),
|
||||
method: 'POST',
|
||||
})
|
||||
@@ -179,7 +187,7 @@ export function transferCsSession(sessionId: string) {
|
||||
|
||||
/** POST /app/cs/session/{sessionId}/end — 结束会话 */
|
||||
export function endCsSession(sessionId: string) {
|
||||
return csRequest<void>({
|
||||
return csSessionRequest<void>({
|
||||
url: buildSessionPath(sessionId, '/end'),
|
||||
method: 'POST',
|
||||
})
|
||||
@@ -187,7 +195,7 @@ export function endCsSession(sessionId: string) {
|
||||
|
||||
/** POST /app/cs/session/{sessionId}/button — 点击机器人按钮 */
|
||||
export function clickCsButton(sessionId: string, data: CsClickButtonBody) {
|
||||
return csRequest<void>({
|
||||
return csSessionRequest<void>({
|
||||
url: buildSessionPath(sessionId, '/button'),
|
||||
method: 'POST',
|
||||
data,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { onBeforeUnmount } from 'vue'
|
||||
import { onHide, onShow, onUnload } from '@dcloudio/uni-app'
|
||||
import { computed, ref } from 'vue'
|
||||
import { ensureCsUploadReady } from '@/api/cs-auth'
|
||||
import { ensureCsSessionReady } from '@/api/cs-auth'
|
||||
import { fetchProfile } from '@/api/profile'
|
||||
import { getErrorMessage } from '@/utils/api-error'
|
||||
import { getStoredToken } from '@/utils/auth-token'
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
uploadCsChatImage,
|
||||
} from './support.api'
|
||||
import {
|
||||
connectCsChatSocket,
|
||||
disconnectCsChatSocket,
|
||||
isCsChatSocketConnected,
|
||||
onCsChatPush,
|
||||
@@ -586,7 +587,12 @@ export function useSupport() {
|
||||
|
||||
function activatePage() {
|
||||
markSupportPageActive(true)
|
||||
ensureCsUploadReady()
|
||||
try {
|
||||
ensureCsSessionReady()
|
||||
} catch {
|
||||
uni.showToast({ title: '请先登录', icon: 'none' })
|
||||
return
|
||||
}
|
||||
void loadUserProfile()
|
||||
if (!sessionId.value) {
|
||||
void ensureSession()
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
<base-input v-model="password" icon="lock" type="password" placeholder="请输入密码" />
|
||||
<base-input v-model="confirmPassword" icon="lock" type="password" placeholder="请确认密码" />
|
||||
|
||||
<text class="auth-form-page__hint">{{ passwordRuleHint }}</text>
|
||||
|
||||
<view class="auth-form-page__btn">
|
||||
<primary-button text="立即注册" @click="submit" />
|
||||
</view>
|
||||
@@ -25,8 +27,11 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { PASSWORD_RULE_HINT } from '@/utils/validate'
|
||||
import { useRegister } from './use-register'
|
||||
|
||||
const passwordRuleHint = `${PASSWORD_RULE_HINT}。`
|
||||
|
||||
const {
|
||||
phone,
|
||||
code,
|
||||
@@ -58,6 +63,14 @@ const {
|
||||
margin-bottom: 48rpx;
|
||||
}
|
||||
|
||||
.auth-form-page__hint {
|
||||
display: block;
|
||||
margin-top: 16rpx;
|
||||
font-size: 24rpx;
|
||||
color: $color-text-secondary;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.auth-form-page__btn {
|
||||
margin-top: 16rpx;
|
||||
margin-bottom: 40rpx;
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import { ref } from 'vue'
|
||||
import { useSmsCode } from '@/hooks/use-sms-code'
|
||||
import { isValidPassword, isValidPhone, isValidSmsCode } from '@/utils/validate'
|
||||
import {
|
||||
isValidPhone,
|
||||
isValidSmsCode,
|
||||
isValidStrongPassword,
|
||||
PASSWORD_INVALID_TOAST,
|
||||
} from '@/utils/validate'
|
||||
import { SMS_CODE_SCENE } from '@/types/api'
|
||||
import { registerUser } from './register.api'
|
||||
|
||||
@@ -31,8 +36,8 @@ export function useRegister() {
|
||||
uni.showToast({ title: '请输入验证码', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!isValidPassword(password.value)) {
|
||||
uni.showToast({ title: '密码至少 6 位', icon: 'none' })
|
||||
if (!isValidStrongPassword(password.value)) {
|
||||
uni.showToast({ title: PASSWORD_INVALID_TOAST, icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (password.value !== confirmPassword.value) {
|
||||
|
||||
Reference in New Issue
Block a user