123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>注册会员</title>
- <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black">
- <link rel="stylesheet" type="text/css" href="css/mui.min.css" />
- <link rel="stylesheet" type="text/css" href="css/iconfont.css" />
- <link rel="stylesheet" type="text/css" href="css/main.css" />
- <link rel="stylesheet" type="text/css" href="css/mui.picker.min.css" />
- <script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
- <script>
- //屏蔽分享
- document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
- WeixinJSBridge.call('hideOptionMenu');
- });
- </script>
- </head>
- <body>
- <div class="mui-content">
- <div style="margin: 20px 0;text-align: center;">
- <div style="padding: 10px 0;">
- <span class="iconfont icon-chenggong" style="color: #3bbf64;font-size: 40px;"></span>
- </div>
- <h4> 已成功扫描唯一码 </h4>
- <p id="barCodeId"></p>
- <p>别忘了完善下方的会员信息</p>
- <p style="width: 60%;margin-left: 20%;">成功注册会员,您将获得延保服务,以及免费积分和刷头福利</p>
- <p style="width: 60%;margin-left: 20%;">“刷头兑换券”请移至上朵公众号【朵粉特供】→【福利社】领取</p>
- </div>
- <img width="100%" src="images/youhuiquan.jpg" />
-
- <div style="padding: 15px 10px;font-weight: bold;font-size: 15px;">
- 完善信息
- </div>
- <form class="mui-input-group">
- <div class="mui-input-row line-bottom">
- <label>您的姓名</label>
- <input type="text" maxlength="10" id="ipt-name" placeholder="填写您的姓名">
- </div>
- <div class="mui-input-row line-bottom" id="js-userBirthDate">
- <label>出生日期</label>
- <input type="text" id="newDate" readonly="readonly" placeholder="选择您的出生日期">
- </div>
- <div class="mui-input-row line-bottom">
- <label>手机号码</label>
-
- <input type="tel" id="ipt-phone" maxlength="11" placeholder="填写您的手机号码">
- </div>
- <div class="mui-input-row line-bottom" id="js-phone" style="display:none;">
-
- <label>验 证 码</label>
- <input style="width: 50% !important;float: left;" type="tel" placeholder="请输入验证码" maxlength="4" id="code"><button type="button" class="pull-code" disabled="disabled">获取验证码</button>
- </div>
- <div class="mui-table my-table" style="padding:15px 10px 0px 10px;">
- <div class="mui-table-cell mui-col-xs-2">
- <label>您的性别</label>
- </div>
- <div class="mui-table-cell mui-col-xs-3">
- <div class="mui-input-row mui-radio mui-left">
- <label>男</label>
- <input id="maleId" class="iconfont icon-boy" name="radio0" type="radio" checked="" value="1">
- </div>
- </div>
- <div class="mui-table-cell mui-col-xs-5">
- <div class="mui-input-row mui-radio mui-left">
- <label>女</label>
- <input id="femaleId" class="iconfont icon-girl" name="radio0" type="radio" value="2">
- </div>
- </div>
- </div>
- <!--<div class="mui-table my-table">
- <div class="mui-table-cell mui-col-xs-2">
- <label style="display: block;width: 60px;">您的年龄</label>
- </div>
- <div class="mui-table-cell mui-col-xs-3">
- <div class="mui-input-row mui-radio mui-left">
- <label class="my-label">80后</label>
- <input name="radio1" class="radio1" type="radio" checked="" value="1">
- </div>
- </div>
- <div class="mui-table-cell mui-col-xs-3">
- <div class="mui-input-row mui-radio mui-left">
- <label class="my-label">85后</label>
- <input name="radio1" class="radio1" type="radio" value="2">
- </div>
- </div>
- <div class="mui-table-cell mui-col-xs-3">
- <div class="mui-input-row mui-radio mui-left">
- <label class="my-label">90后</label>
- <input name="radio1" class="radio1" type="radio" value="3">
- </div>
- </div>
- </div>
- <div class="mui-table my-table" style="padding-bottom: 12px;">
- <div class="mui-table-cell mui-col-xs-2">
- <label></label>
- </div>
- <div class="mui-table-cell mui-col-xs-3">
- <div class="mui-input-row mui-radio mui-left">
- <label class="my-label">95后</label>
- <input name="radio1" class="radio1" type="radio" value="4">
- </div>
- </div>
- <div class="mui-table-cell mui-col-xs-3">
- <div class="mui-input-row mui-radio mui-left">
- <label class="my-label">00后</label>
- <input name="radio1" class="radio1" type="radio" value="5">
- </div>
- </div>
- <div class="mui-table-cell mui-col-xs-3">
- <div class="mui-input-row mui-radio mui-left">
- <label class="my-label">其他</label>
- <input name="radio1" class="radio1" type="radio" value="6">
- </div>
- </div>
- </div>-->
- <div class="mui-table my-table">
- <div class="mui-table-cell mui-col-xs-2">
- <label style="display: block;width: 60px;">购买渠道</label>
- </div>
- <div class="mui-table-cell mui-col-xs-3">
- <div class="mui-input-row mui-radio mui-left">
- <label class="my-label">天猫</label>
- <input name="radio2" class="radio2" type="radio" checked="" value="1">
- </div>
- </div>
- <div class="mui-table-cell mui-col-xs-3">
- <div class="mui-input-row mui-radio mui-left">
- <label class="my-label">微信</label>
- <input name="radio2" class="radio2" type="radio" value="4">
- </div>
- </div>
- <div class="mui-table-cell mui-col-xs-3">
- <div class="mui-input-row mui-radio mui-left">
-
- <label class="my-label">京东</label>
- <input name="radio2" class="radio2" type="radio" value="3">
- </div>
- </div>
- </div>
- <div class="mui-table my-table">
- <div class="mui-table-cell mui-col-xs-2">
- <label style="display: block;width: 60px;"> </label>
- </div>
- <div class="mui-table-cell mui-col-xs-3">
- <div class="mui-input-row mui-radio mui-left">
- <label class="my-label">一条</label>
- <input name="radio2" class="radio2" type="radio" value="6">
- </div>
- </div>
- <div class="mui-table-cell mui-col-xs-3">
- <div class="mui-input-row mui-radio mui-left">
- <label class="my-label">小红书</label>
- <input name="radio2" class="radio2" type="radio" value="7">
- </div>
- </div>
- <div class="mui-table-cell mui-col-xs-3">
- <div class="mui-input-row mui-radio mui-left">
- <label class="my-label">其他</label>
- <input name="radio2" class="radio2" type="radio" value="5">
- </div>
- </div>
- </div>
- <div class="mui-input-row line-top">
- <label>购买日期</label>
- <input type="text" id="buyDate" readonly="readonly" placeholder="选择您的购买日期">
- </div>
- </form>
- <br />
- <div class="mui-content-padded mui-text-center">
- <button type="button" class="my-btn-black" id="my-btn-submit" style="width: 50%;">提交注册</button>
- </div>
- </div>
- <!-- 加载ing begin-->
- <div class="loading covers">
- <div class="loading-bj"></div>
- <p>正在加载...</p>
- </div>
- <!-- 加载ing end -->
- <script type="text/javascript" src="js/mui.min.js"></script>
- <script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
- <script type="text/javascript" src="js/main.js"></script>
- <script src="js/mui.picker.min.js"></script>
- <script type="text/javascript">
-
- /*以前的电话号码*/
- var oldPhone;
- /*是否需要填写验证码 1:需要 2:不需要*/
- var isNeedPhone = 1;
- /*1需要填写,2不需要*/
- var isNeedBirthday = 1;
-
- window.addEventListener('pageshow', function(e) {
- // 通过persisted属性判断是否存在 BF Cache
- if(e.persisted) {
- location.reload();
- }
- });
-
- //实时监听文本框字数
- document.getElementById("ipt-phone").addEventListener("input", function() {
- var phone = this.value;
- if(phone == oldPhone){
- $("#js-phone").hide();
- isNeedPhone = 2;
- return false;
- }else{
- isNeedPhone = 1;
- $("#js-phone").show();
- }
-
- var mobile = /^(13|14|15|17|18)[0-9]{9}$/; //手机号码
- if(phone.length == 11) {
-
- if(mobile.test(phone) && countdown == 60) {
- $(".pull-code").removeAttr("disabled").addClass("active");
- } else {
- $(".pull-code").attr("disabled", "disabled").removeClass("active");
- }
- } else {
- $(".pull-code").attr("disabled", "disabled").removeClass("active");
- }
- });
- //发送验证码
-
- var validate_flag = false,
- show_msg = '';
- $(document).on('tap', '.pull-code', function() {
-
- var th = $(this);
- var mobile = /^(13|14|15|17|18)[0-9]{9}$/; //手机号码
- var phone = $("#ipt-phone").val();
- if(mobile.test(phone)) {
- settime(th);
- if(!window.sessionStorage) {
- mui.alert("您的浏览器不支持sessionStorage");
-
- } else {
- //自定义json数据
- var obj = {};
- obj["phone"] = phone;
- obj["codetime"] = new Date().getTime();
- //json格式化插入
- sessionStorage.setItem('code_data', JSON.stringify(obj));
- }
- //ajax
- $.ajax(base_path + '/wechat/apparatus/send_phone?dates=' + new Date().getTime(), {
- data: {
- "phone": phone
- },
- dataType: 'json',
- xhrFields: {
- withCredentials: true
- },
- crossDomain: true,
- type: 'get',
- timeout: 15000,
- success: function(dt) {
- //console.log(dt);
- if(dt.isRedirect) {
- location.href = dt.redirectURL;
- } else {
- if(dt.status) {
- console.log("获取短信成功!");
- } else {
- mui.alert("获取短信失败!请稍后重试");
- }
- }
- },
- error: function(xhr, type, errorThrown) {
- console.log(xhr);
- mui.alert("获取短信失败!网络错误");
- }
- });
- } else {
- if(phone != '') {
- show_msg = '手机号码格式不正确';
- } else {
- show_msg = '请填写手机号码';
- }
- mui.alert(show_msg);
- }
- });
- var countdown = 60;
- function settime(obj) {
- if(countdown <= 0) {
- obj.addClass("active").removeAttr("disabled");
- obj.text("获取验证码");
- countdown = 60;
- return;
- } else {
- obj.attr("disabled", true).removeClass("active");
- obj.text("重新发送" + countdown + "");
- countdown--;
- }
- setTimeout(function() {
- settime(obj)
- }, 1000)
- }
- //选择购买日期
- mui('body').on('tap', '#buyDate', function(event) {
- var date = new Date();
- var y = date.getFullYear();
- var m = date.getMonth(); //获取当前月份的日期
- var d = date.getDate();
- var picker = new mui.DtPicker({
- type: "date", //设置日历初始视图模式
- beginDate: new Date(2018, 00, 08), //设置开始日期
- endDate: new Date(y, m, d) //设置结束日期
- });
- picker.show(function(rs) {
- $("#buyDate").val(rs.text);
- picker.dispose();
- picker = null;
- });
- });
- //选择出生日期
- mui('body').on('tap', '#newDate', function(event) {
- var date = new Date();
- var y = date.getFullYear();
- var m = date.getMonth(); //获取当前月份的日期
- var d = date.getDate();
- var picker = new mui.DtPicker({
- type: "date", //设置日历初始视图模式
- beginDate: new Date(1949, 9, 01), //设置开始日期
- endDate: new Date((y - 8), 00, 01) //设置结束日期
- });
- picker.show(function(rs) {
- $("#newDate").val(rs.text);
- picker.dispose();
- picker = null;
- });
- });
- var qrCode = null;
- var isFocusOn = null;
- var userIdentity = null;
- mui.ready(function() {
- console.log("页面加载完毕");
- $(".loading").hide().css("opacity", "0"); //隐藏(正在加载...)
- //获取机器条码 barcode
- qrCode = getParam("qrCode");
- var code_data = JSON.parse(sessionStorage.getItem('code_data'));
- if(code_data != null) {
- $("#ipt-phone").val(code_data.phone);
- if((new Date().getTime() - code_data.codetime) > 59000) {
- $(".pull-code").addClass("active").removeAttr("disabled");
- } else {
- countdown = parseInt(60 - ((new Date().getTime() - code_data.codetime) / 1000));
- console.log(countdown)
- settime($(".pull-code"));
- }
- }
- if(qrCode != null) {
- $("#barCodeId").html("(" + qrCode + ")");
- $.ajax(base_path + '/wechat/getActivationAndMember?dates=' + new Date().getTime(), {
- data: {
- "qrCode": qrCode //产品类型id
- },
- dataType: 'json',
- xhrFields: {
- withCredentials: true
- },
- crossDomain: true,
- type: 'get',
- timeout: 15000,
- success: function(dt) {
- if(dt.isRedirect) {
- location.href = dt.redirectURL;
- } else {
- if(dt.status) { //判断接口返回状态status
- if(dt.data.isActivation) {
- //已激活
- mui.alert('该产品已被激活!', '提醒', function() {
- location.href = "my-center.html";
- });
- }
- if(dt.data.memberInfo.userStatus != 2) {
- //未关注
- mui.alert('请先关注公众号再激活!', '提醒', function() {
- location.href = "follow-me-tooth.html";
- });
- }
-
- //填充用户数据
- $("#ipt-name").val(dt.data.memberInfo.userName);
- if(dt.data.memberInfo.userSex != null) {
- if(dt.data.memberInfo.userSex == 1) {
- $("#maleId").attr("checked", true);
- }
- if(dt.data.memberInfo.userSex == 2) {
- $("#femaleId").attr("checked", true);
- }
- }
-
- if(dt.data.memberInfo.userIdentity == 1 && dt.data.memberInfo.userBirthDate != null){
- $("#js-userBirthDate").hide();
- isNeedBirthday = 2;
- }else{
- isNeedBirthday = 1;
- }
- oldPhone = dt.data.memberInfo.userTel;
-
- if(oldPhone != null && oldPhone != "" && typeof(oldPhone) != "undefined"){
- $("#ipt-phone").val(oldPhone);
- isNeedPhone = 2;
- }else{
- $("#js-phone").show();
- isNeedPhone = 1;
- }
-
- var radios = $(".radio1");
- switch(dt.data.memberInfo.userAgeStage) {
- case(1):
- radios.eq(0).attr("checked", true);
- break;
- case(2):
- radios.eq(1).attr("checked", true);
- break;
- case(3):
- radios.eq(2).attr("checked", true);
- break;
- case(4):
- radios.eq(3).attr("checked", true);
- break;
- case(5):
- radios.eq(4).attr("checked", true);
- break;
- case(6):
- radios.eq(5).attr("checked", true);
- }
-
- isFocusOn = dt.data.memberInfo.userStatus;
- userIdentity = dt.data.memberInfo.userIdentity;
- } else {
- mui.alert("查询失败!");
- } }
- },
- error: function(xhr, type, errorThrown) {
- console.log(xhr);
- mui.alert("网络错误!");
- }
- });
- }
- });
- $(document).on('tap', '#my-btn-submit', function() {
- validate(); //验证文本框
- var userName = $("#ipt-name").val();
- var userSex = $('input[name="radio0"]:checked ').val();
- var userBirthDate = $('#newDate').val();
- var apparatusStore = $('input[name="radio2"]:checked').val();
- var buyDate = $("#buyDate").val();
- var tel = $("#ipt-phone").val();
- var code = $("#code").val();
- var selectDate = new Date(Date.parse(buyDate));
- var nowDate = new Date(Date.parse(new Date().toLocaleDateString()));
- //if(selectDate>nowDate){
- //mui.alert("购买日期不能大于当前日期");
- //return false;
- //}
- if(validate_flag) {
- //验证通过
- $.ajax(base_path + '/wechat/apparatus/add_apparatus?dates=' + new Date().getTime(), {
- data: {
- "barCode": qrCode, //条码
- "userName": userName, //用户姓名
- "userSex": userSex, //用户姓名
- "userTel": tel, //手机
- "code": code, //验证码
- "userBirthDate": userBirthDate, //出生日期
- "apparatusStore": apparatusStore, //渠道id 1:天猫 2:淘宝 3:京东 4:微信 5:其他 6:一条 7:小红书
- "buyDate": buyDate //购买日期
- },
- dataType: 'json',
- xhrFields: {
- withCredentials: true
- },
- crossDomain: true,
- type: 'get',
- timeout: 15000,
- success: function(dt) {
- if(dt.isRedirect) {
- location.href = dt.redirectURL;
- } else {
- if(dt.status) { //判断接口返回状态status
- mui.alert('注册成功!', '温馨提示', function() {
- if(userIdentity == 1) { //会员
- if(isFocusOn == 1 || isFocusOn == 0) { //未关注
- location.href = "member-follow-me.html";
- } else { //已关注
- $.ajax(base_path + '/wechat/coupon/getIsReceive?dates=' + new Date().getTime(), {
- data: {},
- dataType: 'json',
- xhrFields: {
- withCredentials: true
- },
- crossDomain: true,
- type: 'get',
- timeout: 15000,
- success: function(dt) {
- //console.log(dt);
- if(dt.isRedirect) {
- location.href = dt.redirectURL;
- } else {
- if(dt.status) {
- console.log("未领取!");
- location.href = "welfare-service.html";
- } else {
- console.log("已领取!");
- location.href = "my-center.html";
- }
- }
- },
- error: function(xhr, type, errorThrown) {
- console.log(xhr);
- }
- });
- }
- } else { //非会员
- if(isFocusOn == 1 || isFocusOn == 0) { //未关注
- location.href = "follow-me.html";
- } else { //已关注
- location.href = "welfare-service.html";
- }
- }
- });
- } else {
- mui.alert(dt.message, '温馨提示', function() {
- location.href = "my-center.html";
- });
- }
- }
- },
- error: function(xhr, type, errorThrown) {
- console.log(xhr);
- mui.alert("网络错误");
- }
- });
- } else {
- mui.alert(dalog_msg); //弹窗提示
- }
- });
- //正则表达式示例
- var dalog_msg = '',
- validate_flag = false;
- function validate() {
- var ch_en_num = /^[A-Za-z_\-\u4e00-\u9fa5]{2,10}$/; //简体中文英文(2-10位)
- var positive_int = /^[0-9]\d*$/; //正整数0-9
- var code_int = /^[0-9]{4}$/; //正整数0-9,4位数字
- var mobile = /^(13|14|15|17|18)[0-9]{9}$/; //手机号码
- var full_date = /^\d{4}(\-|\/|.)\d{1,2}\1\d{1,2}$/; //日期格式 (2016\12\12,2016-12-12,2016.12.12)
- var name = $("#ipt-name").val().trim(),
- tel = $("#ipt-phone").val(),
- code = $("#code").val();
-
- validate_flag = false;
- if(!ch_en_num.test(name)) {
- //未通过验证
- if(name != '') {
- dalog_msg = '名字格式不正确';
- } else {
- dalog_msg = '请填写名字';
- }
- return dalog_msg;
- }
-
- //验证通过
- if($("#newDate").val() == null || $("#newDate").val() == "" ) {
- if(isNeedBirthday == 1){
- dalog_msg = '请选择出生日期';
- return dalog_msg;
- }
- }
-
- if(!mobile.test(tel)) {
- if(tel != '') {
- dalog_msg = '手机格式不正确';
- } else {
- dalog_msg = '请填写手机号码';
- }
- return dalog_msg;
- }
-
- if(isNeedPhone == 1){ //需要验证手机号码
- if(!code_int.test(code)) {
- if(code != '') {
- dalog_msg = '验证码格式不正确';
- } else {
- dalog_msg = '请填写验证码';
- }
- return dalog_msg;
- }
- }
-
- if($("#buyDate").val() == null || $("#buyDate").val() == "") {
- dalog_msg = '请选择购买日期';
- return dalog_msg;
- }
- validate_flag = true;
- return dalog_msg; //返回提示信息
- }
- </script>
- </body>
- </html>
|