|
@@ -6,6 +6,8 @@
|
6
|
6
|
<meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no">
|
7
|
7
|
<title>分享领红包</title>
|
8
|
8
|
<link rel="stylesheet" type="text/css" href="public/public_css.css"/>
|
|
9
|
+<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
|
|
10
|
+<script src="weChatShare.js"></script>
|
9
|
11
|
<style type="text/css">
|
10
|
12
|
body,html{font-size: 0.16rem;height: 100vh;}
|
11
|
13
|
body, div, button, h3, h6, span, ul, li, p, a,input{font-family: -apple-system,SF UI Text,Helvetica Neue,Helvetica,Arial,sans-serif;-webkit-tap-highlight-color: rgba(0, 0, 0, 0); padding: 0; margin: 0; box-sizing: inherit; font-weight: normal;}
|
|
@@ -83,6 +85,32 @@
|
83
|
85
|
color: #555555;
|
84
|
86
|
text-align: center;
|
85
|
87
|
}
|
|
88
|
+ .alert-info {
|
|
89
|
+ position: absolute;
|
|
90
|
+ top: 1.74rem;
|
|
91
|
+ right: 0;
|
|
92
|
+ left: 0;
|
|
93
|
+ bottom: 0;
|
|
94
|
+ text-align: center;
|
|
95
|
+ z-index: 99;
|
|
96
|
+ }
|
|
97
|
+
|
|
98
|
+ .alert-info p {
|
|
99
|
+ display: inline-block;
|
|
100
|
+ height: 0.38rem;
|
|
101
|
+ color: #fff;
|
|
102
|
+ font-size: 0.14rem;
|
|
103
|
+ line-height: 0.38rem;
|
|
104
|
+ padding: 0 0.10rem;
|
|
105
|
+ background-color: rgba(0, 0, 0, 0.7);
|
|
106
|
+ border-radius: 5px;
|
|
107
|
+ }
|
|
108
|
+ .shareWechat{width: 100%;height: 100%;position: fixed;top: 0;left: 0;background: rgba(0,0,0,0.7);display: none;}
|
|
109
|
+ .shareWechatCon{width:2.5rem;background:#ffffff;border-radius:0.12rem;position: absolute;top: 2rem;left: 0;right: 0;margin: auto;}
|
|
110
|
+ .shareWechat .wx_jiantou{width: 0.72rem;position: absolute;right: 0.15rem;top: 0.2rem;}
|
|
111
|
+ .shareWechat .shareWechatCon h3{font-size: 0.16rem;color: #FF2E2E;text-align: center;padding-bottom: 0.15rem;padding-top: 0.3rem;}
|
|
112
|
+ .shareWechat .shareWechatCon p{font-size: 0.14rem;color: #333333;text-align: center;padding-bottom: 0.3rem;}
|
|
113
|
+ .shareWechat .shareWechatCon .cancel{width: 0.34rem;height: 0.34rem;position: absolute;left: 0;right: 0;bottom: -0.5rem;margin: auto;}
|
86
|
114
|
</style>
|
87
|
115
|
<script type="text/javascript">
|
88
|
116
|
document.documentElement.style.fontSize = 100 * (document.documentElement.clientWidth/375) + "px";
|
|
@@ -123,13 +151,27 @@
|
123
|
151
|
<div class="cancel">取消分享</div>
|
124
|
152
|
</div>
|
125
|
153
|
</div>
|
|
154
|
+
|
|
155
|
+ <div class="shareWechat">
|
|
156
|
+ <img src="./images/wx_jiantou.png" class="wx_jiantou" />
|
|
157
|
+ <div class="shareWechatCon">
|
|
158
|
+ <h3>恭喜你,获得淘宝红包</h3>
|
|
159
|
+ <p>分享给好友,有奖一起拿</p>
|
|
160
|
+ <img class="cancel" src="./images/close.png"></img>
|
|
161
|
+ </div>
|
|
162
|
+ </div>
|
|
163
|
+
|
|
164
|
+ <div class="alert-info" style="display: none;">
|
|
165
|
+ <!-- tip提示,3s后消失 -->
|
|
166
|
+ <p></p>
|
|
167
|
+ </div>
|
126
|
168
|
</body>
|
127
|
169
|
</html>
|
128
|
170
|
<script type="text/javascript" src="public/jquery-2.1.0.js"></script>
|
129
|
171
|
<script type="text/javascript">
|
130
|
172
|
var userId = null;
|
131
|
|
- var activity_id = null;
|
132
|
|
- var share_code = null;
|
|
173
|
+// var activity_id = null;
|
|
174
|
+// var share_code = null;
|
133
|
175
|
var str=location.href; //取得整个地址栏
|
134
|
176
|
var num=str.indexOf("?");
|
135
|
177
|
str=str.substr(num+1); //str得到?之后的字符串
|
|
@@ -139,13 +181,13 @@
|
139
|
181
|
userId = brr[i].split('=')[1];//用户id
|
140
|
182
|
localStorage.setItem('userId', userId);
|
141
|
183
|
}
|
142
|
|
- if(brr[i].indexOf('activity_id') != -1){
|
143
|
|
- activity_id = brr[i].split('=')[1];//活动id
|
144
|
|
- localStorage.setItem('activity_id', activity_id);
|
145
|
|
- }
|
146
|
|
- if(brr[i].indexOf('share_code') != -1){
|
147
|
|
- share_code = brr[i].split('=')[1];
|
148
|
|
- }
|
|
184
|
+// if(brr[i].indexOf('activity_id') != -1){
|
|
185
|
+// activity_id = brr[i].split('=')[1];//活动id
|
|
186
|
+// localStorage.setItem('activity_id', activity_id);
|
|
187
|
+// }
|
|
188
|
+// if(brr[i].indexOf('share_code') != -1){
|
|
189
|
+// share_code = brr[i].split('=')[1];
|
|
190
|
+// }
|
149
|
191
|
}
|
150
|
192
|
|
151
|
193
|
|
|
@@ -182,16 +224,25 @@
|
182
|
224
|
}
|
183
|
225
|
|
184
|
226
|
$("#share").click(function () {
|
185
|
|
- $(".shareMask").css('display','block')
|
|
227
|
+// if(navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == "micromessenger"){
|
|
228
|
+ //微信
|
|
229
|
+ $(".shareWechat").css('display','block')
|
|
230
|
+ shareFriend ();
|
|
231
|
+// }else{
|
|
232
|
+//// //app端
|
|
233
|
+// $(".shareMask").css('display','block')
|
|
234
|
+// }
|
186
|
235
|
share();
|
187
|
236
|
})
|
188
|
237
|
$(".cancel").click(function () {
|
189
|
|
- $(".shareMask").css('display','none')
|
|
238
|
+ $(".shareMask").css('display','none');
|
|
239
|
+ $(".shareWechat").css('display','none')
|
190
|
240
|
})
|
191
|
241
|
|
192
|
242
|
var num = 0;
|
193
|
243
|
//分享
|
194
|
244
|
function share() {
|
|
245
|
+ //分享统计
|
195
|
246
|
$.ajax({
|
196
|
247
|
type:"post",
|
197
|
248
|
url:"/api/V2/share",
|
|
@@ -205,5 +256,36 @@
|
205
|
256
|
}
|
206
|
257
|
})
|
207
|
258
|
}
|
208
|
|
-
|
|
259
|
+ function shareFriend () {
|
|
260
|
+ //微信sdk分享验证信息
|
|
261
|
+ $.ajax({
|
|
262
|
+ type:"post",
|
|
263
|
+ url:"/api/V2/jsonConfig",
|
|
264
|
+ dataType:"json",
|
|
265
|
+ data:{
|
|
266
|
+ url:'index.html?userId=' + userId
|
|
267
|
+ },
|
|
268
|
+ success: function (res) {
|
|
269
|
+ if(res && res.code == 0){
|
|
270
|
+ wexinPay(res.res.url,'./hongbao.png',res.res,() => {
|
|
271
|
+ showMsg("成功")
|
|
272
|
+ },() => {
|
|
273
|
+ showMsg("失败")
|
|
274
|
+ })
|
|
275
|
+ }
|
|
276
|
+ }
|
|
277
|
+ })
|
|
278
|
+ }
|
|
279
|
+ /**
|
|
280
|
+ * [showMsg 提示各种错误信息,3s后消失]
|
|
281
|
+ */
|
|
282
|
+ function showMsg(msg) {
|
|
283
|
+ var msgBox = $('.alert-info');
|
|
284
|
+ msgBox.children('p').text(msg);
|
|
285
|
+ msgBox.show();
|
|
286
|
+
|
|
287
|
+ setTimeout(function() {
|
|
288
|
+ msgBox.hide();
|
|
289
|
+ }, 3000);
|
|
290
|
+ }
|
209
|
291
|
</script>
|