李志伟 3 年前
父节点
当前提交
514b2aec22
共有 9 个文件被更改,包括 84 次插入1 次删除
  1. 1
    0
      package.json
  2. 1
    0
      public/index.html
  3. 1
    0
      src/App.vue
  4. 1
    0
      src/utils/request.js
  5. 52
    0
      src/utils/wx.js
  6. 7
    0
      src/views/apartment.vue
  7. 8
    0
      src/views/index.vue
  8. 9
    0
      src/views/office.vue
  9. 4
    1
      src/views/projectIndex.vue

+ 1
- 0
package.json 查看文件

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

+ 1
- 0
public/index.html 查看文件

@@ -11,6 +11,7 @@
11 11
       <link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="stylesheet" />
12 12
 	  <% } %> -->
13 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 15
   </head>
15 16
   <body>
16 17
     <noscript>

+ 1
- 0
src/App.vue 查看文件

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

+ 1
- 0
src/utils/request.js 查看文件

@@ -0,0 +1 @@
1
+// import axios from 'axios'

+ 52
- 0
src/utils/wx.js 查看文件

@@ -0,0 +1,52 @@
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 查看文件

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

+ 8
- 0
src/views/index.vue 查看文件

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

+ 9
- 0
src/views/office.vue 查看文件

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

+ 4
- 1
src/views/projectIndex.vue 查看文件

@@ -20,8 +20,9 @@
20 20
 </template>
21 21
 
22 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 26
 const backSignImg2 = require('@/assets/perjectImages/backButton-2.png')
26 27
 
27 28
 export default {
@@ -79,6 +80,8 @@ export default {
79 80
       }
80 81
       this.swiperShow = true
81 82
     })
83
+
84
+    share({ title: '华侨城欢乐滨江项目介绍', imgUrl: shareImg })
82 85
   },
83 86
   methods: {
84 87
     handleImageLoad() {