Browse Source

获取活动名称、获取微信用户已有信息

caiweigan 6 years ago
parent
commit
50a17bd7e3
3 changed files with 24 additions and 2 deletions
  1. 3 0
      index.html
  2. 9 2
      js/index.js
  3. 12 0
      register.html

+ 3 - 0
index.html

@@ -20,6 +20,9 @@
 </head>
 
 <body>
+<!--<button onclick="alert(accessToken);">获取access_token</button>-->
+<!--<button onclick="localStorage.removeItem('access_token')">删除access_token</button>-->
+<!--<button onclick="alert(currentUrl)">当前页面</button>-->
 <div>金额:<span id="reward"></span>元</div>
 <button id="receiveReward">点击领取</button>
 </body>

+ 9 - 2
js/index.js

@@ -1,7 +1,14 @@
 //进入openid处理流程
 $.authAjax({
-    url: api+"marketing/weixin/openidProcess",
-    async: false
+    url: api+"marketing/weixin/openidProcess"
+});
+
+//获取活动标题
+$.authAjax({
+    url: api+"marketing/weixin/getActivityTitle",
+    success: function (res) {
+        document.title = res;
+    }
 });
 
 //页面结构加载完成后执行

+ 12 - 0
register.html

@@ -20,6 +20,9 @@
 
 <body>
 <div class="warp" style="background: #fff">
+	<!--<button onclick="alert(accessToken);">获取access_token</button>-->
+	<!--<button onclick="localStorage.removeItem('access_token')">删除access_token</button>-->
+	<!--<button onclick="alert(currentUrl)">当前页面</button>-->
 	<div class="weui-cells weui-cells_form" style="margin-top: 0px;">
 		<form id="registerForm">
 		<div class="weui-cell ">
@@ -87,6 +90,15 @@
 <script type="text/javascript">
     $("#birthDate").calendar();
 
+    //填入昵称和性别数据
+    $.authAjax({
+        url: api+"marketing/weixin/getWxUserInfo",
+        success: function (res) {
+            $('input[name="nickName"]').val(res.nickname);
+            $('input[name="sex"][value="'+res.sex+'"]').prop('checked',true);
+        }
+	});
+
     function submit() {
         $.showLoading('数据提交中');