|
@@ -1,26 +1,34 @@
|
|
|
var oauthCode = getUrlParam("code");
|
|
|
// alert("当前地址:"+currentUrl);
|
|
|
-var openid = null;
|
|
|
|
|
|
//进入openid处理流程
|
|
|
-$.ajax({
|
|
|
+$.authAjax({
|
|
|
url: api+"marketing/weixin/openidProcess",
|
|
|
async: false,
|
|
|
data: {
|
|
|
- abbreviationName: abbreviationName,
|
|
|
oauthCode: oauthCode
|
|
|
},
|
|
|
success: function (res) {
|
|
|
if (res.code == 1) {
|
|
|
- hrefIndex();
|
|
|
- } else {
|
|
|
- openid = res.data;
|
|
|
+ console.log(res);
|
|
|
+ localStorage.setItem("access_token", res.data.access_token);
|
|
|
+ location.href = res.data.redictUrl;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+
|
|
|
//页面结构加载完成后执行
|
|
|
$(function() {
|
|
|
+ //TODO start
|
|
|
+ // activityIsExpired();
|
|
|
+ // showReward();
|
|
|
+ // scanRecord('0.0','0.0');
|
|
|
+ // userIsSubscribeApp();
|
|
|
+ // userIsRegister();
|
|
|
+ // redpackProcess();
|
|
|
+ // createJsapiSignature(currentUrl);
|
|
|
+ //TODO end
|
|
|
|
|
|
//判断活动是否过期
|
|
|
if (!activityIsExpired()) {
|
|
@@ -61,13 +69,9 @@ $(function() {
|
|
|
//判断活动是否过期
|
|
|
function activityIsExpired(){
|
|
|
var flag = true;
|
|
|
- $.ajax({
|
|
|
+ $.authAjax({
|
|
|
url: api+"marketing/weixin/activityIsExpired",
|
|
|
async: false,
|
|
|
- data: {
|
|
|
- abbreviationName: abbreviationName,
|
|
|
- activityId: activityId
|
|
|
- },
|
|
|
success: function (res) {
|
|
|
//活动未开始或已结束
|
|
|
if (res.code != 0) {
|
|
@@ -82,14 +86,9 @@ function activityIsExpired(){
|
|
|
//获取并显示码对应的奖励
|
|
|
function showReward() {
|
|
|
var flag = true;
|
|
|
- $.ajax({
|
|
|
+ $.authAjax({
|
|
|
url: api+"marketing/weixin/calculateReward",
|
|
|
async: false,
|
|
|
- data: {
|
|
|
- abbreviationName: abbreviationName,
|
|
|
- qrCode: qrCode,
|
|
|
- openid: openid
|
|
|
- },
|
|
|
success: function (res) {
|
|
|
if (res.code == 0) {
|
|
|
$("#reward").text(res.data);
|
|
@@ -111,16 +110,12 @@ function showReward() {
|
|
|
//记录活动(扫码)事件
|
|
|
function scanRecord(latitude,longitude) {
|
|
|
// alert("记录扫码事件");
|
|
|
- $.ajax({
|
|
|
+ $.authAjax({
|
|
|
url: api+"marketing/weixin/scanRecord",
|
|
|
type: "POST",
|
|
|
data: {
|
|
|
- abbreviationName: abbreviationName,
|
|
|
latitude: latitude,
|
|
|
longitude:longitude,
|
|
|
- openid: openid,
|
|
|
- activityId:activityId,
|
|
|
- qrValue:qrCode
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -129,12 +124,12 @@ function scanRecord(latitude,longitude) {
|
|
|
function receiveReward() {
|
|
|
if (!userIsSubscribeApp()) {
|
|
|
// alert("未关注");
|
|
|
- location.href = "/qrcode.html";
|
|
|
+ location.href = "http://ws.js-dctech.com/qrcode.html";
|
|
|
return false;
|
|
|
}
|
|
|
if (!userIsRegister()) {
|
|
|
// alert("未注册");
|
|
|
- var url = spliceUrl("http://ws.js-dctech.com/register.html?openid="+openid+"&");
|
|
|
+ var url = spliceUrl("http://ws.js-dctech.com/register.html?");
|
|
|
location.href = url;
|
|
|
return false;
|
|
|
}
|
|
@@ -144,13 +139,9 @@ function receiveReward() {
|
|
|
//用户是否关注公众号
|
|
|
function userIsSubscribeApp() {
|
|
|
var userIsSubscribeApp;
|
|
|
- $.ajax({
|
|
|
+ $.authAjax({
|
|
|
url : api+"marketing/weixin/userIsSubscribeApp",
|
|
|
async: false,
|
|
|
- data: {
|
|
|
- abbreviationName: abbreviationName,
|
|
|
- openid: openid
|
|
|
- },
|
|
|
success: function (data) {
|
|
|
userIsSubscribeApp = data;
|
|
|
}
|
|
@@ -161,13 +152,9 @@ function userIsSubscribeApp() {
|
|
|
//用户是否注册(即含地理位置信息)
|
|
|
function userIsRegister() {
|
|
|
var userIsRegister;
|
|
|
- $.ajax({
|
|
|
+ $.authAjax({
|
|
|
url : api+"marketing/weixin/userIsRegister",
|
|
|
async: false,
|
|
|
- data: {
|
|
|
- abbreviationName: abbreviationName,
|
|
|
- openid: openid
|
|
|
- },
|
|
|
success: function (data) {
|
|
|
userIsRegister = data;
|
|
|
}
|
|
@@ -179,14 +166,10 @@ function userIsRegister() {
|
|
|
function redpackProcess() {
|
|
|
getLocation(
|
|
|
function (latitude,longitude) {
|
|
|
- $.ajax({
|
|
|
+ $.authAjax({
|
|
|
url : api+"marketing/weixin/redpackProcess",
|
|
|
async: false,
|
|
|
data: {
|
|
|
- abbreviationName: abbreviationName,
|
|
|
- openid:openid,
|
|
|
- activityId:activityId,
|
|
|
- qrCode: qrCode,
|
|
|
latitude: latitude,
|
|
|
longitude: longitude
|
|
|
},
|
|
@@ -203,4 +186,4 @@ function redpackProcess() {
|
|
|
);
|
|
|
|
|
|
|
|
|
-}
|
|
|
+}
|