registerPhone.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <!-- 课程申请方案弹窗 仅手机使用-->
  3. <div class="course-develop-page register-phone-page">
  4. <div>
  5. <p class="course-develop-title">填写信息,免费为您开通使用账户</p>
  6. <el-form :model="telChangeDate" status-icon ref="ruleTelForm" class="course-develop-form">
  7. <el-form-item prop="tel">
  8. <el-input v-model="telChangeDate.tel" placeholder="请输入手机号" class="dialog-input-tel"></el-input>
  9. </el-form-item>
  10. <el-form-item prop="company">
  11. <el-input v-model="telChangeDate.company" placeholder="请输入公司名称" class="dialog-input-tel"></el-input>
  12. </el-form-item>
  13. <el-form-item prop="company" class="dialog-input-company">
  14. <el-radio-group v-model="telChangeDate.modules" >
  15. <el-radio label="1">考试系统</el-radio>
  16. <el-radio label="2">培训系统</el-radio>
  17. </el-radio-group>
  18. </el-form-item>
  19. <div class="form-blue-btn" @click="dialogSave">申请方案</div>
  20. </el-form>
  21. <a href="tel:400-052-2130" class="course-develop-tel">咨询电话:400-052-2130</a>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. export default {
  27. name: 'CourseDevelopPhone',
  28. layout: 'templateB',
  29. data() {
  30. return {
  31. telChangeDate: {
  32. tel:'',
  33. verification:'',
  34. company:'',
  35. modules:'1',
  36. },
  37. pageName:'',// 跳进来的页面名称
  38. btnTextDisabled: false,
  39. btnText: '获取验证码',
  40. countdown: 60, // 60秒倒计时
  41. sliderData: {},
  42. appKey: 'FFFF0N00000000007EC0',
  43. };
  44. },
  45. head(){
  46. },
  47. computed: {},
  48. methods: {
  49. // 申请方案按钮
  50. dialogSave(){
  51. this.$refs.ruleTelForm.validate((valid) => {
  52. if (valid) {
  53. // 请求后台
  54. const options = {
  55. phone: this.telChangeDate.tel,
  56. };
  57. if (!/^1[3-9]\d{9}$/.test(this.telChangeDate.tel)) {
  58. this.$message.error('手机号格式错误');
  59. return false;
  60. }
  61. this.$axios.$post('/develop/add',options).then(res=>{
  62. if (res.code === 0 && res.data) {
  63. this.$message({customClass:'phone-message-box',type: 'success',message: '申请成功'});
  64. // 根据跳进来的页面跳出去
  65. switch (this.pageName) {
  66. case 'shouye':
  67. this.$router.push({ name: 'index' });
  68. break;
  69. case 'course':
  70. this.$router.push({ name: 'courseware' });
  71. break;
  72. case 'resources':
  73. this.$router.push({ name: 'resources' });
  74. break;
  75. default:
  76. this.$router.push({ name: 'index' });
  77. }
  78. }else{
  79. this.$message({customClass:'phone-message-box',type: 'error',message: res.msg});
  80. }
  81. });
  82. }
  83. });
  84. },
  85. // 验证码
  86. checkVerification() {
  87. if(this.telChangeDate.tel===''||this.telChangeDate.tel===undefined){
  88. this.$message({customClass:'phone-message-box',type: 'error',message: '请填写手机号'});
  89. return;
  90. }else if(this.sliderData.appkey === undefined){
  91. this.$message({customClass:'phone-message-box',type: 'error',message: '请先通过滑块校验'});
  92. return;
  93. }
  94. this.$axios.$post(`/develop/exists`,{ phone: this.telChangeDate.tel}).then(res=>{
  95. if (res.code === 0 && res.data) {
  96. let req = {
  97. 'appkey': this.sliderData.appkey,
  98. 'phone': this.telChangeDate.tel,
  99. 'scene': this.sliderData.scene,
  100. 'sessionid': this.sliderData.csessionid,
  101. 'sig': this.sliderData.sig,
  102. 'token': this.sliderData.token,
  103. 'type': 0,
  104. }
  105. this.$axios.$post('/sendCode',req).then(res=>{
  106. if (res.code === 0 && res.data) {
  107. this.setTime();
  108. }else{
  109. this.$message({customClass:'phone-message-box',type: 'error',message: res.msg});
  110. }
  111. })
  112. } else {
  113. this.$message.error('手机号已存在');
  114. return false;
  115. }
  116. })
  117. },
  118. /**
  119. * 串联加载指定的脚本
  120. * 串联加载[异步]逐个加载,每个加载完成后加载下一个
  121. * 全部加载完成后执行回调
  122. * @param array|string 指定的脚本们
  123. * @param function 成功后回调的函数
  124. * @return array 所有生成的脚本元素对象数组
  125. * 异步加载js后运行回调函数callback / scripts 为数组或字符串
  126. */
  127. seriesLoadScripts(scripts, callback) {
  128. if (typeof (scripts) != 'object') {
  129. var scripts = [scripts];
  130. }
  131. var HEAD = document.getElementsByTagName('head').item(0) || document.documentElement;
  132. var s = new Array(), last = scripts.length - 1, recursiveLoad = function (i) { //递归
  133. s[i] = document.createElement('script');
  134. s[i].setAttribute('type', 'text/javascript');
  135. s[i].onload = s[i].onreadystatechange = function () { //Attach handlers for all browsers
  136. if (!/*@cc_on!@*/0 || this.readyState == 'loaded' || this.readyState == 'complete') {
  137. this.onload = this.onreadystatechange = null;
  138. this.parentNode.removeChild(this);
  139. if (i != last) {
  140. recursiveLoad(i + 1);
  141. } else if (typeof (callback) == 'function') {
  142. callback();
  143. }
  144. }
  145. };
  146. s[i].setAttribute('src', scripts[i]);
  147. HEAD.appendChild(s[i]);
  148. };
  149. recursiveLoad(0);
  150. },
  151. // 倒计时60秒
  152. setTime() {
  153. if (this.countdown === 0) {
  154. this.btnTextDisabled = false;
  155. this.btnText = '免费获取验证码';
  156. this.countdown = 60;
  157. } else {
  158. this.btnTextDisabled = true;
  159. this.btnText = '重新发送(' + this.countdown + 's)';
  160. this.countdown--;
  161. setTimeout(() => {
  162. this.setTime();
  163. }, 1000);
  164. }
  165. },
  166. },
  167. created() {
  168. this.pageName = this.$route.query.pageName;
  169. },
  170. mounted() {
  171. },
  172. beforeDestroy() {
  173. },
  174. };
  175. </script>