Merge branch 'develop' into develop_daisy
# Conflicts: # src/pages/home/home.vue
This commit is contained in:
commit
df7563be13
@ -1,19 +1,30 @@
|
|||||||
|
type ResultCode = 0 | -1 | -2 | 10003
|
||||||
|
|
||||||
|
interface ResultData {
|
||||||
|
message: string
|
||||||
|
data: Record<string, any>
|
||||||
|
}
|
||||||
|
|
||||||
export class Result {
|
export class Result {
|
||||||
static codes = {
|
static codes = {
|
||||||
Success: 0,
|
Success: 0 as const,
|
||||||
Fail: -1,
|
Fail: -1 as const,
|
||||||
NotMore: -2,
|
NotMore: -2 as const,
|
||||||
PaySuccessful: 10003
|
PaySuccessful: 10003 as const
|
||||||
}
|
}
|
||||||
|
|
||||||
static resultsMap = new Map([
|
static resultsMap = new Map<ResultCode, ResultData>([
|
||||||
[Result.codes.Success, { message: '成功', data: {} }],
|
[Result.codes.Success, { message: '成功', data: {} }],
|
||||||
[Result.codes.Fail, { message: '网络加载失败', data: {} }],
|
[Result.codes.Fail, { message: '网络加载失败', data: {} }],
|
||||||
[Result.codes.NotMore, { message: '没有更多', data: {} }],
|
[Result.codes.NotMore, { message: '没有更多', data: {} }],
|
||||||
[Result.codes.PaySuccessful, { message: '支付成功', data: {} }]
|
[Result.codes.PaySuccessful, { message: '支付成功', data: {} }]
|
||||||
])
|
])
|
||||||
|
|
||||||
constructor(code, data, message) {
|
code: ResultCode
|
||||||
|
message: string
|
||||||
|
data: Record<string, any>
|
||||||
|
|
||||||
|
constructor(code: ResultCode, data?: Record<string, any>, message?: string) {
|
||||||
const result = Result.resultsMap.get(code)
|
const result = Result.resultsMap.get(code)
|
||||||
if (result) {
|
if (result) {
|
||||||
this.code = code
|
this.code = code
|
||||||
@ -27,22 +38,22 @@ export class Result {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 成功
|
// 成功
|
||||||
static get Success() {
|
static get Success(): Result {
|
||||||
return new Result(Result.codes.Success)
|
return new Result(Result.codes.Success)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 失败(默认错误)
|
// 失败(默认错误)
|
||||||
static get Fail() {
|
static get Fail(): Result {
|
||||||
return new Result(Result.codes.Fail)
|
return new Result(Result.codes.Fail)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 没有更多
|
// 没有更多
|
||||||
static get NotMore() {
|
static get NotMore(): Result {
|
||||||
return new Result(Result.codes.NotMore)
|
return new Result(Result.codes.NotMore)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 支付成功
|
// 支付成功
|
||||||
static get PaySuccessful() {
|
static get PaySuccessful(): Result {
|
||||||
return new Result(Result.codes.PaySuccessful)
|
return new Result(Result.codes.PaySuccessful)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,24 +6,19 @@
|
|||||||
import { useUserStore } from '@/store'
|
import { useUserStore } from '@/store'
|
||||||
import { getNeedLoginPages, needLoginPages as _needLoginPages } from '@/utils'
|
import { getNeedLoginPages, needLoginPages as _needLoginPages } from '@/utils'
|
||||||
|
|
||||||
// TODO Check
|
const loginRoute = '/pages/login/login'
|
||||||
const loginRoute = '/pages/login/index'
|
|
||||||
|
|
||||||
const isLogined = () => {
|
const loginStatus = () => {
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
return userStore.isLogined
|
return userStore.loginStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
const isDev = import.meta.env.DEV
|
const isDev = import.meta.env.DEV
|
||||||
|
|
||||||
// 黑名单登录拦截器 - (适用于大部分页面不需要登录,少部分页面需要登录)
|
|
||||||
const navigateToInterceptor = {
|
const navigateToInterceptor = {
|
||||||
// 注意,这里的url是 '/' 开头的,如 '/pages/index/index',跟 'pages.json' 里面的 path 不同
|
|
||||||
invoke({ url }: { url: string }) {
|
invoke({ url }: { url: string }) {
|
||||||
// console.log(url) // /pages/route-interceptor/index?name=feige&age=30
|
|
||||||
const path = url.split('?')[0]
|
const path = url.split('?')[0]
|
||||||
let needLoginPages: string[] = []
|
let needLoginPages: string[] = []
|
||||||
// 为了防止开发时出现BUG,这里每次都获取一下。生产环境可以移到函数外,性能更好
|
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
needLoginPages = getNeedLoginPages()
|
needLoginPages = getNeedLoginPages()
|
||||||
} else {
|
} else {
|
||||||
@ -33,12 +28,11 @@ const navigateToInterceptor = {
|
|||||||
if (!isNeedLogin) {
|
if (!isNeedLogin) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
const hasLogin = isLogined()
|
const hasLogin = loginStatus()
|
||||||
if (hasLogin) {
|
if (hasLogin) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
const redirectRoute = `${loginRoute}?redirect=${encodeURIComponent(url)}`
|
uni.navigateTo({ url: loginRoute })
|
||||||
uni.navigateTo({ url: redirectRoute })
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,7 +68,8 @@
|
|||||||
"style": {
|
"style": {
|
||||||
"navigationStyle": "custom",
|
"navigationStyle": "custom",
|
||||||
"disableScroll": true
|
"disableScroll": true
|
||||||
}
|
},
|
||||||
|
"needLogin": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/get-code/get-code",
|
"path": "pages/get-code/get-code",
|
||||||
@ -76,7 +77,8 @@
|
|||||||
"style": {
|
"style": {
|
||||||
"navigationStyle": "custom",
|
"navigationStyle": "custom",
|
||||||
"disableScroll": true
|
"disableScroll": true
|
||||||
}
|
},
|
||||||
|
"needLogin": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/info-publish/info-publish",
|
"path": "pages/info-publish/info-publish",
|
||||||
@ -104,7 +106,8 @@
|
|||||||
"style": {
|
"style": {
|
||||||
"navigationStyle": "custom",
|
"navigationStyle": "custom",
|
||||||
"disableScroll": true
|
"disableScroll": true
|
||||||
}
|
},
|
||||||
|
"needLogin": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/mine/mine",
|
"path": "pages/mine/mine",
|
||||||
@ -120,7 +123,8 @@
|
|||||||
"style": {
|
"style": {
|
||||||
"navigationStyle": "custom",
|
"navigationStyle": "custom",
|
||||||
"disableScroll": true
|
"disableScroll": true
|
||||||
}
|
},
|
||||||
|
"needLogin": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/workbench/workbench",
|
"path": "pages/workbench/workbench",
|
||||||
|
|||||||
@ -3,7 +3,8 @@
|
|||||||
style: {
|
style: {
|
||||||
navigationStyle: 'custom',
|
navigationStyle: 'custom',
|
||||||
disableScroll: true
|
disableScroll: true
|
||||||
}
|
},
|
||||||
|
needLogin: false
|
||||||
}
|
}
|
||||||
</route>
|
</route>
|
||||||
<template>
|
<template>
|
||||||
@ -42,6 +43,7 @@
|
|||||||
import { PlatId } from '@/typings'
|
import { PlatId } from '@/typings'
|
||||||
import { Result } from '@/constants/result'
|
import { Result } from '@/constants/result'
|
||||||
import { useBasicStore, useUserStore } from '@/store'
|
import { useBasicStore, useUserStore } from '@/store'
|
||||||
|
import GetSystemInfoResult = UniNamespace.GetSystemInfoResult
|
||||||
|
|
||||||
const $basic = useBasicStore()
|
const $basic = useBasicStore()
|
||||||
const $user = useUserStore()
|
const $user = useUserStore()
|
||||||
|
|||||||
@ -3,7 +3,8 @@
|
|||||||
style: {
|
style: {
|
||||||
navigationStyle: 'custom',
|
navigationStyle: 'custom',
|
||||||
disableScroll: true
|
disableScroll: true
|
||||||
}
|
},
|
||||||
|
needLogin: false
|
||||||
}
|
}
|
||||||
</route>
|
</route>
|
||||||
<template>
|
<template>
|
||||||
@ -32,7 +33,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { phoneRegExp } from '@/constants/regular-expressions'
|
import { phoneRegExp } from '@/constants/regular-expressions'
|
||||||
import { AccountChannel, CodeType, IResData } from '@/typings'
|
import { AccountChannel, CodeType } from '@/typings'
|
||||||
import { getCodeApi, UserGetCodeRequest } from '@/service/user'
|
import { getCodeApi, UserGetCodeRequest } from '@/service/user'
|
||||||
import { Result } from '@/constants/result'
|
import { Result } from '@/constants/result'
|
||||||
|
|
||||||
@ -54,7 +55,7 @@
|
|||||||
mask: true
|
mask: true
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
const result: IResData = await getCodeApi<UserGetCodeRequest>({
|
const result = await getCodeApi<UserGetCodeRequest>({
|
||||||
account: phone.value,
|
account: phone.value,
|
||||||
channel: AccountChannel.phone,
|
channel: AccountChannel.phone,
|
||||||
codeType: CodeType.reset
|
codeType: CodeType.reset
|
||||||
|
|||||||
@ -7,23 +7,29 @@
|
|||||||
}
|
}
|
||||||
</route>
|
</route>
|
||||||
<template>
|
<template>
|
||||||
<view class="custom-bg-default">
|
<view v-if="systemInfo" :style="{ marginTop: systemInfo.safeAreaInsets?.top + 'px' }">
|
||||||
<view v-if="$user.loginStatus">
|
<view v-if="$user.loginStatus">
|
||||||
|
<view class="h-12 pt-1 flex flex-items-center flex-justify-between mx-4">
|
||||||
|
<view>
|
||||||
|
<view>19104656的互联</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
<CustomTab class="mt-10" :list="featuresList" @clickItem="clickItem"></CustomTab>
|
<CustomTab class="mt-10" :list="featuresList" @clickItem="clickItem"></CustomTab>
|
||||||
<button class="mt-12" @click="$user.logout">退出登录</button>
|
<button class="mt-12" @click="logout">退出登录</button>
|
||||||
</view>
|
|
||||||
<view v-else>
|
|
||||||
<button class="mt-12" @click="toLogin">去登录</button>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import CustomTab from '@/pages/home/CustomTab.vue'
|
import CustomTab from '@/pages/home/CustomTab.vue'
|
||||||
import { useUserStore } from '@/store'
|
import { useBasicStore, useUserStore } from '@/store'
|
||||||
import { Result } from '@/constants/result'
|
import { Result } from '@/constants/result'
|
||||||
|
import { HomeTab, TabBarItem } from '@/typings'
|
||||||
|
|
||||||
const $user = useUserStore()
|
const $user = useUserStore()
|
||||||
|
const $basic = useBasicStore()
|
||||||
|
|
||||||
|
const systemInfo = ref(null)
|
||||||
|
|
||||||
const list = ref<Array<TabBarItem>>([
|
const list = ref<Array<TabBarItem>>([
|
||||||
{
|
{
|
||||||
@ -180,21 +186,21 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '信息发布',
|
title: '其他',
|
||||||
list: [
|
list: [
|
||||||
{
|
{
|
||||||
id: 70,
|
id: 0,
|
||||||
title: '广播',
|
title: '其他中心',
|
||||||
icon: '/static/logo.png'
|
icon: '/static/logo.png'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 71,
|
id: 1,
|
||||||
title: '公告',
|
title: '其他中心',
|
||||||
icon: '/static/logo.png'
|
icon: '/static/logo.png'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 72,
|
id: 2,
|
||||||
title: '信息发布',
|
title: '其他中心',
|
||||||
icon: '/static/logo.png'
|
icon: '/static/logo.png'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -222,9 +228,10 @@
|
|||||||
])
|
])
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
systemInfo.value = await $basic.getSystemInfo()
|
||||||
const tokenStorage: string = uni.getStorageSync('token')
|
const tokenStorage: string = uni.getStorageSync('token')
|
||||||
if (tokenStorage) {
|
if (tokenStorage) {
|
||||||
const result: boolean = await $user.getUserInfo()
|
const result: Result = await $user.getUserInfo()
|
||||||
if (result.code === Result.Success.code) {
|
if (result.code === Result.Success.code) {
|
||||||
console.log('获取用户信息成功')
|
console.log('获取用户信息成功')
|
||||||
} else {
|
} else {
|
||||||
@ -233,40 +240,21 @@
|
|||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/login/login'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const toLogin = () => {
|
const clickItem = item => {
|
||||||
|
console.log(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
const logout = async () => {
|
||||||
|
await $user.logout()
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/login/login'
|
url: '/pages/login/login'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const toNotice = () => {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: '/pages/info-publish/notice'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const toInfoPublish = () => {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: '/pages/info-publish/info-publish'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const clickItem = item => {
|
|
||||||
console.log(item)
|
|
||||||
if (item.id === 71) {
|
|
||||||
toNotice()
|
|
||||||
}
|
|
||||||
if (item.id === 72) {
|
|
||||||
toInfoPublish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
page {
|
|
||||||
background: #f3f5fa;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
@ -3,7 +3,8 @@
|
|||||||
style: {
|
style: {
|
||||||
navigationStyle: 'custom',
|
navigationStyle: 'custom',
|
||||||
disableScroll: true
|
disableScroll: true
|
||||||
}
|
},
|
||||||
|
needLogin: false
|
||||||
}
|
}
|
||||||
</route>
|
</route>
|
||||||
<template>
|
<template>
|
||||||
@ -11,9 +12,9 @@
|
|||||||
<TopNavigation v-if="systemInfo && systemInfo?.uniPlatform === 'app'"></TopNavigation>
|
<TopNavigation v-if="systemInfo && systemInfo?.uniPlatform === 'app'"></TopNavigation>
|
||||||
<swiper
|
<swiper
|
||||||
v-if="systemInfo"
|
v-if="systemInfo"
|
||||||
:circular="true"
|
circular="true"
|
||||||
:current="index"
|
:current="index"
|
||||||
:disable-touch="true"
|
disable-touch="true"
|
||||||
:style="{
|
:style="{
|
||||||
height: 'calc(100vh - ' + (systemInfo.safeAreaInsets?.top + 48) + 'px)'
|
height: 'calc(100vh - ' + (systemInfo.safeAreaInsets?.top + 48) + 'px)'
|
||||||
}"
|
}"
|
||||||
@ -155,8 +156,9 @@
|
|||||||
PasswordLoginRequest,
|
PasswordLoginRequest,
|
||||||
UserGetCodeRequest
|
UserGetCodeRequest
|
||||||
} from '@/service/user'
|
} from '@/service/user'
|
||||||
import { AccountChannel, CodeType, IResData, PlatId } from '@/typings'
|
import { AccountChannel, CodeType, PlatId } from '@/typings'
|
||||||
import { Result } from '@/constants/result'
|
import { Result } from '@/constants/result'
|
||||||
|
import GetSystemInfoResult = UniNamespace.GetSystemInfoResult
|
||||||
|
|
||||||
const $basic = useBasicStore()
|
const $basic = useBasicStore()
|
||||||
const $user = useUserStore()
|
const $user = useUserStore()
|
||||||
@ -250,7 +252,7 @@
|
|||||||
mask: true
|
mask: true
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
const result: IResData = await getCodeApi<UserGetCodeRequest>({
|
const result = await getCodeApi<UserGetCodeRequest>({
|
||||||
account: phone.value,
|
account: phone.value,
|
||||||
channel: AccountChannel.phone,
|
channel: AccountChannel.phone,
|
||||||
codeType: CodeType.login
|
codeType: CodeType.login
|
||||||
|
|||||||
@ -3,7 +3,8 @@
|
|||||||
style: {
|
style: {
|
||||||
navigationStyle: 'custom',
|
navigationStyle: 'custom',
|
||||||
disableScroll: true
|
disableScroll: true
|
||||||
}
|
},
|
||||||
|
needLogin: false
|
||||||
}
|
}
|
||||||
</route>
|
</route>
|
||||||
<template>
|
<template>
|
||||||
@ -25,7 +26,7 @@
|
|||||||
@change="codeChange"
|
@change="codeChange"
|
||||||
use-suffix-slot
|
use-suffix-slot
|
||||||
>
|
>
|
||||||
<template #suffix>
|
<template v-slot:suffix>
|
||||||
<view v-if="countDown > 0" class="text-4 custom-color-grey">
|
<view v-if="countDown > 0" class="text-4 custom-color-grey">
|
||||||
{{ countDown }}s后重新获取
|
{{ countDown }}s后重新获取
|
||||||
</view>
|
</view>
|
||||||
@ -78,7 +79,7 @@
|
|||||||
import { codeRegExp, passwordRegExp } from '@/constants/regular-expressions'
|
import { codeRegExp, passwordRegExp } from '@/constants/regular-expressions'
|
||||||
import { getCodeApi, resetPasswordApi, UserGetCodeRequest } from '@/service/user'
|
import { getCodeApi, resetPasswordApi, UserGetCodeRequest } from '@/service/user'
|
||||||
import { Result } from '@/constants/result'
|
import { Result } from '@/constants/result'
|
||||||
import { AccountChannel, CodeType, IResData } from '@/typings'
|
import { AccountChannel, CodeType } from '@/typings'
|
||||||
|
|
||||||
const phone = ref<string>('')
|
const phone = ref<string>('')
|
||||||
const code = ref<string>('')
|
const code = ref<string>('')
|
||||||
@ -108,7 +109,7 @@
|
|||||||
mask: true
|
mask: true
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
const result: IResData = await getCodeApi<UserGetCodeRequest>({
|
const result = await getCodeApi<UserGetCodeRequest>({
|
||||||
account: phone.value,
|
account: phone.value,
|
||||||
channel: AccountChannel.phone,
|
channel: AccountChannel.phone,
|
||||||
codeType: CodeType.reset
|
codeType: CodeType.reset
|
||||||
|
|||||||
@ -1,18 +1,5 @@
|
|||||||
// @import './iconfont.css';
|
|
||||||
|
|
||||||
.test {
|
|
||||||
// 可以通过 @apply 多个样式封装整体样式
|
|
||||||
@apply mt-4 ml-4;
|
|
||||||
|
|
||||||
padding-top: 4px;
|
|
||||||
color: red;
|
|
||||||
}
|
|
||||||
|
|
||||||
:root,
|
:root,
|
||||||
page {
|
page {
|
||||||
// 修改按主题色
|
background: #f3f5fa;
|
||||||
// --wot-color-theme: #37c2bc;
|
--wot-color-theme: #255cf7;
|
||||||
|
|
||||||
// 修改按钮背景色
|
|
||||||
// --wot-button-primary-bg-color: green;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,23 +78,21 @@ export const getUrlObj = (url: string) => {
|
|||||||
* 如果没有传 key,则表示所有的pages,如果传递了 key, 则表示通过 key 过滤
|
* 如果没有传 key,则表示所有的pages,如果传递了 key, 则表示通过 key 过滤
|
||||||
*/
|
*/
|
||||||
export const getAllPages = (key = 'needLogin') => {
|
export const getAllPages = (key = 'needLogin') => {
|
||||||
// 这里处理主包
|
|
||||||
const mainPages = [
|
const mainPages = [
|
||||||
...pages
|
...pages
|
||||||
.filter(page => !key || page[key])
|
.filter(page => !key || page[key] !== false)
|
||||||
.map(page => ({
|
.map(page => ({
|
||||||
...page,
|
...page,
|
||||||
path: `/${page.path}`
|
path: `/${page.path}`
|
||||||
}))
|
}))
|
||||||
]
|
]
|
||||||
// 这里处理分包
|
|
||||||
const subPages: any[] = []
|
const subPages: any[] = []
|
||||||
subPackages.forEach(subPageObj => {
|
subPackages.forEach(subPageObj => {
|
||||||
// console.log(subPageObj)
|
|
||||||
const { root } = subPageObj
|
const { root } = subPageObj
|
||||||
|
|
||||||
subPageObj.pages
|
subPageObj.pages
|
||||||
.filter(page => !key || page[key])
|
.filter(page => !key || page[key] !== false)
|
||||||
.forEach((page: { path: string } & Record<string, any>) => {
|
.forEach((page: { path: string } & Record<string, any>) => {
|
||||||
subPages.push({
|
subPages.push({
|
||||||
...page,
|
...page,
|
||||||
@ -102,9 +100,7 @@ export const getAllPages = (key = 'needLogin') => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
const result = [...mainPages, ...subPages]
|
return [...mainPages, ...subPages]
|
||||||
// console.log(`getAllPages by ${key} result: `, result)
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user