xtz 4 lat temu
rodzic
commit
99c5e23543

+ 3 - 3
answer/.env.production

@@ -1,9 +1,9 @@
 // 生产环境
 module.exports={
   NODE_ENV = production
-  VUE_APP_API = https://api.yc1min.com
-  VUE_APP_IMG = https://cdn.yc1min.com
+  VUE_APP_API = https://api.winwin-sport.com
+  VUE_APP_IMG = https://zmbx.oss-cn-shanghai.aliyuncs.com
   VUE_APP_VER = 0.0.1
   VUE_APP_DAT = new Date().getTime()
-  VUE_APP_DOMAIN = info666.com
+  VUE_APP_DOMAIN = winwin-sport.com
 }

+ 1 - 1
answer/public/index.html

@@ -16,7 +16,7 @@
     <link rel="icon" href="<%= BASE_URL %>static/logo.ico">
     <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Noto+Sans+SC:100,300,400,500,600,700,900">
     <script src = "https://cdn.jsdelivr.net/npm/proxy-polyfill@0.3.0/proxy.min.js"></script>
-    <title>知识竞赛</title>
+    <title>冬奥冰雪项目线上知识普及竞答</title>
     <style>
       *{
         margin: 0;

+ 17 - 1
answer/src/App.vue

@@ -13,7 +13,23 @@
 </template>
 
 <script>
-
+export default {
+  methods: {
+    detection () {
+      this.$alert('<strong>这是 <i>HTML</i> 片段</strong>', {
+        title: '',
+        dangerouslyUseHTMLString: true,
+        showConfirmButton: false,
+        closeOnClickModal: false,
+        closeOnPressEscape: false,
+        showClose: false
+      })
+    }
+  },
+  mounted () {
+    // this.detection()
+  }
+}
 </script>
 
 <style lang="scss" scoped>

+ 2 - 2
answer/src/common/api/axios.js

@@ -31,10 +31,10 @@ service.interceptors.request.use(
         'from': 0,
         'page': 1,
         'rows': 10,
-        'companyId': localStorage.getItem('managerid') - 0,
+        'userId': (JSON.parse(localStorage.getItem('user')) || {}).id,
         'sidx': '',
         'sord': '',
-        'token': localStorage.getItem('token'),
+        'token': localStorage.getItem('token') || '',
         'reqdata': {}
       }
       config.data = Object.assign(data, config.data)

+ 6 - 0
answer/src/common/utils/utils.js

@@ -17,6 +17,12 @@ export default {
     second = second < 10 ? '0' + second : second
     return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second
   },
+  formatTime (time) {
+    var h = Math.floor(time / 60 / 60)
+    var s = Math.floor(time / 60)
+    var t = time % 60 % 60
+    return (h > 9 ? h : '0' + h) + ':' + (s > 9 ? s : '0' + s) + ':' + (t > 9 ? t : '0' + t)
+  },
   // 只显示年月日
   formatYMD (time) {
     let date = new Date(time)

+ 27 - 0
answer/src/router/index.js

@@ -22,6 +22,11 @@ const routes = [
     name: 'contest',
     component: () => import('@/views/contest.vue')
   },
+  {
+    path: '/index',
+    name: 'index',
+    component: () => import('@/views/index.vue')
+  },
   // error
   {
     path: '*',
@@ -47,4 +52,26 @@ const router = new VueRouter({
   routes
 })
 
+let info = JSON.parse(localStorage.getItem('user'))
+const whiteList = ['/info']
+router.beforeEach((to, from, next) => {
+  if (info && info.isRegister) {
+    whiteList.indexOf(to.path) !== -1
+      ? next({
+        name: 'contest'
+      })
+      : next()
+  } else {
+    // whiteList.indexOf(to.path) !== -1
+    to.path === '/contest'
+      ? next({
+        name: 'info'
+      })
+      : next()
+      // : next({
+      //   name: 'info'
+      // })
+  }
+})
+
 export default router

+ 21 - 11
answer/src/views/contest.vue

@@ -3,9 +3,9 @@
     <img class="bg" :src="bg" alt="">
     <div class="top" v-if="submitState!==2">
         <div class="top-message">
-            您还有
-            <div class="time">09:44</div>
-            秒答题
+            您已回答
+            <div class="time">{{$utils.formatTime(paperDuration)}}</div>
+            秒!
         </div>
         <div class="nav-list">
             <div :class="page===item?'active':''" v-for="item in 5" :key="item" @click="page=item">{{`第${(item-1)*10+1}-${item*10}题`}}</div>
@@ -35,10 +35,12 @@
             <div class="confim-button" @click="submit(false)" v-else>提交</div>
         </div>
         <div class="bounced" :style="conTop" v-if="submitState">
+            <i class="el-icon-error" @click="submitState = 0"></i>
+            <div :style="{'height':'50px'}" v-if="!(submitState===1)"></div>
             <img :src="icon" alt="">
             <div class="bounced-message">{{submitState===1?'您未答完全部题,确认提交吗?':'提交已成功!'}}</div>
             <div class="bounced-button" @click="submit(true)" v-if="submitState===1">提交</div>
-            <div class="bounced-button" v-else>返回</div>
+            <!-- <div class="bounced-button" v-else>返回</div> -->
         </div>
     </div>
 </div>
@@ -61,7 +63,8 @@ export default {
       paperId: null,
       timer: null,
       paperDuration: 0,
-      submitState: 0 // 0 正常 1 警告 2 完成
+      submitState: 0, // 0 正常 1 警告 2 完成
+      user: JSON.parse(localStorage.getItem('user')) || {}
     }
   },
   computed: {
@@ -93,7 +96,7 @@ export default {
     },
     getAttendContest () {
       this.$api.post('/mCompetition/attendContest', {
-        userId: 6
+        userId: this.user.id
       }).then(r => {
         this.questions = this.shuffle(r.object.questions)
           .map(item => {
@@ -135,12 +138,13 @@ export default {
           paperDuration,
           paperScore,
           questionWrong: JSON.stringify(questionWrong),
-          userId: 6
-        },
-        userId: 6
+          userId: this.user.id
+        }
       }).then(r => {
         this.submitState = 2
         clearInterval(this.timer)
+      }).catch(e => {
+        clearInterval(this.timer)
       })
     }
   },
@@ -150,7 +154,6 @@ export default {
   created () {
     this.timer = setInterval(() => {
       this.paperDuration += 1
-      console.log(this.paperDuration)
     }, 1000)
   },
   beforeDestroy () {
@@ -187,7 +190,7 @@ export default {
         align-items: center;
 
         .time {
-            width: 136px;
+            min-width: 136px;
             height: 39px;
             background: #495AFC;
             margin: 0 5px;
@@ -364,6 +367,13 @@ export default {
     flex-direction: column;
     align-items: center;
 
+    >i {
+        position: absolute;
+        top: 20px;
+        right: 10px;
+        font-size: 18px;
+    }
+
     >img {
         padding: 63px 0 34px 0;
         width: 50px;

+ 29 - 1
answer/src/views/index.vue

@@ -1,9 +1,37 @@
 <template>
+<div>
 
+</div>
 </template>
 
 <script>
-
+export default {
+  methods: {
+    login () {
+      this.$api.get('/weChat/pc/login').then(res => {
+        location.href = res.object
+      })
+    },
+    getUserInfo () {
+      let {
+        code,
+        state
+      } = this.$route.query
+      this.$api.get(`/weChat/callback/pc?code=${code}&state=${state}`).then(res => {
+        localStorage.setItem('user', JSON.stringify(res.object))
+        let time = setTimeout(() => {
+          location.href = location.origin + '/contest'
+          clearTimeout(time)
+        }, 500)
+      })
+    }
+  },
+  created () {
+    // let user = localStorage.getItem('user') ? JSON.parse(localStorage.getItem('user')) : {}
+    // this.$route.query.code || ((user && user.id) || this.login())
+    this.$route.query.code && this.getUserInfo()
+  }
+}
 </script>
 
 <style lang="scss" scoped>

+ 206 - 38
answer/src/views/info.vue

@@ -5,8 +5,15 @@
         <div class="form-list">
             <div class="form-item">
                 <div class="item-label">姓名</div>
-                <el-input v-model="form.actualName" class="item-right" placeholder="请输入"></el-input>
+                <el-input v-model.trim="form.actualName" class="item-right" placeholder="请输入中文"></el-input>
             </div>
+
+            <div class="warning" v-show="formItemShow[0]">
+                <img :src="warning" alt="">
+                <div class="warning-text">请填写姓名</div>
+            </div>
+            <div class="holder" v-show="!formItemShow[0]"></div>
+
             <div class="form-item">
                 <div class="item-label">性别</div>
                 <el-select v-model="form.sex" placeholder="请选择">
@@ -14,10 +21,25 @@
                     </el-option>
                 </el-select>
             </div>
+
+            <div class="warning" v-show="formItemShow[1]">
+                <img :src="warning" alt="">
+                <div class="warning-text">请选择性别</div>
+            </div>
+            <div class="holder" v-show="!formItemShow[1]"></div>
+
             <div class="form-item">
-                <div class="item-label">年龄</div>
-                <el-input v-model="form.age" class="item-right" placeholder="请输入"></el-input>
+                <div class="item-label">生日</div>
+                <el-date-picker v-model="form.birthday" prefix-icon="none" type="date" placeholder="选择日期">
+                </el-date-picker>
+            </div>
+
+            <div class="warning" v-show="formItemShow[2]">
+                <img :src="warning" alt="">
+                <div class="warning-text">请填写年龄</div>
             </div>
+            <div class="holder" v-show="!formItemShow[2]"></div>
+
             <div class="form-item">
                 <div class="item-label">区域</div>
                 <el-select v-model="form.area" placeholder="请选择">
@@ -25,6 +47,13 @@
                     </el-option>
                 </el-select>
             </div>
+
+            <div class="warning" v-show="formItemShow[3]">
+                <img :src="warning" alt="">
+                <div class="warning-text">请选择区域</div>
+            </div>
+            <div class="holder" v-show="!formItemShow[3]"></div>
+
             <div class="form-item">
                 <div class="item-label">学校</div>
                 <el-select v-model="form.school" filterable placeholder="请选择">
@@ -33,22 +62,34 @@
                 </el-select>
             </div>
 
-            <div class="warning">
+            <div class="warning" v-show="formItemShow[4]">
                 <img :src="warning" alt="">
                 <div class="warning-text">请填写学校完整名称</div>
             </div>
+            <div class="holder" v-show="!formItemShow[4]"></div>
+
+            <div class="form-item" v-show="schoolList.some(item => item.value === form.school) && schoolList.find(item => item.value === form.school).label.includes('其他')">
+                <div class="item-label">其他</div>
+                <el-input v-model.trim="form.other" class="item-right" placeholder="请输入学校名称"></el-input>
+            </div>
+            <div class="holder" v-show="schoolList.some(item => item.value === form.school) && schoolList.find(item => item.value === form.school).label.includes('其他')"></div>
 
             <div class="form-item">
                 <div class="item-label">年级</div>
-                <el-input v-model="form.grade" class="item-right" placeholder="请输入"></el-input>
+                <el-select v-model="form.grade" placeholder="请选择">
+                    <el-option v-for="item in gradeList" :key="item.value" :label="item.label" :value="item.value">
+                    </el-option>
+                </el-select>
             </div>
-            <div class="form-item">
-                <div class="item-label">其他</div>
-                <el-input v-model="form.other" class="item-right" placeholder="请输入"></el-input>
+
+            <div class="warning" v-show="formItemShow[5]">
+                <img :src="warning" alt="">
+                <div class="warning-text">请选择年级</div>
             </div>
+
         </div>
-        <div class="confim-button" @click="submit">Start Now !</div>
     </div>
+    <div class="confim-button" @click="submit">Start Now !</div>
 </div>
 </template>
 
@@ -58,16 +99,71 @@ export default {
     return {
       bg: require('../../public/img/info/bg.png'),
       warning: require('../../public/img/info/warning.png'),
-      form: {},
+      form: {
+        sex: 1,
+        school: ''
+      },
       sexList: [{
         label: '男',
-        vaule: 1
+        value: 1
       }, {
         label: '女',
         value: 2
       }],
       schoolList: [],
-      areaList: []
+      areaList: [],
+      gradeList: [{
+        label: '一年级',
+        value: '一年级'
+      },
+      {
+        label: '二年级',
+        value: '二年级'
+      },
+      {
+        label: '三年级',
+        value: '三年级'
+      },
+      {
+        label: '四年级',
+        value: '四年级'
+      },
+      {
+        label: '五年级',
+        value: '五年级'
+      },
+      {
+        label: '六年级',
+        value: '六年级'
+      },
+      {
+        label: '七年级',
+        value: '七年级'
+      },
+      {
+        label: '八年级',
+        value: '八年级'
+      },
+      {
+        label: '九年级',
+        value: '九年级'
+      },
+      {
+        label: '高一',
+        value: '高一'
+      },
+      {
+        label: '高二',
+        value: '高二'
+      },
+      {
+        label: '高三',
+        value: '高三'
+      }
+      ],
+      formItemList: ['actualName', 'sex', 'birthday', 'area', 'school', 'grade'],
+      formItemShow: [false, false, false, false, false, false],
+      user: JSON.parse(localStorage.getItem('user')) || {}
     }
   },
   methods: {
@@ -85,7 +181,11 @@ export default {
           id: val
         }
       }).then(r => {
-        this.schoolList = r.list.map(item => ({
+        let list = r.list
+        let index = list.findIndex(item => item.schoolName.includes('其他'))
+        let obj = list.splice(index, 1)
+        list.push(obj[0])
+        this.schoolList = list.map(item => ({
           label: item.schoolName,
           value: item.id
         }))
@@ -93,21 +193,82 @@ export default {
       })
     },
     submit (e) {
-      // let {actualName,age,area,grade,other,school} = this.data.form
-      // let id = wx.getStorageSync('id')
-      // imine.updateUser({reqdata:{actualName,age,area,grade,other,school,id}},r => {
-      this.$router.push({
-        name: 'contest'
+      let {
+        actualName,
+        sex,
+        birthday,
+        area,
+        grade,
+        other,
+        school
+      } = this.form
+      console.log(this.form)
+      this.formItemShow = this.formItemList.map(item => !this.form[item])
+      if (!actualName || !birthday || !area || !grade || !school || !sex) {
+        return
+      }
+      this.$api.post('/user/updateUser', {
+        reqdata: {
+          actualName,
+          sex,
+          birthday: this.$utils.formatYMD(birthday),
+          area,
+          grade,
+          other,
+          school,
+          id: this.user.id
+        }
+      }).then(() => {
+        this.$api.post('/user/queryUserById', {
+          reqdata: {
+            id: this.user.id
+          }
+        }).then(res => {
+          let loading = this.$loading({
+            lock: true,
+            text: 'Loading',
+            spinner: 'el-icon-loading',
+            background: 'rgba(0, 0, 0, 0.7)'
+          })
+          localStorage.setItem('user', JSON.stringify(res.object))
+          let time = setTimeout(() => {
+            location.reload()
+            loading.close()
+            clearTimeout(time)
+          }, 500)
+        })
+      })
+    },
+    login () {
+      this.$api.get('/weChat/pc/login').then(res => {
+        location.href = res.object
+      })
+    },
+    getUserInfo () {
+      let {
+        code,
+        state
+      } = this.$route.query
+      this.$api.get(`/weChat/callback/pc?code=${code}&state=${state}`).then(res => {
+        localStorage.setItem('user', JSON.stringify(res.object))
+        let time = setTimeout(() => {
+          location.href = location.origin + location.pathname
+          clearTimeout(time)
+        }, 500)
       })
-      // })
     }
   },
   mounted () {
+    let user = localStorage.getItem('user') && JSON.parse(localStorage.getItem('user'))
+    user || this.login()
     this.getareaList()
   },
   watch: {
     'form.area' (val) {
       this.getSchoolList(val)
+    },
+    'form.actualName' (val) {
+      this.form.actualName = val.replace(/[^\u4E00-\u9FA5]/g, '')
     }
   }
 }
@@ -117,6 +278,7 @@ export default {
 .el-input__inner {
     border: none;
     width: 340px !important;
+    padding-left: 15px !important;
 }
 
 .el-input {
@@ -138,24 +300,24 @@ export default {
     position: relative;
     z-index: 9;
     display: flex;
-    // justify-content: center;
+    height: 700px;
+    justify-content: center;
     align-items: center;
     flex-direction: column;
     padding-bottom: 20px;
+    padding-top: 300px;
 
     .form-list {
-        padding-top: 400px;
-        margin-bottom: 90px;
 
         .warning {
             width: 440px;
             display: flex;
-            margin-left: 24px;
-            margin-bottom: 20px;
+            margin-bottom: 6px;
+            padding-left: 20px;
 
-            image {
-                width: 18px;
-                height: 18px;
+            >image {
+                width: 16px;
+                height: 16px;
             }
 
             &-text {
@@ -174,7 +336,7 @@ export default {
             border-radius: 100px;
             display: flex;
             align-items: center;
-            margin-bottom: 20px;
+            margin-bottom: 10px;
 
             .item-label {
 
@@ -191,15 +353,21 @@ export default {
         }
     }
 
-    .confim-button {
-        background-image: linear-gradient(to right, #6247FF, #57A8EF);
-        width: 330px;
-        height: 65px;
-        border-radius: 60px;
-        color: #FFFFFF;
-        line-height: 65px;
-        font-size: 24px;
-        text-align: center;
-    }
+}
+
+.confim-button {
+    background-image: linear-gradient(to right, #6247FF, #57A8EF);
+    width: 330px;
+    height: 65px;
+    margin: 20px auto;
+    border-radius: 60px;
+    color: #FFFFFF;
+    line-height: 65px;
+    font-size: 24px;
+    text-align: center;
+}
+
+.holder {
+    height: 24px;
 }
 </style>