Baozhangchao 3 years ago
commit
ce1e0447f9
2 changed files with 87 additions and 0 deletions
  1. BIN
      images/shaer.jpg
  2. 87
    0
      index.html

BIN
images/shaer.jpg View File


+ 87
- 0
index.html View File

@@ -0,0 +1,87 @@
1
+<!DOCTYPE html>
2
+<html lang="en">
3
+
4
+<head>
5
+  <meta charset="UTF-8">
6
+  <meta http-equiv="X-UA-Compatible" content="IE=edge">
7
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
+  <script type="text/javascript" src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js "></script>
9
+  <title>华侨城集团介绍</title>
10
+  <style>
11
+    html,
12
+    body {
13
+      padding: 0;
14
+      margin: 0;
15
+    }
16
+
17
+    .dv_img {
18
+      max-width: 100%;
19
+      height: auto;
20
+    }
21
+  </style>
22
+</head>
23
+
24
+<body>
25
+  <script>
26
+
27
+
28
+    const shareImg = `${location.origin}${location.pathname}images/shaer.jpg`
29
+
30
+    function request(url, options) {
31
+      return fetch(url, options)
32
+        .then(response => response.json())
33
+        .then(data => {
34
+          if (data.code === 1000) return data.data
35
+          return Promise.reject(data.message)
36
+        })
37
+    }
38
+
39
+    const jsApiList = [
40
+      'updateAppMessageShareData',
41
+      'updateTimelineShareData',
42
+      'onMenuShareTimeline',
43
+      'onMenuShareAppMessage',
44
+      'onMenuShareQQ',
45
+      'onMenuShareWeibo',
46
+      'onMenuShareQZone'
47
+    ]
48
+
49
+
50
+
51
+    function init(url) {
52
+      request(`https://api.h5.njyunzhi.com/mp/jssdk?url=${encodeURIComponent(url)}`).then((res) => {
53
+        console.log("🚀 ~ file: index.html ~ line 49 ~ request ~ res", res)
54
+        window.wx.config({
55
+          debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
56
+          appId: res.appId, // 必填,公众号的唯一标识
57
+          timestamp: res.timestamp, // 必填,生成签名的时间戳
58
+          nonceStr: res.nonceStr, // 必填,生成签名的随机串
59
+          signature: res.signature, // 必填,签名
60
+          jsApiList // 必填,需要使用的JS接口列表
61
+        })
62
+      })
63
+    }
64
+    function share(opt) {
65
+      init(opt.link)
66
+      window.wx.ready(function () {
67
+        jsApiList.map((apiName) => {
68
+          const api = window.wx[apiName]
69
+          api({
70
+            title: opt.title || '', // 分享标题
71
+            link: opt.link || '', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
72
+            imgUrl: opt.imgUrl || '', // 分享图标
73
+            desc: opt.desc || ''
74
+          })
75
+        })
76
+      })
77
+    }
78
+
79
+    share({ title: '华侨城集团介绍', link: window.location.href, imgUrl: shareImg })
80
+
81
+
82
+  </script>
83
+
84
+  <img class="dv_img" alt="华侨城集团介绍" src="https://h5.njyunzhi.com/images/huaqiaocheng_20211224112744.jpg" />
85
+</body>
86
+
87
+</html>