enter.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. (function(global,factory){
  2. typeof define == 'function' && define(['store','helper','vue','reg-verify'],factory);
  3. })(this,function(app,$h,Vue,$reg){
  4. Vue.component('enter',{
  5. props: ['appear','url','site_name'],
  6. template:`<div>
  7. <div class="entry" :class="appear?'':'up'">
  8. <div class="title"><span class="knowledge iconguanbi2" @click="close"></span>手机号登录</div>
  9. <div class="entry-list">
  10. <div class="item"><input type="number" v-model="phone" placeholder="请输入手机号"></div>
  11. <div class="item item1 acea-row row-between-wrapper">
  12. <input type="number" style="width: 3.85rem;" v-model="code_num" placeholder="请输入验证码">
  13. <button class="code" style="height:100%;" :disabled="active" :class="active == true?'on':''" @click="code">{{timetext}}</button>
  14. </div>
  15. </div>
  16. <div class="select-btn">
  17. <div class="checkbox-wrapper"><label class="well-check"><input type="checkbox" v-model="agree" name="" value="1" checked="checked"><i class="icon"></i>已阅读并同意 <a :href="goagree()">[{{site_name}}付费用户协议]</a></label></div>
  18. </div>
  19. <div class="enterBnt acea-row row-center-wrapper" @click="login">登录</div>
  20. </div>
  21. <div class="mask" @touchmove.prevent :hidden="appear" @click.stop="close"></div>
  22. </div>`,
  23. data:function () {
  24. return {
  25. timetext:'获取验证码',
  26. active:false,
  27. phone:'',
  28. code_num:'',
  29. agree:1,
  30. }
  31. },
  32. mounted:function(){
  33. var that=this;
  34. $(document).ready(function () {
  35. that.$nextTick(function () {
  36. $("input").blur(function () {
  37. document.body && (document.body.scrollTop = document.body.scrollTop);
  38. })
  39. })
  40. })
  41. },
  42. methods:{
  43. goagree:function(){
  44. return $h.U({c:"index",a:'agree'});
  45. },
  46. login:function(){
  47. var that=this;
  48. if(!this.phone) return $h.pushMsgOnce('请输入手机号码');
  49. if(!$reg.isPhone(this.phone)) return $h.pushMsgOnce('您输入的手机号码不正确');
  50. if(!that.code_num) return $h.pushMsgOnce('请输入验证码');
  51. if(!that.agree) return $h.pushMsgOnce('请同意'+that.site_name+'付费用户协议');
  52. $h.loadFFF();
  53. that.url=that.url ? that.url : $h.U({c:'index',a:'login'});
  54. app.basePost(that.url,{phone:this.phone,code:this.code_num},function (res) {
  55. $h.loadClear();
  56. $h.showMsg({
  57. title:res.data.msg,
  58. icon:'success',
  59. success:function () {
  60. that.$emit("change",{action:'logComplete',value:res.data.data});
  61. }
  62. });
  63. },function (res) {
  64. $h.loadClear();
  65. $h.pushMsgOnce(res)
  66. },true);
  67. },
  68. code:function () {
  69. var that = this;
  70. if(!that.phone) return $h.pushMsgOnce('请输入手机号码');
  71. if(!$reg.isPhone(that.phone)) return $h.pushMsgOnce('请输入正确的手机号码');
  72. that.active = true;
  73. var n = 60;
  74. app.baseGet($h.U({c:'auth_api',a:'code',q:{phone:that.phone}}),function (res){
  75. var data=res.data.data;
  76. if(data.Message=='OK' || data.Code=='OK'){
  77. var run =setInterval(function(){
  78. n--;
  79. if(n<0){
  80. clearInterval(run);
  81. }
  82. that.timetext = "剩余 "+n+"s";
  83. if(that.timetext<"剩余 "+0+"s"){
  84. that.active = false;
  85. that.timetext = "重发";
  86. }
  87. },1000);
  88. }else{
  89. if(data.Code=='isv.BUSINESS_LIMIT_CONTROL')
  90. $h.pushMsgOnce('您的技能正在冷却中,请稍后再试!');
  91. else
  92. $h.pushMsgOnce(data.Message);
  93. that.active =false;
  94. }
  95. },function (res) {
  96. that.active =false;
  97. });
  98. },
  99. close:function (){
  100. this.$emit("change",{action:'loginClose',value:true})//$emit():注册事件;
  101. }
  102. }
  103. });
  104. })