李志伟 3 år sedan
förälder
incheckning
514b2aec22

+ 1
- 0
package.json Visa fil

11
     "lint": "vue-cli-service lint"
11
     "lint": "vue-cli-service lint"
12
   },
12
   },
13
   "dependencies": {
13
   "dependencies": {
14
+    "axios": "^0.24.0",
14
     "core-js": "^3.6.4",
15
     "core-js": "^3.6.4",
15
     "lib-flexible": "^0.3.2",
16
     "lib-flexible": "^0.3.2",
16
     "lodash": "^4.17.15",
17
     "lodash": "^4.17.15",

+ 1
- 0
public/index.html Visa fil

11
       <link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="stylesheet" />
11
       <link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="stylesheet" />
12
 	  <% } %> -->
12
 	  <% } %> -->
13
     <title><%= webpackConfig.name %></title>
13
     <title><%= webpackConfig.name %></title>
14
+    <script type="text/javascript" src="http://res2.wx.qq.com/open/js/jweixin-1.6.0.js "></script>
14
   </head>
15
   </head>
15
   <body>
16
   <body>
16
     <noscript>
17
     <noscript>

+ 1
- 0
src/App.vue Visa fil

4
   </div>
4
   </div>
5
 </template>
5
 </template>
6
 <script>
6
 <script>
7
+
7
 export default {
8
 export default {
8
   name: 'App'
9
   name: 'App'
9
 }
10
 }

+ 1
- 0
src/utils/request.js Visa fil

1
+// import axios from 'axios'

+ 52
- 0
src/utils/wx.js Visa fil

1
+// import request from '@/utils/request'
2
+
3
+function request(url, options) {
4
+  return fetch(url, options)
5
+    .then(response => response.json())
6
+    .then(data => {
7
+      if (data.code === 1000) return data.data
8
+      return Promise.reject(data.message)
9
+    })
10
+}
11
+
12
+function init() {
13
+  const url = location.origin + location.pathname
14
+  request(`https://api.h5.njyunzhi.com/mp/jssdk?url=${encodeURIComponent(url)}`).then((res) => {
15
+    window.wx.config({
16
+      debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
17
+      appId: res.appId, // 必填,公众号的唯一标识
18
+      timestamp: res.timestamp, // 必填,生成签名的时间戳
19
+      nonceStr: res.nonceStr, // 必填,生成签名的随机串
20
+      signature: res.signature, // 必填,签名
21
+      jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData'] // 必填,需要使用的JS接口列表
22
+    })
23
+  })
24
+}
25
+
26
+init()
27
+
28
+/**
29
+ * 分享到好友或者QQ
30
+ * @param {*} opt
31
+ */
32
+export function shareData(opt) {
33
+  window.wx.updateAppMessageShareData({
34
+    title: opt.title, // 分享标题
35
+    desc: opt.desc, // 分享描述
36
+    link: opt.link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
37
+    imgUrl: opt.imgUrl // 分享图标
38
+  })
39
+}
40
+
41
+export function shareTimeline(opt) {
42
+  window.wx.updateTimelineShareData({
43
+    title: opt.title, // 分享标题
44
+    link: opt.link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
45
+    imgUrl: opt.imgUrl // 分享图标
46
+  })
47
+}
48
+
49
+export function share(opt) {
50
+  shareData(opt)
51
+  shareTimeline(opt)
52
+}

+ 7
- 0
src/views/apartment.vue Visa fil

25
 </template>
25
 </template>
26
 
26
 
27
 <script>
27
 <script>
28
+import { share } from '@/utils/wx'
29
+
28
 const backSignImg = require('@/assets/images/apartment/backSign.png')
30
 const backSignImg = require('@/assets/images/apartment/backSign.png')
29
 const backSignImg2 = require('@/assets/images/apartment/backSign-2.png')
31
 const backSignImg2 = require('@/assets/images/apartment/backSign-2.png')
30
 
32
 
33
+const shareImg = `${location.origin}${location.pathname}/wx_share.jpg`
34
+
31
 export default {
35
 export default {
32
   components: {
36
   components: {
33
     PureImage: () => import('./components/PureImage.vue'),
37
     PureImage: () => import('./components/PureImage.vue'),
115
     handleGotoIndex(inx) {
119
     handleGotoIndex(inx) {
116
       this.$router.push({ path: '/' })
120
       this.$router.push({ path: '/' })
117
     }
121
     }
122
+  },
123
+  mounted() {
124
+    share({ title: '华侨城欢乐滨江可售物业', imgUrl: shareImg })
118
   }
125
   }
119
 }
126
 }
120
 </script>
127
 </script>

+ 8
- 0
src/views/index.vue Visa fil

3
 </template>
3
 </template>
4
 
4
 
5
 <script>
5
 <script>
6
+
7
+import { share } from '@/utils/wx'
8
+
9
+const shareImg = `${location.origin}${location.pathname}/wx_share.jpg`
10
+
6
 export default {
11
 export default {
7
   components: {
12
   components: {
8
     IndexImage: () => import('./components/IndexImage.vue')
13
     IndexImage: () => import('./components/IndexImage.vue')
14
+  },
15
+  mounted() {
16
+    share({ title: '华侨城欢乐滨江可售物业', imgUrl: shareImg })
9
   }
17
   }
10
 }
18
 }
11
 </script>
19
 </script>

+ 9
- 0
src/views/office.vue Visa fil

30
 </template>
30
 </template>
31
 
31
 
32
 <script>
32
 <script>
33
+import { share } from '@/utils/wx'
34
+
33
 const backSignImg = require('@/assets/office/1-2.png')
35
 const backSignImg = require('@/assets/office/1-2.png')
34
 const backSignImg2 = require('@/assets/images/apartment/backSign-2.png')
36
 const backSignImg2 = require('@/assets/images/apartment/backSign-2.png')
37
+
38
+const shareImg = `${location.origin}${location.pathname}/wx_share.jpg`
39
+
35
 export default {
40
 export default {
36
   components: {
41
   components: {
37
     PureImage: () => import('./components/PureImage.vue'),
42
     PureImage: () => import('./components/PureImage.vue'),
112
     }
117
     }
113
   },
118
   },
114
 
119
 
120
+  mounted() {
121
+    share({ title: '华侨城欢乐滨江可售物业', imgUrl: shareImg })
122
+  },
123
+
115
   methods: {
124
   methods: {
116
     handleGoto(inx) {
125
     handleGoto(inx) {
117
       // inx 是从1开始的
126
       // inx 是从1开始的

+ 4
- 1
src/views/projectIndex.vue Visa fil

20
 </template>
20
 </template>
21
 
21
 
22
 <script>
22
 <script>
23
+import { share } from '@/utils/wx'
23
 
24
 
24
-// const backSignImg = require('@/assets/perjectImages/backButton.png')
25
+const shareImg = `${location.origin}${location.pathname}/wx_share.jpg`
25
 const backSignImg2 = require('@/assets/perjectImages/backButton-2.png')
26
 const backSignImg2 = require('@/assets/perjectImages/backButton-2.png')
26
 
27
 
27
 export default {
28
 export default {
79
       }
80
       }
80
       this.swiperShow = true
81
       this.swiperShow = true
81
     })
82
     })
83
+
84
+    share({ title: '华侨城欢乐滨江项目介绍', imgUrl: shareImg })
82
   },
85
   },
83
   methods: {
86
   methods: {
84
     handleImageLoad() {
87
     handleImageLoad() {