UiPhone.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <el-row class="form-group">
  3. <el-col :span="3" style="min-height:50px;padding-top:10px;">
  4. <label style="margin-left:10px;vertical-align: middle;" class="control-label">{{label ? label : 'Text'}}</label>
  5. </el-col>
  6. <el-col :span="9">
  7. <el-input
  8. :type="typeV"
  9. v-model="text"
  10. :placeholder="placeholder ? placeholder : ''"
  11. :disabled="disabled ? true : false"
  12. :name="name ? name : 'text'"
  13. :minlength="minlength ? parseInt(minlength) : 0"
  14. :maxlength="maxlength ? parseInt(maxlength) : 200"
  15. :auto-complete="autoComplete ? 'on' : 'off'"
  16. :readonly="readonly ? true : false"
  17. :show-password="showPassword ? true : false"
  18. :autofocus="autofocus ? true : false"
  19. :id="name"
  20. :size="size ? size : 'large'"
  21. @change="selectChange">
  22. </el-input>
  23. </el-col>
  24. <el-col :span="5">
  25. <button type="button" @click="sendCode()" class="btn btn-info" v-if="time_num*1<=0">发送验证码</button>
  26. <button type="button" class="btn" v-else>{{time_num}} s</button>
  27. </el-col>
  28. <el-col :span="6">
  29. <div class="classJs">
  30. <div v-if="tips">
  31. <span class="red">*</span>&ensp;{{tips}}
  32. </div>
  33. </div>
  34. </el-col>
  35. </el-row>
  36. </template>
  37. <script>
  38. export default {
  39. props: ['label','value','placeholder','disabled','name','minlength','maxlength','readonly','autofocus','autoComplete','size','tips', 'type', 'showPassword','send_url'],
  40. data() {
  41. return {
  42. 'text': this.value ? this.value : '',
  43. 'typeV': this.type ? this.type : 'number',
  44. 'time_num':0,
  45. };
  46. },
  47. mounted() {},
  48. methods: {
  49. selectChange(value) {
  50. this.$emit('set-keys',value);
  51. },
  52. sendCode:function (){
  53. var code_vue = this;
  54. console.log(this.send_url)
  55. if(this.text==''){
  56. layer.msg('请输入手机号码', {
  57. icon: 5,
  58. time: 2000
  59. });
  60. return false;
  61. }
  62. $.ajax({
  63. type: 'post',
  64. url: this.send_url,
  65. data: {
  66. 'phone': this.text,
  67. },
  68. dataType: 'json',
  69. success: function(msg) {
  70. console.log(msg)
  71. console.log(msg.message)
  72. if (msg.status * 1 == 1) {
  73. code_vue.time_num=60;
  74. layer.msg('短信发送成功', {
  75. icon: 1,
  76. time: 2000
  77. });
  78. var daojishiintevaltel = setInterval(function () {
  79. --code_vue.time_num;
  80. if (code_vue.time_num <= 0) {
  81. clearInterval(daojishiintevaltel);
  82. }
  83. }, 1000);
  84. }else {
  85. layer.msg(msg.message, {
  86. icon: 5,
  87. time: 2000
  88. });
  89. return false;
  90. }
  91. },
  92. error: function() {
  93. layer.msg('服务器繁忙,请稍后再试!!!', {
  94. icon: 3,
  95. time: 2000
  96. });
  97. }
  98. });
  99. }
  100. }
  101. }
  102. </script>
  103. <style scoped>
  104. .classJs {
  105. margin-left: 10px;
  106. vertical-align: middle;
  107. height:42px;
  108. line-height:42px;
  109. }
  110. .red{
  111. color: red;
  112. }
  113. </style>