Просмотр исходного кода

change:
1. 新闻界面接口对接
2. 产品页面完善

kindring 2 лет назад
Родитель
Сommit
a241c2c91f

+ 16 - 0
README.md

@@ -41,3 +41,19 @@ pm2 start npm --name "hfy" -- run start
 2. tailwindcss 可以移除
 3. nuxt.config.js 中的 `server` 配置项可以移除
 4. 静态打包动态路由页面需要在`nuxt.config.js`中配置`generate.routes`'
+
+## 功能新增设计
+### 图片库功能 image_lab
+> 图片id , 图片名称 , 图片路径 , 图片tag , 上传日期
+| 字段 | 类型 | 可选值 | 默认值 | 备注 |
+| --- | --- | --- | --- | --- |
+| imgId | int | pk | pk | 图片id |
+| imgName | varchar | '' | '' | 图片名称 |
+| tags | varchar | '' | '' | 图片tag,用,隔开 |
+| imgPath | varchar | '' | '' | 图片路径 |
+| uploadTime | varchar | '' | '' | 上传时间 |
+
+
+
+
+

+ 3 - 1
components/newsTypes.vue

@@ -22,9 +22,11 @@
 <script>
 import langMap from "@/map/langMap";
 import {sTypes} from "~/map/newMap";
+import BigTitle from "~/components/public/bigTitle.vue";
 
 export default {
   name: "newsTypes",
+  components: {BigTitle},
   props: {
     lang:{
       default: langMap.lang.cn
@@ -91,7 +93,7 @@ export default {
   font-size: 4rem;
   padding-bottom: 20px;
 }
-.content .product-type .type-selected .icon-box{
+.product-type .type-selected .icon-box{
   border-bottom: 1px solid deepskyblue;
 }
 .product-type .type-item .type-name{

+ 2 - 2
components/productTypes.vue

@@ -79,7 +79,7 @@ export default {
 .product-type .type-item:hover{
   color: orangered;
 }
-.content .product-type .type-selected{
+.product-type .type-selected{
   color: #f88330;
 }
 .product-type .type-item .icon-box{
@@ -91,7 +91,7 @@ export default {
   font-size: 4rem;
   padding-bottom: 20px;
 }
-.content .product-type .type-selected .icon-box{
+.product-type .type-selected .icon-box{
   border-bottom: 1px solid deepskyblue;
 }
 .product-type .type-item .type-name{

+ 6 - 0
map/apiMap.js

@@ -22,5 +22,11 @@ export const apiMap = {
     // 新闻与解决方案都是文章,不多做接口
     path: `/api/solution`
   },
+  downloads: {
+    path: `/api/download/list`
+  },
+  downloadItem: {
+    path: `/api/download/`
+  }
 }
 

+ 3 - 1
pages/news/item/index.vue

@@ -57,6 +57,7 @@ export default {
   beforeMount() {
     console.log(this.pInfo);
     this.solutionDetail = this.pInfo;
+    this.solutionId = this.pId;
     this.solutionDetail.content = unescapeHtml(this.solutionDetail.content);
     this.solutionDetail.date_time  = timestampToTime(this.solutionDetail.date_time);
     this.timer = setTimeout(()=>{
@@ -83,7 +84,8 @@ export default {
     },
     async addRead(){
       let err,res;
-      let url = `/api/addNewsRead.php?id=${this.solutionId}`;
+      let url = apiMap.addPageRead.path;
+      url += `?id=${this.solutionId}`;
       [err,res] = await handle(this.$axios.$get(url));
       if(err) {
         console.log(err);

+ 1 - 0
pages/product/index.vue

@@ -78,6 +78,7 @@ export default {
     if (this.pPageData){
       this.basePageData = this.pPageData
     }
+    this.type = this.pType?this.pType:'all';
     pageData = this.basePageData;
     this.updatePageData(pageData);
   },

+ 3 - 2
pages/solution/item/index.vue

@@ -56,6 +56,7 @@ export default {
   beforeMount() {
     console.log(this.pInfo);
     this.solutionDetail = this.pInfo;
+    this.solutionId = this.pId;
     this.solutionDetail.content = unescapeHtml(this.solutionDetail.content);
     this.solutionDetail.date_time  = timestampToTime(this.solutionDetail.date_time);
     this.timer = setTimeout(()=>{
@@ -100,8 +101,8 @@ export default {
     },
     async addRead(){
       let err,res;
-      let url = apiMap.addPageRead;
-      url += `?id=${this.solutionId}`
+      let url = apiMap.addPageRead.path;
+      url += `?id=${this.solutionId}`;
       [err,res] = await handle(this.$axios.$get(url));
       if(err) {
         console.log(err);

+ 8 - 6
pages/support/index.vue

@@ -29,6 +29,7 @@ import {isMediaView} from "@/until/mediaView";
 import ItemBanner from "~/components/banner/itemBanner.vue";
 import Downloads from "~/components/supportCom/downloads.vue";
 import DefaultFooter from "~/components/footer/defaultFooter.vue";
+import {apiMap} from "~/map/apiMap";
 
 function getFileIcon(fileName){
   // 获取文件后缀
@@ -149,7 +150,8 @@ export default {
     },
     async loadDownloads(){
       let err, res;
-      [err, res] = await handle(this.$axios.$get('/api/getDownloads.php'));
+      let url = apiMap.downloads.path;
+      [err, res] = await handle(this.$axios.$get(url));
       if(err) {
         console.log(err);
         return 0;
@@ -173,11 +175,11 @@ export default {
       const queryData = {
         id: downloadId
       };
-      let url = '/api/getDownloadItems.php';
-      let data = qs.stringify(queryData);
-      [err, res] = await handle(this.$axios.post(
+      let url = apiMap.downloadItem.path;
+      // let data = qs.stringify(queryData);
+      url += `?id=&${downloadId}`;
+      [err, res] = await handle(this.$axios.get(
         url,
-        data
       ));
       if(err){
         console.log(err);
@@ -185,7 +187,7 @@ export default {
       }
       let result = res.data;
       console.log(result)
-      if(result.rcode === 1){
+      if(result.code === 1){
         // 匹配对应的id
         let downloadItem = this.downloadsType.find(item => item.id === downloadId);
         let arr = result.data?result.data:[];

+ 5 - 2
server/control/c_news.js

@@ -4,10 +4,13 @@ const codeMap = require("../map/rcodeMap");
 const log = require("../logger").logger("c_solution","info");
 
 const d_news = require("../database/d_news");
-const d_solution = require("~/server/database/d_solution");
 
 async function addReadNum(newId){
-
+  let [err,res] = await handle(d_news.addReadNum(newId));
+  if(err){
+    return [err,null];
+  }
+  return [null,'ok'];
 }
 
 module.exports = {

+ 13 - 0
server/database/d_news.js

@@ -0,0 +1,13 @@
+const mysql = require('./mysql');
+const {searchSql,limitSql} = require("../tools/searchSql");
+const log = require("../logger").logger("d_news","info");
+
+function addReadNum(id){
+   let sql = `UPDATE hfy_news SET hits = hits + 1 WHERE id = ? limit 1`;
+   let values = [id];
+   return mysql.pq(sql,values);
+}
+
+module.exports = {
+  addReadNum,
+}

+ 1 - 1
server/router/r_news.js

@@ -2,7 +2,7 @@ const router = require('express').Router();
 const {paramFail, ServerError, success, controlError, searchSuccess} = require("../tools/result");
 const c_solution = require("../control/c_solution");
 const typeTool = require("../tools/typeTool");
-const c = require("../control/c_solution");
+const c = require("../control/c_news");
 const log = require("../logger").logger("r_news","info");
 
 router.get(