Merge branch 'master' of https://gitee.com/lvYeJu/lane-crawford-3
This commit is contained in:
@@ -1 +1 @@
|
|||||||
VITE_APP_URL = ''
|
VITE_APP_URL = http://18.167.251.121:10096
|
||||||
22
src/App.vue
22
src/App.vue
@@ -1,9 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
<RouteCache />
|
<RouteCache />
|
||||||
|
<div id="loading" v-if="loading">
|
||||||
|
<van-loading size="10rem" color="#0094ff"/>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import RouteCache from '@/components/RouteCache.vue'
|
import RouteCache from '@/components/RouteCache.vue'
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import { useOverallStore } from '@/stores'
|
||||||
|
|
||||||
|
const overallStore = useOverallStore()
|
||||||
|
const loading = computed(() => overallStore.loading)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
@@ -41,4 +49,16 @@ import RouteCache from '@/components/RouteCache.vue'
|
|||||||
}
|
}
|
||||||
/* touch-action: none; */
|
/* touch-action: none; */
|
||||||
}
|
}
|
||||||
|
#loading {
|
||||||
|
position: fixed;
|
||||||
|
z-index: 999999999;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: rgba(0, 0, 0, 0.3);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import 'vant/lib/index.css'
|
|||||||
import { Locale } from 'vant';
|
import { Locale } from 'vant';
|
||||||
import enUS from 'vant/es/locale/lang/en-US';
|
import enUS from 'vant/es/locale/lang/en-US';
|
||||||
Locale.use('en-US', enUS);
|
Locale.use('en-US', enUS);
|
||||||
|
import { Loading } from 'vant';
|
||||||
|
|
||||||
|
|
||||||
import flexible from "./utils/flexible.js";
|
import flexible from "./utils/flexible.js";
|
||||||
@@ -32,6 +33,7 @@ document.addEventListener('touchend', function(event) {
|
|||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
app.use(router)
|
app.use(router)
|
||||||
.use(store)
|
.use(store)
|
||||||
|
.use(Loading)
|
||||||
.component("SvgIcon", SvgIcon)
|
.component("SvgIcon", SvgIcon)
|
||||||
.mount('#app')
|
.mount('#app')
|
||||||
|
|
||||||
|
|||||||
@@ -5,4 +5,5 @@ const store = createPinia()
|
|||||||
// 使用持久化插件(全局持久化)
|
// 使用持久化插件(全局持久化)
|
||||||
store.use(createPersistedState())
|
store.use(createPersistedState())
|
||||||
export default store
|
export default store
|
||||||
export * from './modules/generate'
|
export * from './modules/generate'
|
||||||
|
export * from './modules/overall'
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ export const useGenerateStore = defineStore({
|
|||||||
id:-1,
|
id:-1,
|
||||||
oldId:-1,//表示从生成页面返回回来,需要调整的样式id
|
oldId:-1,//表示从生成页面返回回来,需要调整的样式id
|
||||||
},
|
},
|
||||||
|
model:{
|
||||||
|
id:-1,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
queryList:[]
|
queryList:[]
|
||||||
}
|
}
|
||||||
@@ -35,6 +38,11 @@ export const useGenerateStore = defineStore({
|
|||||||
if(data.id == this.userData.style.oldId){
|
if(data.id == this.userData.style.oldId){
|
||||||
this.userData.style.oldId = -1
|
this.userData.style.oldId = -1
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
//模特相关
|
||||||
|
selectModel(data:any){
|
||||||
|
this.userData.model.id = data.id
|
||||||
|
console.log(this.userData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
19
src/stores/modules/overall.ts
Normal file
19
src/stores/modules/overall.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
// 每一个存储的模块,命名规则use开头,store结尾
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
export const useOverallStore = defineStore({
|
||||||
|
id: 'overall', // 必须指明唯一的pinia仓库的id
|
||||||
|
state: () => {
|
||||||
|
return {
|
||||||
|
loading:false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getters: {
|
||||||
|
// doubleCount: (state) => state.num * 2
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
// 全局loading
|
||||||
|
setLoading(data:boolean){
|
||||||
|
this.loading = data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { showToast, showLoading, showConfirmDialog, closeToast } from 'vant'
|
import { showToast, showNotify, showConfirmDialog, closeToast } from 'vant'
|
||||||
import { useUserInfoStore } from '@/stores/modules/userInfo'
|
import { useUserInfoStore } from '@/stores/modules/userInfo'
|
||||||
const store = useUserInfoStore()
|
const store = useUserInfoStore()
|
||||||
import { getLocal } from '@/utils/local'
|
import { getLocal } from '@/utils/local'
|
||||||
|
import router from '@/router/index'
|
||||||
|
import { useOverallStore } from '@/stores'
|
||||||
|
|
||||||
|
|
||||||
// 创建axios实例
|
// 创建axios实例
|
||||||
console.log(import.meta.env.VITE_APP_URL)
|
console.log(import.meta.env.VITE_APP_URL,123)
|
||||||
const service = axios.create({
|
const service = axios.create({
|
||||||
baseURL: import.meta.env.VITE_APP_URL, // api的base_url
|
baseURL: import.meta.env.VITE_APP_URL, // api的base_url
|
||||||
// baseURL: import.meta.env.VITE_APP_URL, // api的base_url
|
// baseURL: import.meta.env.VITE_APP_URL, // api的base_url
|
||||||
@@ -57,7 +60,6 @@ service.interceptors.response.use(
|
|||||||
if (response.config.loading) {
|
if (response.config.loading) {
|
||||||
closeLoading()
|
closeLoading()
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = response.data
|
const res = response.data
|
||||||
// 处理异常的情况
|
// 处理异常的情况
|
||||||
if (res.errCode != 0) {
|
if (res.errCode != 0) {
|
||||||
@@ -66,19 +68,7 @@ service.interceptors.response.use(
|
|||||||
type: 'fail',
|
type: 'fail',
|
||||||
duration: 5000
|
duration: 5000
|
||||||
})
|
})
|
||||||
// 403:非法的token; 50012:其他客户端登录了; 401:Token 过期了;
|
|
||||||
if (res.errCode === 403 || res.errCode === 50012 || res.errCode === 401) {
|
|
||||||
showConfirmDialog({
|
|
||||||
title: '确定登出',
|
|
||||||
message: '你已被登出,可以取消继续留在该页面,或者重新登录',
|
|
||||||
confirmButtonText: '重新登录',
|
|
||||||
cancelButtonText: '取消'
|
|
||||||
}).then(() => {
|
|
||||||
store.loginOut().then(() => {
|
|
||||||
location.reload() // 为了重新实例化vue-router对象 避免bug
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return Promise.reject(new Error('error'))
|
return Promise.reject(new Error('error'))
|
||||||
} else {
|
} else {
|
||||||
// 默认只返回data,不返回状态码和message
|
// 默认只返回data,不返回状态码和message
|
||||||
@@ -92,6 +82,20 @@ service.interceptors.response.use(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
|
if(error?.response?.status === 401){//如果是记录浏览器页面就不跳转login
|
||||||
|
// showConfirmDialog({
|
||||||
|
// title: '确定登出',
|
||||||
|
// message: '你已被登出,可以取消继续留在该页面,或者重新登录',
|
||||||
|
// confirmButtonText: '重新登录',
|
||||||
|
// cancelButtonText: '取消'
|
||||||
|
// }).then(() => {
|
||||||
|
// store.loginOut().then(() => {
|
||||||
|
// location.reload() // 为了重新实例化vue-router对象 避免bug
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
router.replace('/login')
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
error.config && removePending(error.config)
|
error.config && removePending(error.config)
|
||||||
// 关闭loading
|
// 关闭loading
|
||||||
if (error.config?.loading) {
|
if (error.config?.loading) {
|
||||||
@@ -149,23 +153,18 @@ function removePending(config: any) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----------------------------------loading的函数-------------------------------
|
// ----------------------------------loading的函数-------------------------------
|
||||||
const LoadingInstance: { _target: any; _count: number } = {
|
const LoadingInstance: { _count: number } = {
|
||||||
_target: null, // 保存Loading实例
|
|
||||||
_count: 0
|
_count: 0
|
||||||
}
|
}
|
||||||
function openLoading(loadingDom: any) {
|
function openLoading(loadingDom: any) {
|
||||||
LoadingInstance._target = showLoading({
|
useOverallStore().setLoading(true)
|
||||||
message: '数据正在加载中',
|
|
||||||
forbidClick: true,
|
|
||||||
background: 'rgba(25, 32, 53, 1)'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
function closeLoading() {
|
function closeLoading() {
|
||||||
if (LoadingInstance._count > 0) LoadingInstance._count--
|
if (LoadingInstance._count > 0) LoadingInstance._count--
|
||||||
if (LoadingInstance._count === 0) {
|
if (LoadingInstance._count === 0) {
|
||||||
LoadingInstance._target?.close()
|
useOverallStore().setLoading(false)
|
||||||
LoadingInstance._target = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default service
|
export default service
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, onUnmounted, reactive, toRefs } from "vue";
|
import { onMounted, onUnmounted, reactive, toRefs, computed } from "vue";
|
||||||
import HeaderTitle from '@/components/HeaderTitle.vue'
|
import HeaderTitle from '@/components/HeaderTitle.vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import imgReturn from '@/assets/images/workshop/posture/posture_1.png'
|
import imgReturn from '@/assets/images/workshop/posture/posture_1.png'
|
||||||
|
import { useGenerateStore } from '@/stores'
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
//const props = defineProps({
|
//const props = defineProps({
|
||||||
//})
|
//})
|
||||||
const emit = defineEmits([
|
const emit = defineEmits([
|
||||||
'view-type'
|
'view-type'
|
||||||
])
|
])
|
||||||
|
const generateStore = useGenerateStore()
|
||||||
let data = reactive({
|
let data = reactive({
|
||||||
modelList:
|
modelList:
|
||||||
[
|
[
|
||||||
@@ -38,11 +40,11 @@ let data = reactive({
|
|||||||
},
|
},
|
||||||
|
|
||||||
],
|
],
|
||||||
selectedModelId: null,
|
selectModel:computed(()=>generateStore.userData.model),
|
||||||
})
|
})
|
||||||
|
|
||||||
const setSelectedModelId = (item)=>{
|
const setSelectedModelId = (item)=>{
|
||||||
data.selectedModelId = item.id;
|
generateStore.selectModel(item)
|
||||||
}
|
}
|
||||||
onMounted(()=>{
|
onMounted(()=>{
|
||||||
emit('view-type', 1)
|
emit('view-type', 1)
|
||||||
@@ -50,12 +52,10 @@ onMounted(()=>{
|
|||||||
const toProduct = ()=>{
|
const toProduct = ()=>{
|
||||||
router.push({ path: 'product' })
|
router.push({ path: 'product' })
|
||||||
}
|
}
|
||||||
onMounted(()=>{
|
|
||||||
})
|
|
||||||
onUnmounted(()=>{
|
onUnmounted(()=>{
|
||||||
})
|
})
|
||||||
defineExpose({})
|
defineExpose({})
|
||||||
const { modelList, selectedModelId } = toRefs(data);
|
const { modelList, selectModel } = toRefs(data);
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<header-title style-type="2" />
|
<header-title style-type="2" />
|
||||||
@@ -72,7 +72,7 @@ const { modelList, selectedModelId } = toRefs(data);
|
|||||||
<div class="modelList">
|
<div class="modelList">
|
||||||
<div v-for="item in modelList" :key="item.id" class="item" @click.stop="setSelectedModelId(item)">
|
<div v-for="item in modelList" :key="item.id" class="item" @click.stop="setSelectedModelId(item)">
|
||||||
<img :src="item.imgUrl" alt="">
|
<img :src="item.imgUrl" alt="">
|
||||||
<div class="icon" v-if="item.id == selectedModelId">
|
<div class="icon" v-if="item.id == selectModel.id">
|
||||||
<SvgIcon name="modelSelected" size="60" />
|
<SvgIcon name="modelSelected" size="60" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user