CourseDevelopPhone.vue 6.1 KB

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