[baozhangchao] před 3 roky
rodič
revize
e94465575b

+ 1
- 0
package.json Zobrazit soubor

@@ -8,6 +8,7 @@
8 8
     "lint": "vue-cli-service lint"
9 9
   },
10 10
   "dependencies": {
11
+    "axios": "^0.26.1",
11 12
     "core-js": "^3.8.3",
12 13
     "two.js": "^0.8.4",
13 14
     "vue": "^3.2.13",

+ 48
- 42
src/App.vue Zobrazit soubor

@@ -1,56 +1,62 @@
1 1
 <template>
2
-  <div ref="el"></div>
3
-  <FireWorkListVue :center="center" :raduis="raduis" ref="firesRef" />
2
+  <div>
3
+    <router-view />
4
+  </div>
5
+  <!-- <div ref="el"></div> -->
6
+  <!-- <FireWorkListVue :center="center" :raduis="raduis" ref="firesRef" /> -->
4 7
 </template>
5 8
 
6 9
 <script setup>
7
-  import { onBeforeUnmount, onMounted, ref } from 'vue';
8
-  import Two from "two.js";
9
-  import FireWorkListVue from './components/FireWorkList.vue';
10
-  import game from "./game";
11
-
12
-  const el = ref()
13
-  const destroyRef = ref()
14
-  const firesRef = ref()
15
-
16
-  const raduis = 150
17
-  const center = {
18
-        x: document.body.offsetWidth / 2,
19
-        y: document.body.offsetHeight / 2,
20
-      }
21
-
22
-
23
-  const gameInit = () => {
24
-    destroyRef.value = game({
25
-      el: el.value,
26
-      center,
27
-      raduis,
28
-      onError: () => {
29
-        alert('oo ~')
30
-      },
31
-      onSuccess: () => {
32
-        alert('你真牛逼')
33
-      },
34
-      onBingo: () => {
35
-        firesRef.value.toggle()
36
-      }
37
-    })
38
-  }
39
-
40
-  onMounted(() => {
41
-    gameInit()
42
-  })
10
+import { onBeforeUnmount, onMounted, ref } from 'vue'
11
+import Two from 'two.js'
12
+import FireWorkListVue from './components/FireWorkList.vue'
13
+import homePage from './components/homePage.vue'
14
+import game from './game'
15
+
16
+const el = ref()
17
+const destroyRef = ref()
18
+const firesRef = ref()
19
+
20
+const raduis = 150
21
+const center = {
22
+  x: document.body.offsetWidth / 2,
23
+  y: document.body.offsetHeight / 2
24
+}
43 25
 
44
-  onBeforeUnmount(() => {
45
-    if (destroyRef.value) {
46
-      destroyRef.value();
26
+const gameInit = () => {
27
+  destroyRef.value = game({
28
+    el: el.value,
29
+    center,
30
+    raduis,
31
+    onError: () => {
32
+      alert('oo ~')
33
+    },
34
+    onSuccess: () => {
35
+      alert('你真牛逼')
36
+    },
37
+    onBingo: () => {
38
+      firesRef.value.toggle()
47 39
     }
48 40
   })
41
+}
49 42
 
43
+onMounted(() => {
44
+  // gameInit()
45
+})
46
+
47
+onBeforeUnmount(() => {
48
+  if (destroyRef.value) {
49
+    destroyRef.value()
50
+  }
51
+})
50 52
 </script>
51 53
 
52 54
 <style>
53
-html, body, #app {
55
+html,
56
+body,
57
+#app {
54 58
   height: 100%;
59
+  padding: 0;
60
+  margin: 0;
55 61
 }
56 62
 </style>

binární
src/assets/BackImage/backHome.jpg Zobrazit soubor


binární
src/assets/BackImage/首页背景.jpg Zobrazit soubor


binární
src/assets/TipsImage/3-4.png Zobrazit soubor


binární
src/assets/shareImage/share.png Zobrazit soubor


binární
src/assets/shareImage/转发预览图.jpg Zobrazit soubor


+ 1
- 0
src/components/FireWorkList.vue Zobrazit soubor

@@ -16,6 +16,7 @@
16 16
 <script setup>
17 17
 import { ref } from 'vue'
18 18
 import FireWork from './FireWork.vue'
19
+
19 20
 const colorList = [
20 21
   '#f5222d',
21 22
   '#d4380d',

+ 141
- 0
src/components/TopRulePage.vue Zobrazit soubor

@@ -0,0 +1,141 @@
1
+<template>
2
+  <BackPage>
3
+    <div v-if="route.query.type =='rule'">
4
+      <div class="ruleImage-box">
5
+        <img :src="ruleImage" />
6
+      </div>
7
+      <div class="IKnow-box">
8
+        <img :src="IKnow" @click="goBack" />
9
+      </div>
10
+    </div>
11
+    <div v-else>
12
+      <div class="ruleImage-box">
13
+        <img :src="TopImage" />
14
+        <div class="Scroll-box">
15
+          <div class="Scroll-box-Content" v-for="(item,index) in Toplist" :key="index">
16
+            <div class="Scroll-box-Content-sum">{{item.sum}}</div>
17
+            <div class="Scroll-box-Content-name">{{item.name}}</div>
18
+            <img
19
+              src="https://cn.bing.com/th?id=OVFT.JaWQdfSE_pzTsHLmGjbsgS&pid=News&w=197&h=112&c=14&rs=2&qlt=90"
20
+            />
21
+            <div class="Scroll-box-Content-time">{{item.tiem}}</div>
22
+          </div>
23
+        </div>
24
+      </div>
25
+      <div class="IKnow-box">
26
+        <img :src="GoHome" @click="goBack" />
27
+      </div>
28
+    </div>
29
+  </BackPage>
30
+</template>
31
+
32
+<script>
33
+import { useRoute, useRouter } from 'vue-router'
34
+import ruleImage from '../assets/TipsImage/3-3.png'
35
+import IKnow from '../assets/ButtonImage/我知道了.png'
36
+import { onMounted } from 'vue'
37
+
38
+import TopImage from '../assets/TipsImage/3-2.png'
39
+import GoHome from '../assets/ButtonImage/返回首页.png'
40
+export default {
41
+  setup() {
42
+    const route = useRoute()
43
+    const router = useRouter()
44
+
45
+    const goBack = () => {
46
+      // 字符串路径
47
+      // router.push('/about')
48
+      router.go(-1)
49
+    }
50
+    onMounted(() => {
51
+      if (route.query.type == 'top') {
52
+      }
53
+      console.log(router)
54
+      // 打印
55
+    })
56
+
57
+    const Toplist = [
58
+      { sum: 2, name: '陈一狗', tiem: '10s' },
59
+      { sum: 45, name: '陈二狗', tiem: '10s' },
60
+      { sum: 5, name: '陈三狗', tiem: '10s' },
61
+      { sum: 4, name: '陈四狗', tiem: '26s' },
62
+      { sum: 2, name: '陈五狗', tiem: '10s' },
63
+      { sum: 1, name: '陈六狗', tiem: '10s' },
64
+      { sum: 2, name: '陈七狗', tiem: '6s' },
65
+      { sum: 2, name: '陈八狗', tiem: '10s' },
66
+      { sum: 2, name: '陈九个狗', tiem: '10s' },
67
+      { sum: 2, name: '陈十狗', tiem: '10m6s' },
68
+      { sum: 2, name: '山二猫', tiem: '10s' },
69
+      { sum: 2, name: '陈把饭狗', tiem: '1h12m33s' }
70
+    ]
71
+    return {
72
+      goBack,
73
+      ruleImage,
74
+      IKnow,
75
+      TopImage,
76
+      GoHome,
77
+      Toplist,
78
+      router,
79
+      route
80
+    }
81
+  }
82
+}
83
+</script>
84
+
85
+<style lang="less" scoped>
86
+.ruleImage-box {
87
+  width: 100vw;
88
+  position: absolute;
89
+  top: 13vh;
90
+  display: flex;
91
+  justify-content: center;
92
+  > img {
93
+    width: 93%;
94
+    height: 100%;
95
+  }
96
+  .Scroll-box {
97
+    width: 80%;
98
+    height: 40vh;
99
+    top: 18vh;
100
+    position: absolute;
101
+    overflow: auto;
102
+    .Scroll-box-Content {
103
+      display: flex;
104
+      border-bottom: 1px dashed rgba(0, 0, 0, 0.3);
105
+      align-items: center;
106
+      height: 7vh;
107
+
108
+      > img {
109
+        width: 10vw;
110
+        height: 5vh;
111
+        border-radius: 50%;
112
+      }
113
+      &-sum {
114
+        // text-align: left;
115
+        // padding-left: 2em;
116
+        width: 25vw;
117
+        text-align: center;
118
+      }
119
+      &-name {
120
+        width: 30vw;
121
+        text-align: left;
122
+      }
123
+      &-time {
124
+        width: 30vw;
125
+        text-align: center;
126
+      }
127
+    }
128
+  }
129
+}
130
+.IKnow-box {
131
+  position: absolute;
132
+  width: 100vw;
133
+  display: flex;
134
+  bottom: 7vh;
135
+
136
+  justify-content: center;
137
+  > img {
138
+    width: 30%;
139
+  }
140
+}
141
+</style>

+ 33
- 0
src/components/componentsPages/BackPage.vue Zobrazit soubor

@@ -0,0 +1,33 @@
1
+
2
+<template>
3
+  <div>
4
+    <!-- :style="HomeStyle" -->
5
+    <div class="index-image">
6
+      <img :src="backHome" class="bg-image" />
7
+      <slot></slot>
8
+    </div>
9
+  </div>
10
+</template>
11
+
12
+<script >
13
+import backHome from '../../assets/BackImage/backHome.jpg'
14
+export default {
15
+  name: 'BackPage',
16
+  setup() {
17
+    return {
18
+      backHome
19
+    }
20
+  }
21
+}
22
+</script>
23
+
24
+<style lang="less" scoped>
25
+.index-image {
26
+  height: 100vh;
27
+  overflow: hidden;
28
+
29
+  .bg-image {
30
+    width: 100vw;
31
+  }
32
+}
33
+</style>

+ 110
- 0
src/components/homePage.vue Zobrazit soubor

@@ -0,0 +1,110 @@
1
+
2
+<template>
3
+  <div>
4
+    <!-- :style="HomeStyle" -->
5
+    <BackPage>
6
+      <!-- <img :src="backHome" class="bg-image" /> -->
7
+
8
+      <div class="TitleBox">
9
+        <img :src="gameTitle" />
10
+      </div>
11
+      <div class="bth-div">
12
+        <!-- <img src="../assets/index/开始游戏.png" class="bth-image" /> -->
13
+        <img :src="gameSatrt" class="bth-image" @click="linkTo" />
14
+        <img :src="gameRule" class="bth-image" @click="goRule" />
15
+      </div>
16
+    </BackPage>
17
+  </div>
18
+</template>
19
+
20
+<script >
21
+import { useRouter } from 'vue-router'
22
+import backHome from '../assets/BackImage/backHome.jpg'
23
+import gameTitle from '../assets/BackImage/首页大标.png'
24
+
25
+import gameSatrt from '../assets/ButtonImage/开始游戏.png'
26
+import gameRule from '../assets/ButtonImage/游戏规则.png'
27
+// import BackPage from './componentsPages/BackPage.vue'
28
+
29
+export default {
30
+  components: {
31
+    // 2.第二步:父组件中注册子组件
32
+  },
33
+  setup() {
34
+    const router = useRouter()
35
+    const HomeStyle = {
36
+      backgroundImage:
37
+        'url(' + require('../assets/BackImage/backHome.jpg') + ')',
38
+      backgroundRepeat: 'no-repeat',
39
+      backgroundSize: '100% auto'
40
+    }
41
+
42
+    const linkTo = () => {
43
+      // 字符串路径
44
+      // router.push('/about')
45
+
46
+      // 带有路径的对象
47
+      router.push({
48
+        path: '/OverPage',
49
+        query: {
50
+          type: 'top'
51
+        }
52
+      })
53
+    }
54
+    const goRule = () => {
55
+      // 字符串路径
56
+      // router.push('/about')
57
+
58
+      // 带有路径的对象
59
+      router.push({
60
+        path: '/TopRulePage',
61
+        query: {
62
+          // type: 'top'
63
+          type: 'rule'
64
+        }
65
+      })
66
+    }
67
+
68
+    return {
69
+      HomeStyle,
70
+      linkTo,
71
+      backHome,
72
+      gameSatrt,
73
+      gameRule,
74
+      gameTitle,
75
+      goRule
76
+    }
77
+  }
78
+}
79
+</script>
80
+
81
+<style lang="less" scoped>
82
+.TitleBox {
83
+  width: 99%;
84
+  position: absolute;
85
+  top: 15vh;
86
+  display: flex;
87
+  justify-content: center;
88
+
89
+  > img {
90
+    width: 85%;
91
+    height: 100%;
92
+  }
93
+}
94
+
95
+.bg-image {
96
+  // width: 100%;
97
+  width: 100vw;
98
+}
99
+.bth-div {
100
+  width: 33vw;
101
+  position: absolute;
102
+  top: 80vh;
103
+  left: 35vw;
104
+  display: flex;
105
+  justify-content: center;
106
+  .bth-image {
107
+    width: 100%;
108
+  }
109
+}
110
+</style>

+ 31
- 1
src/main.js Zobrazit soubor

@@ -1,4 +1,34 @@
1 1
 import { createApp } from 'vue'
2 2
 import App from './App.vue'
3 3
 
4
-createApp(App).mount('#app')
4
+import router from './router'
5
+import BackPage from './components/componentsPages/BackPage.vue'
6
+
7
+// 创建 App实例
8
+const app = createApp(App)
9
+
10
+// redirect()
11
+
12
+// Login().then(e => {
13
+//   new Vue({
14
+//     router,
15
+//     store,
16
+//     render: h => h(App),
17
+//   }).$mount('#app')
18
+
19
+// }).catch(e => {
20
+//   console.error(e)
21
+//   // alert('系统错误, 请刷新重试')
22
+//   // 重试一次
23
+//   redirect(true)
24
+// })
25
+
26
+// 让整个App应用支持路由
27
+app.use(router)
28
+// 将实例挂载到 #app节点上
29
+app.mount('#app')
30
+app.component('BackPage', BackPage)
31
+
32
+// createApp(App).mount('#app')
33
+
34
+

+ 26
- 0
src/router/index.js Zobrazit soubor

@@ -0,0 +1,26 @@
1
+import { createRouter, createWebHistory } from 'vue-router'
2
+import homePage from '../components/homePage.vue'
3
+import OverPage from '../components/OverPage.vue'
4
+import TopRulePage from '../components/TopRulePage.vue'
5
+const routerHistory = createWebHistory()
6
+const routes = [
7
+  {
8
+    path: '/',
9
+    component: homePage
10
+  },
11
+  {
12
+    path: '/OverPage',
13
+    component: OverPage
14
+  },
15
+  {
16
+    path: '/TopRulePage',
17
+    component: TopRulePage
18
+  }
19
+]
20
+
21
+
22
+const router = createRouter({
23
+  history: routerHistory,
24
+  routes
25
+})
26
+export default router

+ 11
- 0
src/utils/api.js Zobrazit soubor

@@ -0,0 +1,11 @@
1
+import request from "./request";
2
+
3
+
4
+
5
+// /**
6
+//  * @login
7
+//  *
8
+//  */
9
+// //
10
+// export const LoginUser = (params, data,) => request(`/api/wx/login?code=${params}`, { method: 'post' })
11
+

+ 173
- 0
src/utils/initial.js Zobrazit soubor

@@ -0,0 +1,173 @@
1
+import request from './request'
2
+import { LoginUser, pv } from './api'
3
+
4
+
5
+
6
+const jsApiList = [
7
+  'updateAppMessageShareData',
8
+  'updateTimelineShareData',
9
+  'onMenuShareTimeline',
10
+  'onMenuShareAppMessage',
11
+  'onMenuShareQQ',
12
+  'onMenuShareWeibo',
13
+  'onMenuShareQZone'
14
+]
15
+
16
+function initSDK (url) {
17
+  request(`/api/wx/jssdk?url=${encodeURIComponent(url)}`)
18
+    .then((res) => {
19
+      window.wx.config({
20
+        debug: process.env.NODE_ENV === 'development', // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
21
+        appId: res.appId, // 必填,公众号的唯一标识
22
+        timestamp: res.timestamp, // 必填,生成签名的时间戳
23
+        nonceStr: res.nonceStr, // 必填,生成签名的随机串
24
+        signature: res.signature, // 必填,签名
25
+        jsApiList // 必填,需要使用的JS接口列表
26
+      })
27
+    })
28
+}
29
+// Vue.use(Vuex)
30
+
31
+/**
32
+ * 分享
33
+ * @param {*} opt
34
+ */
35
+export function share (opt) {
36
+  const { origin, pathname, search } = window.location
37
+  // const defaultLink = origin + pathname
38
+  const defaultImg = `${origin}${pathname}images/share.png`
39
+
40
+  const link = origin + pathname + search // window.location.href
41
+  const imgUrl = opt.imgUrl || defaultImg
42
+
43
+  initSDK(link)
44
+  window.wx.ready(function () {
45
+    jsApiList.map((apiName) => {
46
+      const fn = window.wx[apiName]
47
+      if (typeof fn === 'function') {
48
+        fn({
49
+          title: opt.title || '干洗护理 诠释新生', // 分享标题
50
+          link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
51
+          imgUrl, // 分享图标
52
+          desc: opt.desc || 'COLMO开启干洗护理新时代'
53
+        })
54
+      }
55
+    })
56
+  })
57
+}
58
+
59
+
60
+export function Login () {
61
+  console.log(1);
62
+  const code = process.env.NODE_ENV === 'development' ? '123' : getCode()
63
+
64
+  let isLoaded = false; //定义变量
65
+
66
+
67
+  //执行Timeout 如果一秒内登陆成功,由LoginUser改变isLoaded状态,Timeout 一秒后发现isLoaded为true,则关闭。
68
+  const t = setTimeout(() => {
69
+    console.log(2);
70
+
71
+    if (isLoaded) {
72
+      console.log(isLoaded);
73
+
74
+      hideLoading()
75
+    } else {
76
+      console.log('isLoaded=true');
77
+
78
+      isLoaded = true
79
+    }
80
+    clearTimeout(t);
81
+  }, 2000);
82
+
83
+
84
+  return LoginUser(code).then(e => {
85
+    // PVsum
86
+    console.log(e);
87
+    let userInfo = {
88
+      token: e.token,
89
+      name: e.person.name,
90
+      phone: e.person.phone,
91
+      personId: e.person.personId,
92
+    }
93
+    let location = window.location.href
94
+
95
+    console.log(3, isLoaded);
96
+
97
+
98
+    try {
99
+      pv({ addr: location })
100
+    } catch (error) {
101
+      console.error(error)
102
+    }
103
+    try {
104
+      share({
105
+        title: '干洗护理 诠释新生',
106
+        desc: 'COLMO开启干洗护理新时代'
107
+      })
108
+    } catch (error) {
109
+      console.error(error)
110
+    }
111
+    if (isLoaded) {
112
+      console.log('hideLoading', isLoaded);
113
+      hideLoading()
114
+
115
+
116
+    } else {
117
+      isLoaded = true
118
+
119
+      console.log(4, isLoaded);
120
+
121
+    }
122
+    // setTimeout(() => {
123
+    //   console.log("🚀 ~ file: initial.js ~ line 110 ~ setTimeout ~ isLoaded", isLoaded)
124
+
125
+    //   if (isLoaded) {
126
+    //     hideLoading()
127
+    //   } else {
128
+
129
+    //     isLoaded = true
130
+    //   }
131
+    // }, 5000)
132
+
133
+
134
+    return;
135
+  })
136
+}
137
+
138
+function hideLoading () {
139
+  document.getElementsByClassName('boxZoom')[0].style = "display: none"
140
+
141
+}
142
+
143
+/**
144
+ * 获取 code
145
+ * @returns 
146
+ */
147
+export function getCode () {
148
+  const matched = /[?&]*code=([^&]+)/.exec(location.search)
149
+  if (matched) {
150
+    return decodeURIComponent(matched[1])
151
+  }
152
+}
153
+
154
+/**
155
+ * 跳转授权页面
156
+ */
157
+export function redirect (force) {
158
+  if (process.env.NODE_ENV === 'development') return;
159
+
160
+  const originCode = localStorage.getItem('wxcode');
161
+  const wxfirst = localStorage.getItem('wxfirst') === null;
162
+  const queryCode = getCode();
163
+
164
+  localStorage.setItem('wxcode', queryCode)
165
+  localStorage.setItem('wxfirst', 'not');
166
+
167
+  if (force || wxfirst || !queryCode || queryCode === originCode) {
168
+
169
+    const local = encodeURIComponent(location.origin + location.pathname)
170
+    const url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxd3bab568bc42d1de&redirect_uri=${local}&response_type=code&scope=snsapi_base&state=123#wechat_redirect`
171
+    window.location.href = url;
172
+  }
173
+}

+ 38
- 0
src/utils/request.js Zobrazit soubor

@@ -0,0 +1,38 @@
1
+
2
+import axios from 'axios'
3
+
4
+export const domain = process.env.NODE_ENV === 'development' ? '' : 'http://colmo-service.dianyang.njyunzhi.com'
5
+
6
+export default function (url, options) {
7
+  const { params, header, ...leftOptions } = options || {}
8
+
9
+  return new Promise((resolve, reject) => {
10
+    // const { code, token } = store.state.user
11
+    // let header = {
12
+    //   'X-Authorization-JWT': token,
13
+    // }
14
+    axios.request({
15
+      ...leftOptions,
16
+      url: `${domain}${url}`,
17
+      // header: header,
18
+      headers: header,
19
+    }).then(res => {
20
+      const { code, data, message } = res.data
21
+      if (code === 1000) {
22
+        resolve(data)
23
+      } else {
24
+        reject(res.data)
25
+      }
26
+    }).catch(err => {
27
+      const message = err.message || err.errMsg || err
28
+      console.error("🚀 错误~ err", err)
29
+
30
+
31
+      if (err.message.includes('timeout')) {
32
+        // 请求超时
33
+        // Message.error('请求超时')
34
+      }
35
+      reject(err)
36
+    })
37
+  })
38
+}

+ 8
- 1
yarn.lock Zobrazit soubor

@@ -1939,6 +1939,13 @@ autoprefixer@^10.2.4:
1939 1939
     picocolors "^1.0.0"
1940 1940
     postcss-value-parser "^4.2.0"
1941 1941
 
1942
+axios@^0.26.1:
1943
+  version "0.26.1"
1944
+  resolved "https://registry.yarnpkg.com/axios/-/axios-0.26.1.tgz#1ede41c51fcf51bbbd6fd43669caaa4f0495aaa9"
1945
+  integrity sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==
1946
+  dependencies:
1947
+    follow-redirects "^1.14.8"
1948
+
1942 1949
 babel-loader@^8.2.2:
1943 1950
   version "8.2.4"
1944 1951
   resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-8.2.4.tgz#95f5023c791b2e9e2ca6f67b0984f39c82ff384b"
@@ -3224,7 +3231,7 @@ flatted@^3.1.0:
3224 3231
   resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.5.tgz#76c8584f4fc843db64702a6bd04ab7a8bd666da3"
3225 3232
   integrity sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==
3226 3233
 
3227
-follow-redirects@^1.0.0:
3234
+follow-redirects@^1.0.0, follow-redirects@^1.14.8:
3228 3235
   version "1.14.9"
3229 3236
   resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.9.tgz#dd4ea157de7bfaf9ea9b3fbd85aa16951f78d8d7"
3230 3237
   integrity sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==