Browse Source

获取用户授权

xiuli.gao 6 years ago
parent
commit
93c611b50a
2 changed files with 17 additions and 18 deletions
  1. 4 3
      share/js/index.js
  2. 13 15
      share/js/invitation.js

+ 4 - 3
share/js/index.js

17
 	$.ajax({
17
 	$.ajax({
18
 		type:"post",
18
 		type:"post",
19
 		url:"/api/V2/returnRedPacket",
19
 		url:"/api/V2/returnRedPacket",
20
+		dataType:'json',
20
 		success: function (res) {
21
 		success: function (res) {
21
-			var data =JSON.parse(res)
22
-//				console.log(data)
22
+			var data =res;
23
+				console.log(data)
23
 			if(data.code == 0){
24
 			if(data.code == 0){
24
 				var dataArr = data.res.list,html = '',numHtml = '', name = '' , img = '';
25
 				var dataArr = data.res.list,html = '',numHtml = '', name = '' , img = '';
25
 				numHtml +='已有'+ data.res.count +'位用户领取红包';
26
 				numHtml +='已有'+ data.res.count +'位用户领取红包';
34
 					}else{
35
 					}else{
35
 						img = 'images/moren.png'
36
 						img = 'images/moren.png'
36
 					}
37
 					}
37
-					html += '<li><img src='+ img +' /><span class="username">'+ name +'</span><span class="ed">领取了红包</span><span class="day">'+ item.received_time +'</span></li>'
38
+					html += '<li><img src='+ img +' /><span class="username">'+ name +'</span><span class="ed">领取了红包</span><span class="day">'+ item.shared_time +'</span></li>'
38
 				})
39
 				})
39
 				$('.num').html(numHtml);
40
 				$('.num').html(numHtml);
40
 				$('.roll-wrap ul').html(html)
41
 				$('.roll-wrap ul').html(html)

+ 13 - 15
share/js/invitation.js

51
 		if(navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == "micromessenger"){
51
 		if(navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == "micromessenger"){
52
 			//微信
52
 			//微信
53
 			$(".shareWechat").css('display','block')
53
 			$(".shareWechat").css('display','block')
54
-			shareFriend ();
54
+			shareRedPacket ();
55
 		}else{
55
 		}else{
56
 			//app端
56
 			//app端
57
 			$(".shareMask").css('display','block')
57
 			$(".shareMask").css('display','block')
58
 		}
58
 		}
59
-	collarRed();
60
 	share();
59
 	share();
61
 })
60
 })
62
 //带你几取消分享
61
 //带你几取消分享
76
 			type:1,
75
 			type:1,
77
 			count: num
76
 			count: num
78
 		},
77
 		},
78
+		dataType:'json',
79
 		success: function (res) {
79
 		success: function (res) {
80
-			var data =JSON.parse(res)
80
+			var data =res;
81
 			num = data.res.count;
81
 			num = data.res.count;
82
 		}
82
 		}
83
 	})
83
 	})
145
     }, 3000);
145
     }, 3000);
146
 }
146
 }
147
 
147
 
148
-$('.shareCopy').click(function () {
149
-	copyPassword()
150
-})
151
-
152
-//记录用户  领红包
153
-function collarRed() {
148
+//分享用户授权
149
+function shareRedPacket () {
154
 	$.ajax({
150
 	$.ajax({
155
 		type:"post",
151
 		type:"post",
156
-		url:"/api/V2/receiveRedPacket",
152
+		url:"/api/V2/shareRedPacket",
157
 		dataType:"json",
153
 		dataType:"json",
158
-		data:{
159
-			user_id:userId
160
-		},
161
-		success: function (res) {
154
+		success: function () {
155
+			shareFriend ();
162
 		}
156
 		}
163
 	})
157
 	})
164
-}
158
+}
159
+
160
+$('.shareCopy').click(function () {
161
+	copyPassword()
162
+})