|
@@ -1,78 +1,83 @@
|
|
|
-(function($) {
|
|
|
- $.fn.extend({
|
|
|
- addClear: function(options) {
|
|
|
- var options = $.extend({
|
|
|
- closeSymbol: "✖",
|
|
|
- color: "#CCC",
|
|
|
- top: 1,
|
|
|
- right: 4,
|
|
|
- returnFocus: true,
|
|
|
- showOnLoad: false,
|
|
|
- onClear: null
|
|
|
- }, options);
|
|
|
-
|
|
|
- $(this).wrap("<span style='position:relative;' class='add-clear-span'>");
|
|
|
- $(this).after("<a href='#clear'>" + options.closeSymbol + "</a>");
|
|
|
- $("a[href='#clear']").css({
|
|
|
- color: options.color,
|
|
|
- 'text-decoration': 'none',
|
|
|
- display: 'none',
|
|
|
- 'line-height': 1,
|
|
|
- overflow: 'hidden',
|
|
|
- position: 'absolute',
|
|
|
- right: options.right,
|
|
|
- top: options.top
|
|
|
- }, this);
|
|
|
-
|
|
|
- if ($(this).val().length >= 1 && options.showOnLoad === true) {
|
|
|
- $(this).siblings("a[href='#clear']").show();
|
|
|
- }
|
|
|
+(function ($) {
|
|
|
+ $.fn.extend({
|
|
|
+ addClear: function (options) {
|
|
|
+ var options = $.extend({
|
|
|
+ closeSymbol: "✖",
|
|
|
+ color: "#CCC",
|
|
|
+ top: 1,
|
|
|
+ right: 4,
|
|
|
+ returnFocus: true,
|
|
|
+ showOnLoad: false,
|
|
|
+ onClear: null
|
|
|
+ }, options);
|
|
|
+
|
|
|
+ $(this).wrap("<span style='position:relative;' class='add-clear-span'>");
|
|
|
+ $(this).after("<a href='#clear'>" + options.closeSymbol + "</a>");
|
|
|
+ $("a[href='#clear']").css({
|
|
|
+ color: options.color,
|
|
|
+ 'text-decoration': 'none',
|
|
|
+ display: 'none',
|
|
|
+ 'line-height': 1,
|
|
|
+ overflow: 'hidden',
|
|
|
+ position: 'absolute',
|
|
|
+ right: options.right,
|
|
|
+ top: options.top
|
|
|
+ }, this);
|
|
|
|
|
|
- $(this).keyup(function() {
|
|
|
- if ($(this).val().length >= 1) {
|
|
|
+ if ($(this).val().length >= 1 && options.showOnLoad === true) {
|
|
|
$(this).siblings("a[href='#clear']").show();
|
|
|
- } else {
|
|
|
- $(this).siblings("a[href='#clear']").hide();
|
|
|
}
|
|
|
- });
|
|
|
|
|
|
- $("a[href='#clear']").click(function() {
|
|
|
- $(this).siblings("input").val("");
|
|
|
- $(this).hide();
|
|
|
- if (options.returnFocus === true) {
|
|
|
- $(this).siblings("input").focus();
|
|
|
- }
|
|
|
- if (options.onClear) {
|
|
|
- options.onClear($(this).siblings("input"));
|
|
|
- }
|
|
|
- return false;
|
|
|
- });
|
|
|
- return this;
|
|
|
- }
|
|
|
- });
|
|
|
-}
|
|
|
+ $(this).keyup(function () {
|
|
|
+ if ($(this).val().length >= 1) {
|
|
|
+ $(this).siblings("a[href='#clear']").show();
|
|
|
+ } else {
|
|
|
+ $(this).siblings("a[href='#clear']").hide();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $("a[href='#clear']").click(function () {
|
|
|
+ $(this).siblings("input").val("");
|
|
|
+ $(this).hide();
|
|
|
+ if (options.returnFocus === true) {
|
|
|
+ $(this).siblings("input").focus();
|
|
|
+ }
|
|
|
+ if (options.onClear) {
|
|
|
+ options.onClear($(this).siblings("input"));
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
)(jQuery);
|
|
|
|
|
|
-// var phoneReg = /^1\d{11}$/; //
|
|
|
+var phoneReg = /^1\d{10}$/; //
|
|
|
var count = 60;
|
|
|
var InterValObj1;
|
|
|
var curCount1;
|
|
|
+
|
|
|
function sendMessage1() {
|
|
|
curCount1 = count;
|
|
|
var phone = $.trim($('#phone1').val());
|
|
|
- // if (!phoneReg.test(phone)) {
|
|
|
- // alert("请输入有效的手机号码");
|
|
|
- // return false;
|
|
|
- // }
|
|
|
+ if (!phoneReg.test(phone)) {
|
|
|
+ alert("请输入有效的手机号码");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
$("#btnSendCode1").attr("disabled", "true");
|
|
|
$("#btnSendCode1").val(+curCount1 + "秒再获取");
|
|
|
|
|
|
- $.get("https://wxservice.ds-bay.com/user/send?phoneNumber=" + phone+"&openId="+sessionStorage.getItem("openid"), function (res) {
|
|
|
+ $.get("https://wxservice.ds-bay.com/user/send?phoneNumber=" + phone + "&openId=" + sessionStorage.getItem("openid"), function (res) {
|
|
|
})
|
|
|
|
|
|
InterValObj1 = window.setInterval(SetRemainTime1, 1000);
|
|
|
|
|
|
}
|
|
|
+returnMethod = function (){
|
|
|
+ WeixinJSBridge.call('closeWindow');
|
|
|
+ window.close();
|
|
|
+}
|
|
|
function SetRemainTime1() {
|
|
|
if (curCount1 == 0) {
|
|
|
window.clearInterval(InterValObj1);
|
|
@@ -89,26 +94,56 @@ submitForm = function () {
|
|
|
|
|
|
if (flag) {
|
|
|
var openid = getUrlParam("openid");
|
|
|
- $("#btnSendCode2").val(openid);
|
|
|
- $("#submit_form").submit();
|
|
|
+ $.ajax({
|
|
|
+ url: "https://wxservice.ds-bay.com/binding",
|
|
|
+ data: JSON.stringify({phone: $("#phone1").val(), code: $("#code1").val(), openId: openid}),
|
|
|
+ type: "POST",
|
|
|
+ contentType: 'application/json',
|
|
|
+ dataType: "json",
|
|
|
+ success: function (result) {
|
|
|
+ if(result && result.code == "0"){
|
|
|
+
|
|
|
+ // window.location.href="../../templates/return.html";
|
|
|
+
|
|
|
+ alert("绑定成功!请扫码取件!")
|
|
|
+ returnMethod();
|
|
|
+ var t1 = window.setTimeout(function() {
|
|
|
+ returnMethod();
|
|
|
+ window.clearTimeout(t1) // 去除定时器
|
|
|
+ },1000)
|
|
|
+
|
|
|
+ }else{
|
|
|
+ alert(result.message);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function () {
|
|
|
+ alert("请求失败");
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
-checkInput = function (){
|
|
|
+checkInput = function () {
|
|
|
var a = true;
|
|
|
var code = $("#code1").val;
|
|
|
- if ($.trim(code) === '') {
|
|
|
+ if (!code) {
|
|
|
a = false;
|
|
|
alert("请输入验证码!");
|
|
|
return a;
|
|
|
}
|
|
|
|
|
|
+ var phone1 = $("#phone1").val;
|
|
|
+ if (!phone1) {
|
|
|
+ a = false;
|
|
|
+ alert("请输入手机号!");
|
|
|
+ return a;
|
|
|
+ }
|
|
|
return a;
|
|
|
}
|
|
|
|
|
|
|
|
|
// 强制关注公众号,获取openid
|
|
|
getCode = function () {
|
|
|
- if (sessionStorage.getItem("openid")&&sessionStorage.getItem("openid")!="undefined") {
|
|
|
+ if (sessionStorage.getItem("openid") && sessionStorage.getItem("openid") != "undefined") {
|
|
|
return false;
|
|
|
}
|
|
|
var code = getUrlParam('code') // 截取路径中的code,如果没有就去微信授权,如果已经获取到了就直接传code给后台获取openId
|
|
@@ -125,7 +160,7 @@ getOpenId = function (code) {
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
dataType: 'text',
|
|
|
- url: 'https://wxservice.ds-bay.com/oauth2?code='+code,
|
|
|
+ url: 'https://wxservice.ds-bay.com/oauth2?code=' + code,
|
|
|
success: function (res) {
|
|
|
if (res.status == -1) {
|
|
|
// 提示没有关注公众号 没有关注公众号跳转到关注公众号页面
|
|
@@ -142,14 +177,16 @@ getOpenId = function (code) {
|
|
|
});
|
|
|
}
|
|
|
//获取地址栏的参数
|
|
|
-getUrlParam= function (name) {
|
|
|
+getUrlParam = function (name) {
|
|
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
|
|
|
var r = window.location.search.substr(1).match(reg);
|
|
|
- if (r != null) return unescape(r[2]); return null;
|
|
|
+ if (r != null) return unescape(r[2]);
|
|
|
+ return null;
|
|
|
}
|
|
|
//页面执行调用
|
|
|
getCode();
|
|
|
window.scroll(0, 0);
|
|
|
+
|
|
|
function binding() {
|
|
|
alert(1)
|
|
|
}
|