fix:重构前的保存

This commit is contained in:
MJ 2025-08-02 13:20:34 +08:00
parent feeaa6a561
commit e7104a1ae9
10 changed files with 241 additions and 226 deletions

View File

@ -7,7 +7,7 @@
"editor.tabSize": 1,
"editor.formatOnPaste": true,
"editor.guides.bracketPairs": "active",
"files.autoSave": "off",
"files.autoSave": "onFocusChange",
"git.confirmSync": false,
"workbench.startupEditor": "newUntitledFile",
"editor.suggestSelection": "first",

View File

@ -1,17 +1,17 @@
<script setup lang="ts">
import { onMounted, nextTick } from 'vue'
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
import { parseUrlParams } from '@/utils/tool'
import db from './utils/db'
onLaunch(() => {
console.log('App Launch')
})
onShow(() => {
console.log('App Show')
})
onHide(() => {
console.log('App Hide')
const { code } = parseUrlParams()
if (code) {
// code
db.set('code', code)
}
})
onShow(() => {})
onHide(() => {})
</script>
<style lang="scss">
page {

View File

@ -1,27 +1,20 @@
import $req from '../request'
import { request } from '../request/request'
import { http } from '../request/request'
/**
*
* @param data
*/
export const getJsapiSignatureApi = async (params: any) =>
await request.get<any>('/wechatPublic/createJsapiSignature', params)
await http.get<any>('/wechatPublic/createJsapiSignature', params)
/**
*
* @param data
*/
export const parentBindInviteApi = (data: any) =>
$req({
method: 'post',
url: '/parentBindInvite',
data,
})
export const parentBindInviteApi = async (data: any) =>
await http.post<any>('/parentBindInvite', data)
/**
*
* @param data
*/
export const getInviteInfoApi = id =>
$req({
method: 'get',
url: `/parentBindInvite/${id}`,
})
export const getInviteInfoApi = async id => await http.get<any>(`/parentBindInvite/${id}`)

View File

@ -1,5 +1,5 @@
import $req from '../request'
import { request } from '../request/request'
import { http } from '../request/request'
/**
*
@ -16,7 +16,7 @@ export const getParentBindChildApi = (params: any) =>
* @param params
*/
export const getParentBindDeviceApi = async (params: any) =>
await request.get<any>('/parentBindDevice/list', params)
await http.get<any>('/parentBindDevice/list', params)
/**
* -
* @param params
@ -51,7 +51,7 @@ export const parentUnBoundDeviceApi = (data: any) =>
* @param params
*/
export const parentDeviceCurrentLoginApi = async (id: string) =>
await request.get<any>(`/parentBindDevice/${id}`)
await http.get<any>(`/parentBindDevice/${id}`)
/**
* -

View File

@ -1,4 +1,4 @@
import { type RequestOptions, type ResponseData } from './types'
import type { RequestOptions, ResponseData } from './types'
import { BASE_URL, REQUEST_TIMEOUT } from './config'
import { requestInterceptor, responseInterceptor, errorInterceptor } from './interceptor'
import obj from '@/utils/obj'
@ -17,7 +17,7 @@ class HttpRequest {
obj.clearNullProps(options.data)
const interceptedOptions = await requestInterceptor(options)
// URL处理
let url = this.baseURL + interceptedOptions.url
const url = this.baseURL + interceptedOptions.url
const response = (await uni.request({
...interceptedOptions,
url,
@ -39,6 +39,15 @@ class HttpRequest {
})
}
public async del<T>(url: string, data?: any, options: Partial<RequestOptions> = {}): Promise<T> {
return this.http<T>({
url,
data,
method: 'DELETE',
...options,
})
}
// 默认是json格式
public async post<T>(url: string, data?: any, options: Partial<RequestOptions> = {}): Promise<T> {
return this.http<T>({
@ -53,6 +62,20 @@ class HttpRequest {
})
}
// 默认是json格式
public async put<T>(url: string, data?: any, options: Partial<RequestOptions> = {}): Promise<T> {
return this.http<T>({
url,
data,
method: 'PUT',
...options,
header: {
'Content-Type': 'application/json',
...options.header,
},
})
}
// 表单格式
public async postForm<T>(
url: string,
@ -72,4 +95,4 @@ class HttpRequest {
}
}
export const request = new HttpRequest()
export const http = new HttpRequest()

View File

@ -50,46 +50,46 @@
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { useRelation1, maskPhone } from '@/hooks';
import type { ChildrenType, DeviceType } from './interface';
import Empty from '@/components/Empty/index.vue';
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { useRelation1, maskPhone } from '@/hooks'
import type { ChildrenType, DeviceType } from '../interface'
import Empty from '@/components/Empty/index.vue'
import {
getParentBindChildApi,
getParentBindDeviceApi,
childUnBoundParentApi,
parentUnBoundDeviceApi,
} from '@/api';
import CustomPopup from '@/components/CustomPopup/index.vue';
} from '@/api'
import CustomPopup from '@/components/CustomPopup/index.vue'
const props = withDefaults(
defineProps<{
type?: number; // 1- 2-
top?: number; //
type?: number // 1- 2-
top?: number //
}>(),
{
type: 1,
top: 445,
},
);
const OSS_URL = import.meta.env.VITE_OSS_HOST;
const defaultAvatar = `${OSS_URL}/urm/default_avatar.png`;
const showCustomPopup = ref(false);
const unbind = ref<ChildrenType | DeviceType>();
const dataList = ref<ChildrenType[] | DeviceType[]>();
const paging = ref(null);
)
const OSS_URL = import.meta.env.VITE_OSS_HOST
const defaultAvatar = `${OSS_URL}/urm/default_avatar.png`
const showCustomPopup = ref(false)
const unbind = ref<ChildrenType | DeviceType>()
const dataList = ref<ChildrenType[] | DeviceType[]>()
const paging = ref(null)
const detailInfo = ref<ChildrenType | DeviceType>();
const detailInfo = ref<ChildrenType & DeviceType>()
const queryList = (pageNo: number, pageSize: number) => {
if (props.type === 1) {
getParentBindChildApi({ childId: detailInfo.value.childId, current: pageNo, size: pageSize })
.then(res => {
paging.value.complete(res.data.rows);
paging.value.complete(res.data.rows)
})
.catch(res => {
paging.value.complete(false);
});
paging.value.complete(false)
})
} else {
getParentBindDeviceApi({
simSerialNumber: detailInfo.value.simSerialNumber,
@ -97,41 +97,41 @@ const queryList = (pageNo: number, pageSize: number) => {
size: pageSize,
})
.then(res => {
paging.value.complete(res.data.rows);
paging.value.complete(res.data.rows)
})
.catch(res => {
paging.value.complete(false);
});
paging.value.complete(false)
})
}
}
};
//
function handleUnbind(i: ChildrenType | DeviceType) {
showCustomPopup.value = true;
unbind.value = i;
showCustomPopup.value = true
unbind.value = i
}
async function handleConfirmPopup() {
uni.showLoading({
title: '解绑中...',
mask: true,
});
})
if (props.type === 1) {
await childUnBoundParentApi({
parentId: unbind.value.parentId,
childId: detailInfo.value.childId,
});
})
} else {
await parentUnBoundDeviceApi({
parentId: unbind.value.parentId,
simSerialNumber: detailInfo.value.simSerialNumber,
});
})
}
uni.hideLoading();
paging.value.reload();
showCustomPopup.value = false;
uni.hideLoading()
paging.value.reload()
showCustomPopup.value = false
}
onLoad(option => {
detailInfo.value = JSON.parse(decodeURIComponent(option.details));
});
detailInfo.value = JSON.parse(decodeURIComponent(option.details))
})
</script>
<style lang="scss" scoped>
.patriarch_list {

View File

@ -29,30 +29,30 @@
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import dayjs from 'dayjs';
import bindPatriarch from './bindPatriarch.vue';
import type { ChildrenType } from '../interface';
import { user, shareConfigStore } from '@/store';
import { storeToRefs } from 'pinia';
import { parentBindInviteApi } from '@/api';
import { onMounted } from 'vue';
const { initWeixinShareConfig } = shareConfigStore();
const { appId } = storeToRefs(shareConfigStore());
const { userInfo } = storeToRefs(user());
const detailInfo = ref<ChildrenType>({});
const OSS_URL = import.meta.env.VITE_OSS_HOST;
const showMaskTip = ref(false); //
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import dayjs from 'dayjs'
import bindPatriarch from './bindPatriarch.vue'
import type { ChildrenType } from '../interface'
import { user, shareConfigStore } from '@/store'
import { storeToRefs } from 'pinia'
import { parentBindInviteApi } from '@/api'
import { onMounted } from 'vue'
const { initWeixinShareConfig } = shareConfigStore()
const { appId } = storeToRefs(shareConfigStore())
const { userInfo } = storeToRefs(user())
const detailInfo = ref<ChildrenType>({})
const OSS_URL = import.meta.env.VITE_OSS_HOST
const showMaskTip = ref(false) //
async function share() {
const { data } = await parentBindInviteApi({ bindId: detailInfo.value.id, bindType: 1 });
const data = await parentBindInviteApi({ bindId: detailInfo.value.id, bindType: 1 })
const options = {
title: `[${userInfo.value.nickName}]邀请您一起绑定学小乐学习机`, //
desc: '快来管理孩子的学习情况',
link: `${import.meta.env.VITE_HOST}/#/pages/mine/inviteBind/index?id=${data.id}`, //
imgUrl: `${OSS_URL}/urm/invite_bg.png`, //
};
await initWeixinShareConfig(options);
}
await initWeixinShareConfig(options)
}
async function clickShareBtn() {
//
@ -61,23 +61,23 @@ async function clickShareBtn() {
title: '请稍后再试~',
icon: 'none',
mask: true,
});
return;
})
return
}
showMaskTip.value = true;
showMaskTip.value = true
// 使
// const { data } = await parentBindInviteApi({ bindId: detailInfo.value.id, bindType: 1 });
// const data = await parentBindInviteApi({ bindId: detailInfo.value.id, bindType: 1 });
// uni.navigateTo({
// url: `/pages/mine/inviteBind/index?id=${data.id}`,
// });
}
onLoad(option => {
detailInfo.value = JSON.parse(decodeURIComponent(option.details));
});
detailInfo.value = JSON.parse(decodeURIComponent(option.details))
})
onMounted(async () => {
share();
});
share()
})
</script>
<style lang="scss" scoped>
.page {

View File

@ -45,39 +45,39 @@
</view>
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { onLoad, onShareAppMessage } from '@dcloudio/uni-app';
import { onMounted, ref } from 'vue'
import { onLoad, onShareAppMessage } from '@dcloudio/uni-app'
import type { DeviceType, CurrentLoginAccountType } from '../interface';
import type { DeviceType, CurrentLoginAccountType } from '../interface'
import bindPatriarch from './bindPatriarch.vue';
import { parentDeviceCurrentLoginApi, parentBindInviteApi } from '@/api';
import { user, shareConfigStore } from '@/store';
import { storeToRefs } from 'pinia';
import dayjs from 'dayjs';
import bindPatriarch from './bindPatriarch.vue'
import { parentDeviceCurrentLoginApi, parentBindInviteApi } from '@/api'
import { user, shareConfigStore } from '@/store'
import { storeToRefs } from 'pinia'
import dayjs from 'dayjs'
const { initWeixinShareConfig } = shareConfigStore();
const { appId } = storeToRefs(shareConfigStore());
const { userInfo } = storeToRefs(user());
const showMaskTip = ref(false);
const detailInfo = ref<DeviceType>();
const currentLogin = ref<CurrentLoginAccountType>();
const OSS_URL = import.meta.env.VITE_OSS_HOST;
const defaultAvatar = `${OSS_URL}/urm/default_avatar.png`;
const { initWeixinShareConfig } = shareConfigStore()
const { appId } = storeToRefs(shareConfigStore())
const { userInfo } = storeToRefs(user())
const showMaskTip = ref(false)
const detailInfo = ref<DeviceType>()
const currentLogin = ref<CurrentLoginAccountType>()
const OSS_URL = import.meta.env.VITE_OSS_HOST
const defaultAvatar = `${OSS_URL}/urm/default_avatar.png`
//
async function deviceCurrentLogin() {
const { data } = await parentDeviceCurrentLoginApi(detailInfo.value.id);
currentLogin.value = data;
const { data } = await parentDeviceCurrentLoginApi(detailInfo.value.id)
currentLogin.value = data
}
async function share() {
const { data } = await parentBindInviteApi({ bindId: detailInfo.value.id, bindType: 0 });
const data = await parentBindInviteApi({ bindId: detailInfo.value.id, bindType: 0 })
const options = {
title: `[${userInfo.value.nickName}]邀请您一起绑定学小乐学习机`, //
desc: '快来管理设备的使用情况',
link: `${import.meta.env.VITE_HOST}/#/pages/mine/inviteBind/index?id=${data.id}`, //
imgUrl: `${OSS_URL}/urm/invite_bg.png`, //
};
await initWeixinShareConfig(options);
}
await initWeixinShareConfig(options)
}
async function clickShareBtn() {
//
@ -86,24 +86,24 @@ async function clickShareBtn() {
title: '请稍后再试~',
icon: 'none',
mask: true,
});
return;
})
return
}
showMaskTip.value = true;
showMaskTip.value = true
// 使
// const { data } = await parentBindInviteApi({ bindId: detailInfo.value.id, bindType: 0 });
// const data = await parentBindInviteApi({ bindId: detailInfo.value.id, bindType: 0 });
// uni.navigateTo({
// url: `/pages/mine/inviteBind/index?id=${data.id}`,
// });
}
onMounted(() => {
deviceCurrentLogin();
share();
});
deviceCurrentLogin()
share()
})
onLoad(option => {
detailInfo.value = JSON.parse(decodeURIComponent(option.details));
});
detailInfo.value = JSON.parse(decodeURIComponent(option.details))
})
</script>
<style lang="scss" scoped>
.page {

View File

@ -1,73 +1,73 @@
// 我的孩子
export interface ChildrenType {
createTime?: string;
createUser?: string;
updateTime?: string;
updateUser?: string;
id?: string;
parentId?: string;
childId?: string;
adminFlag?: number;
identityType?: null;
bindFlag?: number;
bindTime?: string;
unBindTime?: string;
childName?: string;
childAvatar?: string;
parentName?: string;
parentAvatar?: string;
parentPhone?: string;
vipEndTime?: string;
currentLevel?: number;
gradeId?: string;
gradeName?: string;
expLevel?: number;
createTime?: string
createUser?: string
updateTime?: string
updateUser?: string
id?: string
parentId?: string
childId?: string
adminFlag?: number
identityType?: null
bindFlag?: number
bindTime?: string
unBindTime?: string
childName?: string
childAvatar?: string
parentName?: string
parentAvatar?: string
parentPhone?: string
vipEndTime?: string
currentLevel?: number
gradeId?: string
gradeName?: string
expLevel?: number
}
// 我的设备
export interface DeviceType {
createTime?: string;
createUser?: string;
updateTime?: string;
updateUser?: string;
id?: string;
parentId?: string;
simSerialNumber?: string;
adminFlag?: number;
identityType?: number;
bindFlag?: number;
bindTime?: string;
unBindTime?: string;
parentName?: string;
parentAvatar?: string;
parentPhone?: string;
firstLoginSimTime?: string;
warrantyStatus?: string;
warrantyEndTime?: string;
createTime?: string
createUser?: string
updateTime?: string
updateUser?: string
id?: string
parentId?: string
simSerialNumber?: string
adminFlag?: number
identityType?: number
bindFlag?: number
bindTime?: string
unBindTime?: string
parentName?: string
parentAvatar?: string
parentPhone?: string
firstLoginSimTime?: string
warrantyStatus?: string
warrantyEndTime?: string
}
// 当前登录
export interface CurrentLoginAccountType {
createTime?: string;
createUser?: string;
updateTime?: string;
updateUser?: string;
id?: string;
parentId?: string;
simSerialNumber?: string;
adminFlag?: number;
identityType?: number;
bindFlag?: number;
bindTime?: string;
unBindTime?: string;
parentName?: string;
parentAvatar?: string;
parentPhone?: string;
firstLoginSimTime?: string;
warrantyStatus?: string;
warrantyEndTime?: string;
curDeviceUserId?: string;
curDeviceUserName?: string;
curDeviceUserAvatar?: string;
curDeviceUserAccount?: string;
vipEndTime?: string;
currentLevel?: number;
createTime?: string
createUser?: string
updateTime?: string
updateUser?: string
id?: string
parentId?: string
simSerialNumber?: string
adminFlag?: number
identityType?: number
bindFlag?: number
bindTime?: string
unBindTime?: string
parentName?: string
parentAvatar?: string
parentPhone?: string
firstLoginSimTime?: string
warrantyStatus?: string
warrantyEndTime?: string
curDeviceUserId?: string
curDeviceUserName?: string
curDeviceUserAvatar?: string
curDeviceUserAccount?: string
vipEndTime?: string
currentLevel?: number
}

View File

@ -74,103 +74,102 @@
</template>
<script setup lang="ts">
import { onLoad, onShow, onUnload } from '@dcloudio/uni-app';
import { ref } from 'vue';
import { getInviteInfoApi, parentBindApply, adminInfo } from '@/api';
import { maskPhone } from '@/hooks';
import CustomPopup from '@/components/CustomPopup/index.vue';
const OSS_URL = import.meta.env.VITE_OSS_HOST;
const defaultAvatar = `${OSS_URL}/urm/default_avatar.png`;
const lightDefaultAvatar = `${OSS_URL}/urm/default_avatar_light.png`;
const bg = `url(${OSS_URL}/urm/invite_tip_bg.png)`;
const showCustomPopup = ref(false);
const tipText = ref('您已绑定该学生账号!不用重复绑定哦~');
const customPopupType = ref<number>(0); // 0- 1-
const inviterInfo = ref<any>({}); //
const applyBindInfo = ref<any>({}); //
import { onLoad, onShow, onUnload } from '@dcloudio/uni-app'
import { ref } from 'vue'
import { getInviteInfoApi, parentBindApply, adminInfo } from '@/api'
import { maskPhone } from '@/hooks'
import CustomPopup from '@/components/CustomPopup/index.vue'
const OSS_URL = import.meta.env.VITE_OSS_HOST
const defaultAvatar = `${OSS_URL}/urm/default_avatar.png`
const lightDefaultAvatar = `${OSS_URL}/urm/default_avatar_light.png`
const bg = `url(${OSS_URL}/urm/invite_tip_bg.png)`
const showCustomPopup = ref(false)
const tipText = ref('您已绑定该学生账号!不用重复绑定哦~')
const customPopupType = ref<number>(0) // 0- 1-
const inviterInfo = ref<any>({}) //
const applyBindInfo = ref<any>({}) //
const chooseRelation = ref<any>({}); //
const chooseRelation = ref<any>({}) //
function subFun() {
if (inviterInfo.value.bindFlag === 1) {
showCustomPopup.value = true;
customPopupType.value = 0;
showCustomPopup.value = true
customPopupType.value = 0
tipText.value =
inviterInfo.value.bindType === 1
? '您已绑定该学生账号!不用重复绑定哦~'
: '您已绑定该设备!不用重复绑定哦~';
: '您已绑定该设备!不用重复绑定哦~'
return;
return
}
if (inviterInfo.value.bindType === 0) {
//
applyBindInfo.value.deviceDto = {
simSerialNumber: inviterInfo.value.simSerialNumber,
parentId: inviterInfo.value.inviteUserId,
};
}
} else {
//
applyBindInfo.value.childDto = {
childId: inviterInfo.value.childId,
identityType: chooseRelation.value.id,
parentId: inviterInfo.value.inviteUserId,
};
}
}
if (inviterInfo.value.bindType === 1 && !chooseRelation.value.id) {
uni.showToast({
title: '请选择亲子关系',
icon: 'none',
});
return;
})
return
}
parentBindApply(applyBindInfo.value).then(res => {
showCustomPopup.value = true;
customPopupType.value = 1;
showCustomPopup.value = true
customPopupType.value = 1
// uni.showToast({ title: '', icon: 'none' });
});
})
}
//
function chooseRelative() {
if (inviterInfo.value.bindFlag === 1) {
showCustomPopup.value = true;
customPopupType.value = 0;
tipText.value = '您已绑定该学生账号!不用重复绑定哦~';
return;
showCustomPopup.value = true
customPopupType.value = 0
tipText.value = '您已绑定该学生账号!不用重复绑定哦~'
return
}
uni.navigateTo({
url: '/pages/mine/inviteBind/relationShips',
});
})
}
function handleConfirmPopup() {
showCustomPopup.value = false;
showCustomPopup.value = false
}
//
async function getInviteInfo(id: string) {
try {
uni.showLoading({
title: '加载中...',
});
const { data } = await getInviteInfoApi(id);
inviterInfo.value = data;
})
inviterInfo.value = await getInviteInfoApi(id)
} catch (err) {
console.log('邀请绑定错误', err);
console.log('邀请绑定错误', err)
} finally {
uni.hideLoading();
uni.hideLoading()
}
}
onLoad(option => {
getInviteInfo(option.id);
});
getInviteInfo(option.id)
})
onShow(() => {
uni.$on('updateChooseRelation', data => {
chooseRelation.value = JSON.parse(decodeURIComponent(data.relation));
});
});
chooseRelation.value = JSON.parse(decodeURIComponent(data.relation))
})
})
onUnload(() => {
uni.$off('updateChooseRelation');
});
uni.$off('updateChooseRelation')
})
</script>
<style lang="scss" scoped>