yuantianjiao 6 år sedan
förälder
incheckning
1e0d8c588b

+ 1
- 1
build/webpack.base.conf.js Visa fil

@@ -71,7 +71,7 @@ module.exports = {
71 71
         test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
72 72
         loader: 'url-loader',
73 73
         options: {
74
-          limit: 10000,
74
+          limit: 10000000,
75 75
           name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
76 76
         }
77 77
       }

+ 4
- 1
package.json Visa fil

@@ -46,6 +46,7 @@
46 46
     "friendly-errors-webpack-plugin": "^1.6.1",
47 47
     "html-webpack-plugin": "^2.30.1",
48 48
     "node-notifier": "^5.1.2",
49
+    "node-sass": "^4.9.3",
49 50
     "optimize-css-assets-webpack-plugin": "^3.2.0",
50 51
     "ora": "^1.2.0",
51 52
     "portfinder": "^1.0.13",
@@ -53,12 +54,14 @@
53 54
     "postcss-loader": "^2.0.8",
54 55
     "postcss-url": "^7.2.1",
55 56
     "rimraf": "^2.6.0",
57
+    "sass-loader": "^7.1.0",
56 58
     "semver": "^5.3.0",
57 59
     "shelljs": "^0.7.6",
58 60
     "uglifyjs-webpack-plugin": "^1.1.1",
59 61
     "url-loader": "^0.5.8",
62
+    "vue-lazyload": "^1.2.6",
60 63
     "vue-loader": "^13.3.0",
61
-    "vue-style-loader": "^3.0.1",
64
+    "vue-style-loader": "^3.1.2",
62 65
     "vue-template-compiler": "^2.5.2",
63 66
     "webpack": "^3.6.0",
64 67
     "webpack-bundle-analyzer": "^2.9.0",

src/assets/font/hkhb.ttf → src/assets/hkhb.ttf Visa fil


+ 1
- 1
src/config/index.js Visa fil

@@ -1,6 +1,6 @@
1 1
 export default {
2 2
   appid: 'wx7320287e057bbeee',
3
-  redirect_uri: encodeURIComponent(window.location.href),
3
+  redirect_uri: encodeURIComponent(window.location.href + '#/index'),
4 4
   response_type: 'code',
5 5
   scope: 'snsapi_userinfo',
6 6
   state: '12313'

+ 15
- 0
src/page/getCode/index.vue Visa fil

@@ -0,0 +1,15 @@
1
+<template>
2
+  <div></div>
3
+</template>
4
+
5
+<script>
6
+import wechatConfig from '@/config/index'
7
+export default {
8
+  created () {
9
+    let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${wechatConfig.appid}&redirect_uri=${wechatConfig.redirect_uri}&response_type=${wechatConfig.response_type}&scope=${wechatConfig.scope}&state=${wechatConfig.state}#wechat_redirect`
10
+    window.location.href = url
11
+  }
12
+}
13
+</script>
14
+ <style lang="scss" scoped>
15
+</style>

+ 8
- 2
src/page/index/index.vue Visa fil

@@ -167,9 +167,11 @@ export default {
167 167
     }
168 168
   },
169 169
   created () {
170
-    this.getUserInfo({ luckdrawid: this.lotteryId }).then((res) => {
170
+    console.log(this.toolClass.UrlSearch(location.search))
171
+    localStorage.setItem('code', this.toolClass.UrlSearch(location.search).code)
172
+    this.code = localStorage.getItem('code')
173
+    this.getUserInfo({ code: this.code, luckdrawid: this.lotteryId }).then((res) => {
171 174
       this.data.userInfo = this.userInfo
172
-      console.log(this.data.userInfo)
173 175
       if (this.data.userInfo.record) {
174 176
         this.winning = this.data.userInfo.record.PrizeName
175 177
         this.showDialog = true
@@ -276,5 +278,9 @@ export default {
276 278
 </script>
277 279
 
278 280
 <style lang="scss" scoped>
281
+@font-face {
282
+  font-family: myFont;
283
+  src: url("../../assets/hkhb.ttf")
284
+}
279 285
 @import "page.scss";
280 286
 </style>

+ 1
- 4
src/page/index/page.scss Visa fil

@@ -1,7 +1,4 @@
1
-@font-face {
2
-  font-family: myFont;
3
-  src: url("../../assets/font/hkhb.ttf")
4
-}
1
+// @import  '../../assets/hkhb.ttf'
5 2
 body * {
6 3
   font-family: myFont;
7 4
 }

+ 2
- 1
src/page/lotteryList/index.vue Visa fil

@@ -31,7 +31,8 @@ export default {
31 31
     })
32 32
   },
33 33
   created () {
34
-    this.getUserInfo({ luckdrawid: this.lotteryId }).then((res) => {
34
+    this.code = localStorage.getItem('code')
35
+    this.getUserInfo({ code: this.code, luckdrawid: this.lotteryId }).then((res) => {
35 36
       this.data.userInfo = this.userInfo
36 37
       this.getLotteryList({ userid: this.data.userInfo.user.Id }).then((res) => {
37 38
         this.data.list = this.list

+ 7
- 4
src/router/index.js Visa fil

@@ -1,5 +1,6 @@
1 1
 import Vue from 'vue'
2 2
 import Router from 'vue-router'
3
+import getCode from '@/page/getCode'
3 4
 import index from '@/page/index'
4 5
 import lotteryList from '@/page/lotteryList'
5 6
 import lotteryDetail from '@/page/lotteryDetail'
@@ -10,11 +11,13 @@ export default new Router({
10 11
   routes: [
11 12
     {
12 13
       path: '/',
14
+      name: 'getCode',
15
+      component: getCode
16
+    },
17
+    {
18
+      path: '/index',
13 19
       name: 'index',
14
-      component: index,
15
-      meta: {
16
-        id: '1'
17
-      }
20
+      component: index
18 21
     },
19 22
     {
20 23
       path: '/lotteryList',

+ 10
- 14
src/store/app.js Visa fil

@@ -5,20 +5,16 @@ const http = {}
5 5
 // 请求数据
6 6
 http.getUserInfo = (data) => {
7 7
   return new Promise((resolve, reject) => {
8
-    Ajax(api.system.getCode.url, {
9
-      method: api.system.getCode.method
10
-    }).then((result) => {
11
-      Ajax(api.lottery.userInfo.url, {
12
-        method: api.lottery.userInfo.method,
13
-        queryData: {
14
-          code: result.code,
15
-          luckdrawid: data.luckdrawid
16
-        }
17
-      }).then(res => {
18
-        resolve(res)
19
-      }).catch((err) => {
20
-        reject(err)
21
-      })
8
+    Ajax(api.lottery.userInfo.url, {
9
+      method: api.lottery.userInfo.method,
10
+      queryData: {
11
+        code: data.code,
12
+        luckdrawid: data.luckdrawid
13
+      }
14
+    }).then(res => {
15
+      resolve(res)
16
+    }).catch((err) => {
17
+      reject(err)
22 18
     })
23 19
   })
24 20
 }

+ 1
- 8
src/util/api.js Visa fil

@@ -1,5 +1,4 @@
1
-import wechatConfig from '@/config/index'
2
-const baseUrl = '/api'
1
+const baseUrl = '/check-api'
3 2
 const wechat = ''
4 3
 
5 4
 const $api = {
@@ -28,12 +27,6 @@ const $api = {
28 27
       method: 'get',
29 28
       url: `${baseUrl}${wechat}/user/record/:id`
30 29
     }
31
-  },
32
-  system: {
33
-    getCode: {
34
-      method: 'get',
35
-      url: `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${wechatConfig.appid}&redirect_uri=${wechatConfig.redirect_uri}&response_type=${wechatConfig.response_type}&scope=${wechatConfig.scope}&state=${wechatConfig.state}#wechat_redirect`
36
-    }
37 30
   }
38 31
 }
39 32
 export default $api

+ 17
- 0
src/util/util.js Visa fil

@@ -1,3 +1,4 @@
1
+import wechatConfig from '@/config/index'
1 2
 const toolClass = {
2 3
   dateFormat: (timestamp) => {
3 4
     let date = new Date(timestamp)
@@ -19,6 +20,22 @@ const toolClass = {
19 20
       min = '0' + min
20 21
     }
21 22
     return y + '-' + m + '-' + d + ' ' + h + ':' + min
23
+  },
24
+  UrlSearch: (urls) => {
25
+    let url = urls // 获取url中"?"符后的字串
26
+    let theRequest = {}
27
+    if (url.indexOf('?') !== -1) {
28
+      let str = url.substr(1)
29
+      let strs = str.split('&')
30
+      for (var i = 0; i < strs.length; i++) {
31
+        theRequest[strs[i].split('=')[0]] = unescape(strs[i].split('=')[1])
32
+      }
33
+    }
34
+    return theRequest
35
+  },
36
+  getCode: () => {
37
+    let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${wechatConfig.appid}&redirect_uri=${wechatConfig.redirect_uri}&response_type=${wechatConfig.response_type}&scope=${wechatConfig.scope}&state=${wechatConfig.state}#wechat_redirect`
38
+    window.location.href = url
22 39
   }
23 40
 }
24 41