123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
- <title>绑定手机</title>
- <!-- <link href="../../../../static/h5sdk/css/bindMobile.css" rel="stylesheet"> -->
- <link href="__STATIC__/h5sdk/css/bindMobile.css?v=0.03" rel="stylesheet">
- </head>
- <body>
- <div class="float_pop-outer">
- <div class="float_pop-inner float_auth">
- <h4 class="float_pop-tit" style="color: #FF6905;">绑定手机
- <if condition="$game_auth neq 2">
- <i class="ic_off"><img src="__STATIC__/h5sdk/images/ic_off@2x.png"></i>
- </if>
- </h4>
- <div class="float_pop-con">
- <p class="float_auth-item">
- <label>
- <i class="icon_user"></i>
- <input name="mobile" type="text" placeholder="输入手机号">
- </label>
- </p>
- <div class="float_auth-item float_auth_item">
- <label class="code_label">
- <i class="icon_card"></i>
- <input name="code" type="text" placeholder="输入验证码" />
- </label>
- <button class="send">发送验证码</button>
- </div>
- <div class="float_auth-item password_item">
- <label>
- <i class="icon_card"></i>
- <input name="password" id="password" type="password" placeholder="设置新密码" />
- </label>
- <i class="showPwd"><img src="__STATIC__/h5sdk/images/icon-openeye.png"></i>
- <i class="hidePwd" style="display:none"><img src="__STATIC__/h5sdk/images/icon-closeeye.png"></i>
- </div>
- </div>
- <div class="float_pop-btn">
- <a style="max-width: 100%;background:#FF6905;" id="bindMobile" href="javascript:;"
- class="float_auth-primary">确定</a>
- </div>
- </div>
- </div>
- <div class="pop huosdk_tips" style="display: none;">
- <div class="pop_body">
- <h5>提示信息</h5>
- <p class="cont">请输入用户名</p>
- <p class="btn">
- <a href="javascript:;" onclick=" $(this).parents('.pop').hide()">确定</a>
- </p>
- </div>
- </div>
- <script src="__STATIC__/h5sdk/js/jquery.js"></script>
- <script src="__STATIC__/h5wap/js/md5.js"></script>
- <script>
- function getQueryString(name) {
- var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
- var r = window.location.search.substr(1).match(reg);
- if (r != null) {
- return unescape(r[2]);
- }
- return null;
- }
- window.identify_status = 1;
- var skip = getQueryString('skip')
- console.log(skip);
- /*默认为未验证通过*/
- $('#identify').click(function () {
- var realname = $('[name="realname"]').val().trim()
- var type = $('[name="type"]').val()
- var idcard = $('[name="idcard"]').val().trim()
- if (!realname) {
- $('.huosdk_tips').show().find('.cont').text('请输入您的真实姓名')
- return false
- }
- if (!idcard) {
- $('.huosdk_tips').show().find('.cont').text('请输入您的证件号码')
- return false
- }
- var token = window.sessionStorage.getItem('huosdk_HS-Token') || ''
- var device_type = $('[name="device_type"]').val();
- if (!token) {
- token = $('[name="token"]').val();
- }
- // var deviceType = window.sessionStorage.getItem('huosdk_HS-Device-Type')
- var data = {
- format: 'json',
- idcard: idcard,
- realname: realname,
- token: token,
- type: type,
- app_id: "{$app_id}",
- device_id: "{$device_id}",
- device_type: device_type
- }
- var sign = ''
- for (var key in data) {
- sign += '&' + key + '=' + data[key]
- }
- sign = sign.substr(1)
- sign = ('POST&' + encodeURIComponent('wap/identify/set') + '&' + encodeURIComponent(sign) + '&' + token).replace(/\(/g, '%28').replace(/\)/g, '%29')
- data.sign = md5(sign).toString()
- $.ajax({
- url: '/wap/identify/set',
- method: 'post',
- data: data,
- beforeSend: function (req) {
- // req.setRequestHeader('HS-Lang', 'cn')
- // req.setRequestHeader('HS-Token', token)
- // req.setRequestHeader('HS-Device-Type', deviceType)
- },
- success: function (res) {
- if (res.code === 200) {
- $('.huosdk_tips').show().find('.cont').text('认证成功!')
- $('.huosdk_tips .btn').click(function () {
- // var urlParams = new URLSearchParams(window.location.search);
- // var loginUrl = urlParams.get('login_url');
- // var username = urlParams.get('username')
- // var isBindPhone = urlParams.get('is_bind_phone')
- var loginUrl = getQueryString('login_url');
- var username = getQueryString('username')
- var isBindPhone = getQueryString('is_bind_phone')
- if (loginUrl) {
- var loginHref = loginUrl + '?is_back_from_auth=true&username=' + username
- if (isBindPhone) {
- loginHref += '&is_bind_phone=true'
- } else {
- loginHref += 'is_back_from_auth=true'
- }
- location.href = loginHref
- } else {
- window.parent.postMessage({
- type: 'identify.success'
- // type: 'frame.close'
- }, '*')
- $('#next').click()
- /*关闭窗口*/
- // window.huo && huo.closeWeb();
- }
- })
- window.identify_status = 2;
- $('.float_pop-outer').hide()
- /*传递身份证信息到客户端*/
- if (skip) return
- window.huo && huo.setIdentify(JSON.stringify({
- id_card: res.data.id_card, /*身份证信息*/
- real_name: res.data.real_name, /*身份证名称*/
- is_auth: $('[name=game_auth]').val(), /*认证模式*/
- birthday: res.data.birthday, /*用户生日*/
- status: 2
- }));
- } else {
- $('.huosdk_tips').show().find('.cont').text(res.msg);
- }
- }
- })
- })
- $('#bindMobile').click(function () {
- var token = window.sessionStorage.getItem('huosdk_HS-Token') || ''
- var mobile = $('[name="mobile"]').val();
- var code = $('[name="code"]').val();
- var password = $('[name="password"]').val();
- if (mobile == "") {
- $('.huosdk_tips').show().find('.cont').text('请输入手机号码');
- return;
- }
- if (code == "") {
- $('.huosdk_tips').show().find('.cont').text('请输入验证码');
- return;
- }
- if (password == "") {
- $('.huosdk_tips').show().find('.cont').text('请输入密码');
- return;
- }
- if (!token) {
- token = $('[name="token"]').val();
- }
- var data = {
- format: 'json',
- token: token,
- 'sms-type': 6,
- app_id: "{$app_id}",
- device_id: "{$device_id}",
- password:password,
- 'sms-mobile': mobile,
- 'sms-code': code
- }
- var sign = ''
- for (var key in data) {
- sign += '&' + key + '=' + data[key]
- }
- sign = sign.substr(1)
- sign = ('POST&' + encodeURIComponent('wap/identify/bind/post') + '&' + encodeURIComponent(sign) + '&' + token).replace(/\(/g, '%28').replace(/\)/g, '%29')
- data.sign = md5(sign).toString()
- $.ajax({
- url: '/wap/identify/bind/post',
- method: 'post',
- data: data,
- success: function (res) {
- if (res.code === 200) {
- if (res.data && res.data.url) {
- window.location.replace(res.data.url)
- } else {
- try {
- window.huo.completeAuth()
- } catch (err) {
- _self.huoAlert(err)
- }
- try {
- window.parent.postMessage({
- type: 'identify.success'
- }, '*')
- }catch(e){
- }
- }
- try {
- window.parent.postMessage({
- type: 'bindMobile.success'
- }, '*')
- }catch(e){
- }
- } else {
- $('.huosdk_tips').show().find('.cont').text(res.msg);
- }
- }
- })
- })
- $('#next').click(function () {
- // var urlParams = new URLSearchParams(window.location.search);
- // var loginUrl = urlParams.get('login_url');
- // var username = urlParams.get('username')
- // var isBindPhone = urlParams.get('is_bind_phone')
- var loginUrl = getQueryString('login_url');
- var username = getQueryString('username')
- var isBindPhone = getQueryString('is_bind_phone')
- if (loginUrl) {
- var loginHref = loginUrl + '?is_back_from_auth=true&username=' + username
- if (isBindPhone) {
- loginHref += '&is_bind_phone=true'
- }
- location.href = loginHref
- } else {
- window.parent.postMessage({
- type: 'frame.close'
- }, '*');
- /*关闭窗口*/
- if (skip) {
- } else {
- window.huo && huo.closeWeb();
- }
- }
- if (skip) {
- return
- }
- /*传递身份证信息到客户端*/
- if (window.identify_status == 1) {
- window.huo && huo.setIdentify(JSON.stringify({
- id_card: '', /*身份证信息*/
- real_name: '', /*身份证名称*/
- is_auth: $('[name=game_auth]').val(), /*认证模式*/
- birthday: '', /*用户生日*/
- status: 1
- }));
- }
- })
- $('.ic_off').click(function () {
- var identify_url='{$identify_url}';
- if(identify_url){
- window.location.replace(identify_url);
- return;
- }
- try {
- window.parent.postMessage({
- type: 'frame.close'
- }, '*');
- } catch (e) {
-
- }
- try {
- window.huo.completeAuth()
- } catch (err) {
- // $('.huosdk_tips').show().find('.cont').text(err)
- }
- })
- $('.showPwd').click(function () {
- $(this).hide()
- $('.hidePwd').show()
- $('#password').attr('type', "text")
- })
- $('.hidePwd').click(function () {
- $(this).hide()
- $('.showPwd').show()
- $('#password').attr('type', "password")
- })
- $('.send').click(function () {
- var mobile = $('[name="mobile"]').val();
- if (mobile == "") {
- $('.huosdk_tips').show().find('.cont').text('请输入手机号码');
- return;
- }
- getSms(mobile)
- })
- function getSms(mobile) {
- var token = window.sessionStorage.getItem('huosdk_HS-Token') || ''
- if (!token) {
- token = $('[name="token"]').val();
- }
- // var deviceType = window.sessionStorage.getItem('huosdk_HS-Device-Type')
- var data = {
- format: 'json',
- token: token,
- 'sms-type': 6,
- app_id: "{$app_id}",
- 'sms-mobile': mobile
- }
- var sign = ''
- for (var key in data) {
- sign += '&' + key + '=' + data[key]
- }
- sign = sign.substr(1)
- sign = ('POST&' + encodeURIComponent('wap/identify/sms/send') + '&' + encodeURIComponent(sign) + '&' + token).replace(/\(/g, '%28').replace(/\)/g, '%29')
- data.sign = md5(sign).toString()
- $.ajax({
- url: '/wap/identify/sms/send',
- method: 'post',
- data: data,
- success: function (res) {
- if (res.code === 200) {
- $('.huosdk_tips').show().find('.cont').text('发送验证码成功');
- var second = 60
- $(".send").prop('disabled', true)
- var timer = setInterval(function () {
- second--
- if (second == 0) {
- $('.send').text('发送验证码')
- clearInterval(timer)
- $('.send').removeAttr("disabled");
- } else {
- $('.send').text('时间('+second+')')
- }
- }, 1000)
- } else {
- $('.huosdk_tips').show().find('.cont').text(res.msg || '发送验证码失败');
- }
- }
- })
- }
- $(function () {
- /*隐藏APP标题栏*/
- window.huo && huo.setTitleVisibility(0);
- })
- </script>
- </body>
- </html>
|