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>
|
||||
<RouteCache />
|
||||
<RouteCache />
|
||||
<div id="loading" v-if="loading">
|
||||
<van-loading size="10rem" color="#0094ff"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import RouteCache from '@/components/RouteCache.vue'
|
||||
import { computed } from 'vue'
|
||||
import { useOverallStore } from '@/stores'
|
||||
|
||||
const overallStore = useOverallStore()
|
||||
const loading = computed(() => overallStore.loading)
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
@@ -41,4 +49,16 @@ import RouteCache from '@/components/RouteCache.vue'
|
||||
}
|
||||
/* 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>
|
||||
|
||||
@@ -13,6 +13,7 @@ import 'vant/lib/index.css'
|
||||
import { Locale } from 'vant';
|
||||
import enUS from 'vant/es/locale/lang/en-US';
|
||||
Locale.use('en-US', enUS);
|
||||
import { Loading } from 'vant';
|
||||
|
||||
|
||||
import flexible from "./utils/flexible.js";
|
||||
@@ -32,6 +33,7 @@ document.addEventListener('touchend', function(event) {
|
||||
const app = createApp(App)
|
||||
app.use(router)
|
||||
.use(store)
|
||||
.use(Loading)
|
||||
.component("SvgIcon", SvgIcon)
|
||||
.mount('#app')
|
||||
|
||||
|
||||
@@ -5,4 +5,5 @@ const store = createPinia()
|
||||
// 使用持久化插件(全局持久化)
|
||||
store.use(createPersistedState())
|
||||
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,
|
||||
oldId:-1,//表示从生成页面返回回来,需要调整的样式id
|
||||
},
|
||||
model:{
|
||||
id:-1,
|
||||
}
|
||||
},
|
||||
queryList:[]
|
||||
}
|
||||
@@ -35,6 +38,11 @@ export const useGenerateStore = defineStore({
|
||||
if(data.id == this.userData.style.oldId){
|
||||
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 { showToast, showLoading, showConfirmDialog, closeToast } from 'vant'
|
||||
import { showToast, showNotify, showConfirmDialog, closeToast } from 'vant'
|
||||
import { useUserInfoStore } from '@/stores/modules/userInfo'
|
||||
const store = useUserInfoStore()
|
||||
import { getLocal } from '@/utils/local'
|
||||
import router from '@/router/index'
|
||||
import { useOverallStore } from '@/stores'
|
||||
|
||||
|
||||
// 创建axios实例
|
||||
console.log(import.meta.env.VITE_APP_URL)
|
||||
console.log(import.meta.env.VITE_APP_URL,123)
|
||||
const service = axios.create({
|
||||
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) {
|
||||
closeLoading()
|
||||
}
|
||||
|
||||
const res = response.data
|
||||
// 处理异常的情况
|
||||
if (res.errCode != 0) {
|
||||
@@ -66,19 +68,7 @@ service.interceptors.response.use(
|
||||
type: 'fail',
|
||||
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'))
|
||||
} else {
|
||||
// 默认只返回data,不返回状态码和message
|
||||
@@ -92,6 +82,20 @@ service.interceptors.response.use(
|
||||
}
|
||||
},
|
||||
(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)
|
||||
// 关闭loading
|
||||
if (error.config?.loading) {
|
||||
@@ -149,23 +153,18 @@ function removePending(config: any) {
|
||||
}
|
||||
}
|
||||
// ----------------------------------loading的函数-------------------------------
|
||||
const LoadingInstance: { _target: any; _count: number } = {
|
||||
_target: null, // 保存Loading实例
|
||||
const LoadingInstance: { _count: number } = {
|
||||
_count: 0
|
||||
}
|
||||
function openLoading(loadingDom: any) {
|
||||
LoadingInstance._target = showLoading({
|
||||
message: '数据正在加载中',
|
||||
forbidClick: true,
|
||||
background: 'rgba(25, 32, 53, 1)'
|
||||
})
|
||||
useOverallStore().setLoading(true)
|
||||
}
|
||||
function closeLoading() {
|
||||
if (LoadingInstance._count > 0) LoadingInstance._count--
|
||||
if (LoadingInstance._count === 0) {
|
||||
LoadingInstance._target?.close()
|
||||
LoadingInstance._target = null
|
||||
useOverallStore().setLoading(false)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default service
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
<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 { useRouter } from 'vue-router'
|
||||
import imgReturn from '@/assets/images/workshop/posture/posture_1.png'
|
||||
import { useGenerateStore } from '@/stores'
|
||||
const router = useRouter()
|
||||
//const props = defineProps({
|
||||
//})
|
||||
const emit = defineEmits([
|
||||
'view-type'
|
||||
])
|
||||
const generateStore = useGenerateStore()
|
||||
let data = reactive({
|
||||
modelList:
|
||||
[
|
||||
@@ -38,11 +40,11 @@ let data = reactive({
|
||||
},
|
||||
|
||||
],
|
||||
selectedModelId: null,
|
||||
selectModel:computed(()=>generateStore.userData.model),
|
||||
})
|
||||
|
||||
const setSelectedModelId = (item)=>{
|
||||
data.selectedModelId = item.id;
|
||||
generateStore.selectModel(item)
|
||||
}
|
||||
onMounted(()=>{
|
||||
emit('view-type', 1)
|
||||
@@ -50,12 +52,10 @@ onMounted(()=>{
|
||||
const toProduct = ()=>{
|
||||
router.push({ path: 'product' })
|
||||
}
|
||||
onMounted(()=>{
|
||||
})
|
||||
onUnmounted(()=>{
|
||||
})
|
||||
defineExpose({})
|
||||
const { modelList, selectedModelId } = toRefs(data);
|
||||
const { modelList, selectModel } = toRefs(data);
|
||||
</script>
|
||||
<template>
|
||||
<header-title style-type="2" />
|
||||
@@ -72,7 +72,7 @@ const { modelList, selectedModelId } = toRefs(data);
|
||||
<div class="modelList">
|
||||
<div v-for="item in modelList" :key="item.id" class="item" @click.stop="setSelectedModelId(item)">
|
||||
<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" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user