Ver Fonte

优化集成

wbspool há 4 anos atrás
pai
commit
3b39e4f816

+ 2 - 2
package.json

@@ -2,8 +2,8 @@
   "private": true,
   "scripts": {
     "postinstall": "husky install",
-    "dev:pc": "vite --mode pc",
-    "dev:h5": "vite --mode h5",
+    "dev:pc": "vite --mode pc --host",
+    "dev:h5": "vite --mode h5 --host",
     "build": "vite build",
     "build:h5": "vite build --mode h5",
     "build:pc": "vite build --mode pc",

+ 1 - 1
src/h5/components/ui-search/ui-search.vue

@@ -43,7 +43,7 @@
                 },1000);
             },
             handleConfirm(){
-                if(this.searchPage){
+                if(!this.searchPage){
                     this.$router.push('/search?keyword=' + this.keyword);
                 }else{
                     this.$emit('search',this.keyword);

+ 35 - 7
src/h5/pages/article-detail/article-detail.vue

@@ -90,7 +90,7 @@
             <div class="font-light text-size-30rem text-primary mt-23rem">{{$t('分享海报')}}
             </div>
           </div>
-          <div class="flex flex-col items-center">
+          <div @click="handleShareLink" class="flex flex-col items-center">
             <img src="/imgs/h5-share-link.png" class="w-70rem"/>
             <div class="font-light text-size-30rem text-primary mt-23rem">
               {{$t('分享链接')}}
@@ -100,8 +100,8 @@
       </van-action-sheet>
 
       <van-overlay :show="exportVisible">
-        <div class="w-screen h-full flex flex-col items-center justify-between ">
-          <div ref="post"
+        <div  class="w-screen h-full flex flex-col items-center justify-between ">
+          <div v-if="!postUrl" ref="post"
             class="mt-24rem w-675rem h-1037rem  py-38rem flex flex-col items-center bg-white rounded-10rem px-45rem">
             <div class=" text-primary text-size-36rem mb-72rem">
               {{ $t("杂志期刊") }}
@@ -113,7 +113,7 @@
             <div class="text-size-30rem text-[#686868] leading-30rem mt-36rem font-light">
               {{article.description}}
             </div>
-            <div class="flex items-center w-full justify-end mt-74rem">
+            <div class="flex items-center w-full justify-end mt-74rem pb-45rem">
               <div class="mr-10rem text-[#B8B8B8] text-size-14rem h-84rem flex flex-col justify-between">
                 <div class="mb-10rem">{{$t('作者')}}:{{article.author}}</div>
                 <div class="text-right">{{$t('时间')}}:{{article.publishTimeStr}}</div>
@@ -121,6 +121,8 @@
               <img src="/imgs/export-qrcode.png" class="w-120rem h-120rem" />
             </div>
           </div>
+          <img v-else :src="postUrl" >
+
           <div class="w-full h-200rem bg-white flex justify-center items-center relative">
             <img @click="exportVisible = false" src="/imgs/h5-action-close.png"
               class="w-32rem absolute top-30rem right-30rem" />
@@ -165,6 +167,18 @@ import FileSaver from "file-saver";
 import domtoimage from "dom-to-image";
 export default {
   methods: {
+    async handleShareLink(){
+
+      const str = window.location.href;
+      const inputo = document.createElement("input");
+      document.body.appendChild(inputo);
+      inputo.value = str;
+      inputo.setAttribute('readOnly', 'readOnly')
+      inputo.select();
+      document.execCommand("Copy");
+      document.body.removeChild(inputo);
+      this.$toast(this.$t('链接已复制到剪贴板'));
+    },
     async handleCommentInputBlur(){
         setTimeout(()=>{
            this.commentFocus =false;
@@ -172,9 +186,9 @@ export default {
     },
     async exportPost() {
 
-      const url = await domtoimage.toPng(this.$refs.post, { filter: false });
-
-      FileSaver.saveAs(url, "post.png");
+      // const url = await domtoimage.toPng(this.$refs.post, { filter: false });
+      // window.open(url);
+      this.$toast(this.$t('长按上面图片保存到相册'));
     },
   async handleCollect(){
 
@@ -248,6 +262,19 @@ export default {
       })
     },
   },
+  watch:{
+    exportVisible(){
+       if(this.exportVisible){
+          this.$nextTick(()=>{
+            domtoimage.toSvg(this.$refs.post, { filter: false ,scale:8}).then((url)=>{
+              this.postUrl = url;
+            });
+          })
+
+         //  FileSaver.saveAs(url, "post.png");
+       }
+    }
+  },
 
   computed:{
     shareUrl(){
@@ -260,6 +287,7 @@ export default {
   },
   data() {
     return {
+      postUrl:'',
       exportVisible: false,
       subscriped: true,
       html: ``,

+ 1 - 1
src/h5/pages/home/home.vue

@@ -11,7 +11,7 @@
             <ui-banner class="w-full h-390rem" flag="首页"></ui-banner>
 
             <div class="flex justify-around mt-24rem mb-24rem">
-              <div class="type-item">
+              <div @click="$router.push('/recommend')" class="type-item">
                 <img class="w-68rem h-68rem object-contain" src="/imgs/recommend-type.png" />
                 <div>{{$t('首页')}}</div>
               </div>

+ 2 - 1
src/h5/pages/publish/publish.vue

@@ -4,7 +4,8 @@
       <div  v-html="simpleArticle.content"></div>
     </div>
 
-    
+     <div class="w-180rem h-88rem bg-primary rounded-full flex justify-center items-center text-[#fff] " style="position:fixed;bottom: 120rem;right: 24rem;ackground: #124026;box-shadow: 0px 3rem 6rem 1rem rgba(0,0,0,0.16);">我要投稿</div>
+
   </ui-page-layout>
 </template>
 

+ 120 - 34
src/h5/pages/recommend/recommend.vue

@@ -1,46 +1,132 @@
 <template>
-  <ui-page-layout title="推荐内容">
+  <ui-page-layout title="实时新闻">
     <template v-slot:search>
       <ui-search></ui-search>
     </template>
-    <ui-mask-picture class="w-full h-136rem"></ui-mask-picture>
-    
-    <UiMainArticle v-for="index in 8"></UiMainArticle>
+    <ui-mask-picture flag="实时新闻" bannerClass="w-full h-136rem"></ui-mask-picture>
+
+    <div class="pl-22rem pr-22rem">
+      <UiMainArticle v-for="art in latestArts" :item="art"></UiMainArticle>
+    </div>
+
+
+  </ui-page-layout>
+</template>
+
+<script>
+  export default {
+    data() {
+      return {
+        banner1: [
+          { url: "/imgs/banner1.png", title: "這裏是輪播圖推薦內容標題" },
+          { url: "/imgs/banner1.png", title: "這裏是輪播圖推薦內容標題" },
+          { url: "/imgs/banner1.png", title: "這裏是輪播圖推薦內容標題" },
+          { url: "/imgs/banner1.png", title: "這裏是輪播圖推薦內容標題" },
+          { url: "/imgs/banner1.png", title: "這裏是輪播圖推薦內容標題" },
+        ],
+        latestArts: [],
+        pageIndex: 1
+      };
+    },
+    methods: {
+      async loadLatestArts(pageIndex) {
+        let resp = await this.$http.post(this.$api.cms.articles, this.$qs.stringify(Object.assign(this.$route.query,{pageIndex: pageIndex,type:'2'})));
+        if (resp.data.status === 200) {
+          if(pageIndex === 1){
+            this.latestArts = resp.data.data.cmsArticles;
+          }else{
+            this.latestArts.push(...resp.data.data.cmsArticles);
+          }
+        }
+      }
+    },
+    async created() {
+      this.loadLatestArts(this.pageIndex);
+    }
+  };
+</script>
+<style>
+  .swiper-group {
+    display: grid;
+    grid-template-columns: repeat(2, 290px);
+    grid-template-rows: repeat(2, 163px);
+    grid-gap: 10px;
+  }
+
+  .swiper {
+    @apply w-290px;
+
+    /* align-items: end; */
+    /* @apply w-290px h-163px; */
+  }
+
+  .swiper-title {
+    @apply bottom-17px left-17px text-size-16px;
+  }
+</style>
+<template>
+  <ui-page-layout title="推荐新闻">
+    <template v-slot:search>
+      <ui-search></ui-search>
+    </template>
+    <ui-mask-picture flag="推荐" bannerClass="w-full h-136rem"></ui-mask-picture>
+
+    <div class="pl-22rem pr-22rem">
+      <UiMainArticle v-for="art in latestArts" :item="art"></UiMainArticle>
+    </div>
+
 
   </ui-page-layout>
 </template>
 
 <script>
-export default {
-  data() {
-    return {
-      banner1: [
-        { url: "/imgs/banner1.png", title: "這裏是輪播圖推薦內容標題" },
-        { url: "/imgs/banner1.png", title: "這裏是輪播圖推薦內容標題" },
-        { url: "/imgs/banner1.png", title: "這裏是輪播圖推薦內容標題" },
-        { url: "/imgs/banner1.png", title: "這裏是輪播圖推薦內容標題" },
-        { url: "/imgs/banner1.png", title: "這裏是輪播圖推薦內容標題" },
-      ],
-    };
-  },
-};
+  export default {
+    data() {
+      return {
+        banner1: [
+          { url: "/imgs/banner1.png", title: "這裏是輪播圖推薦內容標題" },
+          { url: "/imgs/banner1.png", title: "這裏是輪播圖推薦內容標題" },
+          { url: "/imgs/banner1.png", title: "這裏是輪播圖推薦內容標題" },
+          { url: "/imgs/banner1.png", title: "這裏是輪播圖推薦內容標題" },
+          { url: "/imgs/banner1.png", title: "這裏是輪播圖推薦內容標題" },
+        ],
+        latestArts: [],
+        pageIndex: 1
+      };
+    },
+    methods: {
+      async loadLatestArts(pageIndex) {
+        let resp = await this.$http.post(this.$api.cms.articles, this.$qs.stringify(Object.assign(this.$route.query,{pageIndex: pageIndex})));
+        if (resp.data.status === 200) {
+          if(pageIndex === 1){
+            this.latestArts = resp.data.data.cmsArticles;
+          }else{
+            this.latestArts.push(...resp.data.data.cmsArticles);
+          }
+        }
+      }
+    },
+    async created() {
+      this.loadLatestArts(this.pageIndex);
+    }
+  };
 </script>
 <style>
-.swiper-group {
-  display: grid;
-  grid-template-columns: repeat(2, 290px);
-  grid-template-rows: repeat(2, 163px);
-  grid-gap: 10px;
-}
-
-.swiper {
-  @apply w-290px;
-
-  /* align-items: end; */
-  /* @apply w-290px h-163px; */
-}
-
-.swiper-title {
-  @apply bottom-17px left-17px text-size-16px;
-}
+  .swiper-group {
+    display: grid;
+    grid-template-columns: repeat(2, 290px);
+    grid-template-rows: repeat(2, 163px);
+    grid-gap: 10px;
+  }
+
+  .swiper {
+    @apply w-290px;
+
+    /* align-items: end; */
+    /* @apply w-290px h-163px; */
+  }
+
+  .swiper-title {
+    @apply bottom-17px left-17px text-size-16px;
+  }
 </style>