sunran 3 лет назад
Родитель
Сommit
a9bef970bd

+ 2 - 13
src/utils/request.js

@@ -9,18 +9,6 @@ import {
 // request interceptor
 service.interceptors.request.use(
     config => {
-        // 根据requestBase判断切换不同域名 默认为VUE_APP_BASE_API
-        if (config.requestBase == 'VUE_APP_ZL_WSS') {
-            config.baseURL = process.env.VUE_APP_ZL_WSS;
-        }
-        if (config.requestBase == 'VUE_APP_ZL_WSS_ZP') {
-            config.baseURL = process.env.VUE_APP_ZL_WSS_ZP;
-        }
-        if (config.requestBase == 'VUE_APP_ZL_JF') {
-            config.baseURL = process.env.VUE_APP_ZL_JF;
-        }
-
-
         if (sessionStorage.getItem('x-token')) {
             config.headers['x-token'] = sessionStorage.getItem('x-token')
         }
@@ -51,13 +39,14 @@ service.interceptors.response.use(
                 return res
             }
         }
+        console.log(res)
         if (res.code === '0001') {
             Dialog({
                 message: res.message || 'Error'
             });
             return res
         }
-        if (res.code !== '0000') {
+        if (res.code !== '0000' || res.code !== '200') {
             Dialog({
                 message: res.message || 'Error'
             });

+ 80 - 0
src/utils/zprequest.js

@@ -0,0 +1,80 @@
+import axios from 'axios'
+
+const service = axios.create(
+    //     {
+    //     baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
+    // }
+)
+import {
+    Dialog
+} from 'vant';
+// request interceptor
+service.interceptors.request.use(
+    config => {
+        // 根据requestBase判断切换不同域名 默认为VUE_APP_BASE_API
+        if (config.requestBase == 'VUE_APP_ZL_WSS') {
+            config.baseURL = process.env.VUE_APP_ZL_WSS;
+            config.headers['Content-Type'] = 'application/x-www-form-urlencoded'
+        }
+        if (config.requestBase == 'VUE_APP_ZL_WSS_ZP') {
+            config.baseURL = process.env.VUE_APP_ZL_WSS_ZP;
+        }
+        if (config.requestBase == 'VUE_APP_ZL_JF') {
+            config.baseURL = process.env.VUE_APP_ZL_JF;
+        }
+
+
+        if (sessionStorage.getItem('x-token')) {
+            config.headers['x-token'] = sessionStorage.getItem('x-token')
+        }
+        if (config.type === 'change') {
+            config.headers['Content-Type'] = 'application/x-www-form-urlencoded'
+        } else if (config.type === 'formData') {
+            config.headers['Content-Type'] = 'multipart/form-data;charset=utf-8;'
+        } else {
+            config.headers['Content-Type'] = 'application/json'
+        }
+        return config
+    },
+    error => {
+        // do something with request error
+        console.log(error) // for debug
+        return Promise.reject(error)
+    }
+)
+
+// response interceptor
+service.interceptors.response.use(
+    response => {
+        console.log(response, 'response')
+        const res = response.data
+        const config = response.config
+        if (config != null) {
+            const blob = response.config.responseType
+            if (blob == 'blob') {
+                return res
+            }
+        }
+
+        if (res.code === '0001') {
+            Dialog({
+                message: res.msg || 'Error'
+            });
+            return res
+        }
+        if (res.code == '200' || response.status == '200') {
+            return res
+        } else if (response.statusCode == '500' || response.statusCode == '403' || response.statusCode == '404') {
+            Dialog({
+                message: res.msg || 'Error'
+            });
+            return Promise.reject(new Error(res.message || 'Error'))
+        }
+    },
+    error => {
+        console.log('err' + error) // for debug
+        return Promise.reject(error)
+    }
+)
+
+export default service

+ 0 - 1
src/views/zhulao/App.vue

@@ -21,7 +21,6 @@ export default {
   font-family: Avenir, Helvetica, Arial, sans-serif;
   -webkit-font-smoothing: antialiased;
   -moz-osx-font-smoothing: grayscale;
-  text-align: center;
   color: #2c3e50;
 }
 

+ 16 - 6
src/views/zhulao/api/index.js

@@ -1,4 +1,4 @@
-import request from '@/utils/request'
+import request from '@/utils/zprequest'
 // 新闻
 export function getTags(data) {
     return request({
@@ -8,11 +8,21 @@ export function getTags(data) {
         data
     })
 }
-// 新闻
-export function pageNews(data) {
+// 资讯 首页 邹平
+export function getArticleList(params) {
     return request({
-        url: '/pmadmin/app/mini/pageNews',
-        method: 'post',
-        data
+        url: '/cms/portal/article/list',
+        method: 'get',
+        requestBase: 'VUE_APP_ZL_WSS_ZP',
+        params
+    })
+}
+// 资讯 详情
+export function getArticleMessage(params) {
+    return request({
+        url: '/cms/portal/article/' + params.id,
+        method: 'get',
+        requestBase: 'VUE_APP_ZL_WSS_ZP',
+        params
     })
 }

+ 48 - 0
src/views/zhulao/components/Tabbar.vue

@@ -0,0 +1,48 @@
+<template>
+  <div>
+    <van-tabbar v-model="active" placeholder safe-area-inset-bottom active-color="#f0896e">
+      <van-tabbar-item v-for="(item,index) in list" :key="index">
+        <span>{{item.text}}</span>
+        <template #icon="props">
+          <img :src="props.active ? item.selectedIconPath : item.iconPath" />
+        </template>
+      </van-tabbar-item>
+    </van-tabbar>
+  </div>
+</template>
+<script>
+export default {
+  data() {
+    return {
+      active: 0,
+      list: [
+        {
+          iconPath: require('../assets/images/nav/home-off.png'),
+          selectedIconPath: require('../assets/images/nav/home-on.png'),
+          text: '首页',
+        },
+        {
+          iconPath: require('../assets/images/nav/book-off.png'),
+          selectedIconPath: require('../assets/images/nav/book-on.png'),
+          text: '老年课堂',
+        },
+        {
+          iconPath: require('../assets/images/nav/map-off.png'),
+          selectedIconPath: require('../assets/images/nav/map-on.png'),
+          text: '养老服务圈',
+        },
+        {
+          iconPath: require('../assets/images/nav/serve-store-off.png'),
+          selectedIconPath: require('../assets/images/nav/serve-store-on.png'),
+          text: '养老商城',
+        },
+        {
+          iconPath: require('../assets/images/nav/my-off.png'),
+          selectedIconPath: require('../assets/images/nav/my-on.png'),
+          text: '我的',
+        },
+      ],
+    }
+  },
+}
+</script>

+ 15 - 6
src/views/zhulao/router/router.js

@@ -4,13 +4,22 @@ import VueRouter from 'vue-router'
 Vue.use(VueRouter)
 
 const routes = [{
-    path: '/',
-    name: 'Login',
-    meta: {
-        keepAlive: true
+        path: '/',
+        name: 'Home',
+        meta: {
+            keepAlive: true
+        },
+        component: () => import('../views/home/index.vue')
     },
-    component: () => import('../views/login/index.vue')
-}]
+    {
+        path: '/newsDetails',
+        name: 'NewsDetails',
+        meta: {
+            keepAlive: true
+        },
+        component: () => import('../views/home/newsDetails.vue')
+    }
+]
 const router = new VueRouter({
     routes
 })

+ 245 - 0
src/views/zhulao/views/home/index.vue

@@ -0,0 +1,245 @@
+<template>
+  <div>
+    <van-nav-bar title="首页" fixed placeholder safe-area-inset-top />
+    <van-swipe class="my-swipe">
+      <van-swipe-item v-for="item in banner" :key="item.linkUrl" @click="$router.push({path:'/text',query:{id:item.linkUrl,title:'新闻资讯'}})">
+        <img :src="item.coverImgUrl" alt="">
+      </van-swipe-item>
+    </van-swipe>
+    <div class='main'>
+      <div class='collectName'>养老资讯</div>
+      <van-list v-model="loading" :immediate-check="false" :finished="finished" finished-text="没有更多了" @load="onLoad">
+        <div class="videoList">
+          <div v-for="(item,index) in info" @click="$router.push({path:'/newsDetails',query:{id:item.id}})" :key="index">
+            <div v-if="index == 2" class="info_bg">
+              <div class="sub_info_bg" bindtap="bedTap">
+                <div class="left">
+                  <img src="../../assets/images/homePage/bed.png" style="margin-left: 5px;width: 55px;height:45px;" />
+                  <div class="title_bg">
+                    <div>家庭养老床位</div>
+                    <div class="sub_title">把养老床位搬回家</div>
+                  </div>
+                </div>
+                <div class="right">
+                  <div class="right_info">立即了解</div>
+                </div>
+              </div>
+
+              <div class='videoBg'>
+                <!-- 标题 收藏数量 -->
+                <div class='videoNameBg'>
+                  <div class='videoName'>{{item.title}}</div>
+                  <div class='videoCollectBg'>
+                    <div class='videoCollectNum'>{{item.publishTime}}</div>
+                  </div>
+                </div>
+
+                <!-- 图文 或视频的图片 -->
+                <div class='coverImageBg' v-if='item.coverImgUrl != null'>
+                  <div class="videoImageBg">
+                    <van-image class='videoContent' :src='item.coverImgUrl' />
+                  </div>
+
+                </div>
+              </div>
+            </div>
+            <div class='videoBg' v-else>
+              <!-- 标题 收藏数量 -->
+              <div class='videoNameBg'>
+                <div class='videoName'>{{item.title}}</div>
+                <div class='videoCollectBg'>
+                  <div class='videoCollectNum'>{{item.publishTime}}</div>
+                </div>
+              </div>
+
+              <!-- 图文 或视频的图片 -->
+              <div class='coverImageBg' v-if='item.coverImgUrl != null'>
+                <div class="videoImageBg">
+                  <van-image class='videoContent' :src='item.coverImgUrl' />
+                </div>
+              </div>
+            </div>
+          </div>
+        </div>
+      </van-list>
+    </div>
+    <Tabbar />
+  </div>
+</template>
+<script>
+import { getTags, getArticleList } from '../../api/index.js'
+import Tabbar from '../../components/Tabbar.vue'
+export default {
+  components: { Tabbar },
+  data() {
+    return {
+      banner: [],
+      info: [],
+      loading: false,
+      finished: false,
+      pageNum: 1,
+      pageSize: 10,
+    }
+  },
+  created() {
+    this.getList('image')
+    this.onLoad()
+  },
+  methods: {
+    async getList(type) {
+      var data = {
+        orderByColumn: 'publish_time',
+        isAsc: 'desc',
+        pageNum: this.pageNum,
+        pageSize: this.pageSize,
+      }
+      if (type == 'image') {
+        data.articleLabel = 'image'
+      } else if (type == 'dynamic') {
+        data.columnCode = 'dynamic'
+      }
+      const res = await getArticleList(data)
+      if (res.code == '200') {
+        if (type == 'image') {
+          this.banner = res.rows
+        } else if (type == 'dynamic') {
+          if (this.pageNum == 1) {
+            this.info = res.rows
+          } else {
+            this.info = this.info.concat(res.rows)
+          }
+          if (this.info.length >= res.total) {
+            this.finished = true
+          }
+          this.loading = false
+          this.pageNum++
+        }
+      }
+    },
+    onLoad() {
+      this.getList('dynamic')
+    },
+    async getTags() {
+      const res = await getTags({})
+      console.log(res)
+    },
+  },
+}
+</script>
+<style lang="scss" scoped>
+.my-swipe {
+  width: 100%;
+  height: 300px;
+  overflow: hidden;
+  margin: 0 auto;
+  transform: translateY(0);
+  /deep/.van-swipe-item {
+    text-align: center;
+    overflow: hidden;
+    img {
+      width: 100%;
+      height: 100%;
+    }
+  }
+}
+.main {
+  margin-top: 26px;
+  width: calc(100% - 60px);
+  padding: 0 30px;
+  text-align: left;
+  .collectName {
+    margin-top: 10px;
+    color: #1c1c1c;
+    font-size: 34px;
+    padding-top: 10px;
+    box-sizing: border-box;
+  }
+}
+.videoBg {
+  margin-top: 26px;
+  display: flex;
+  flex-wrap: wrap;
+  border-bottom: 1px solid #f5f5f8;
+  .videoNameBg {
+    flex: 2;
+    height: 100%;
+    display: flex;
+    flex-direction: column;
+    justify-content: space-between;
+    align-items: flex-start;
+    .videoName {
+      color: #1a1a1a;
+      font-size: 30px;
+      display: -webkit-box;
+      overflow: hidden;
+      text-overflow: ellipsis;
+      word-wrap: break-word;
+      white-space: normal !important;
+      -webkit-line-clamp: 2;
+      -webkit-box-orient: vertical;
+    }
+    .videoCollectNum {
+      color: #9f9f9f;
+      font-size: 27px;
+    }
+    .videoCollectBg {
+      display: flex;
+      justify-content: flex-start;
+      align-items: center;
+      margin-bottom: 16px;
+      margin-top: 26px;
+    }
+  }
+}
+.info_bg {
+  width: 100%;
+  height: 335px;
+}
+.sub_info_bg {
+  margin: 0 auto;
+  height: 44%;
+  border-radius: 80px;
+  background-color: #ec9c67;
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+}
+.sub_info_bg .left {
+  flex: 2;
+  display: flex;
+}
+.title_bg {
+  color: white;
+  font-size: 34px;
+}
+.sub_title {
+  font-size: 26px;
+}
+.sub_info_bg .right {
+  flex: 1;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+}
+.right_info {
+  width: 80%;
+  line-height: 80px;
+  background-color: rgb(238, 238, 146);
+  border-radius: 40px;
+  font-size: 32px;
+  text-align: center;
+}
+.coverImageBg {
+  flex: 1;
+  height: 100%;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  margin-left: 16px;
+}
+.videoImageBg {
+  position: relative;
+  width: 214px;
+  height: 154px;
+}
+</style>

+ 32 - 0
src/views/zhulao/views/home/newsDetails.vue

@@ -0,0 +1,32 @@
+<template>
+  <div class="main">
+    <van-nav-bar title="资讯详情" @click-left="$router.back()" left-arrow fixed placeholder safe-area-inset-top />
+    <div v-html="content"></div>
+  </div>
+</template>
+<script>
+import { getArticleMessage } from '../../api/index.js'
+export default {
+  data() {
+    return {
+      content: '',
+    }
+  },
+  created() {
+    this.id = this.$route.query.id
+    this.getArticleMessage()
+  },
+  methods: {
+    async getArticleMessage() {
+      const res = await getArticleMessage({ id: this.id })
+      this.content = res.data.content
+    },
+  },
+}
+</script>
+<style lang="scss" scoped>
+.main {
+  padding: 0 30px;
+  font-size: 24px;
+}
+</style>