liangzhaozhou 7 ヶ月 前
コミット
0a599a4d43
1 ファイル変更61 行追加0 行削除
  1. 61 0
      lottery/index.html

+ 61 - 0
lottery/index.html

@@ -10,6 +10,7 @@
 		<script src="js/mui.js"></script>
 		<script src="js/mui.picker.js"></script>
 		<script src="js/mui.poppicker.js"></script>
+		<script src="http://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
 		<!-- <script src="https://unpkg.com/vconsole/dist/vconsole.min.js"></script>
 		<script>
 		  var vConsole = new window.VConsole();
@@ -978,6 +979,7 @@
 					mui.alert('无权限访问', '提示', '确定');
 				} else {
 					h5Type = getQueryParam('h5Type')
+					getQyWxSign()
 					if (h5Type == 19) {
 						showCityLevel();
 						raffleInfo();
@@ -994,6 +996,65 @@
 			}
 			document.getElementById("city-rightIcon").src = 'https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/1000/1720163006057/icon_jiantou2%402x.png';
 		};
+		// 内容类型的分享页,获取企业微信的签名
+		function getQyWxSign () {
+		  let shareUrl = `${window.location.origin}?bId=${getQueryParam('bId')}&h5Type=${getQueryParam('h5Type')}`
+		  mui.ajax('https://wlapi.wefanbot.com/scrm/v1/ct-share/p/getSignature',{
+			data:{
+				url: 'https://lottery.camlook.cn'//window.location.origin
+			},
+			dataType:'json',//服务器返回json格式数据
+			type:'get',//HTTP请求类型
+			success:function(res){
+					if (res.code === 1) {
+						wx.config({
+						  beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
+						  debug: false, // 开启调试模式,
+						  appId: res.data.appId, // 必填,企业号的唯一标识,此处填写企业号corpid
+						  timestamp: res.data.timestamp, // 必填,生成签名的时间戳
+						  nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
+						  signature: res.data.signature, // 必填,签名,见附录1
+						  jsApiList: [
+							'onMenuShareAppMessage',
+							'onMenuShareWechat',
+							'onMenuShareTimeline',
+							'shareAppMessage', // 自定义转发到会话
+							'shareWechatMessage' // 自定义转发到微信
+						  ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2test
+						})
+						// 分享接口仅激活的成员数超过200人且已经认证的企业才可在微信上调用。
+						wx.ready(() => {
+						  //   let noSharp = shareUrl
+						  // 微信分享的数据
+						  /*     alert('ready--success') */
+						  let shareData = {
+							link: shareUrl,
+							title: '寻找可靠的伙伴——宝骏14周年车主故事征集', // 分享标题
+							desc: '暨宝骏云海新车上市500万车主送祝福有奖活动,说出你和宝骏的故事', // 分享描述
+							imgUrl: 'https://lottery.camlook.cn/img/blessing.png', // 分享图标
+						  }
+						  wx.onMenuShareAppMessage(shareData) // 获取“转发”按钮点击状态及自定义分享内容接口,即将废弃
+						  wx.onMenuShareWechat(shareData)
+						  wx.onMenuShareTimeline(shareData) // 获取“分享到朋友圈”按钮点击状态及自定义分享内容接口,即将废弃
+						  wx.invoke('shareAppMessage', shareData, function(res) {
+							if (res.err_msg == 'shareAppMessage:ok') {
+							}
+						  }
+						  )
+						  wx.invoke('shareWechatMessage', shareData, function(res) {
+							if (res.err_msg == 'shareWechatMessage:ok') {
+							}
+						  }
+						  )
+						})
+					}
+			},
+			error:function(error){
+				//异常处理;
+				console.log(error);
+			}
+		  })
+		}
 		// 公众号授权,获取code
 		function getAuth() {
 			// 获取url上的code