Commit d22a26403bdb1a8cd023ec7d2c1b7acde0e82bba

Authored by sanmu
1 parent aa1ded8a

feat: url存在flag才会执行弹窗

components/Header.vue
@@ -54,6 +54,8 @@ const input = ref() @@ -54,6 +54,8 @@ const input = ref()
54 54
55 const router = useRouter() 55 const router = useRouter()
56 56
  57 +const dialog = useDialogStore()
  58 +
57 const handleKeyDown = (e: any) => { 59 const handleKeyDown = (e: any) => {
58 if (e.keyCode == 13) { 60 if (e.keyCode == 13) {
59 handleClick() 61 handleClick()
@@ -77,6 +79,24 @@ const handleTabClick = () => { @@ -77,6 +79,24 @@ const handleTabClick = () => {
77 watchEffect(() => { 79 watchEffect(() => {
78 input.value = productStore.keyword 80 input.value = productStore.keyword
79 }) 81 })
  82 +
  83 +onMounted(() => {
  84 + // 获取url的参数
  85 + const url = window.location.href
  86 + const index = url.indexOf('?')
  87 + if (index !== -1) {
  88 + const params = url.slice(index + 1).split('&')
  89 + const obj: any = {}
  90 + params.forEach((item) => {
  91 + const arr = item.split('=')
  92 + obj[arr[0]] = arr[1]
  93 + })
  94 + // 获取dialog的状态
  95 + if (obj.flag) {
  96 + dialog.updateDialog(true)
  97 + }
  98 + }
  99 +})
80 </script> 100 </script>
81 101
82 <style lang="scss" scoped> 102 <style lang="scss" scoped>
components/MobileProductDetail.vue
@@ -31,8 +31,7 @@ @@ -31,8 +31,7 @@
31 </v-col> 31 </v-col>
32 </v-row> 32 </v-row>
33 <div v-if="info.ticketTypes?.length" class="py-4 mx-4 bg-white rounded-lg tw-flex tw-flex-wrap tw-justify-around"> 33 <div v-if="info.ticketTypes?.length" class="py-4 mx-4 bg-white rounded-lg tw-flex tw-flex-wrap tw-justify-around">
34 - <v-sheet v-for="item in info.ticketTypes || []" :key="item.rank" rounded="lg" border  
35 - class="tw-w-[40%] mb-4"> 34 + <v-sheet v-for="item in info.ticketTypes || []" :key="item.rank" rounded="lg" border class="tw-w-[40%] mb-4">
36 <div 35 <div
37 class="tw-bg-[#dcecfa] tw-h-[64px] !tw-leading-[64px] rounded-lg rounded-b-0 pa-2 tw-text-center text-h6 tw-overflow-hidden tw-text-ellipsis"> 36 class="tw-bg-[#dcecfa] tw-h-[64px] !tw-leading-[64px] rounded-lg rounded-b-0 pa-2 tw-text-center text-h6 tw-overflow-hidden tw-text-ellipsis">
38 {{ item.typeName }} 37 {{ item.typeName }}
@@ -111,25 +110,9 @@ const props = defineProps&lt;{ @@ -111,25 +110,9 @@ const props = defineProps&lt;{
111 info: Product 110 info: Product
112 }>() 111 }>()
113 const info = props.info 112 const info = props.info
114 -onMounted(() => {  
115 - dialogStore.updateDialog(true)  
116 -})  
117 -// getDetail({ id: route.params.id as string }).then((res) => {  
118 -  
119 -// const doc = document as any  
120 -// const head = doc.getElementsByTagName('head')  
121 -// const meta = doc.createElement('meta')  
122 -// document.title = data.name  
123 -// doc  
124 -// .querySelector('meta[name="keywords"]')  
125 -// .setAttribute('content', data.metakeywords || data.name)  
126 -// doc  
127 -// .querySelector('meta[name="description"]')  
128 -// .setAttribute('content', data.metadescription || data.name)  
129 -// head[0].appendChild(meta)  
130 -// }) 113 +// onMounted(() => {
  114 +// dialogStore.updateDialog(true)
131 // }) 115 // })
132 -  
133 const tab = ref(0) 116 const tab = ref(0)
134 const slide = ref(0) 117 const slide = ref(0)
135 </script> 118 </script>
components/ProductDetail.vue
@@ -117,10 +117,9 @@ const props = defineProps&lt;{ @@ -117,10 +117,9 @@ const props = defineProps&lt;{
117 }>() 117 }>()
118 const info = props.info 118 const info = props.info
119 119
120 -onMounted(() => {  
121 - console.log('%c [ ]-124', 'font-size:13px; background:pink; color:#bf2c9f;', 111)  
122 - dialogStore.updateDialog(true)  
123 -}) 120 +// onMounted(() => {
  121 +// dialogStore.updateDialog(true)
  122 +// })
124 123
125 const tab = ref(0) 124 const tab = ref(0)
126 const slide = ref(0) 125 const slide = ref(0)
stores/dialog.ts
@@ -5,7 +5,6 @@ export const useDialogStore = defineStore(&#39;dialog&#39;, () =&gt; { @@ -5,7 +5,6 @@ export const useDialogStore = defineStore(&#39;dialog&#39;, () =&gt; {
5 const dialog = ref(false) 5 const dialog = ref(false)
6 6
7 const updateDialog = (value: boolean) => { 7 const updateDialog = (value: boolean) => {
8 - console.log('%c [ value ]-8', 'font-size:13px; background:pink; color:#bf2c9f;', value)  
9 dialog.value = value 8 dialog.value = value
10 } 9 }
11 10