فهرست منبع

添加默认图片

sunjh 6 سال پیش
والد
کامیت
101cb7212b
5فایلهای تغییر یافته به همراه41 افزوده شده و 24 حذف شده
  1. 7 6
      src/components/Home.vue
  2. 7 4
      src/components/InstitutionRank.vue
  3. 4 3
      src/components/Mine.vue
  4. 18 11
      src/components/PersonRank.vue
  5. 5 0
      src/js/index.js

+ 7 - 6
src/components/Home.vue

@@ -51,7 +51,7 @@ import PersonRank from '@/components/PersonRank'
 import Http from '@/js/http.js'
 import Apis from '@/js/api.js'
 import {notify} from '@/constants/index'
-import {getRolesPermissions, storageGet} from '@/js/index'
+import {defaultValue, getRolesPermissions, storageGet} from '@/js/index'
 
 export default {
   name: 'Home',
@@ -60,6 +60,7 @@ export default {
     return {
       user: null,
       loading: false,
+      defaultValue: defaultValue,
       hotTaskList: [],
       institutionRank: [],
       personRank: [],
@@ -87,10 +88,10 @@ export default {
       //   notify('error','用户信息获取失败')
       // })
       this.setUserInfo()
-      if(this.rolesPermissions == null){
-        let NewPage = '_empty' + '?time=' + new Date().getTime()/500;
-        this.$router.push(NewPage);
-        this.$router.go(-1);
+      if (this.rolesPermissions == null) {
+        let NewPage = '_empty' + '?time=' + new Date().getTime() / 500
+        this.$router.push(NewPage)
+        this.$router.go(-1)
       }
       this.loadData()
     },
@@ -117,7 +118,7 @@ export default {
     //notify('warning', 'warning')
     //this.loadData()
   },
-  watch:{
+  watch: {
     rolesPermissions (val) {
       console.log(this.rolesPermissions)
       console.log(val)

+ 7 - 4
src/components/InstitutionRank.vue

@@ -4,7 +4,7 @@
       <el-table-column type="index" width="50"></el-table-column>
       <el-table-column prop="logo" width="120">
         <template slot-scope="scope">
-          <img class="logo-img" :src="scope.row.logo"/>
+          <img class="logo-img" :src="scope.row.logo==null?defaultValue.image:scope.row.logo"/>
         </template>
       </el-table-column>
       <el-table-column prop="name">
@@ -15,16 +15,19 @@
 </template>
 
 <script>
+import {defaultValue} from '@/js/index'
+
 export default {
   name: 'InstitutionRank',
   props: {item: {}},
   data () {
     return {
-      tableData: this.item
+      tableData: this.item,
+      defaultValue: defaultValue
     }
   },
-  watch:{
-    item(){
+  watch: {
+    item () {
       this.tableData = this.item
     }
   }

+ 4 - 3
src/components/Mine.vue

@@ -13,7 +13,7 @@
           <div class="user-banner">
             <p class="head">
               <a href="javascript:;" class="login-link">
-                <img src="http://www.mooctest.net/assets/img/mooctest.png" class="user-img">
+                <img :src="user == null || user.userVO.photo == null?defaultValue.image:user.userVO.photo" class="user-img">
                 <span class="vertify hide"></span>
               </a>
             </p>
@@ -90,7 +90,7 @@ import ProjectItem from '@/components/commons/ProjectItem'
 import Http from '@/js/http.js'
 import Apis from '@/js/api.js'
 import {notify} from '@/constants/index'
-import {getRolesPermissions, storageGet} from '@/js/index'
+import {defaultValue, getRolesPermissions, storageGet} from '@/js/index'
 
 export default {
   name: 'Mine',
@@ -102,7 +102,7 @@ export default {
     rolesPermissions (val) {
       this.rolesPermissions = val
     },
-    deep:true
+    deep: true
   },
   data () {
     return {
@@ -112,6 +112,7 @@ export default {
       myProjects: [],
       handlingProjects: [],
       acceptableProjects: [],
+      defaultValue: defaultValue,
       rolesPermissions: {
         isRegionManager: false,
         isIndividualUser: false,

+ 18 - 11
src/components/PersonRank.vue

@@ -4,35 +4,42 @@
       <el-table-column type="index" width="50"></el-table-column>
       <el-table-column prop="logo" width="70">
         <template slot-scope="scope">
-            <img class="user-img" :src="scope.row.logo"/>
+          <img class="user-img" :src="scope.row.logo==null?defaultValue.image:scope.row.logo"/>
         </template>
       </el-table-column>
-      <el-table-column prop="name"><template slot-scope="scope"><span class="institution-style">{{scope.row.name}}</span></template></el-table-column>
-      <el-table-column prop="number"><template slot-scope="scope"><span class="institution-style">{{scope.row.number}}</span></template></el-table-column>
+      <el-table-column prop="name">
+        <template slot-scope="scope"><span class="institution-style">{{scope.row.name}}</span></template>
+      </el-table-column>
+      <el-table-column prop="number">
+        <template slot-scope="scope"><span class="institution-style">{{scope.row.number}}</span></template>
+      </el-table-column>
     </el-table>
   </div>
 </template>
 
 <script>
+import {defaultValue} from '@/js/index'
+
 export default {
-  name: "PersonRank",
+  name: 'PersonRank',
   props: {item: {}},
-  data() {
+  data () {
     return {
-      tableData: this.item
+      tableData: this.item,
+      defaultValue: defaultValue
     }
   },
-  watch:{
-    item(){
+  watch: {
+    item () {
       this.tableData = this.item
     }
   }
-};
+}
 </script>
 
 <style lang="less" scoped>
-.institution-style{
+  .institution-style {
     font-size: 16px;
     font-weight: 600;
-}
+  }
 </style>

+ 5 - 0
src/js/index.js

@@ -2,6 +2,11 @@ import Http from './http'
 import Apis from './api'
 import ProvinceJson from '../constants/provinceCity'
 
+export const defaultValue = {
+  name: '普通用户',
+  image: 'http://www.mooctest.net/assets/img/mooctest.png',
+}
+
 //存session
 export const storageSave = (key, value) => {
   sessionStorage.setItem(key, JSON.stringify(value))