瀏覽代碼

add role to user table and add hot_columns to homepage

Starink 6 年之前
父節點
當前提交
f4f96cd762

+ 38 - 0
assets/css/column-card.scss

@@ -0,0 +1,38 @@
+.column-card{
+  cursor: pointer;
+  width: 320px;
+  height: 265px;
+  padding: 0;
+  border-radius: 5px;
+
+  &__picture{
+    width: 320px;
+    height: 160px;
+  }
+
+  &__header{
+    margin: 15px 20px 5px 20px;
+
+  }
+  &__title{
+    display: block;
+    color: $common-color;
+  }
+
+  &__origin{
+    display: block;
+    color: $sub-color;
+    font-size: 13px;
+  }
+
+  &__description{
+    color: $note-color;
+    width: 100%;
+    padding: 5px 20px;
+    font-size: 12px;
+  }
+
+  .el-card__body{
+    padding: 0;
+  }
+}

+ 1 - 1
assets/css/home.scss

@@ -36,5 +36,5 @@ a{
   flex-wrap: nowrap;
   flex-wrap: nowrap;
   align-items: flex-end;
   align-items: flex-end;
   justify-content: space-between;
   justify-content: space-between;
-  padding: 30px 50px 60px 50px;
+  padding: 30px 50px;
 }
 }

+ 1 - 0
assets/css/main.scss

@@ -87,6 +87,7 @@ body{
   padding: 30px 50px 0 50px;
   padding: 30px 50px 0 50px;
   border: 1px solid #ebeef5;
   border: 1px solid #ebeef5;
   box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
   box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
+  margin-top: 50px;
 
 
   &__main{
   &__main{
     width: 100%;
     width: 100%;

+ 56 - 0
components/ColumnCard.vue

@@ -0,0 +1,56 @@
+<template>
+  <el-card class="column-card" @click.native="checkColumnDetail" shadow="hover" :body-style="bodyStyle">
+    <img :src="picture" class="column-card__picture"/>
+    <div class="column-card__header">
+      <h4 class="column-card__title">{{title}}</h4>
+    </div>
+    <div class="column-card__description">{{description}}</div>
+  </el-card>
+</template>
+
+<script>
+  export default {
+    name: "ColumnCard",
+    props: {
+      title: {
+        type: String,
+        require: true,
+        default: "课程xxxxxxx"
+      },
+      // origin: {
+      //   type: String,
+      //   require: true,
+      //   default:"课程提供者xxx"
+      // },
+      picture: {
+        type: String,
+        require: true,
+        default: "/image/seec_logo.png"
+      },
+      url: {
+        type: String,
+        require: true,
+        default: "/"
+      },
+      description: {
+        type: String,
+        default: ""
+      }
+    },
+    data(){
+      return{
+        bodyStyle: {padding : '0'}
+      }
+    },
+    methods: {
+      checkColumnDetail(){
+        // window.location.href = this.url;
+      }
+    }
+
+  };
+</script>
+
+<style lang="scss" scoped>
+  @import '~/assets/css/column-card.scss';
+</style>

+ 25 - 2
pages/index.vue

@@ -33,18 +33,33 @@
       >
       >
       </course-card>
       </course-card>
     </div>
     </div>
+
+    <h1 class="title">热门专栏</h1>
+    <div class="course-list">
+      <column-card
+        v-for="(item,index) in columns"
+        v-bind:key="index"
+        :picture="item.picture"
+        :title="item.title"
+        :description="item.description"
+        :url="item.url"
+      >
+      </column-card>
+    </div>
   </div>
   </div>
 </template>
 </template>
 
 
 <script>
 <script>
 import Logo from '~/components/Logo.vue'
 import Logo from '~/components/Logo.vue'
 import CourseCard from '~/components/CourseCard'
 import CourseCard from '~/components/CourseCard'
+import ColumnCard from '~/components/ColumnCard'
 import { mapState } from 'vuex'
 import { mapState } from 'vuex'
 
 
 export default {
 export default {
   components: {
   components: {
     Logo,
     Logo,
-    CourseCard
+    CourseCard,
+    ColumnCard
   },
   },
   data() {
   data() {
     return {
     return {
@@ -54,7 +69,7 @@ export default {
           origin: '中国大学MOOC',
           origin: '中国大学MOOC',
           picture: '/image/java.png',
           picture: '/image/java.png',
           url: 'http://mooc.seecoder.cn',
           url: 'http://mooc.seecoder.cn',
-          description: '了解编程基本思想 养成编程基本习惯 理解面向对象思想'
+          description: '了解编程基本思想,养成编程基本习惯,理解面向对象思想'
         },
         },
         {
         {
           title: '软件工程与计算I',
           title: '软件工程与计算I',
@@ -70,6 +85,14 @@ export default {
           url: 'http://seec.seecoder.cn',
           url: 'http://seec.seecoder.cn',
           description: '基于DevOps培养团队开发中小规模软件系统的能力'
           description: '基于DevOps培养团队开发中小规模软件系统的能力'
         },
         },
+      ],
+      columns: [
+        {
+          title: '深度学习入门',
+          picture: '/image/deep_learning.png',
+          url: 'http://seec.seecoder.cn',
+          description: '掌握深度学习基础数学知识,理解深度学习有关算法和原理,了解和使用深度学习工具'
+        }
       ]
       ]
     }
     }
   },
   },

+ 0 - 1
pages/login.vue

@@ -140,7 +140,6 @@
           password: this.password
           password: this.password
         }).then((res) =>
         }).then((res) =>
           {
           {
-            console.log("login res:", res.data);
             if(res.code === 0){
             if(res.code === 0){
               localStorage.phone=this.phone;
               localStorage.phone=this.phone;
               if(this.rememberPassword){
               if(this.rememberPassword){

+ 1 - 1
pages/register.vue

@@ -69,7 +69,7 @@
           }
           }
         }, 1000);
         }, 1000);
         this.$api.post("/user/sendMessage", {"phone":this.phone}).then(res => {
         this.$api.post("/user/sendMessage", {"phone":this.phone}).then(res => {
-          if(res.code === 0){
+          if(res.data.code === 0){
             this.$message({
             this.$message({
               showClose: true,
               showClose: true,
               message: '发送成功',
               message: '发送成功',

+ 6 - 3
server/controller/user.js

@@ -39,7 +39,7 @@ class UserController {
                 auth_time: Math.floor(new Date().getTime() / 1000),
                 auth_time: Math.floor(new Date().getTime() / 1000),
                 iat: Math.floor(new Date().getTime() / 1000),
                 iat: Math.floor(new Date().getTime() / 1000),
                 exp: Math.floor(new Date().getTime() / 1000 + 24 * 60 * 60),
                 exp: Math.floor(new Date().getTime() / 1000 + 24 * 60 * 60),
-                user_info: {phone: user.phone, email: user.email, id: user.id, name: user.name}
+                user_info: {phone: user.phone, email: user.email, id: user.id, name: user.name ,role: user.role}
               };
               };
               const token = jwt.sign(data, secret.sign);
               const token = jwt.sign(data, secret.sign);
 
 
@@ -104,13 +104,16 @@ class UserController {
         if(result.Code === "OK"){
         if(result.Code === "OK"){
           ctx.session.verification_code = code;
           ctx.session.verification_code = code;
           ctx.session.verification_phone = phone;
           ctx.session.verification_phone = phone;
-          console.log('verification_code:', ctx.session.verification_code );
+          console.log('verification_code:', ctx.session.verification_code);
+          ctx.body = Response.success({message: '发送成功'});
         }else{
         }else{
-          console.log("error:", message);
+          console.log("error:", result.message);
+          ctx.body = Response.failed("发送失败,请重试");
         }
         }
 
 
       }catch (e) {
       }catch (e) {
         console.log(e);
         console.log(e);
+        ctx.body = Response.failed("发送失败,请重试");
       }
       }
 
 
     }
     }

+ 7 - 1
server/schema/user.js

@@ -20,12 +20,18 @@ module.exports = (sequelize, DataTypes) =>
         phone: {
         phone: {
             type: DataTypes.STRING(64),
             type: DataTypes.STRING(64),
             allowNull: false,
             allowNull: false,
-            unique: true
+            unique: 'column'
         },
         },
       email: {
       email: {
         type: DataTypes.STRING(512),
         type: DataTypes.STRING(512),
         allowNull: false,
         allowNull: false,
         defaultValue: "xxxxx@xxx.com"
         defaultValue: "xxxxx@xxx.com"
+      },
+      role: {
+        type:   DataTypes.ENUM,
+        values: ['STUDENT', 'TEACHER', 'ADMIN'],
+        allowNull: false,
+        defaultValue: 'STUDENT'
       },
       },
         signature: {
         signature: {
             type: DataTypes.STRING(512),
             type: DataTypes.STRING(512),

二進制
static/image/SEEC_banner3.png


二進制
static/image/deep_learning.png