fix:大改造前的保存
This commit is contained in:
parent
3c5e2578c0
commit
973c4f5ab6
@ -26,8 +26,8 @@ module.exports = {
|
|||||||
|
|
||||||
'vue/v-on-event-hyphenation': 'off', // 关闭 vue 中 @ 使用短横线命名
|
'vue/v-on-event-hyphenation': 'off', // 关闭 vue 中 @ 使用短横线命名
|
||||||
'no-duplicate-imports': 'off', // 使用ts-eslint的重复导入规则
|
'no-duplicate-imports': 'off', // 使用ts-eslint的重复导入规则
|
||||||
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
'no-console': import.meta.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
||||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
'no-debugger': import.meta.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
||||||
'vue/multi-word-component-names': 'off',
|
'vue/multi-word-component-names': 'off',
|
||||||
'vue/no-duplicate-attributes': [
|
'vue/no-duplicate-attributes': [
|
||||||
'error',
|
'error',
|
||||||
@ -51,4 +51,4 @@ module.exports = {
|
|||||||
withDefaults: 'readonly',
|
withDefaults: 'readonly',
|
||||||
},
|
},
|
||||||
plugins: ['@typescript-eslint'],
|
plugins: ['@typescript-eslint'],
|
||||||
};
|
}
|
||||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -48,5 +48,5 @@
|
|||||||
"src/uni_modules/uni-search-bar/components/uni-search-bar/i18n",
|
"src/uni_modules/uni-search-bar/components/uni-search-bar/i18n",
|
||||||
"src/uni_modules/z-paging/components/z-paging/i18n"
|
"src/uni_modules/z-paging/components/z-paging/i18n"
|
||||||
],
|
],
|
||||||
"cSpell.words": ["iconfont", "pinia", "VITE", "xuexiaole"]
|
"cSpell.words": ["iconfont", "persistedstate", "pinia", "VITE", "Wechat", "Weixin", "xuexiaole"]
|
||||||
}
|
}
|
||||||
|
@ -62,13 +62,13 @@
|
|||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"echarts": "^5.5.1",
|
"echarts": "^5.5.1",
|
||||||
"lint-staged": "^15.0.1",
|
"lint-staged": "^15.0.1",
|
||||||
|
"lodash": "4.17.21",
|
||||||
"pinia": "^2.0.36",
|
"pinia": "^2.0.36",
|
||||||
"qs": "^6.14.0",
|
"qs": "^6.14.0",
|
||||||
"sass": "^1.72.0",
|
"sass": "^1.72.0",
|
||||||
"unplugin-vue-define-options": "^1.4.2",
|
"unplugin-vue-define-options": "^1.4.2",
|
||||||
"vue": "^3.3.4",
|
"vue": "^3.3.4",
|
||||||
"vue-i18n": "^9.1.9",
|
"vue-i18n": "^9.1.9",
|
||||||
"lodash": "4.17.21",
|
|
||||||
"vue-qrcode-reader": "^5.5.7",
|
"vue-qrcode-reader": "^5.5.7",
|
||||||
"weixin-js-sdk": "^1.6.5"
|
"weixin-js-sdk": "^1.6.5"
|
||||||
},
|
},
|
||||||
@ -82,6 +82,7 @@
|
|||||||
"@dcloudio/uni-cli-shared": "3.0.0-3081220230817001",
|
"@dcloudio/uni-cli-shared": "3.0.0-3081220230817001",
|
||||||
"@dcloudio/uni-stacktracey": "3.0.0-3081220230817001",
|
"@dcloudio/uni-stacktracey": "3.0.0-3081220230817001",
|
||||||
"@dcloudio/vite-plugin-uni": "3.0.0-3081220230817001",
|
"@dcloudio/vite-plugin-uni": "3.0.0-3081220230817001",
|
||||||
|
"@types/lodash": "4.17.16",
|
||||||
"@typescript-eslint/eslint-plugin": "^6.8.0",
|
"@typescript-eslint/eslint-plugin": "^6.8.0",
|
||||||
"@typescript-eslint/parser": "^6.8.0",
|
"@typescript-eslint/parser": "^6.8.0",
|
||||||
"@vue/runtime-core": "^3.4.21",
|
"@vue/runtime-core": "^3.4.21",
|
||||||
@ -94,7 +95,6 @@
|
|||||||
"prettier": "^3.0.3",
|
"prettier": "^3.0.3",
|
||||||
"typescript": "^4.9.5",
|
"typescript": "^4.9.5",
|
||||||
"vite": "4.1.4",
|
"vite": "4.1.4",
|
||||||
"@types/lodash": "4.17.16",
|
|
||||||
"vue-eslint-parser": "^9.3.2",
|
"vue-eslint-parser": "^9.3.2",
|
||||||
"vue-tsc": "^1.0.24"
|
"vue-tsc": "^1.0.24"
|
||||||
},
|
},
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
import { http } from './request/request'
|
import { http } from './request/request'
|
||||||
|
|
||||||
// 获取客服信息
|
|
||||||
export const getCsInfo = async (id: string) =>
|
|
||||||
await http.get<any>(`/customerService/getInfoByUserId/${id}`)
|
|
||||||
|
|
||||||
// 更新用户信息
|
// 更新用户信息
|
||||||
export const updateUserInfo = async (data: any) =>
|
export const updateUserInfo = async (data: any) =>
|
||||||
await http.post<any>('/sysUser/editPerfectMessage', data)
|
await http.post<any>('/sysUser/editPerfectMessage', data)
|
||||||
|
@ -46,16 +46,6 @@ export const wxLoginApi = async data =>
|
|||||||
clientType: 'PARENT',
|
clientType: 'PARENT',
|
||||||
})
|
})
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 微信绑定账号
|
|
||||||
// * @param data 请求参数
|
|
||||||
// */
|
|
||||||
// export const wxBindAccountApi = async data =>
|
|
||||||
// await http.post<any>('/wxBindAccount', {
|
|
||||||
// ...data,
|
|
||||||
// clientType: 'PARENT',
|
|
||||||
// })
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户信息
|
* 获取用户信息
|
||||||
* @param data 请求参数
|
* @param data 请求参数
|
||||||
@ -83,4 +73,4 @@ export const bindAuthInfoApi = async data =>
|
|||||||
export const getAuthUrlApi = async () => await http.get<any>('/wechatPublic/getAuthUrl')
|
export const getAuthUrlApi = async () => await http.get<any>('/wechatPublic/getAuthUrl')
|
||||||
|
|
||||||
// 退出登录
|
// 退出登录
|
||||||
export const logout = async () => await http.get<any>('/logout')
|
export const logoutApi = async () => await http.get<any>('/logout')
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { http } from '../request/request'
|
import { http } from '../request/request'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { user } from '@/store'
|
|
||||||
import { getCache } from '@/utils'
|
import { getCache } from '@/utils'
|
||||||
import db from '@/utils/db'
|
import db from '@/utils/db'
|
||||||
|
import { userStore } from '@/store'
|
||||||
|
|
||||||
// 课表日历
|
// 课表日历
|
||||||
export const getScheduleList = async (data?: Record<string, any>): Promise<any> =>
|
export const getScheduleList = async (data?: Record<string, any>): Promise<any> =>
|
||||||
@ -64,9 +64,9 @@ export const getUserInfo = async (data?: Record<string, any>): Promise<any> =>
|
|||||||
await http.get<any>('/phone/inspectorTeacher/getCurrentTeacher')
|
await http.get<any>('/phone/inspectorTeacher/getCurrentTeacher')
|
||||||
// 文件上传
|
// 文件上传
|
||||||
export const uploadFile = async (file): Promise<any> => {
|
export const uploadFile = async (file): Promise<any> => {
|
||||||
const { token } = storeToRefs(user())
|
const { token } = storeToRefs(userStore())
|
||||||
|
|
||||||
const mergerToken = token.value || db.get('token')
|
const mergerToken = token.value
|
||||||
|
|
||||||
const data = await uni.uploadFile({
|
const data = await uni.uploadFile({
|
||||||
url: `/api/main/sysFileInfo/tenUploadAll`, // ${import.meta.env.VITE_HOST}
|
url: `/api/main/sysFileInfo/tenUploadAll`, // ${import.meta.env.VITE_HOST}
|
||||||
|
@ -5,6 +5,8 @@ import { HTTP_STATUS, ERROR_MSG } from './config'
|
|||||||
import router from '@/router/router'
|
import router from '@/router/router'
|
||||||
import db from '@/utils/db'
|
import db from '@/utils/db'
|
||||||
import toast from '@/utils/hud'
|
import toast from '@/utils/hud'
|
||||||
|
import { storeToRefs } from 'pinia'
|
||||||
|
import { userStore } from '@/store'
|
||||||
|
|
||||||
// 请求拦截器
|
// 请求拦截器
|
||||||
export const requestInterceptor = async (options: RequestOptions): Promise<RequestOptions> => {
|
export const requestInterceptor = async (options: RequestOptions): Promise<RequestOptions> => {
|
||||||
@ -12,12 +14,12 @@ export const requestInterceptor = async (options: RequestOptions): Promise<Reque
|
|||||||
const header: any = {
|
const header: any = {
|
||||||
...options?.header,
|
...options?.header,
|
||||||
}
|
}
|
||||||
|
const { token } = storeToRefs(userStore())
|
||||||
|
|
||||||
// 获取token
|
// 获取token
|
||||||
const token = db.get('token')
|
|
||||||
// 如果有token,添加到请求头
|
// 如果有token,添加到请求头
|
||||||
if (token) {
|
if (token.value) {
|
||||||
header['Authorization'] = `Bearer ${token}`
|
header['Authorization'] = `Bearer ${token.value}`
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { useWebSocket } from '@vueuse/core'
|
import { useWebSocket } from '@vueuse/core'
|
||||||
import { user } from '@/store'
|
import { userStore } from '@/store'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import type { UseWebSocketReturn } from '@vueuse/core'
|
import type { UseWebSocketReturn } from '@vueuse/core'
|
||||||
|
|
||||||
let SOCKET: UseWebSocketReturn<any>
|
let SOCKET: UseWebSocketReturn<any>
|
||||||
export const useSocket = () => {
|
export const useSocket = () => {
|
||||||
const { token, userInfo } = user()
|
const { token, userInfo } = userStore()
|
||||||
const inspectorMessage = ref<any>()
|
const inspectorMessage = ref<any>()
|
||||||
const inspectorDesktopMessage = ref([])
|
const inspectorDesktopMessage = ref([])
|
||||||
const desktopPath = ref<string>()
|
const desktopPath = ref<string>()
|
||||||
@ -18,7 +18,7 @@ export const useSocket = () => {
|
|||||||
}
|
}
|
||||||
function init() {
|
function init() {
|
||||||
SOCKET = useWebSocket(
|
SOCKET = useWebSocket(
|
||||||
`${process.env.VITE_WS_URL}?accessToken=${token.replace('Bearer ', '')}`,
|
`${import.meta.env.VITE_WS_URL}?accessToken=${token.replace('Bearer ', '')}`,
|
||||||
{
|
{
|
||||||
autoReconnect: {
|
autoReconnect: {
|
||||||
retries: 5,
|
retries: 5,
|
||||||
|
@ -5,11 +5,14 @@ import * as Pinia from 'pinia'
|
|||||||
import './styles/global.scss'
|
import './styles/global.scss'
|
||||||
import './styles/font.scss'
|
import './styles/font.scss'
|
||||||
import './styles/iconfont.scss'
|
import './styles/iconfont.scss'
|
||||||
import BackBar from '@/components/BackBar/index'
|
import PiniaPluginPersist from './plugins/pinia-plugin-persist'
|
||||||
|
import BackBar from '@/components/BackBar/index.vue'
|
||||||
|
|
||||||
export function createApp() {
|
export function createApp() {
|
||||||
const app = createSSRApp(App)
|
const app = createSSRApp(App)
|
||||||
app.use(Pinia.createPinia())
|
const pinia = Pinia.createPinia()
|
||||||
|
pinia.use(PiniaPluginPersist)
|
||||||
|
app.use(pinia)
|
||||||
app.component('BackBar', BackBar)
|
app.component('BackBar', BackBar)
|
||||||
return {
|
return {
|
||||||
app,
|
app,
|
||||||
|
@ -47,11 +47,11 @@ import type { ChildrenType } from '@/pages/mine/interface'
|
|||||||
import type { SubjectType } from './interface'
|
import type { SubjectType } from './interface'
|
||||||
import './index.scss'
|
import './index.scss'
|
||||||
import { getParentBindChildApi, subjectApi } from '@/api'
|
import { getParentBindChildApi, subjectApi } from '@/api'
|
||||||
import { user } from '@/store'
|
import { userStore } from '@/store'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import hud from '@/utils/hud'
|
import hud from '@/utils/hud'
|
||||||
|
|
||||||
const { userInfo } = storeToRefs(user())
|
const { userInfo } = storeToRefs(userStore())
|
||||||
|
|
||||||
const childrenList = ref<ChildrenType[]>() // 所有孩子
|
const childrenList = ref<ChildrenType[]>() // 所有孩子
|
||||||
const empty = ref(false)
|
const empty = ref(false)
|
||||||
|
@ -143,10 +143,10 @@ import { getParentBindDeviceApi, parentDeviceCurrentLoginApi, queryAppRecordApi
|
|||||||
import TabBar from '@/components/Tabbar/index.vue'
|
import TabBar from '@/components/Tabbar/index.vue'
|
||||||
import CustomPopup from '@/components/CustomPopup/index.vue'
|
import CustomPopup from '@/components/CustomPopup/index.vue'
|
||||||
import Empty from '@/components/Empty/index.vue'
|
import Empty from '@/components/Empty/index.vue'
|
||||||
import { user } from '@/store'
|
import { userStore } from '@/store'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
|
|
||||||
const { userInfo } = storeToRefs(user())
|
const { userInfo } = storeToRefs(userStore())
|
||||||
const OSS_URL = import.meta.env.VITE_OSS_HOST
|
const OSS_URL = import.meta.env.VITE_OSS_HOST
|
||||||
const defaultAvatar = `${OSS_URL}/urm/default_avatar.png`
|
const defaultAvatar = `${OSS_URL}/urm/default_avatar.png`
|
||||||
const arrow = `${OSS_URL}/iconfont/down_arrow.png`
|
const arrow = `${OSS_URL}/iconfont/down_arrow.png`
|
||||||
|
@ -108,14 +108,14 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
import { getCurInfo, parentBindAdmin } from '@/api'
|
import { getCurInfo, parentBindAdmin } from '@/api'
|
||||||
import { user, shareConfigStore } from '@/store'
|
import { userStore, shareConfigStore } from '@/store'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import TipPopup from '@/components/TipPopup/index.vue'
|
import TipPopup from '@/components/TipPopup/index.vue'
|
||||||
import router from '@/router/router'
|
import router from '@/router/router'
|
||||||
import jWeixin from 'weixin-js-sdk'
|
import jWeixin from 'weixin-js-sdk'
|
||||||
const { initWeixinShareConfig } = shareConfigStore()
|
const { initWeixinShareConfig } = shareConfigStore()
|
||||||
|
|
||||||
const { userInfo } = storeToRefs(user())
|
const { userInfo } = storeToRefs(userStore())
|
||||||
const OSS_URL = import.meta.env.VITE_OSS_HOST
|
const OSS_URL = import.meta.env.VITE_OSS_HOST
|
||||||
const show = ref(false)
|
const show = ref(false)
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ async function determine() {
|
|||||||
} else {
|
} else {
|
||||||
router.navigateTo({
|
router.navigateTo({
|
||||||
path: './familyRelationships',
|
path: './familyRelationships',
|
||||||
query: { parameter: JSON.stringify(obj) }
|
query: { parameter: JSON.stringify(obj) },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,14 +79,14 @@
|
|||||||
import { onMounted, reactive, ref } from 'vue'
|
import { onMounted, reactive, ref } from 'vue'
|
||||||
import { getParentBindDeviceApi, parentDeviceCurrentLoginApi } from '@/api'
|
import { getParentBindDeviceApi, parentDeviceCurrentLoginApi } from '@/api'
|
||||||
import TabBar from '@/components/Tabbar/index.vue'
|
import TabBar from '@/components/Tabbar/index.vue'
|
||||||
import { user } from '@/store'
|
import { userStore } from '@/store'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import hud from '@/utils/hud'
|
import hud from '@/utils/hud'
|
||||||
import router from '@/router/router'
|
import router from '@/router/router'
|
||||||
|
|
||||||
const userStore = user()
|
const store = userStore()
|
||||||
const { getUserInfo } = userStore
|
const { getUserInfo } = store
|
||||||
const { userInfo } = storeToRefs(userStore)
|
const { userInfo } = storeToRefs(store)
|
||||||
const OSS_URL = import.meta.env.VITE_OSS_HOST
|
const OSS_URL = import.meta.env.VITE_OSS_HOST
|
||||||
const scanQr = `${OSS_URL}/iconfont/scan_qr.png`
|
const scanQr = `${OSS_URL}/iconfont/scan_qr.png`
|
||||||
const arrow = `${OSS_URL}/iconfont/down_arrow.png`
|
const arrow = `${OSS_URL}/iconfont/down_arrow.png`
|
||||||
@ -185,19 +185,24 @@ function change(i: any) {
|
|||||||
}
|
}
|
||||||
// 我的设备
|
// 我的设备
|
||||||
async function getParentBindDevice() {
|
async function getParentBindDevice() {
|
||||||
equipmentList.value = []
|
|
||||||
hud.load({
|
hud.load({
|
||||||
task: async () => {
|
task: async () => {
|
||||||
|
equipmentList.value = []
|
||||||
|
showEquipment.value = {}
|
||||||
const data = await getParentBindDeviceApi({ parentId: userInfo.value.id, size: -1 })
|
const data = await getParentBindDeviceApi({ parentId: userInfo.value.id, size: -1 })
|
||||||
for (let i in data.rows) {
|
if (data.rows?.length > 0) {
|
||||||
const _r = await parentDeviceCurrentLoginApi(data.rows[i].id)
|
equipmentList.value = data.rows
|
||||||
equipmentList.value.push({
|
showEquipment.value = data.rows[0]
|
||||||
...data.rows[i],
|
|
||||||
curDeviceUserName: _r.curDeviceUserName,
|
|
||||||
curDeviceUserAvatar: _r.curDeviceUserAvatar,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
showEquipment.value = data.rows?.length > 0 ? equipmentList.value[0] : {}
|
// for (let i in data.rows) {
|
||||||
|
// const _r = await parentDeviceCurrentLoginApi(data.rows[i].id)
|
||||||
|
// equipmentList.value.push({
|
||||||
|
// ...data.rows[i],
|
||||||
|
// curDeviceUserName: _r.curDeviceUserName,
|
||||||
|
// curDeviceUserAvatar: _r.curDeviceUserAvatar,
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// showEquipment.value = data.rows?.length > 0 ? equipmentList.value[0] : {}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -55,10 +55,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, inject, onBeforeMount, type Ref, ref } from 'vue'
|
import { computed, inject, onBeforeMount, type Ref, ref } from 'vue'
|
||||||
import type { UserInfo } from '@/types/inspector/mine'
|
import type { UserInfo } from '@/types/inspector/mine'
|
||||||
import { getUserInfo, queryUserRoles, switchRole } from '@/api/inspector/mine'
|
import { queryUserRoles, switchRole } from '@/api/inspector/mine'
|
||||||
import { getAvatarUrl, getCache, setCache } from '@/utils'
|
import { getAvatarUrl } from '@/utils'
|
||||||
import { getAuthUrlApi } from '@/api/login'
|
import { getAuthUrlApi } from '@/api/login'
|
||||||
import { user } from '@/store'
|
import { userStore } from '@/store'
|
||||||
import db from '@/utils/db'
|
import db from '@/utils/db'
|
||||||
|
|
||||||
const roleRef = ref(null)
|
const roleRef = ref(null)
|
||||||
@ -67,7 +67,7 @@ const userInfo = inject<Ref<UserInfo>>('userInfo')
|
|||||||
|
|
||||||
const roleList = ref<any[]>([])
|
const roleList = ref<any[]>([])
|
||||||
|
|
||||||
const { getUserInfo: getLoginUserInfo } = user()
|
const { getUserInfo: getLoginUserInfo } = userStore()
|
||||||
|
|
||||||
const queryRole = async () => {
|
const queryRole = async () => {
|
||||||
const data = await queryUserRoles({ phone: userInfo.value.phone })
|
const data = await queryUserRoles({ phone: userInfo.value.phone })
|
||||||
|
@ -181,8 +181,8 @@
|
|||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { user } from '@/store'
|
import { userStore } from '@/store'
|
||||||
const { logout } = user()
|
const { logout } = userStore()
|
||||||
import { onLaunch, onShow, onHide, onLoad } from '@dcloudio/uni-app'
|
import { onLaunch, onShow, onHide, onLoad } from '@dcloudio/uni-app'
|
||||||
import { usepersonalStoreHook } from '@/store/inspector'
|
import { usepersonalStoreHook } from '@/store/inspector'
|
||||||
import Picker from '../releasePlan/components/picker.vue'
|
import Picker from '../releasePlan/components/picker.vue'
|
||||||
|
@ -55,14 +55,14 @@
|
|||||||
import { ref, computed, nextTick, onMounted } from 'vue'
|
import { ref, computed, nextTick, onMounted } from 'vue'
|
||||||
|
|
||||||
import { sendCodeMessageApi, smsLoginApi, wxLoginApi } from '@/api'
|
import { sendCodeMessageApi, smsLoginApi, wxLoginApi } from '@/api'
|
||||||
import { user } from '@/store'
|
import { userStore } from '@/store'
|
||||||
import router from '@/router/router'
|
import router from '@/router/router'
|
||||||
import db from '@/utils/db'
|
import db from '@/utils/db'
|
||||||
import hud from '@/utils/hud'
|
import hud from '@/utils/hud'
|
||||||
|
|
||||||
const emits = defineEmits(['reloadFun'])
|
const emits = defineEmits(['reloadFun'])
|
||||||
const OSS_URL = import.meta.env.VITE_OSS_HOST
|
const OSS_URL = import.meta.env.VITE_OSS_HOST
|
||||||
const { getUserInfo, setToken } = user()
|
const { getUserInfo, setToken } = userStore()
|
||||||
|
|
||||||
const formatPhone = ref('')
|
const formatPhone = ref('')
|
||||||
const verifyCode = ref('')
|
const verifyCode = ref('')
|
||||||
|
@ -67,17 +67,17 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app';
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia'
|
||||||
import Empty from '@/components/Empty/index.vue';
|
import Empty from '@/components/Empty/index.vue'
|
||||||
import CustomPopup from '@/components/CustomPopup/index.vue';
|
import CustomPopup from '@/components/CustomPopup/index.vue'
|
||||||
import { updateTaskStatusApi, getParentBindChildApi, getFamilyTaskStuApi } from '@/api';
|
import { updateTaskStatusApi, getParentBindChildApi, getFamilyTaskStuApi } from '@/api'
|
||||||
import { user } from '@/store';
|
import { userStore } from '@/store'
|
||||||
const { userInfo } = storeToRefs(user());
|
const { userInfo } = storeToRefs(userStore())
|
||||||
const OSS_URL = import.meta.env.VITE_OSS_HOST;
|
const OSS_URL = import.meta.env.VITE_OSS_HOST
|
||||||
const pageStatus = ref('');
|
const pageStatus = ref('')
|
||||||
const taskType = ref(); // 任务类型 0-系统任务 1-自定义任务
|
const taskType = ref() // 任务类型 0-系统任务 1-自定义任务
|
||||||
const taskStatusOpt = ref([
|
const taskStatusOpt = ref([
|
||||||
{
|
{
|
||||||
status: 0,
|
status: 0,
|
||||||
@ -87,40 +87,40 @@ const taskStatusOpt = ref([
|
|||||||
status: 1,
|
status: 1,
|
||||||
text: '已完成',
|
text: '已完成',
|
||||||
},
|
},
|
||||||
]);
|
])
|
||||||
const activeStatus = ref(0);
|
const activeStatus = ref(0)
|
||||||
const taskStatusInfo = ref({
|
const taskStatusInfo = ref({
|
||||||
taskId: '',
|
taskId: '',
|
||||||
status: 0,
|
status: 0,
|
||||||
});
|
})
|
||||||
const showFinishPopup = ref(false);
|
const showFinishPopup = ref(false)
|
||||||
|
|
||||||
const checkedList = ref([]); // 选中值
|
const checkedList = ref([]) // 选中值
|
||||||
|
|
||||||
const pageType = ref<number>(); // 1查看 2编辑
|
const pageType = ref<number>() // 1查看 2编辑
|
||||||
const childrenList = ref([]); // 家长孩子
|
const childrenList = ref([]) // 家长孩子
|
||||||
const page = ref({
|
const page = ref({
|
||||||
current: 1,
|
current: 1,
|
||||||
size: 10,
|
size: 10,
|
||||||
});
|
})
|
||||||
// 完成状态过滤
|
// 完成状态过滤
|
||||||
function filterStatus(i) {
|
function filterStatus(i) {
|
||||||
taskStatusInfo.value.status = i.status;
|
taskStatusInfo.value.status = i.status
|
||||||
activeStatus.value = i.status;
|
activeStatus.value = i.status
|
||||||
fetchStudentTaskStatus();
|
fetchStudentTaskStatus()
|
||||||
}
|
}
|
||||||
// 单选
|
// 单选
|
||||||
function handleSingleCheck(i) {
|
function handleSingleCheck(i) {
|
||||||
let id = i.childId;
|
let id = i.childId
|
||||||
if (pageType.value === 1) {
|
if (pageType.value === 1) {
|
||||||
taskStatusInfo.value.status = 1;
|
taskStatusInfo.value.status = 1
|
||||||
showFinishPopup.value = true;
|
showFinishPopup.value = true
|
||||||
}
|
}
|
||||||
i.checked = !i.checked;
|
i.checked = !i.checked
|
||||||
if (i.checked) {
|
if (i.checked) {
|
||||||
checkedList.value.push(id);
|
checkedList.value.push(id)
|
||||||
} else {
|
} else {
|
||||||
checkedList.value.splice(checkedList.value.indexOf(id), 1);
|
checkedList.value.splice(checkedList.value.indexOf(id), 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,31 +128,31 @@ function handleSingleCheck(i) {
|
|||||||
async function handleConfirmFinish() {
|
async function handleConfirmFinish() {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '正在完成...',
|
title: '正在完成...',
|
||||||
});
|
})
|
||||||
let res = await updateTaskStatusApi({
|
let res = await updateTaskStatusApi({
|
||||||
...taskStatusInfo.value,
|
...taskStatusInfo.value,
|
||||||
stuIdList: checkedList.value,
|
stuIdList: checkedList.value,
|
||||||
});
|
})
|
||||||
uni.hideLoading();
|
uni.hideLoading()
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
title: '已完成',
|
title: '已完成',
|
||||||
});
|
})
|
||||||
taskStatusInfo.value.status = 0;
|
taskStatusInfo.value.status = 0
|
||||||
fetchStudentTaskStatus();
|
fetchStudentTaskStatus()
|
||||||
showFinishPopup.value = false;
|
showFinishPopup.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 取消完成
|
// 取消完成
|
||||||
function handleCancelFinish() {
|
function handleCancelFinish() {
|
||||||
checkedList.value = [];
|
checkedList.value = []
|
||||||
childrenList.value = childrenList.value.map(item => {
|
childrenList.value = childrenList.value.map(item => {
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
checked: false,
|
checked: false,
|
||||||
};
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取家长孩子数据
|
// 获取家长孩子数据
|
||||||
@ -160,22 +160,22 @@ async function fetchChildrenInfo() {
|
|||||||
try {
|
try {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '加载中...',
|
title: '加载中...',
|
||||||
});
|
})
|
||||||
const data = await getParentBindChildApi({
|
const data = await getParentBindChildApi({
|
||||||
parentId: userInfo.value.id,
|
parentId: userInfo.value.id,
|
||||||
...page.value,
|
...page.value,
|
||||||
});
|
})
|
||||||
for (let i in data.rows) {
|
for (let i in data.rows) {
|
||||||
childrenList.value.push({
|
childrenList.value.push({
|
||||||
...data.rows[i],
|
...data.rows[i],
|
||||||
checked: checkedList.value.includes(data.rows[i].childId),
|
checked: checkedList.value.includes(data.rows[i].childId),
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
pageStatus.value = childrenList.value.length === 0 ? 'empty' : '';
|
pageStatus.value = childrenList.value.length === 0 ? 'empty' : ''
|
||||||
uni.hideLoading();
|
uni.hideLoading()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err)
|
||||||
uni.hideLoading();
|
uni.hideLoading()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 学生完成情况
|
// 学生完成情况
|
||||||
@ -183,16 +183,16 @@ async function fetchStudentTaskStatus() {
|
|||||||
try {
|
try {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '加载中...',
|
title: '加载中...',
|
||||||
});
|
})
|
||||||
const data = await getFamilyTaskStuApi({
|
const data = await getFamilyTaskStuApi({
|
||||||
...taskStatusInfo.value,
|
...taskStatusInfo.value,
|
||||||
});
|
})
|
||||||
childrenList.value = data;
|
childrenList.value = data
|
||||||
pageStatus.value = childrenList.value.length === 0 ? 'empty' : '';
|
pageStatus.value = childrenList.value.length === 0 ? 'empty' : ''
|
||||||
uni.hideLoading();
|
uni.hideLoading()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err)
|
||||||
uni.hideLoading();
|
uni.hideLoading()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,31 +200,31 @@ async function fetchStudentTaskStatus() {
|
|||||||
function handleConfirm() {
|
function handleConfirm() {
|
||||||
uni.$emit('updateTaskSendObject', {
|
uni.$emit('updateTaskSendObject', {
|
||||||
list: JSON.stringify(checkedList.value),
|
list: JSON.stringify(checkedList.value),
|
||||||
});
|
})
|
||||||
uni.navigateBack();
|
uni.navigateBack()
|
||||||
}
|
}
|
||||||
// 取消
|
// 取消
|
||||||
function handleCancel() {
|
function handleCancel() {
|
||||||
checkedList.value = [];
|
checkedList.value = []
|
||||||
uni.navigateBack();
|
uni.navigateBack()
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoad(option => {
|
onLoad(option => {
|
||||||
pageType.value = Number(option.pageType);
|
pageType.value = Number(option.pageType)
|
||||||
uni.setNavigationBarTitle({
|
uni.setNavigationBarTitle({
|
||||||
title: pageType.value === 1 ? '发送对象' : '选择发送对象',
|
title: pageType.value === 1 ? '发送对象' : '选择发送对象',
|
||||||
});
|
})
|
||||||
if (pageType.value === 1) {
|
if (pageType.value === 1) {
|
||||||
// 查看
|
// 查看
|
||||||
let details = JSON.parse(decodeURIComponent(option.details));
|
let details = JSON.parse(decodeURIComponent(option.details))
|
||||||
taskType.value = details.customTask;
|
taskType.value = details.customTask
|
||||||
taskStatusInfo.value.taskId = details.id;
|
taskStatusInfo.value.taskId = details.id
|
||||||
fetchStudentTaskStatus();
|
fetchStudentTaskStatus()
|
||||||
} else {
|
} else {
|
||||||
checkedList.value = JSON.parse(option.checkedList);
|
checkedList.value = JSON.parse(option.checkedList)
|
||||||
fetchChildrenInfo();
|
fetchChildrenInfo()
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -3,11 +3,9 @@
|
|||||||
<z-paging
|
<z-paging
|
||||||
ref="paging"
|
ref="paging"
|
||||||
v-model="dataList"
|
v-model="dataList"
|
||||||
:paging-style="{ margin: isAdmin ? '402rpx 30rpx 0 30rpx' : '226rpx 30rpx 0 30rpx' }"
|
:paging-style="{ margin: '402rpx 30rpx 0 30rpx' }"
|
||||||
:style="{
|
:style="{
|
||||||
height: isAdmin
|
height: `calc(100% - 532rpx - 120rpx - 52rpx)`,
|
||||||
? `calc(100% - 532rpx - 120rpx - 52rpx)`
|
|
||||||
: `calc(100% - 356rpx - 120rpx - 52rpx)`,
|
|
||||||
}"
|
}"
|
||||||
@query="queryList"
|
@query="queryList"
|
||||||
>
|
>
|
||||||
@ -83,18 +81,18 @@
|
|||||||
import { reactive, ref, onMounted, nextTick } from 'vue'
|
import { reactive, ref, onMounted, nextTick } from 'vue'
|
||||||
import { onShow } from '@dcloudio/uni-app'
|
import { onShow } from '@dcloudio/uni-app'
|
||||||
import { getParentBindChildApi, getParentBindDeviceApi } from '@/api'
|
import { getParentBindChildApi, getParentBindDeviceApi } from '@/api'
|
||||||
import { user } from '@/store'
|
import { userStore } from '@/store'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { getCache } from '@/utils'
|
import { getCache } from '@/utils'
|
||||||
import router from '@/router/router'
|
import router from '@/router/router'
|
||||||
import type { ChildrenType, DeviceType } from './interface'
|
import type { ChildrenType, DeviceType } from './interface'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import db from '@/utils/db'
|
import db from '@/utils/db'
|
||||||
const { userInfo } = storeToRefs(user())
|
const { userInfo } = storeToRefs(userStore())
|
||||||
const OSS_URL = import.meta.env.VITE_OSS_HOST
|
const OSS_URL = import.meta.env.VITE_OSS_HOST
|
||||||
const defaultAvatar = `${OSS_URL}/urm/default_avatar.png`
|
const defaultAvatar = `${OSS_URL}/urm/default_avatar.png`
|
||||||
const empty = `${OSS_URL}/empty.png`
|
const empty = `${OSS_URL}/empty.png`
|
||||||
const isAdmin = ref(false)
|
|
||||||
// 导航
|
// 导航
|
||||||
const activeNav = ref({
|
const activeNav = ref({
|
||||||
title: '我的孩子',
|
title: '我的孩子',
|
||||||
@ -173,9 +171,7 @@ onShow(() => {
|
|||||||
paging.value.refresh()
|
paging.value.refresh()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
onMounted(() => {
|
onMounted(() => {})
|
||||||
isAdmin.value = db.get('userAdmin')
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -34,13 +34,13 @@ import { onLoad } from '@dcloudio/uni-app'
|
|||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import bindPatriarch from './bindPatriarch.vue'
|
import bindPatriarch from './bindPatriarch.vue'
|
||||||
import type { ChildrenType } from '../interface'
|
import type { ChildrenType } from '../interface'
|
||||||
import { user, shareConfigStore } from '@/store'
|
import { userStore, shareConfigStore } from '@/store'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { parentBindInviteApi } from '@/api'
|
import { parentBindInviteApi } from '@/api'
|
||||||
import { onMounted } from 'vue'
|
import { onMounted } from 'vue'
|
||||||
const { initWeixinShareConfig } = shareConfigStore()
|
const { initWeixinShareConfig } = shareConfigStore()
|
||||||
const { appId } = storeToRefs(shareConfigStore())
|
const { appId } = storeToRefs(shareConfigStore())
|
||||||
const { userInfo } = storeToRefs(user())
|
const { userInfo } = storeToRefs(userStore())
|
||||||
const detailInfo = ref<ChildrenType>({})
|
const detailInfo = ref<ChildrenType>({})
|
||||||
const OSS_URL = import.meta.env.VITE_OSS_HOST
|
const OSS_URL = import.meta.env.VITE_OSS_HOST
|
||||||
const showMaskTip = ref(false) // 指示蒙层
|
const showMaskTip = ref(false) // 指示蒙层
|
||||||
|
@ -52,13 +52,13 @@ import type { DeviceType, CurrentLoginAccountType } from '../interface'
|
|||||||
|
|
||||||
import bindPatriarch from './bindPatriarch.vue'
|
import bindPatriarch from './bindPatriarch.vue'
|
||||||
import { parentDeviceCurrentLoginApi, parentBindInviteApi } from '@/api'
|
import { parentDeviceCurrentLoginApi, parentBindInviteApi } from '@/api'
|
||||||
import { user, shareConfigStore } from '@/store'
|
import { userStore, shareConfigStore } from '@/store'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
const { initWeixinShareConfig } = shareConfigStore()
|
const { initWeixinShareConfig } = shareConfigStore()
|
||||||
const { appId } = storeToRefs(shareConfigStore())
|
const { appId } = storeToRefs(shareConfigStore())
|
||||||
const { userInfo } = storeToRefs(user())
|
const { userInfo } = storeToRefs(userStore())
|
||||||
const showMaskTip = ref(false)
|
const showMaskTip = ref(false)
|
||||||
const detailInfo = ref<DeviceType>()
|
const detailInfo = ref<DeviceType>()
|
||||||
const currentLogin = ref<CurrentLoginAccountType>()
|
const currentLogin = ref<CurrentLoginAccountType>()
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<text class="name">{{ userInfo.nickName }}</text>
|
<text class="name">{{ userInfo.nickName }}</text>
|
||||||
<text class="identity">家长</text>
|
<text class="identity">家长</text>
|
||||||
</view>
|
</view>
|
||||||
<!-- <view class="function">
|
<view class="function">
|
||||||
<template v-for="i in list" :key="i.title">
|
<template v-for="i in list" :key="i.title">
|
||||||
<view v-if="i.show" class="function_item" @click="handleJump(i)">
|
<view v-if="i.show" class="function_item" @click="handleJump(i)">
|
||||||
<view class="photo_box">
|
<view class="photo_box">
|
||||||
@ -19,19 +19,19 @@
|
|||||||
<text class="title">{{ i.title }}</text>
|
<text class="title">{{ i.title }}</text>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
</view> -->
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import { user } from '@/store'
|
import { userStore } from '@/store'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { getCache } from '@/utils'
|
import { getCache } from '@/utils'
|
||||||
import router from '@/router/router'
|
import router from '@/router/router'
|
||||||
import db from '@/utils/db'
|
import db from '@/utils/db'
|
||||||
|
|
||||||
const { userInfo } = storeToRefs(user())
|
const { userInfo } = storeToRefs(userStore())
|
||||||
|
|
||||||
const OSS_URL = import.meta.env.VITE_OSS_HOST
|
const OSS_URL = import.meta.env.VITE_OSS_HOST
|
||||||
const defaultAvatar = `${OSS_URL}/urm/default_avatar.png`
|
const defaultAvatar = `${OSS_URL}/urm/default_avatar.png`
|
||||||
@ -45,33 +45,33 @@ const list = ref([
|
|||||||
{
|
{
|
||||||
title: '绑定申请',
|
title: '绑定申请',
|
||||||
photo: `${OSS_URL}/urm/my_binding_apply.png`,
|
photo: `${OSS_URL}/urm/my_binding_apply.png`,
|
||||||
show: false,
|
show: true,
|
||||||
url: '/pages/mine/bindApply/index',
|
url: '/pages/mine/bindApply/index',
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
title: '电子保修卡',
|
// title: '电子保修卡',
|
||||||
photo: `${OSS_URL}/urm/my_warranty.png`,
|
// photo: `${OSS_URL}/urm/my_warranty.png`,
|
||||||
show: true,
|
// show: true,
|
||||||
url: '/pages/mine/warranty/index',
|
// url: '/pages/mine/warranty/index',
|
||||||
},
|
// },
|
||||||
// {
|
// {
|
||||||
// title: '使用攻略',
|
// title: '使用攻略',
|
||||||
// photo: `${OSS_URL}/urm/my_use_guideline.png`,
|
// photo: `${OSS_URL}/urm/my_use_guideline.png`,
|
||||||
// show: true,
|
// show: true,
|
||||||
// url: '',
|
// url: '',
|
||||||
// },
|
// },
|
||||||
{
|
// {
|
||||||
title: '任务管理',
|
// title: '任务管理',
|
||||||
photo: `${OSS_URL}/urm/my_task_manage.png`,
|
// photo: `${OSS_URL}/urm/my_task_manage.png`,
|
||||||
show: true,
|
// show: true,
|
||||||
url: '/pages/mine/taskManage/index',
|
// url: '/pages/mine/taskManage/index',
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
title: '奖励管理',
|
// title: '奖励管理',
|
||||||
photo: `${OSS_URL}/urm/my_award_manage.png`,
|
// photo: `${OSS_URL}/urm/my_award_manage.png`,
|
||||||
show: true,
|
// show: true,
|
||||||
url: '/pages/mine/awardManage/index',
|
// url: '/pages/mine/awardManage/index',
|
||||||
},
|
// },
|
||||||
])
|
])
|
||||||
function handleJump(i: any) {
|
function handleJump(i: any) {
|
||||||
router.navigateTo({
|
router.navigateTo({
|
||||||
@ -86,9 +86,7 @@ function handlePrefectInfo() {
|
|||||||
// })
|
// })
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {})
|
||||||
list.value[1].show = db.get('userAdmin')
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -59,13 +59,12 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
import { user } from '@/store'
|
|
||||||
import { updateUserInfoApi } from '@/api'
|
import { updateUserInfoApi } from '@/api'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import router from '@/router/router'
|
import router from '@/router/router'
|
||||||
import CustomPopup from '@/components/CustomPopup/index.vue'
|
import CustomPopup from '@/components/CustomPopup/index.vue'
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
import { h5Authorization } from '@/store'
|
import { h5Authorization, userStore } from '@/store'
|
||||||
import hud from '@/utils/hud'
|
import hud from '@/utils/hud'
|
||||||
const { authorizedLogin } = h5Authorization()
|
const { authorizedLogin } = h5Authorization()
|
||||||
// #endif
|
// #endif
|
||||||
@ -73,8 +72,9 @@ const popupRef = ref(null)
|
|||||||
const OSS_URL = import.meta.env.VITE_OSS_HOST
|
const OSS_URL = import.meta.env.VITE_OSS_HOST
|
||||||
const defaultAvatar = `${OSS_URL}/urm/default_avatar.png`
|
const defaultAvatar = `${OSS_URL}/urm/default_avatar.png`
|
||||||
const arrow = `${OSS_URL}/iconfont/down_arrow.png`
|
const arrow = `${OSS_URL}/iconfont/down_arrow.png`
|
||||||
const { logout, getUserInfo } = user()
|
const store = userStore()
|
||||||
const { userInfo } = storeToRefs(user())
|
const { logout, getUserInfo } = store
|
||||||
|
const { userInfo } = storeToRefs(store)
|
||||||
const indicatorStyle = ref(`height: 50px;`)
|
const indicatorStyle = ref(`height: 50px;`)
|
||||||
const showCustomPopup = ref(false)
|
const showCustomPopup = ref(false)
|
||||||
const pageType = ref() // 1-非首次注册进入
|
const pageType = ref() // 1-非首次注册进入
|
||||||
|
48
src/plugins/pinia-plugin-persist/index.ts
Normal file
48
src/plugins/pinia-plugin-persist/index.ts
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import db from '@/utils/db'
|
||||||
|
import type { PiniaPluginContext, StateTree, Store } from 'pinia'
|
||||||
|
|
||||||
|
const cache = ['user']
|
||||||
|
|
||||||
|
function getStoreKey(key: string) {
|
||||||
|
return `store_${key}`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解析数据同步到state
|
||||||
|
function hydrateStore(store: Store, key: string) {
|
||||||
|
try {
|
||||||
|
const data = db.get(getStoreKey(key))
|
||||||
|
if (!data) return
|
||||||
|
store.$patch(data)
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 序列化之后存储到storage
|
||||||
|
function persistState(state: StateTree, key: string) {
|
||||||
|
try {
|
||||||
|
db.set(getStoreKey(key), state)
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function PiniaPluginPersist(context: PiniaPluginContext) {
|
||||||
|
const { store } = context
|
||||||
|
// 没包含的就不缓存
|
||||||
|
if (!cache.includes(store.$id)) return
|
||||||
|
|
||||||
|
hydrateStore(store, store.$id)
|
||||||
|
// 监听数据变化
|
||||||
|
store.$subscribe(
|
||||||
|
(mutation, state) => {
|
||||||
|
persistState(state, store.$id)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// 组件销毁时,当前监听不会被销毁
|
||||||
|
detached: true,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PiniaPluginPersist
|
@ -1,7 +1,9 @@
|
|||||||
/* eslint-disable no-param-reassign */
|
/* eslint-disable no-param-reassign */
|
||||||
|
import { userStore } from '@/store'
|
||||||
import db from '../utils/db'
|
import db from '../utils/db'
|
||||||
import page from '../utils/page'
|
import page from '../utils/page'
|
||||||
import qs from 'qs'
|
import qs from 'qs'
|
||||||
|
import { storeToRefs } from 'pinia'
|
||||||
|
|
||||||
// 页面路径常量
|
// 页面路径常量
|
||||||
export const route_login = '/pages/login/index'
|
export const route_login = '/pages/login/index'
|
||||||
@ -109,8 +111,8 @@ function beforeEach(options: RouterOptions) {
|
|||||||
console.log('beforeEach', from, to)
|
console.log('beforeEach', from, to)
|
||||||
|
|
||||||
// 执行跳转
|
// 执行跳转
|
||||||
const token = db.get('token')
|
const { token } = storeToRefs(userStore())
|
||||||
if (!noTokenRoutes.includes(to.path) && !token) {
|
if (!noTokenRoutes.includes(to.path) && !token.value) {
|
||||||
console.log('token 过期')
|
console.log('token 过期')
|
||||||
toLogin(to)
|
toLogin(to)
|
||||||
return false
|
return false
|
||||||
|
@ -1,19 +1,13 @@
|
|||||||
import { getCache, setCache } from '@/utils'
|
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { user } from '@/store'
|
import { userStore } from '@/store'
|
||||||
import { bindAuthInfoApi } from '@/api'
|
import { bindAuthInfoApi } from '@/api'
|
||||||
import db from '@/utils/db'
|
import db from '@/utils/db'
|
||||||
const { afterLogin, getUserInfo } = user()
|
|
||||||
// const { } = user();
|
|
||||||
|
|
||||||
export const h5Authorization = defineStore('h5Authorization', () => {
|
export const h5Authorization = defineStore('h5Authorization', () => {
|
||||||
const H5Openid = ref('')
|
const H5Openid = ref('')
|
||||||
|
|
||||||
const authorizedLogin = async () => {
|
const authorizedLogin = async () => {
|
||||||
// if (getCache('userInfo')) {
|
|
||||||
// await getUserInfo();
|
|
||||||
// }
|
|
||||||
const code = getQueryString('code')
|
const code = getQueryString('code')
|
||||||
const state = getQueryString('state')
|
const state = getQueryString('state')
|
||||||
console.log('进入授权code和state', code, state)
|
console.log('进入授权code和state', code, state)
|
||||||
@ -28,6 +22,7 @@ export const h5Authorization = defineStore('h5Authorization', () => {
|
|||||||
// setCache('H5_OPENID', res.data.openId);
|
// setCache('H5_OPENID', res.data.openId);
|
||||||
// setCache('H5_UNIONID', res.data.unionId);
|
// setCache('H5_UNIONID', res.data.unionId);
|
||||||
// setCache('token', res.data.token);
|
// setCache('token', res.data.token);
|
||||||
|
const { afterLogin } = userStore()
|
||||||
await afterLogin()
|
await afterLogin()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
@ -4,7 +4,9 @@ import { ref } from 'vue'
|
|||||||
import { global } from './global'
|
import { global } from './global'
|
||||||
import { getCache, setCache } from '@/utils'
|
import { getCache, setCache } from '@/utils'
|
||||||
import db from '@/utils/db'
|
import db from '@/utils/db'
|
||||||
|
import { userStore } from './user'
|
||||||
export const socket = defineStore('socket', () => {
|
export const socket = defineStore('socket', () => {
|
||||||
|
const { token } = storeToRefs(userStore())
|
||||||
const socket = ref()
|
const socket = ref()
|
||||||
const status = ref(true) // true在线 false离线
|
const status = ref(true) // true在线 false离线
|
||||||
let hbTimer: any
|
let hbTimer: any
|
||||||
@ -23,12 +25,11 @@ export const socket = defineStore('socket', () => {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
async function initSocket(simSerialNumber: string) {
|
async function initSocket(simSerialNumber: string) {
|
||||||
const token = db.get('token')
|
|
||||||
init()
|
init()
|
||||||
function init() {
|
function init() {
|
||||||
if (!beforeInit()) return
|
if (!beforeInit()) return
|
||||||
socket.value = uni.connectSocket({
|
socket.value = uni.connectSocket({
|
||||||
url: `${process.env.VITE_WS_URL}?accessToken=${token}`,
|
url: `${import.meta.env.VITE_WS_URL}?accessToken=${token.value}`,
|
||||||
complete: () => {},
|
complete: () => {},
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ export const socket = defineStore('socket', () => {
|
|||||||
// 心跳
|
// 心跳
|
||||||
function _heartBeat() {
|
function _heartBeat() {
|
||||||
// console.log('心跳')
|
// console.log('心跳')
|
||||||
if (!db.get('token')) {
|
if (!token.value) {
|
||||||
socket.value?.close()
|
socket.value?.close()
|
||||||
clearInterval(hbTimer)
|
clearInterval(hbTimer)
|
||||||
return
|
return
|
||||||
|
@ -1,94 +1,53 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import {
|
import { getUserInfoApi, logoutApi } from '@/api'
|
||||||
// phoneLogin as phoneLoginApi,
|
|
||||||
getUserInfoApi,
|
|
||||||
// psdLogin as psdLoginApi,
|
|
||||||
logout as logoutApi,
|
|
||||||
getCsInfo as getCsInfoApi,
|
|
||||||
bindRegId,
|
|
||||||
userInfoPermitApi,
|
|
||||||
// updatePwdByPhone,
|
|
||||||
} from '@/api'
|
|
||||||
// import type { smsLoginType, accountLoginType, updatePasswordType } from '@/api';
|
// import type { smsLoginType, accountLoginType, updatePasswordType } from '@/api';
|
||||||
// import defaultAvatar from "@/static/default_avatar.png";
|
// import defaultAvatar from "@/static/default_avatar.png";
|
||||||
import { global } from '@/store'
|
import { global } from '@/store'
|
||||||
import router from '@/router/router'
|
import router from '@/router/router'
|
||||||
import db from '@/utils/db'
|
import db from '@/utils/db'
|
||||||
|
|
||||||
export const user = defineStore('user', () => {
|
export const userStore = defineStore('user', () => {
|
||||||
const userInfo = ref(db.get('userInfo') || ({} as any))
|
const userInfo = ref({} as any)
|
||||||
const csInfo = ref(db.get('csInfo') || {})
|
const token = ref('')
|
||||||
const token = ref(db.get('token') || '')
|
|
||||||
const { getDicts } = global()
|
const { getDicts } = global()
|
||||||
|
|
||||||
const afterLogin = async () => {
|
const afterLogin = async () => {
|
||||||
await Promise.allSettled([getUserInfo(), getDicts()])
|
await Promise.allSettled([getUserInfo(), getDicts()])
|
||||||
// getCsInfo(); // 需等待用户信息加载完毕
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const logout = async () => {
|
const logout = async () => {
|
||||||
// #ifdef APP-PLUS
|
|
||||||
if (db.get('registerID')) {
|
|
||||||
await bindRegId({
|
|
||||||
registrationId: db.get('registerID'),
|
|
||||||
type: 2,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// #endif
|
|
||||||
await logoutApi()
|
await logoutApi()
|
||||||
clear()
|
clear()
|
||||||
router.toLogin()
|
router.toLogin()
|
||||||
}
|
}
|
||||||
|
|
||||||
const getUserInfo = async () => {
|
const getUserInfo = async () => {
|
||||||
// 如果不是微信公众号环境,直接跳回登录页面
|
const mode = import.meta.env.MODE
|
||||||
if (!db.get('openid')) {
|
// 如果是正式环境 && 且缺少openid,直接跳回登录页面
|
||||||
|
if (mode !== 'dev' && mode !== 'mp' && !db.get('openid')) {
|
||||||
router.toLogin()
|
router.toLogin()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await getUserInfoApi()
|
const res = await getUserInfoApi()
|
||||||
userInfo.value = res
|
userInfo.value = res
|
||||||
db.set('userInfo', res)
|
|
||||||
await getUserInfoPermit()
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
// 当前登录用户是否管理员身份
|
|
||||||
async function getUserInfoPermit() {
|
|
||||||
const data = await userInfoPermitApi()
|
|
||||||
db.set('userAdmin', data)
|
|
||||||
}
|
|
||||||
const getCsInfo = async () => {
|
|
||||||
const res = await getCsInfoApi(userInfo.value.id)
|
|
||||||
csInfo.value = res
|
|
||||||
db.set('csInfo', res)
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
const clear = async () => {
|
const clear = async () => {
|
||||||
token.value = ''
|
token.value = ''
|
||||||
userInfo.value = {}
|
userInfo.value = {}
|
||||||
csInfo.value = {}
|
|
||||||
await db.clear()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const setToken = (data: string) => {
|
const setToken = (data: string) => {
|
||||||
token.value = data
|
token.value = data
|
||||||
db.set('token', data)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
userInfo,
|
userInfo,
|
||||||
csInfo,
|
|
||||||
token,
|
token,
|
||||||
// setInfo,
|
|
||||||
// login,
|
|
||||||
// phoneLogin,
|
|
||||||
// accordLogin,
|
|
||||||
// updatePassword,
|
|
||||||
getUserInfo,
|
getUserInfo,
|
||||||
getCsInfo,
|
|
||||||
logout,
|
logout,
|
||||||
clear,
|
clear,
|
||||||
afterLogin,
|
afterLogin,
|
||||||
|
@ -695,7 +695,7 @@ export function isImageUrl(url: string): boolean {
|
|||||||
/**
|
/**
|
||||||
* 判断环境是否是H5
|
* 判断环境是否是H5
|
||||||
*/
|
*/
|
||||||
export const isH5 = process.env.UNI_PLATFORM === 'h5'
|
export const isH5 = import.meta.env.UNI_PLATFORM === 'h5'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 剔除对象中的某些属性
|
* 剔除对象中的某些属性
|
||||||
|
@ -49,7 +49,7 @@ function isSameSecond(time1: number, time2: number): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 判断当前环境是否为 H5
|
// 判断当前环境是否为 H5
|
||||||
const isH5 = process.env.UNI_PLATFORM === 'h5'
|
const isH5 = import.meta.env.UNI_PLATFORM === 'h5'
|
||||||
|
|
||||||
// 封装 requestAnimationFrame 和 setTimeout
|
// 封装 requestAnimationFrame 和 setTimeout
|
||||||
function raf(fn: FrameRequestCallback): number {
|
function raf(fn: FrameRequestCallback): number {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user