Commit bb25858a authored by shangbj's avatar shangbj

全部后端渲染

parent d0e24c83
......@@ -6,10 +6,13 @@ const app = express()
// Require API routes
const product = require('./routes/product')
const news = require('./routes/news')
const qualifications = require('./routes/qualifications')
const engineering = require('./routes/engineering')
// Import API Routes
app.use(product)
app.use(news)
app.use(qualifications)
app.use(engineering)
// Export the server middleware
module.exports = {
......
This diff is collapsed.
const qualificationsData = [
{
title:'“母亲水窖”捐赠证书',
id:20,
thumbnail:'/images/qualifications/02001.jpg',
time:'2014-09-22',
con:`<p style="text-align: center"><img alt="" src="/images/qualifications/02001.jpg" style="height:600px; width:427px"></p>`
},
{
title:'营业执照',
id:19,
thumbnail:'/images/qualifications/01901.jpg',
time:'2011-03-03',
con:`<p style="text-align: center"><img alt="" src="/images/qualifications/01901.jpg"></p>`
},
{
title:'组织机构代码证',
id:18,
thumbnail:'/images/qualifications/01801.jpg',
time:'2011-03-01',
con:`<p>&nbsp;</p>
<p style="text-align: center"><img alt="" src="/images/qualifications/01801.jpg" style="height:447px; width:600px"></p>`
},
{
title:'税务登记证',
id:17,
thumbnail:'/images/qualifications/01701.jpg',
time:'2011-03-01',
con:`<p>&nbsp;</p>
<p style="text-align: center">&nbsp;&nbsp;<img alt="" src="/images/qualifications/01701.jpg"></p>`
},
{
title:'ISO9001质量体系认证证书',
id:16,
thumbnail:'/images/qualifications/01601.jpg',
time:'2011-02-26',
con:`<p style="text-align: center"><img alt="" src="/images/qualifications/01601.jpg" style="height:600px; width:427px"></p>`
},
{
title:'ISO14001环境管理体系认证证书',
id:15,
thumbnail:'/images/qualifications/01501.jpg',
time:'2011-02-25',
con:`<p style="text-align: center"><img alt="" src="/images/qualifications/01501.jpg" style="height:600px; width:429px"></p>`
},
{
title:'产品认证证书',
id:14,
thumbnail:'/images/qualifications/01401.jpg',
time:'2011-02-24',
con:`<p>&nbsp;</p>
<p style="text-align: center"><img alt="" src="/images/qualifications/01401.jpg" style="height:600px; width:428px"></p>`
},
{
title:'绿恒纯二氧化氯发生器卫生许可批件',
id:13,
thumbnail:'/images/qualifications/01301.jpg',
time:'2011-02-23',
con:`<p>&nbsp;</p>
<p style="text-align: center">&nbsp; <img src="/images/qualifications/01301.jpg"><br>
<img src="/images/qualifications/01302.jpg"><br>
&nbsp;</p>`
},
{
title:'绿恒臭氧发生器卫生许可批件',
id:12,
thumbnail:'/images/qualifications/01201.jpg',
time:'2011-02-22',
con:`<p>&nbsp;</p>
<p style="text-align: center"><img alt="" src="/images/qualifications/01201.jpg"></p>`
},
{
title:'水木兰消毒粉卫生部许可批件',
id:11,
thumbnail:'/images/qualifications/01101.jpg',
time:'2011-02-21',
con:`<p align="center">&nbsp;</p>
<p align="center"><img class="" alt="" src="/images/qualifications/01101.jpg"></p>`
},
{
title:'绿恒商标注册证',
id:10,
thumbnail:'/images/qualifications/01001.jpg',
time:'2011-02-20',
con:`<p align="center"><img class="" alt="" src="/images/qualifications/01001.jpg"></p>`
},
{
title:'水木兰商标注册证',
id:9,
thumbnail:'/images/qualifications/00901.jpg',
time:'2011-02-19',
con:`<p align="center"><img class="" alt="" width="500" height="688" src="/images/qualifications/00901.jpg"></p>`
},
{
title:'计算机软件著作权登记证书-1',
id:8,
thumbnail:'/images/qualifications/00801.jpg',
time:'2011-02-14',
con:`<p align="center"><img style="width: 606px; height: 417px" class="" alt="" width="582" height="413" src="/images/qualifications/00801.jpg"></p>`
},
{
title:'计算机软件著作权登记证书-2',
id:7,
thumbnail:'/images/qualifications/00701.jpg',
time:'2011-02-13',
con:`<p align="center"><img style="width: 604px; height: 419px" class="" alt="" width="582" height="409" src="/images/qualifications/00701.jpg"></p>`
},
{
title:'计算机软件著作权登记证书-3',
id:6,
thumbnail:'/images/qualifications/00601.jpg',
time:'2011-02-12',
con:`<p align="center">&nbsp;</p>
<p align="center"><img style="width: 610px; height: 402px" class="" alt="" width="542" height="396" src="/images/qualifications/00601.jpg"></p>`
},
{
title:'计算机软件著作权登记证书-4',
id:5,
thumbnail:'/images/qualifications/00501.jpg',
time:'2011-02-11',
con:`<p align="center"><img style="width: 600px; height: 408px" class="" alt="" width="542" height="397" src="/images/qualifications/00501.jpg"></p>`
},
{
title:'计算机软件著作权登记证书-5',
id:4,
thumbnail:'/images/qualifications/00401.jpg',
time:'2011-02-10',
con:`<p align="center"><img style="width: 614px; height: 414px" class="" alt="" width="542" height="399" src="/images/qualifications/00401.jpg"></p>`
},
{
title:'计算机软件著作权登记证书-6',
id:3,
thumbnail:'/images/qualifications/00301.jpg',
time:'2011-02-09',
con:`<p align="center"><img class="" alt="" width="616" height="415" src="/images/qualifications/00301.jpg"></p>`
},
{
title:'抗震救灾爱心捐赠证书-1',
id:2,
thumbnail:'/images/qualifications/00201.jpg',
time:'2011-02-08',
con:`<p><img alt="" src="/images/qualifications/00201.jpg"></p>`
},
{
title:'抗震救灾爱心捐赠证书-2',
id:1,
thumbnail:'/images/qualifications/00101.jpg',
time:'2011-02-07',
con:`<p><img alt="" src="/images/qualifications/00101.jpg" style="height:442px; width:584px"></p>`
},
{
title:'水利部办公厅感谢信',
id:0,
thumbnail:'/images/qualifications/00001.jpg',
time:'2011-02-06',
con:`<p style="text-align: center"><img alt="" src="/images/qualifications/00001.jpg" style="height:630px; width:508px"></p>`
},
]
module.exports = qualificationsData;
\ No newline at end of file
const { Router } = require('express')
const engineeringData = require('./data/engineering')
const router = Router()
const engineeringKeys = Object.keys(engineeringData);
/* GET users listing. */
router.get('/engineering', function (req, res, next) {
const engineeringList = engineeringData;
if(req.query.type === 'simplify'){
engineeringKeys.forEach((key)=>{
engineeringData[key].data.forEach((item)=>{
delete engineeringList[key].data.con;
})
})
}
const engineeringType = req.query.engineeringType;
if(req.query.engineeringType){
if(req.query.pageSize){
const total = engineeringList[engineeringType].data.length;
if(req.query.pageIndex){
res.json({
total,
data:engineeringList[engineeringType].data.slice((req.query.pageIndex-1)*req.query.pageSize,(req.query.pageIndex-1)*req.query.pageSize+parseInt(req.query.pageSize)),
result:true
})
}else{
res.json({
total,
data:engineeringList[engineeringType].data.slice(0,req.query.pageSize),
result:true
})
}
}else{
res.json({
total:0,
data:[],
result:true
})
}
}else{
res.json(engineeringList)
}
})
router.get('/engineering/detail/:type/:id', function (req, res, next) {
const engineeringDetails = {};
engineeringData[req.params.type].data.forEach((item)=>{
engineeringDetails[item.id]={
title:item.title,
time:item.time,
con:item.con,
id:item.id,
}
})
const id = parseInt(req.params.id)
if (id >= 0 && id < engineeringData[req.params.type].data.length) {
res.json({
data:engineeringDetails[id],
result:true
})
} else {
res.json({
data:null,
message:'该页面不存在',
result:false
})
}
})
module.exports = router
\ No newline at end of file
const { Router } = require('express')
const productData = require('./data/product')
const productsData = require('./data/products')
const router = Router()
const productKeys = Object.keys(productsData);
/* GET users listing. */
router.get('/product', function (req, res, next) {
res.json(productData)
const productsList = productsData;
if(req.query.type === 'simplify'){
productKeys.forEach((key)=>{
productsData[key].data.forEach((item)=>{
delete productsList[key].data.con;
})
})
}
const productType = req.query.productType;
if(req.query.productType){
if(req.query.pageSize){
const total = productsList[productType].data.length;
if(req.query.pageIndex){
res.json({
total,
data:productsList[productType].data.slice((req.query.pageIndex-1)*req.query.pageSize,(req.query.pageIndex-1)*req.query.pageSize+parseInt(req.query.pageSize)),
result:true
})
}else{
res.json({
total,
data:productsList[productType].data.slice(0,req.query.pageSize),
result:true
})
}
}else{
res.json({
total:0,
data:[],
result:true
})
}
}else{
res.json(productsList)
}
})
router.get('/product/detail/:type/:id', function (req, res, next) {
const productDetails = {};
productsData[req.params.type].data.forEach((item)=>{
productDetails[item.id]={
title:item.title,
time:item.time,
con:item.con,
id:item.id,
url:item.url,
thumbnail:item.thumbnail,
}
})
const id = parseInt(req.params.id)
if (id >= 0 && id < productsData[req.params.type].data.length) {
res.json({
data:productDetails[id],
result:true
})
} else {
res.json({
data:null,
message:'该页面不存在',
result:false
})
}
})
module.exports = router
\ No newline at end of file
const { Router } = require('express')
const qualificationsData = require('./data/qualifications');
const router = Router()
const total = qualificationsData.length;
const qualificationsDetails = {};
qualificationsData.forEach((item)=>{
qualificationsDetails[item.id]={
title:item.title,
time:item.time,
con:item.con,
id:item.id,
}
})
// const tetails
/* GET users listing. */
router.get('/qualifications', function (req, res, next) {
const qualificationsList = req.query.type==='simplify'?qualificationsData.map((item)=>{
return({
title:item.title,
time:item.time,
id:item.id,
thumbnail:item.thumbnail,
})
}):qualificationsData;
if(req.query.pageSize){
if(req.query.pageIndex){
res.json({
total,
data:qualificationsList.slice((req.query.pageIndex-1)*req.query.pageSize,(req.query.pageIndex-1)*req.query.pageSize+parseInt(req.query.pageSize)),
result:true
})
}else{
res.json({
total,
data:qualificationsList.slice(0,req.query.pageSize),
result:true
})
}
}else{
res.json({
total:0,
data:[],
result:true
})
}
})
router.get('/qualifications/detail/:id', function (req, res, next) {
const id = parseInt(req.params.id);
if (id >= 0 && id < qualificationsData.length) {
res.json({
data:qualificationsDetails[id],
result:true
})
} else {
res.json({
data:null,
message:'该页面不存在',
result:false
})
}
})
module.exports = router
\ No newline at end of file
......@@ -19,9 +19,10 @@
<script>
export default {
async asyncData({ app }) {
const newsData = await app.$axios.$get('/api/news?pageIndex=1&pageSize=20&type=simplify');
return { newsData: newsData.data||[] }
data:()=>{
return{
newsData:[],
}
},
computed:{
optionTop(){
......@@ -29,6 +30,17 @@ export default {
step:0.4
}
}
},
mounted() {
// console.log(this.$store);
this.$axios.$get('/api/news?pageIndex=1&pageSize=20&type=simplify').then(res => {
if (res.result) {
this.newsData = res.data;
// this.$store.commit('newsScrollData',res.data);
} else {
this.newsData = [];
}
})
}
}
</script>
......
<template>
<div class="currently-wrap">
<div class="currently-node"><div>饮用水消毒</div></div>
<div class="currently-title">{{title}}</div>
<div class="currently-time">发布时间:{{time}}</div>
<div class="currently-text" v-html="con"></div>
<div class="currently-title">{{details.title}}</div>
<div class="currently-time">发布时间:{{details.time}}</div>
<div class="currently-text" v-html="details.con"></div>
</div>
</template>
<script>
export default {
asyncData({ params, store, error }) {
const item = store.state.engineering.data.drinkingWater.data.find((item) => String(item.id) === params.id)
if (!item) {
async asyncData({ app, params, error }) {
const details = await app.$axios.$get(`/api/engineering/detail/drinkingWater/${params.id}`);
if(details.result){
return {details: details.data};
}else{
return error({ message: '页面不存在', statusCode: 404 })
}
return item
},
head() {
return {
}
}
}
</script>
......
......@@ -15,32 +15,32 @@
layout="prev, pager, next"
prev-text="上一页"
next-text="下一页"
:page-size="pageSize"
:page-size='20'
@current-change="handleCurrentChange"
:total="data.length">
:total="total">
</el-pagination>
</div>
</template>
<script>
export default {
async asyncData({ app }) {
const data = await app.$axios.$get('/api/engineering?pageIndex=1&pageSize=20&type=simplify&engineeringType=drinkingWater');
return { data: data.data || [] ,total:data.total}
},
data(){
return{
data:this.$store.state.engineering.data.drinkingWater.data,
pageSize:20,
currentPage:1,
}
},
computed:{
startPage(){
return this.pageSize*(this.currentPage-1);
},
endPage(){
return this.startPage + this.pageSize;
}
},
methods:{
handleCurrentChange(val){
this.currentPage = val
handleCurrentChange(page){
this.$axios.$get(`/api/engineering?pageIndex=${page}&pageSize=20&type=simplify&engineeringType=drinkingWater`).then(res => {
if (res.result) {
this.data = res.data;
} else {
this.data = [];
}
});
}
}
}
......
<template>
<div class="currently-wrap">
<div class="currently-node"><div>医院污水消毒</div></div>
<div class="currently-title">{{title}}</div>
<div class="currently-time">发布时间:{{time}}</div>
<div class="currently-text" v-html="con"></div>
<div class="currently-title">{{details.title}}</div>
<div class="currently-time">发布时间:{{details.time}}</div>
<div class="currently-text" v-html="details.con"></div>
</div>
</template>
<script>
export default {
asyncData({ params, store, error }) {
const item = store.state.engineering.data.hospitalSewage.data.find((item) => String(item.id) === params.id)
if (!item) {
async asyncData({ app, params, error }) {
const details = await app.$axios.$get(`/api/engineering/detail/hospitalSewage/${params.id}`);
if(details.result){
return {details: details.data};
}else{
return error({ message: '页面不存在', statusCode: 404 })
}
return item
},
head() {
return {
}
}
}
</script>
......
......@@ -15,32 +15,32 @@
layout="prev, pager, next"
prev-text="上一页"
next-text="下一页"
:page-size="pageSize"
:page-size='20'
@current-change="handleCurrentChange"
:total="data.length">
:total="total">
</el-pagination>
</div>
</template>
<script>
export default {
async asyncData({ app }) {
const data = await app.$axios.$get('/api/engineering?pageIndex=1&pageSize=20&type=simplify&engineeringType=hospitalSewage');
return { data: data.data || [] ,total:data.total}
},
data(){
return{
data:this.$store.state.engineering.data.hospitalSewage.data,
pageSize:20,
currentPage:1,
}
},
computed:{
startPage(){
return this.pageSize*(this.currentPage-1);
},
endPage(){
return this.startPage + this.pageSize;
}
},
methods:{
handleCurrentChange(val){
this.currentPage = val
handleCurrentChange(page){
this.$axios.$get(`/api/engineering?pageIndex=${page}&pageSize=20&type=simplify&engineeringType=hospitalSewage`).then(res => {
if (res.result) {
this.data = res.data;
} else {
this.data = [];
}
});
}
}
}
......
<template>
<div class="currently-wrap">
<div class="currently-node">中水消毒</div>
<div class="currently-title">{{title}}</div>
<div class="currently-time">发布时间:{{time}}</div>
<div class="currently-text" v-html="con"></div>
<div class="currently-title">{{details.title}}</div>
<div class="currently-time">发布时间:{{details.time}}</div>
<div class="currently-text" v-html="details.con"></div>
</div>
</template>
<script>
export default {
asyncData({ params, store, error }) {
const item = store.state.engineering.data.mediumWater.data.find((item) => String(item.id) === params.id)
if (!item) {
async asyncData({ app, params, error }) {
const details = await app.$axios.$get(`/api/engineering/detail/mediumWater/${params.id}`);
if(details.result){
return {details: details.data};
}else{
return error({ message: '页面不存在', statusCode: 404 })
}
return item
},
head() {
return {
}
}
}
</script>
......
......@@ -3,7 +3,7 @@
<div class="currently-node">中水消毒</div>
<div class="currently-list">
<ul>
<li class="listItem" v-for="(item, index) in data.slice(startPage,endPage)" :key="index">
<li class="listItem" v-for="(item, index) in data" :key="index">
<nuxt-link :to="'/engineering/mediumWater/' + item.id" class="itemTitle">{{item.title}}</nuxt-link>
<span class="contentTime">&nbsp;&nbsp;{{item.time}}</span>
</li>
......@@ -15,32 +15,32 @@
layout="prev, pager, next"
prev-text="上一页"
next-text="下一页"
:page-size="pageSize"
:page-size='20'
@current-change="handleCurrentChange"
:total="data.length">
:total="total">
</el-pagination>
</div>
</template>
<script>
export default {
async asyncData({ app }) {
const data = await app.$axios.$get('/api/engineering?pageIndex=1&pageSize=20&type=simplify&engineeringType=mediumWater');
return { data: data.data || [] ,total:data.total}
},
data(){
return{
data:this.$store.state.engineering.data.mediumWater.data,
pageSize:20,
currentPage:1,
}
},
computed:{
startPage(){
return this.pageSize*(this.currentPage-1);
},
endPage(){
return this.startPage + this.pageSize;
}
},
methods:{
handleCurrentChange(val){
this.currentPage = val
handleCurrentChange(page){
this.$axios.$get(`/api/engineering?pageIndex=${page}&pageSize=20&type=simplify&engineeringType=mediumWater`).then(res => {
if (res.result) {
this.data = res.data;
} else {
this.data = [];
}
});
}
}
}
......
......@@ -105,11 +105,15 @@ export default {
async asyncData({ app }) {
const newsData = await app.$axios.$get('/api/news?pageSize=10&type=simplify');
const productData = await app.$axios.$get('/api/product');
return { newsData: newsData.data||[],productData:[...productData.ozonizer.data,...productData.disinfectant.data,...productData.equipment.data] }
const qualificationsData = await app.$axios.$get('/api/qualifications?pageSize=20&type=simplify');
return {
newsData: newsData.data||[],
productData:[...productData.ozonizer.data,...productData.disinfectant.data,...productData.equipment.data],
qualificationsData: qualificationsData.data||[],
}
},
data:function(){
return {
qualificationsData:this.$store.state.qualifications.data,
engineeringData:this.$store.state.engineeringData,
}
},
......
......@@ -8,13 +8,6 @@
</template>
<script>
export default {
// asyncData({ params, store, error }) {
// const item = store.state.news.newsData.find((item) => String(item.id) === params.id)
// if (!item) {
// return error({ message: '页面不存在', statusCode: 404 })
// }
// return item
// },
async asyncData({ app, params, error }) {
const details = await app.$axios.$get(`/api/news/detail/${params.id}`);
if(details.result){
......@@ -22,7 +15,6 @@ export default {
}else{
return error({ message: '页面不存在', statusCode: 404 })
}
}
}
</script>
......
......@@ -22,10 +22,9 @@ import ProductImgList from '~/components/ProductImgList.vue'
import ContactUs from '~/components/ContactUs.vue'
export default {
data(){
return {
columnData: this.$store.state.product.data
}
async asyncData({ app }) {
const columnData = await app.$axios.$get('/api/product');
return { columnData: columnData }
},
components:{
ProductImgList,
......
<template>
<div class="currently-wrap">
<div class="currently-node"><div>水木兰二氧化氯消毒粉</div></div>
<div class="currently-title">{{title}}</div>
<div class="currently-time">发布时间:{{time}}</div>
<div class="currently-text" v-html="con"></div>
<div class="currently-title">{{details.title}}</div>
<div class="currently-time">发布时间:{{details.time}}</div>
<div class="currently-text" v-html="details.con"></div>
</div>
</template>
<script>
export default {
asyncData({ params, store, error }) {
const item = store.state.product.data.disinfectant.data.find((item) => String(item.id) === params.id)
if (!item) {
async asyncData({ app, params, error }) {
const details = await app.$axios.$get(`/api/product/detail/disinfectant/${params.id}`);
if(details.result){
return {details: details.data};
}else{
return error({ message: '页面不存在', statusCode: 404 })
}
return item
},
head() {
return {
}
}
}
</script>
......
......@@ -3,7 +3,7 @@
<div class="currently-node"><div>水木兰二氧化氯消毒粉</div></div>
<div class="currently-list">
<ul>
<li class="listItem" v-for="(item, index) in data.slice(startPage,endPage)" :key="index">
<li class="listItem" v-for="(item, index) in data" :key="index">
<nuxt-link :to="'/product/disinfectant/' + item.id" class="itemTitle">{{item.title}}</nuxt-link>
<span class="contentTime">&nbsp;&nbsp;{{item.time}}</span>
</li>
......@@ -15,32 +15,32 @@
layout="prev, pager, next"
prev-text="上一页"
next-text="下一页"
:page-size="pageSize"
:page-size='20'
@current-change="handleCurrentChange"
:total="data.length">
:total="total">
</el-pagination>
</div>
</template>
<script>
export default {
async asyncData({ app }) {
const data = await app.$axios.$get('/api/product?pageIndex=1&pageSize=20&type=simplify&productType=disinfectant');
return { data: data.data || [] ,total:data.total}
},
data(){
return{
data:this.$store.state.product.data.disinfectant.data,
pageSize:20,
currentPage:1,
}
},
computed:{
startPage(){
return this.pageSize*(this.currentPage-1);
},
endPage(){
return this.startPage + this.pageSize;
}
},
methods:{
handleCurrentChange(val){
this.currentPage = val
handleCurrentChange(page){
this.$axios.$get(`/api/product?pageIndex=${page}&pageSize=20&type=simplify&productType=disinfectant`).then(res => {
if (res.result) {
this.data = res.data;
} else {
this.data = [];
}
});
}
}
}
......
......@@ -22,10 +22,9 @@ import ProductImgList from '~/components/ProductImgList.vue'
import ContactUs from '~/components/ContactUs.vue'
export default {
data(){
return {
columnData: this.$store.state.product.data
}
async asyncData({ app }) {
const columnData = await app.$axios.$get('/api/product');
return { columnData: columnData }
},
components:{
ProductImgList,
......
<template>
<div class="currently-wrap">
<div class="currently-node"><div>绿恒二氧化氯消毒设备</div></div>
<div class="currently-title">{{title}}</div>
<div class="currently-time">发布时间:{{time}}</div>
<div class="currently-text" v-html="con"></div>
<div class="currently-title">{{details.title}}</div>
<div class="currently-time">发布时间:{{details.time}}</div>
<div class="currently-text" v-html="details.con"></div>
</div>
</template>
<script>
export default {
asyncData({ params, store, error }) {
const item = store.state.product.data.equipment.data.find((item) => String(item.id) === params.id)
if (!item) {
async asyncData({ app, params, error }) {
const details = await app.$axios.$get(`/api/product/detail/equipment/${params.id}`);
if(details.result){
return {details: details.data};
}else{
return error({ message: '页面不存在', statusCode: 404 })
}
return item
},
head() {
return {
}
}
}
</script>
......
......@@ -3,7 +3,7 @@
<div class="currently-node"><div>绿恒二氧化氯消毒设备</div></div>
<div class="currently-list">
<ul>
<li class="listItem" v-for="(item, index) in data.slice(startPage,endPage)" :key="index">
<li class="listItem" v-for="(item, index) in data" :key="index">
<nuxt-link :to="'/product/equipment/' + item.id" class="itemTitle">{{item.title}}</nuxt-link>
<span class="contentTime">&nbsp;&nbsp;{{item.time}}</span>
</li>
......@@ -15,32 +15,32 @@
layout="prev, pager, next"
prev-text="上一页"
next-text="下一页"
:page-size="pageSize"
:page-size='20'
@current-change="handleCurrentChange"
:total="data.length">
:total="total">
</el-pagination>
</div>
</template>
<script>
export default {
async asyncData({ app }) {
const data = await app.$axios.$get('/api/product?pageIndex=1&pageSize=20&type=simplify&productType=equipment');
return { data: data.data || [] ,total:data.total}
},
data(){
return{
data:this.$store.state.product.data.equipment.data,
pageSize:20,
currentPage:1,
}
},
computed:{
startPage(){
return this.pageSize*(this.currentPage-1);
},
endPage(){
return this.startPage + this.pageSize;
}
},
methods:{
handleCurrentChange(val){
this.currentPage = val
handleCurrentChange(page){
this.$axios.$get(`/api/product?pageIndex=${page}&pageSize=20&type=simplify&productType=equipment`).then(res => {
if (res.result) {
this.data = res.data;
} else {
this.data = [];
}
});
}
}
}
......
......@@ -32,7 +32,10 @@ export default {
ContactUs,
},
beforeCreate(){
window.location.href="/product/equipment"
this.$router.push({
path:'/product/equipment'
})
// window.location.href="/product/equipment"
}
}
</script>
......
......@@ -22,10 +22,9 @@ import ProductImgList from '~/components/ProductImgList.vue'
import ContactUs from '~/components/ContactUs.vue'
export default {
data(){
return {
columnData: this.$store.state.product.data
}
async asyncData({ app }) {
const columnData = await app.$axios.$get('/api/product');
return { columnData: columnData }
},
components:{
ProductImgList,
......
<template>
<div class="currently-wrap">
<div class="currently-node"><div>臭氧发生器</div></div>
<div class="currently-title">{{title}}</div>
<div class="currently-time">发布时间:{{time}}</div>
<div class="currently-text" v-html="con"></div>
<div class="currently-title">{{details.title}}</div>
<div class="currently-time">发布时间:{{details.time}}</div>
<div class="currently-text" v-html="details.con"></div>
</div>
</template>
<script>
export default {
asyncData({ params, store, error }) {
const item = store.state.product.data.ozonizer.data.find((item) => String(item.id) === params.id)
if (!item) {
async asyncData({ app, params, error }) {
const details = await app.$axios.$get(`/api/product/detail/ozonizer/${params.id}`);
if(details.result){
return {details: details.data};
}else{
return error({ message: '页面不存在', statusCode: 404 })
}
return item
},
head() {
return {
}
}
}
</script>
......
......@@ -3,7 +3,7 @@
<div class="currently-node"><div>臭氧发生器</div></div>
<div class="currently-list">
<ul>
<li class="listItem" v-for="(item, index) in data.slice(startPage,endPage)" :key="index">
<li class="listItem" v-for="(item, index) in data" :key="index">
<nuxt-link :to="'/product/ozonizer/' + item.id" class="itemTitle">{{item.title}}</nuxt-link>
<span class="contentTime">&nbsp;&nbsp;{{item.time}}</span>
</li>
......@@ -15,32 +15,32 @@
layout="prev, pager, next"
prev-text="上一页"
next-text="下一页"
:page-size="pageSize"
:page-size='20'
@current-change="handleCurrentChange"
:total="data.length">
:total="total">
</el-pagination>
</div>
</template>
<script>
export default {
async asyncData({ app }) {
const data = await app.$axios.$get('/api/product?pageIndex=1&pageSize=20&type=simplify&productType=ozonizer');
return { data: data.data || [] ,total:data.total}
},
data(){
return{
data:this.$store.state.product.data.ozonizer.data,
pageSize:20,
currentPage:1,
}
},
computed:{
startPage(){
return this.pageSize*(this.currentPage-1);
},
endPage(){
return this.startPage + this.pageSize;
}
},
methods:{
handleCurrentChange(val){
this.currentPage = val
handleCurrentChange(page){
this.$axios.$get(`/api/product?pageIndex=${page}&pageSize=20&type=simplify&productType=ozonizer`).then(res => {
if (res.result) {
this.data = res.data;
} else {
this.data = [];
}
});
}
}
}
......
<template>
<div class="currently-wrap">
<div class="currently-node">荣誉资质</div>
<div class="currently-title">{{title}}</div>
<div class="currently-text" v-html="con"></div>
<div class="currently-title">{{details.title}}</div>
<div class="currently-text" v-html="details.con"></div>
</div>
</template>
<script>
export default {
asyncData({ params, store, error }) {
const item = store.state.qualifications.data.find((item) => String(item.id) === params.id)
if (!item) {
async asyncData({ app, params, error }) {
const details = await app.$axios.$get(`/api/qualifications/detail/${params.id}`);
if(details.result){
return {details: details.data};
}else{
return error({ message: '页面不存在', statusCode: 404 })
}
return item
},
head() {
return {
}
}
}
</script>
......
......@@ -3,7 +3,7 @@
<div class="currently-node">荣誉资质</div>
<div class="currently-list">
<ul>
<li class="listItem" v-for="(item, index) in data.slice(startPage,endPage)" :key="index">
<li class="listItem" v-for="(item, index) in data" :key="index">
<nuxt-link :to="'/qualifications/' + item.id" class="itemTitle">{{item.title}}</nuxt-link>
</li>
</ul>
......@@ -14,34 +14,54 @@
layout="prev, pager, next"
prev-text="上一页"
next-text="下一页"
:page-size="pageSize"
:page-size='20'
@current-change="handleCurrentChange"
:total="data.length">
:total="total">
</el-pagination>
</div>
</template>
<script>
export default {
async asyncData({ app }) {
const data = await app.$axios.$get('/api/qualifications?pageIndex=1&pageSize=20&type=simplify');
return { data: data.data || [] ,total:data.total}
},
data(){
return{
data:this.$store.state.qualifications.data,
pageSize:20,
currentPage:1,
}
},
computed:{
startPage(){
return this.pageSize*(this.currentPage-1);
},
endPage(){
return this.startPage + this.pageSize;
}
},
methods:{
handleCurrentChange(val){
this.currentPage = val
handleCurrentChange(page){
this.$axios.$get(`/api/qualifications?pageIndex=${page}&pageSize=20&type=simplify`).then(res => {
if (res.result) {
this.data = res.data;
} else {
this.data = [];
}
});
}
}
// data(){
// return{
// data:this.$store.state.qualifications.data,
// pageSize:20,
// currentPage:1,
// }
// },
// computed:{
// startPage(){
// return this.pageSize*(this.currentPage-1);
// },
// endPage(){
// return this.startPage + this.pageSize;
// }
// },
// methods:{
// handleCurrentChange(val){
// this.currentPage = val
// }
// }
}
</script>
<style lang="scss" scoped>
......
This diff is collapsed.
This diff is collapsed.
export const state = () => ({
data: [
{
title:'“母亲水窖”捐赠证书',
id:20,
thumbnail:'/images/qualifications/02001.jpg',
time:'2014-09-22',
con:`<p style="text-align: center"><img alt="" src="/images/qualifications/02001.jpg" style="height:600px; width:427px"></p>`
},
{
title:'营业执照',
id:19,
thumbnail:'/images/qualifications/01901.jpg',
time:'2011-03-03',
con:`<p style="text-align: center"><img alt="" src="/images/qualifications/01901.jpg"></p>`
},
{
title:'组织机构代码证',
id:18,
thumbnail:'/images/qualifications/01801.jpg',
time:'2011-03-01',
con:`<p>&nbsp;</p>
<p style="text-align: center"><img alt="" src="/images/qualifications/01801.jpg" style="height:447px; width:600px"></p>`
},
{
title:'税务登记证',
id:17,
thumbnail:'/images/qualifications/01701.jpg',
time:'2011-03-01',
con:`<p>&nbsp;</p>
<p style="text-align: center">&nbsp;&nbsp;<img alt="" src="/images/qualifications/01701.jpg"></p>`
},
{
title:'ISO9001质量体系认证证书',
id:16,
thumbnail:'/images/qualifications/01601.jpg',
time:'2011-02-26',
con:`<p style="text-align: center"><img alt="" src="/images/qualifications/01601.jpg" style="height:600px; width:427px"></p>`
},
{
title:'ISO14001环境管理体系认证证书',
id:15,
thumbnail:'/images/qualifications/01501.jpg',
time:'2011-02-25',
con:`<p style="text-align: center"><img alt="" src="/images/qualifications/01501.jpg" style="height:600px; width:429px"></p>`
},
{
title:'产品认证证书',
id:14,
thumbnail:'/images/qualifications/01401.jpg',
time:'2011-02-24',
con:`<p>&nbsp;</p>
<p style="text-align: center"><img alt="" src="/images/qualifications/01401.jpg" style="height:600px; width:428px"></p>`
},
{
title:'绿恒纯二氧化氯发生器卫生许可批件',
id:13,
thumbnail:'/images/qualifications/01301.jpg',
time:'2011-02-23',
con:`<p>&nbsp;</p>
<p style="text-align: center">&nbsp; <img src="/images/qualifications/01301.jpg"><br>
<img src="/images/qualifications/01302.jpg"><br>
&nbsp;</p>`
},
{
title:'绿恒臭氧发生器卫生许可批件',
id:12,
thumbnail:'/images/qualifications/01201.jpg',
time:'2011-02-22',
con:`<p>&nbsp;</p>
<p style="text-align: center"><img alt="" src="/images/qualifications/01201.jpg"></p>`
},
{
title:'水木兰消毒粉卫生部许可批件',
id:11,
thumbnail:'/images/qualifications/01101.jpg',
time:'2011-02-21',
con:`<p align="center">&nbsp;</p>
<p align="center"><img class="" alt="" src="/images/qualifications/01101.jpg"></p>`
},
{
title:'绿恒商标注册证',
id:10,
thumbnail:'/images/qualifications/01001.jpg',
time:'2011-02-20',
con:`<p align="center"><img class="" alt="" src="/images/qualifications/01001.jpg"></p>`
},
{
title:'水木兰商标注册证',
id:9,
thumbnail:'/images/qualifications/00901.jpg',
time:'2011-02-19',
con:`<p align="center"><img class="" alt="" width="500" height="688" src="/images/qualifications/00901.jpg"></p>`
},
{
title:'计算机软件著作权登记证书-1',
id:8,
thumbnail:'/images/qualifications/00801.jpg',
time:'2011-02-14',
con:`<p align="center"><img style="width: 606px; height: 417px" class="" alt="" width="582" height="413" src="/images/qualifications/00801.jpg"></p>`
},
{
title:'计算机软件著作权登记证书-2',
id:7,
thumbnail:'/images/qualifications/00701.jpg',
time:'2011-02-13',
con:`<p align="center"><img style="width: 604px; height: 419px" class="" alt="" width="582" height="409" src="/images/qualifications/00701.jpg"></p>`
},
{
title:'计算机软件著作权登记证书-3',
id:6,
thumbnail:'/images/qualifications/00601.jpg',
time:'2011-02-12',
con:`<p align="center">&nbsp;</p>
<p align="center"><img style="width: 610px; height: 402px" class="" alt="" width="542" height="396" src="/images/qualifications/00601.jpg"></p>`
},
{
title:'计算机软件著作权登记证书-4',
id:5,
thumbnail:'/images/qualifications/00501.jpg',
time:'2011-02-11',
con:`<p align="center"><img style="width: 600px; height: 408px" class="" alt="" width="542" height="397" src="/images/qualifications/00501.jpg"></p>`
},
{
title:'计算机软件著作权登记证书-5',
id:4,
thumbnail:'/images/qualifications/00401.jpg',
time:'2011-02-10',
con:`<p align="center"><img style="width: 614px; height: 414px" class="" alt="" width="542" height="399" src="/images/qualifications/00401.jpg"></p>`
},
{
title:'计算机软件著作权登记证书-6',
id:3,
thumbnail:'/images/qualifications/00301.jpg',
time:'2011-02-09',
con:`<p align="center"><img class="" alt="" width="616" height="415" src="/images/qualifications/00301.jpg"></p>`
},
{
title:'抗震救灾爱心捐赠证书-1',
id:2,
thumbnail:'/images/qualifications/00201.jpg',
time:'2011-02-08',
con:`<p><img alt="" src="/images/qualifications/00201.jpg"></p>`
},
{
title:'抗震救灾爱心捐赠证书-2',
id:1,
thumbnail:'/images/qualifications/00101.jpg',
time:'2011-02-07',
con:`<p><img alt="" src="/images/qualifications/00101.jpg" style="height:442px; width:584px"></p>`
},
{
title:'水利部办公厅感谢信',
id:0,
thumbnail:'/images/qualifications/00001.jpg',
time:'2011-02-06',
con:`<p style="text-align: center"><img alt="" src="/images/qualifications/00001.jpg" style="height:630px; width:508px"></p>`
},
],
})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment