Browse Source

添加banner图配置

asd123a20 3 years ago
parent
commit
c046038c5f

BIN
src/assets/people/new1.png


BIN
src/assets/people/new2.png


BIN
src/assets/people/new3.png


BIN
src/assets/people/r1.png


BIN
src/assets/people/r2.png


BIN
src/assets/people/r4.png


BIN
src/assets/people/r5.png


BIN
src/assets/people/r6.png


BIN
src/assets/people/r8.png


+ 14 - 25
src/components/banner.vue

@@ -1,47 +1,36 @@
 <template>
   <el-carousel indicator-position="none" height="500px" class="carousel">
-    <el-carousel-item v-for="(item, index) in list" :key="index">
+    <el-carousel-item v-for="(item, index) in bannerList" :key="index">
       <img :src="item.path" alt="banner" class="banner" @click="btn(item)">
     </el-carousel-item>
   </el-carousel>
 </template>
 
 <script>
+import { createNamespacedHelpers } from 'vuex'
+const { mapState, mapActions } = createNamespacedHelpers('banner')
 export default {
   components: {},
   data () {
-    return {
-      list: [
-        {
-          title: '图片1',
-          shortTitle: '这是第一张图片',
-          slug: '这是第一张图片描述',
-          path: require('../assets/banner/26025416.png'),
-          annex: '',
-          istop: false,
-          id: '2'
-        },
-        {
-          title: '图片2',
-          shortTitle: '这是第2张图片',
-          slug: '这是第2张图片描述',
-          path: require('../assets/banner/26025632.png'),
-          annex: '',
-          istop: false,
-          id: '2'
-        }
-      ]
-    }
+    return {}
   },
   methods: {
+    ...mapActions(['getbanner']),
     btn (e) {
+      localStorage.setItem('itemId', -1)
       const routeData = this.$router.resolve({
-        path: `/www/page/${e.id}`
+        path: `/www/page/${e._id}`,
+        query: { type: 'banenr' }
       })
       window.open(routeData.href)
     }
   },
-  mounted () {}
+  async mounted () {
+    await this.getbanner()
+  },
+  computed: {
+    ...mapState(['bannerList'])
+  }
 }
 </script>
 

+ 2 - 0
src/components/heads/menus.vue

@@ -27,6 +27,7 @@ export default {
       // eslint-disable-next-line eqeqeq
       if (e.code == '0') {
         this.$router.push('/www/')
+        localStorage.setItem('itemId', e.code)
         return
       }
       // eslint-disable-next-line eqeqeq
@@ -34,6 +35,7 @@ export default {
         window.open(e.uri)
         return
       }
+      // localStorage.setItem('itemId', e.code)
       // eslint-disable-next-line eqeqeq
       if (e.type == '0') {
         this.$router.push(

+ 30 - 0
src/store/banner.js

@@ -0,0 +1,30 @@
+import axios from 'axios'
+const api = {
+  query: '/api/banner/query',
+  details: '/api/banner/details/'
+}
+const state = {
+  bannerList: [],
+  banneritem: {}
+}
+const mutations = {
+  banner (state, payload) {
+    state.bannerList = payload
+  },
+  details (state, payload) {
+    state.banneritem = payload.data
+  }
+}
+const actions = {
+  async getbanner ({ commit }, payload) {
+    const res = await axios.get(api.query)
+    if (res.data.errcode === 0) commit('banner', res.data.data)
+    return res
+  },
+  async getdetails ({ commit }, { id } = {}) {
+    const res = await axios.get(`${api.details}${id}`)
+    if (res.data.errcode === 0) commit('details', res.data)
+    return res
+  }
+}
+export default { state, mutations, actions, namespaced: true }

+ 1 - 1
src/store/content.js

@@ -19,7 +19,7 @@ const mutations = {
 }
 const actions = {
   async getcontent ({ commit }, { code, skip, limit } = {}) {
-    const res = await axios.get(api.query, { params: { code, skip, limit } })
+    const res = await axios.get(api.query, { params: { columns: code, skip, limit } })
     if (res.data.errcode === 0) commit('content', res.data)
     return res
   },

+ 3 - 1
src/store/index.js

@@ -4,6 +4,7 @@ import menu from './menu'
 import column from './column'
 import content from './content'
 import page from './page'
+import banner from './banner'
 Vue.use(Vuex)
 
 export default new Vuex.Store({
@@ -17,6 +18,7 @@ export default new Vuex.Store({
     menu,
     column,
     content,
-    page
+    page,
+    banner
   }
 })

+ 15 - 3
src/views/Home.vue

@@ -9,7 +9,7 @@
         <div class="abouttext">
           <h4>本刊介绍:</h4>
           <p>
-            {{ pageitem && pageitem.shortTitle }}
+            {{ pageitem && pageitem.title }}
           </p>
           <p>{{ pageitem && pageitem.slug }}</p>
           <b>→</b>
@@ -60,7 +60,7 @@
         <div class="circular" @click="jump(item, '4')" :class="{ circular2: mous == index }" v-for="(item, index) in reviewlist" :key="index" @mouseover="mouseOver(index)" @mouseleave="mouseLeave(index)">
           <div class="txtbox">
             <p class="year" :class="{ year2: mous == index }">{{ item.year }}</p>
-            <p class="date" :class="{ date2: mous == index }">{{ item.date }}</p>
+            <p class="date" :class="{ date2: mous == index }">{{ item.term }}</p>
             <p class="title" :class="{ title2: mous == index }">{{ item.title }}</p>
             <p class="text" :class="{ text2: mous == index }">{{ item.slug }}</p>
             <p class="yes" :class="{ yes2: mous == index }">✔</p>
@@ -143,8 +143,8 @@ export default {
       window.open(routeData.href)
     },
     jumpList (e) {
-      console.log(e)
       this.$router.push(`/www/list/${e}`)
+      localStorage.setItem('itemId', e)
     }
   },
   async mounted () {
@@ -384,6 +384,12 @@ export default {
           margin-top: 5px;
           font-size: 1em;
           color: #222;
+          overflow: hidden;
+          text-overflow: ellipsis;
+          display: -webkit-box;
+          -webkit-line-clamp: 1;
+          -webkit-box-orient: vertical;
+          word-break: break-all;
         }
         .date {
           font-size: 2.5em;
@@ -393,6 +399,12 @@ export default {
           margin-top: 10px;
           font-size: 0.8em;
           color: #666666;
+          overflow: hidden;
+          text-overflow: ellipsis;
+          display: -webkit-box;
+          -webkit-line-clamp: 2;
+          -webkit-box-orient: vertical;
+          word-break: break-all;
         }
         .yes {
           width: 30px;

+ 7 - 8
src/views/details.vue

@@ -7,7 +7,6 @@
         <titles :type="'正文'" :title="item" :en="en"></titles>
         <div class="html">
           <h2>{{ contentitem.title }}</h2>
-          <h4>{{ contentitem.shortTitle }}</h4>
           <p class="slug">{{ contentitem.slug }}</p>
           <div class="content" v-html="contentitem.content"></div>
         </div>
@@ -35,24 +34,24 @@ export default {
   data () {
     return {
       item: '',
-      en: '',
-      code: ''
+      en: ''
     }
   },
   methods: {
     ...mapActions(['getmenu']),
     ...contentmapActions(['getdetails']),
     async filteritem () {
-      this.code = localStorage.getItem('itemId')
-      const items = this.items.filter(p => p.code === this.code)[0]
-      this.item = items.name
-      this.en = items.en
+      const code = localStorage.getItem('itemId') || -1
+      const items = this.items.filter(p => p.code === code)[0]
+      this.item = items.name || ''
+      this.en = items.en || ''
     }
   },
   async mounted () {
     const res = await this.getmenu()
     if (res.data.errcode === 0) this.filteritem()
-    this.getdetails({ id: this.id })
+    console.log(this.$router)
+    // await this.getdetails({ id: this.id })
   },
   computed: {
     ...mapState(['items']),

+ 5 - 5
src/views/list.vue

@@ -11,7 +11,7 @@
           <div class="details">{{ item.slug }}</div>
           <div class="other">
             <div class="el-icon-time date">{{ item.createAt | dates }}</div>
-            <div class="el-icon-view num">{{ item.num || 100 }}</div>
+            <div class="el-icon-view num">{{ item.hits || 0 }}</div>
           </div>
         </div>
       </el-card>
@@ -68,16 +68,16 @@ export default {
     },
     async filteritem () {
       const items = this.items.filter(p => p.code === this.id)[0]
-      this.item = items.name
-      this.en = items.en
+      this.item = items.name || ''
+      this.en = items.en || ''
       const res = await this.getcolumn(items)
       if (res.data.errcode === 0) {
         await this.getcontent({ code: this.columnitems[0].code, skip: 0, limit: this.pageSize })
       }
     }
   },
-  mounted () {
-    this.getmenu()
+  async mounted () {
+    await this.getmenu()
     this.filteritem()
   },
   computed: {

+ 28 - 11
src/views/page.vue

@@ -6,10 +6,9 @@
       <div class="box">
         <titles :type="'正文'" :title="item" :en="en"></titles>
         <div class="html">
-          <h2>{{ pageitem && pageitem.title }}</h2>
-          <h4>{{ pageitem && pageitem.shortTitle }}</h4>
-          <p class="slug">{{ pageitem && pageitem.slug }}</p>
-          <div class="content" v-html="pageitem && pageitem.content"></div>
+          <h2>{{ pagedetails && pagedetails.title }}</h2>
+          <p class="slug">{{ pagedetails && pagedetails.slug }}</p>
+          <div class="content" v-html="pagedetails && pagedetails.content"></div>
         </div>
       </div>
     </div>
@@ -23,6 +22,7 @@ import titles from '../components/sidebar/title.vue'
 import { createNamespacedHelpers } from 'vuex'
 const { mapState, mapActions } = createNamespacedHelpers('menu')
 const { mapState: pagemapState, mapActions: pagemapActions } = createNamespacedHelpers('page')
+const { mapState: bannermapState, mapActions: bannermapActions } = createNamespacedHelpers('banner')
 export default {
   props: {
     id: String
@@ -36,27 +36,44 @@ export default {
     return {
       item: '',
       en: '',
-      code: ''
+      code: '',
+      pagedetails: {}
     }
   },
   methods: {
     ...mapActions(['getmenu']),
     ...pagemapActions(['getdetails']),
+    ...bannermapActions({ bannergetdetails: 'getdetails' }),
     async filteritem () {
-      this.code = localStorage.getItem('itemId')
-      const items = this.items.filter(p => p.code === this.id)[0]
-      this.item = items.name
-      this.en = items.en
+      let items = {}
+      if (this.code !== '-1') {
+        items = this.items.filter(p => p.code === this.id)[0]
+      }
+      // eslint-disable-next-line eqeqeq
+      this.item = this.code == '-1' ? '轮播图' : items.name
+      // eslint-disable-next-line eqeqeq
+      this.en = this.code == '-1' ? 'image' : items.en
     }
   },
   async mounted () {
+    this.code = localStorage.getItem('itemId')
     const res = await this.getmenu()
     if (res.data.errcode === 0) this.filteritem()
-    this.getdetails({ code: this.id })
+    // eslint-disable-next-line eqeqeq
+    if (this.code == '-1') {
+      console.log(111)
+      await this.bannergetdetails({ id: this.id })
+      this.pagedetails = this.banneritem
+    } else {
+      console.log(222)
+      await this.getdetails({ code: this.id })
+      this.pagedetails = this.pageitem
+    }
   },
   computed: {
     ...mapState(['items']),
-    ...pagemapState(['pageitem'])
+    ...pagemapState(['pageitem']),
+    ...bannermapState(['banneritem'])
   },
   watch: {
     id (val) {

+ 1 - 1
vue.config.js

@@ -11,7 +11,7 @@ module.exports = {
         target: 'http://localhost:7001'
         // target: 'http://192.168.4.1:7001'
       },
-      '/files/images/': {
+      '/filespath/resource/': {
         target: 'http://jjzh.cc-lotus.info'
       }
     }