页面
This commit is contained in:
parent
35afeb10e9
commit
539af26541
@ -3,7 +3,7 @@
|
|||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"description": "unibest - 最好的 uniapp 开发模板",
|
"description": "unibest - 最好的 uniapp 开发模板",
|
||||||
"update-time": "2025-08-27",
|
"update-time": "2025-09-08",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "feige996",
|
"name": "feige996",
|
||||||
"zhName": "菲鸽",
|
"zhName": "菲鸽",
|
||||||
|
24
src/App.vue
24
src/App.vue
@ -2,13 +2,33 @@
|
|||||||
import { onHide, onLaunch, onShow } from '@dcloudio/uni-app'
|
import { onHide, onLaunch, onShow } from '@dcloudio/uni-app'
|
||||||
import { usePageAuth } from '@/hooks/usePageAuth'
|
import { usePageAuth } from '@/hooks/usePageAuth'
|
||||||
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
|
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
|
||||||
|
import { useUserStore } from '@/store'
|
||||||
|
import { getInfoAPI } from '@/service/crmeb/product.ts'
|
||||||
usePageAuth()
|
usePageAuth()
|
||||||
|
|
||||||
onLaunch(() => {
|
onLaunch(() => {
|
||||||
|
// 在main.js或App.vue中
|
||||||
|
// uni.addInterceptor('switchTab', {
|
||||||
|
// async invoke(args) {
|
||||||
|
// console.log('拦截到tab切换', args.url)
|
||||||
|
// // await useUserStore().getUserInfo
|
||||||
|
// const res = await getInfoAPI()
|
||||||
|
// },
|
||||||
|
// fail(err) {
|
||||||
|
// console.error(err)
|
||||||
|
// },
|
||||||
|
// })
|
||||||
|
|
||||||
console.log('App Launch')
|
console.log('App Launch')
|
||||||
})
|
})
|
||||||
onShow(() => {
|
onShow(async () => {
|
||||||
|
// const res = await getInfoAPI()
|
||||||
|
// if (!uni.getStorageSync('token')) {
|
||||||
|
// uni.redirectTo({ url: '/pages/login/login' });
|
||||||
|
// } else {
|
||||||
|
// this.fetchData(); // 发起请求
|
||||||
|
// }
|
||||||
|
|
||||||
console.log('App Show')
|
console.log('App Show')
|
||||||
})
|
})
|
||||||
onHide(() => {
|
onHide(() => {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<view class="">
|
<view class="">
|
||||||
<view class="background_home">
|
<view class="background_home">
|
||||||
<view class="">
|
<view class="">
|
||||||
<view class="" style="" @click="more">
|
<view class="" style="">
|
||||||
<wd-card custom-class="card-content">
|
<wd-card custom-class="card-content">
|
||||||
<view class="relative h-50">
|
<view class="relative h-50">
|
||||||
<wd-img
|
<wd-img
|
||||||
@ -68,7 +68,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<scroll-view scroll-x="true" class="scroll-view-container">
|
<scroll-view scroll-x="true" class="scroll-view-container">
|
||||||
<view class="p-2" style="" @click="more" v-for="item in index_list">
|
<view class="p-2" style="" v-for="item in index_list">
|
||||||
<wd-card custom-class="card-content">
|
<wd-card custom-class="card-content">
|
||||||
<view class="content p-2" style="align-items: normal" @click="goPage(item)">
|
<view class="content p-2" style="align-items: normal" @click="goPage(item)">
|
||||||
<view class="ps-2 flex-content-column">
|
<view class="ps-2 flex-content-column">
|
||||||
@ -157,15 +157,6 @@ export default defineComponent({
|
|||||||
goPage(item) {
|
goPage(item) {
|
||||||
getUrl('/pages/about/detail?id=' + item.id)
|
getUrl('/pages/about/detail?id=' + item.id)
|
||||||
},
|
},
|
||||||
|
|
||||||
more(item) {
|
|
||||||
console.log(item)
|
|
||||||
if (item.type == 1) {
|
|
||||||
getUrl(item.url)
|
|
||||||
} else if (item.type == 2) {
|
|
||||||
getWebUrl(item.url)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@ -164,15 +164,17 @@ export default defineComponent({
|
|||||||
// })
|
// })
|
||||||
|
|
||||||
// url: '/pages/columnGoods/goods_list/index?id=38&title=名优特产',
|
// url: '/pages/columnGoods/goods_list/index?id=38&title=名优特产',
|
||||||
more(item) {
|
async more(item) {
|
||||||
this.islogin = hasLogin()
|
await hasLogin()
|
||||||
if (this.islogin === false) {
|
|
||||||
uni.navigateTo({
|
// this.islogin = hasLogin()
|
||||||
url: '/pages/login/login',
|
// if (this.islogin === false) {
|
||||||
})
|
// uni.navigateTo({
|
||||||
return
|
// url: '/pages/login/login',
|
||||||
}
|
// })
|
||||||
if (this.islogin === true) {
|
// return
|
||||||
|
// }
|
||||||
|
// if (this.islogin === true) {
|
||||||
// console.log(item)
|
// console.log(item)
|
||||||
if (item.type == 1) {
|
if (item.type == 1) {
|
||||||
getUrl(item.url)
|
getUrl(item.url)
|
||||||
@ -181,7 +183,7 @@ export default defineComponent({
|
|||||||
} else if (item.type == 3) {
|
} else if (item.type == 3) {
|
||||||
getShopWebUrl(item.url)
|
getShopWebUrl(item.url)
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -526,17 +526,8 @@ export default defineComponent({
|
|||||||
url: '/pages/about/index?category_id=' + index,
|
url: '/pages/about/index?category_id=' + index,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
more(item) {
|
async more(item) {
|
||||||
// const islogin = hasLogin()
|
await hasLogin()
|
||||||
const islogin = true
|
|
||||||
if (islogin === false) {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: '/pages/login/login',
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (islogin === true) {
|
|
||||||
// console.log(item)
|
|
||||||
if (item.type == 1) {
|
if (item.type == 1) {
|
||||||
getUrl(item.url)
|
getUrl(item.url)
|
||||||
} else if (item.type == 2) {
|
} else if (item.type == 2) {
|
||||||
@ -544,7 +535,7 @@ export default defineComponent({
|
|||||||
} else if (item.type == 3) {
|
} else if (item.type == 3) {
|
||||||
getShopWebUrl(item.url)
|
getShopWebUrl(item.url)
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -21,7 +21,11 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
|
function onClose() {
|
||||||
|
uni.navigateBack({
|
||||||
|
delta: 1,
|
||||||
|
})
|
||||||
|
}
|
||||||
async function decryptPhoneNumber(e) {
|
async function decryptPhoneNumber(e) {
|
||||||
if (!e.detail.iv) {
|
if (!e.detail.iv) {
|
||||||
toast.error('取消登录')
|
toast.error('取消登录')
|
||||||
|
@ -129,59 +129,8 @@ const userStore = useUserStore()
|
|||||||
console.log('userStore', userStore)
|
console.log('userStore', userStore)
|
||||||
import { defineComponent } from 'vue'
|
import { defineComponent } from 'vue'
|
||||||
|
|
||||||
// export default defineComponent({
|
async function more(item) {
|
||||||
// data() {
|
await hasLogin()
|
||||||
// return {
|
|
||||||
// isLogin: false,
|
|
||||||
// userIsLogin: false,
|
|
||||||
// show: false,
|
|
||||||
// userStore: {},
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// onLoad(option) {
|
|
||||||
// this.userStore = useUserStore()
|
|
||||||
// this.userIsLogin = useUserStore().userInfo.id ? true : false
|
|
||||||
// console.log('获取用户信息', this.userIsLogin)
|
|
||||||
// console.log('获取用户信息', this.userStore.userInfo)
|
|
||||||
// },
|
|
||||||
// methods: {
|
|
||||||
// toLogin() {
|
|
||||||
// uni.navigateTo({
|
|
||||||
// url: '/pages/login/login',
|
|
||||||
// })
|
|
||||||
// },
|
|
||||||
// more(item) {
|
|
||||||
// this.islogin = hasLogin()
|
|
||||||
// if (this.islogin === false) {
|
|
||||||
// uni.navigateTo({
|
|
||||||
// url: '/pages/login/login',
|
|
||||||
// })
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// if (this.islogin === true) {
|
|
||||||
// // console.log(item)
|
|
||||||
// if (item.type == 1) {
|
|
||||||
// getUrl(item.url)
|
|
||||||
// } else if (item.type == 2) {
|
|
||||||
// getWebUrl(item.url)
|
|
||||||
// } else if (item.type == 3) {
|
|
||||||
// getShopWebUrl(item.url)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// })
|
|
||||||
function more(item) {
|
|
||||||
const islogin = hasLogin()
|
|
||||||
// const islogin = true
|
|
||||||
if (islogin === false) {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: '/pages/login/login',
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (islogin === true) {
|
|
||||||
// console.log(item)
|
// console.log(item)
|
||||||
if (item.type == 1) {
|
if (item.type == 1) {
|
||||||
getUrl(item.url)
|
getUrl(item.url)
|
||||||
@ -191,7 +140,6 @@ function more(item) {
|
|||||||
getShopWebUrl(item.url)
|
getShopWebUrl(item.url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
const show = ref(false)
|
const show = ref(false)
|
||||||
|
|
||||||
function toLogin() {
|
function toLogin() {
|
||||||
|
@ -22,8 +22,12 @@ const formData = reactive({
|
|||||||
user_id: '',
|
user_id: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const address = ref('')
|
||||||
|
|
||||||
function getUserInfo() {
|
function getUserInfo() {
|
||||||
userInfoApi().then((res) => {
|
userInfoApi().then((res) => {
|
||||||
|
address.value = '审核通过后商品会自动上架到(' + res.data.village_name + ')'
|
||||||
|
|
||||||
if (res.data.group_id == 2) {
|
if (res.data.group_id == 2) {
|
||||||
isManager.value = true
|
isManager.value = true
|
||||||
userListApi({ code: res.data.village }).then((res) => {
|
userListApi({ code: res.data.village }).then((res) => {
|
||||||
@ -147,6 +151,9 @@ getUserInfo()
|
|||||||
@success="uploadSuccess"
|
@success="uploadSuccess"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
<view>
|
||||||
|
<wd-notice-bar :text="address" wrapable :scrollable="false" prefix="warn-bold" />
|
||||||
|
</view>
|
||||||
</wd-cell-group>
|
</wd-cell-group>
|
||||||
</wd-form>
|
</wd-form>
|
||||||
</view>
|
</view>
|
||||||
|
@ -59,6 +59,11 @@ export const useUserStore = defineStore(
|
|||||||
const getUserInfo = async () => {
|
const getUserInfo = async () => {
|
||||||
const res = await _getUserInfo()
|
const res = await _getUserInfo()
|
||||||
const user = res.data
|
const user = res.data
|
||||||
|
if (res.code === 401) {
|
||||||
|
toast.error('登录已过期,请重新登录')
|
||||||
|
_logout()
|
||||||
|
removeUserInfo()
|
||||||
|
}
|
||||||
const newData = userInfo.value
|
const newData = userInfo.value
|
||||||
newData.isset = !!user.village
|
newData.isset = !!user.village
|
||||||
newData.avatar = user.avatar
|
newData.avatar = user.avatar
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { CustomRequestOptions } from '@/interceptors/request'
|
import type { CustomRequestOptions } from '@/interceptors/request'
|
||||||
|
import { useUserStore } from '@/store'
|
||||||
export function http<T>(options: CustomRequestOptions) {
|
export function http<T>(options: CustomRequestOptions) {
|
||||||
// 1. 返回 Promise 对象
|
// 1. 返回 Promise 对象
|
||||||
return new Promise<IResData<T>>((resolve, reject) => {
|
return new Promise<IResData<T>>((resolve, reject) => {
|
||||||
@ -10,14 +10,15 @@ export function http<T>(options: CustomRequestOptions) {
|
|||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
// #endif
|
// #endif
|
||||||
// 响应成功
|
// 响应成功
|
||||||
success(res) {
|
async success(res) {
|
||||||
// 状态码 2xx,参考 axios 的设计
|
// 状态码 2xx,参考 axios 的设计
|
||||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||||
// 2.1 提取核心数据 res.data
|
// 2.1 提取核心数据 res.data
|
||||||
resolve(res.data as IResData<T>)
|
resolve(res.data as IResData<T>)
|
||||||
} else if (res.statusCode === 401) {
|
} else if (res.statusCode === 401) {
|
||||||
// 401错误 -> 清理用户信息,跳转到登录页
|
// 401错误 -> 清理用户信息,跳转到登录页
|
||||||
// userStore.clearUserInfo()
|
const userStore = useUserStore()
|
||||||
|
await userStore.logout()
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
title: (res.data as IResData<T>).msg || '请登录',
|
title: (res.data as IResData<T>).msg || '请登录',
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { pages, subPackages } from '@/pages.json'
|
import { pages, subPackages } from '@/pages.json'
|
||||||
import { isMpWeixin } from './platform'
|
import { isMpWeixin } from './platform'
|
||||||
|
import { getInfoAPI } from '@/service/crmeb/product.ts'
|
||||||
|
import { http } from '@/utils/http'
|
||||||
export function getLastPage() {
|
export function getLastPage() {
|
||||||
// getCurrentPages() 至少有1个元素,所以不再额外判断
|
// getCurrentPages() 至少有1个元素,所以不再额外判断
|
||||||
// const lastPage = getCurrentPages().at(-1)
|
// const lastPage = getCurrentPages().at(-1)
|
||||||
@ -219,11 +220,38 @@ export function getShopWebUrl(url) {
|
|||||||
import { useUserStore } from '@/store'
|
import { useUserStore } from '@/store'
|
||||||
// const userStore = useUserStore()
|
// const userStore = useUserStore()
|
||||||
// 代登录跳转
|
// 代登录跳转
|
||||||
export function hasLogin() {
|
export async function hasLogin() {
|
||||||
const hasLogin = useUserStore().userInfo.id ? true : false
|
const res = await getInfoAPI()
|
||||||
// console.log(useUserStore().userInfo)
|
// const res = await http.get('/api/user/info', {})
|
||||||
// console.log('是否登录', hasLogin)
|
console.log('hasLogin', res)
|
||||||
// console.log('是否登录sss', useUserStore().userInfo)
|
if (res.code === 401) {
|
||||||
|
const hasLogin = false
|
||||||
|
//强制跳转设置村庄
|
||||||
|
if (hasLogin && !useUserStore().userInfo.isset) {
|
||||||
|
// if (!this.phone) {
|
||||||
|
// uni.showToast({
|
||||||
|
// title: '请填写手机号',
|
||||||
|
// icon: 'none',
|
||||||
|
// })
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
uni.showModal({
|
||||||
|
title: '温馨提示',
|
||||||
|
content: ' 您尚未完善个人信息,是否前往设置你的个人地址?',
|
||||||
|
success: function (res) {
|
||||||
|
if (res.confirm) {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/my/setting?type=1',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//返回是否登录
|
||||||
|
return hasLogin
|
||||||
|
} else {
|
||||||
|
const hasLogin = true
|
||||||
//强制跳转设置村庄
|
//强制跳转设置村庄
|
||||||
if (hasLogin && !useUserStore().userInfo.isset) {
|
if (hasLogin && !useUserStore().userInfo.isset) {
|
||||||
// if (!this.phone) {
|
// if (!this.phone) {
|
||||||
@ -249,3 +277,4 @@ export function hasLogin() {
|
|||||||
//返回是否登录
|
//返回是否登录
|
||||||
return hasLogin
|
return hasLogin
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user