registerDialog.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <el-dialog
  3. :close-on-click-modal="false"
  4. :visible.sync="telDl"
  5. @close="delDlClose"
  6. class="register-free-dialog"
  7. center>
  8. <i></i>
  9. <h4>为帮助您更好的使用产品,请先验证手机信息</h4>
  10. <p v-if="systemType==='ksAdmin'||systemType==='ksClient'||systemType==='ksDownload'">今日已有<span>{{kaoshiCnt}}</span>人 体验了考试系统</p>
  11. <p v-if="systemType==='pxAdmin'||systemType==='pxClient'||systemType==='pxDownload'">今日已有<span>{{peixunCnt}}</span>人 体验了培训系统</p>
  12. <el-form :model="telChangeDate" status-icon :rules="telRules" ref="ruleTelForm" class="application-scheme-form">
  13. <el-form-item prop="tel">
  14. <el-input v-model="telChangeDate.tel" placeholder="请输入手机号" class="dialog-input-tel"></el-input>
  15. </el-form-item>
  16. <!--<div id="your-dom-id" class="nc-container"></div>-->
  17. <!--<el-form-item prop="verification">-->
  18. <!--<div class="verification">-->
  19. <!--<el-input v-model="telChangeDate.verification" placeholder="请输入验证码" class="dialog-input-code"></el-input>-->
  20. <!--<el-button @click="checkVerification" :disabled="btnTextDisabled" type="primary" class="jcrk-primary-btn">{{btnText}}</el-button>-->
  21. <!--</div>-->
  22. <!--</el-form-item>-->
  23. <el-form-item prop="company">
  24. <el-input v-model="telChangeDate.company" placeholder="请输入公司名称" class="dialog-input-tel"></el-input>
  25. </el-form-item>
  26. </el-form>
  27. <div class="application-scheme-btn" @click="dialogSave">进入使用</div>
  28. </el-dialog>
  29. </template>
  30. <script>
  31. export default {
  32. name: 'regDialog',
  33. props: {
  34. //弹窗显隐 flag
  35. dialogVisible: {
  36. type: Boolean,
  37. require: true,
  38. },
  39. // ks为考试 px为培训
  40. systemType: {
  41. type: String,
  42. default: 'ksClient',
  43. require: true,
  44. },
  45. },
  46. data() {
  47. return {
  48. telDl: false,
  49. telChangeDate: {},// 弹窗信息
  50. btnTextDisabled: false,
  51. btnText: '获取验证码',
  52. countdown: 60, // 60秒倒计时
  53. sliderData: {},
  54. appKey: 'FFFF0N00000000007EC0',
  55. telRules: {
  56. tel: [
  57. { trigger: 'blur', required: true, message: '请输入手机号' },
  58. ],
  59. company: [
  60. { trigger: 'blur', required: true, message: '请输入公司名称' },
  61. ],
  62. },
  63. kaoshiCnt:0,// 考试人数
  64. peixunCnt:0,// 培训人数
  65. };
  66. },
  67. computed: {
  68. baseUrl() {
  69. },
  70. },
  71. watch:{
  72. // 监听 addOrUpdateVisible 改变
  73. dialogVisible(oldVal,newVal){
  74. this.telDl = this.dialogVisible;
  75. },
  76. },
  77. methods: {
  78. // 关闭
  79. delDlClose(){
  80. this.countdown = -1;
  81. this.telChangeDate.appKey=undefined;
  82. this.$refs.ruleTelForm.resetFields();
  83. // 子组件调用父组件方法,并传递参数
  84. this.$emit('changeShow','false')
  85. },
  86. // 倒计时60秒
  87. setTime() {
  88. if (this.countdown === 0) {
  89. this.btnTextDisabled = false;
  90. this.btnText = '免费获取验证码';
  91. this.countdown = 60;
  92. } else if(this.countdown === -1){
  93. this.btnTextDisabled = false;
  94. this.btnText = '获取验证码';
  95. this.countdown = 60;
  96. } else {
  97. this.btnTextDisabled = true;
  98. this.btnText = '重新发送(' + this.countdown + 's)';
  99. this.countdown--;
  100. setTimeout(() => {
  101. this.setTime();
  102. }, 1000);
  103. }
  104. },
  105. /**
  106. * 串联加载指定的脚本
  107. * 串联加载[异步]逐个加载,每个加载完成后加载下一个
  108. * 全部加载完成后执行回调
  109. * @param array|string 指定的脚本们
  110. * @param function 成功后回调的函数
  111. * @return array 所有生成的脚本元素对象数组
  112. * 异步加载js后运行回调函数callback / scripts 为数组或字符串
  113. */
  114. seriesLoadScripts(scripts, callback) {
  115. if (typeof (scripts) != 'object') {
  116. var scripts = [scripts];
  117. }
  118. var HEAD = document.getElementsByTagName('head').item(0) || document.documentElement;
  119. var s = new Array(), last = scripts.length - 1, recursiveLoad = function (i) { //递归
  120. s[i] = document.createElement('script');
  121. s[i].setAttribute('type', 'text/javascript');
  122. s[i].onload = s[i].onreadystatechange = function () { //Attach handlers for all browsers
  123. if (!/*@cc_on!@*/0 || this.readyState == 'loaded' || this.readyState == 'complete') {
  124. this.onload = this.onreadystatechange = null;
  125. this.parentNode.removeChild(this);
  126. if (i != last) {
  127. recursiveLoad(i + 1);
  128. } else if (typeof (callback) == 'function') {
  129. callback();
  130. }
  131. }
  132. };
  133. s[i].setAttribute('src', scripts[i]);
  134. HEAD.appendChild(s[i]);
  135. };
  136. recursiveLoad(0);
  137. },
  138. // 用户注册接口(帮助后台计算)
  139. userRegister(){
  140. const options = {
  141. tel: '下载记录',
  142. code: '123123',
  143. company: "LLISOFT",
  144. };
  145. this.$axios.$post('/user/tiyan/add',options).then(res=>{});
  146. },
  147. // 进入使用
  148. dialogSave(){
  149. this.$refs.ruleTelForm.validate((valid) => {
  150. if (valid) {
  151. // 请求后台
  152. const options = {
  153. tel: this.telChangeDate.tel,
  154. // code: this.telChangeDate.verification,
  155. company: this.telChangeDate.company,
  156. };
  157. if (!/^1[3-9]\d{9}$/.test(this.telChangeDate.tel)) {
  158. this.$message.error('手机号格式错误');
  159. return false;
  160. }
  161. this.$axios.$post('/user/tiyan/add',options).then(res=>{
  162. if (res.code === 0 && res.data) {
  163. this.telDl = false;
  164. switch (this.systemType) {
  165. case 'ksAdmin':
  166. window.open('http://8.144.165.203:8087/kaoshi/admin/loginForTiyan.html');
  167. break;
  168. case 'ksClient':
  169. window.open('http://8.144.165.203:8087/kaoshi/mta/loginForTiyan.html');
  170. break;
  171. case 'pxAdmin':
  172. window.open('http://8.144.165.203:8087/peixun/admin/loginForTiyan.html');
  173. break;
  174. case 'pxClient':
  175. window.open('http://8.144.165.203:8087/peixun/mta/loginForTiyan.html');
  176. break;
  177. case 'ksDownload':
  178. window.location.href='https://mta3.oss-cn-qingdao.aliyuncs.com/kaoshi%20v3.8.3_190618.zip';
  179. this.userRegister();
  180. break;
  181. case 'pxDownload':
  182. window.location.href='https://mta3.oss-cn-qingdao.aliyuncs.com/peixun%20v3.8.3_190618.zip';
  183. this.userRegister();
  184. break;
  185. default:
  186. window.open('http://8.144.165.203:8087/kaoshi/admin/loginForTiyan.html');
  187. }
  188. this.$message.success('申请成功');
  189. } else {
  190. this.$message.error(res.msg);
  191. }
  192. });
  193. }
  194. });
  195. },
  196. },
  197. created() {
  198. // 页面初始化
  199. this.$axios.$post('/user/tiyan/info').then(res=>{
  200. this.kaoshiCnt = res.data.kaoshiCnt;
  201. this.peixunCnt = res.data.kaoshiCnt;
  202. });
  203. },
  204. };
  205. </script>