Browse Source

修改提出的问题

Limengbo 5 years ago
parent
commit
30a725aa40
6 changed files with 72 additions and 41 deletions
  1. 2 1
      build/webpack.base.conf.js
  2. 3 0
      build/webpack.prod.conf.js
  3. 1 1
      config/prod.env.js
  4. 0 1
      package.json
  5. 44 33
      src/js/login.js
  6. 22 5
      src/js/main.js

+ 2 - 1
build/webpack.base.conf.js

@@ -9,7 +9,8 @@ var config = {
   },
   output: {
     path: path.resolve(__dirname, '../broadcast'),
-    filename: '[name].[hash].js'
+    filename: '[name].[hash].js',
+    publicPath: '/'
   },
   module:{
     rules: [

+ 3 - 0
build/webpack.prod.conf.js

@@ -11,6 +11,9 @@ const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
 
 module.exports = merge(baseConfig, {
   mode: 'production',
+  output: {
+    publicPath: './'
+  },
   module:{
     rules: [
       {

+ 1 - 1
config/prod.env.js

@@ -1,5 +1,5 @@
 'use strict'
 module.exports = {
   NODE_ENV: '"production"',
-  BASE_API: '"https://whiteboard.ai160.com/"',
+  BASE_API: '"https://whiteboardtest.ai160.com/"',
 }

+ 0 - 1
package.json

@@ -19,7 +19,6 @@
     "clean-webpack-plugin": "^2.0.2",
     "css-loader": "^2.1.1",
     "file-loader": "^3.0.1",
-    "glob": "^7.1.4",
     "html-webpack-plugin": "^3.2.0",
     "jquery": "^3.4.1",
     "less": "^3.9.0",

+ 44 - 33
src/js/login.js

@@ -1,21 +1,18 @@
 import '../style/style';
 import '../style/login';
 import $ from 'jquery';
-// 手机号正则
-const telStr = /^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/;
+import { fail } from 'assert';
 let code = '';
 let num = 10;
 let flag = true;
 $('.jurisdiction').hide();
+if(window.localStorage.getItem('uid')) {
+  $('.login').hide();
+  $('.jurisdiction').show();
+}
 $('#sendCode').click(function () {
   const phoneNum = $('#phoneNum').val().replace(/\s/ig,'');
-  if(!phoneNum) {
-    alert('请输入手机号')
-  }else if (!(telStr.test(phoneNum))) {
-    alert('手机号码输入不规范');
-    return false;
-  }
-  if(flag) {
+  if(proving(phoneNum) && flag) {
     // 调用获取验证码接口
     $.get(`${process.env.BASE_API}sharedWhiteBoard/wx/user/sendMag`, {
       phoneNum
@@ -31,27 +28,30 @@ $('#login').click(function () {
   const mobile = $('#phoneNum').val().replace(/\s/ig,'');
   const sign = $('#phoneCode').val().replace(/\s/ig,'');
   // if(sign == code) {
-    $.ajax({
-      url:`${process.env.BASE_API}sharedWhiteBoard/wx/user/loginByPhone`, 
-      type: 'POST',
-      data: JSON.stringify({
-        mobile,
-        sign
-      }), 
-      contentType: "application/json",
-      dataType: "json",
-      success: function (res) {
-        console.log(res)
-        if(res.code == 200) {
-          console.log(res.data.id)
-          window.localStorage.setItem('uid', res.data.id);
-          $('.login').hide();
-          $('.jurisdiction').show();
-        }else if (res.code == 600) {
-          console.log(res.message)
+    if(proving(mobile)) {
+      $.ajax({
+        url:`${process.env.BASE_API}sharedWhiteBoard/wx/user/loginByPhone`, 
+        type: 'POST',
+        data: JSON.stringify({
+          mobile,
+          sign
+        }), 
+        contentType: "application/json",
+        dataType: "json",
+        success: function (res) {
+          console.log(res)
+          if(res.code == 200) {
+            console.log(res.data.id)
+            window.localStorage.setItem('uid', res.data.id);
+            $('.login').hide();
+            $('.jurisdiction').show();
+          }else if (res.code == 600) {
+            console.log(res.message);
+            alert(res.message)
+          }
         }
-      }
-    });
+      });
+    }
   // }else {
   //   alert('验证码错误')
   // }
@@ -81,9 +81,9 @@ $('#ok').click(function () {
     dataType: "json",
     success: function (res) {
       if(res.code == 200) {
-        const  shareTask = JSON.stringify(res.data.shareTask);
-        window.sessionStorage.setItem('shareTask', shareTask);
-        window.location.href="/index.html"
+        const  shareTask = JSON.stringify(res.data);
+        window.sessionStorage.setItem('dataList', shareTask);
+        window.location.href="./index.html"
       }else if (res.code == 600) {
         console.log(res.message)
         alert(res.message)
@@ -92,7 +92,7 @@ $('#ok').click(function () {
   });
 })
 
-// 倒计时
+// 倒计时 
 const time = function () {
   setTimeout(function () {
     flag = false;
@@ -106,4 +106,15 @@ const time = function () {
       $('#sendCode').html('发送验证码').removeClass('color')
     }
   },1000)
+}
+
+// 验证手机号码
+const proving = (phone) => {
+  // 手机号正则
+ const telStr = /^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/;
+ if (!(telStr.test(phone))) {
+    alert('手机号码输入不规范');
+    return false;
+  }
+  return true;
 }

+ 22 - 5
src/js/main.js

@@ -1,14 +1,18 @@
 import '../style/style';
 import '../style/index';
 import $ from 'jquery';
+import { setTimeout } from 'timers';
 $(document).ready(function() {
-  const shareTask = window.sessionStorage.getItem('shareTask');
-  if(!shareTask) {
-    window.location.href="/login.html";
+  const dataList = window.sessionStorage.getItem('dataList');
+  if(!dataList) {
+    window.location.href="./login.html";
     return false;
   }
-  const boardUrl = JSON.parse(shareTask).boardUrl;
-  const desktopUrl = JSON.parse(shareTask).desktopUrl;
+  const boardUrl = JSON.parse(dataList).shareTask.boardUrl;
+  const desktopUrl = JSON.parse(dataList).shareTask.desktopUrl;
+  const title = JSON.parse(dataList).shareJoinUser.title;
+  const shareJoinUserId =  JSON.parse(dataList).shareJoinUser.id;
+  $('.title').html(title)
   let bigVideo = new ChimeePlayer({
     wrapper: '#bigVideo',  // video dom容器
     src: boardUrl,
@@ -37,4 +41,17 @@ $(document).ready(function() {
     smallVideo.muted = true;
     bigVideo.muted = false;
   })
+  // 判断用户是否存在回调
+  function shareJoin () {
+    setTimeout(function () {
+      $.get(`${process.env.BASE_API}sharedWhiteBoard/shareJoin/update`, {
+        shareJoinUserId
+      }, function (res) {
+        if(res.code == 200) {
+          shareJoin();
+        }
+      });
+    },5000)
+  }
+  shareJoin();
 })