zhengkaixin 1 rok temu
rodzic
commit
aa80c30cdd

+ 16 - 0
apis/pagejs/message.js

@@ -64,3 +64,19 @@ import request from '@/apis/utils/request'
  	})
  }
  
+export function newsList(data) {
+ 	var url='/mobile/newsInfo/newsList';
+ 	return request({
+ 		method: 'post',
+ 		data: data,
+ 		url: url
+ 	})
+ }
+ export function newsDetails(data) {
+  	var url='/mobile/newsInfo/newsDetails';
+  	return request({
+  		method: 'post',
+  		data: data,
+  		url: url
+  	})
+  }

+ 6 - 0
assets/img/if-book-alt.svg

@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" width="28" height="28" style="" filter="drop-shadow(0px 2px 4px rgba(255,0,54,0.5))">
+    <defs><linearGradient id="ik4s6tsjU23UVPQd5riU3Z1" x1="0" x2="100%" y1="0" y2="0" gradientTransform="matrix(6.123233995736766e-17, 1, -1, 6.123233995736766e-17, 16, 0)" gradientUnits="userSpaceOnUse"><stop stop-color="#ffffff" stop-opacity="1" offset="0.4"></stop><stop stop-color="#ffffff" stop-opacity="0.6" offset="1"></stop></linearGradient></defs>
+    <g>
+    <path d="M25.024 0.032v4.672h3.872v27.264c-0.256 0-0.48 0.032-0.736 0.032h-18.848c-3.328 0-6.144-2.656-6.176-5.952-0.064-7.104-0.064-14.24 0-21.376 0-2.784 1.984-4.608 4.896-4.64 3.84-0.064 7.68-0.032 11.52-0.032h4.672c0.224 0 0.48 0.032 0.8 0.032zM27.52 30.24v-23.904h-2.496v17.216h-0.864c-4.96 0-9.92-0.032-14.88 0.032-0.896 0.032-1.856 0.288-2.72 0.64-1.28 0.608-1.824 1.92-1.6 3.488 0.16 1.248 1.056 2.112 2.464 2.368 0.448 0.096 0.896 0.16 1.344 0.16h18.752zM15.36 9.792h-4.512c-0.48 0-0.896 0.096-0.896 0.64 0 0.576 0.416 0.704 0.896 0.672h8.992c0.512 0 0.992-0.096 0.96-0.704 0-0.544-0.48-0.608-0.928-0.608h-4.512zM15.36 7.648c1.504 0 3.008-0.032 4.512 0 0.48 0 0.928-0.064 0.928-0.64 0.032-0.608-0.448-0.704-0.96-0.704h-8.928c-0.48 0-0.96 0.096-0.96 0.704s0.512 0.64 0.992 0.64c1.472-0.032 2.944 0 4.416 0zM15.36 13.28h-4.576c-0.448 0-0.832 0.096-0.832 0.64s0.384 0.64 0.864 0.64h9.152c0.448 0 0.864-0.128 0.832-0.64 0-0.544-0.384-0.64-0.864-0.64h-4.576zM25.12 27.52h-16.064c-0.192 0-0.448 0.064-0.576-0.032-0.256-0.192-0.544-0.48-0.576-0.736-0.032-0.192 0.352-0.448 0.576-0.64 0.096-0.064 0.32-0.032 0.448-0.032h14.944c1.344 0 1.344 0 1.248 1.44z" fill="url(#ik4s6tsjU23UVPQd5riU3Z1)"></path>
+    </g>
+  </svg>

+ 8 - 0
pages.json

@@ -392,6 +392,14 @@
 				"navigationBarTitleText" : "",
 				"enablePullDownRefresh" : false
 			}
+		},
+		{
+			"path" : "pages/message/knowledgeList",
+			"style" : {}
+		},
+		{
+			"path" : "pages/message/knowledge",
+			"style" : {}
 		}
        
     ],

+ 8 - 1
pages/index/index.vue

@@ -142,7 +142,7 @@
 						</view>
 					</u-grid-item>
 					
-					<u-grid-item     @click="gotoUrl('/pages/mine/contactService')"  >
+					<u-grid-item   v-if="false"   @click="gotoUrl('/pages/mine/contactService')"  >
 						<view class="icon icon4">
 							<image class="img" src="@/assets/img/if-support.svg" mode=""></image>
 						</view>
@@ -156,6 +156,13 @@
 						<view class="grid-text">用电常识
 						</view>
 					</u-grid-item>
+					<u-grid-item   @click="gotoUrl('/pages/message/knowledgeList')">
+						<view class="icon icon4">
+							<image class="img" src="@/assets/img/if-book-alt.svg" mode=""></image>
+						</view>
+						<view class="grid-text">用电知识
+						</view>
+					</u-grid-item>
 				</u-grid>
 			</view>
 		</view>

+ 92 - 0
pages/message/knowledge.vue

@@ -0,0 +1,92 @@
+<template>
+	<view style="background-color: #fff;">
+		<u-navbar title="详情"></u-navbar>
+		<view class="main">
+			
+			<view style="font-size: 32rpx;margin: 18rpx 0;font-weight: bold; ">{{newsDetail.title}}</view>
+			<view style="display: flex;justify-content: space-between; border-bottom: 1px solid #e6e3e3;color: #888;padding: 8rpx 0;" >
+				<view>阅读量:{{newsDetail.readNum}}</view>
+				<view  style="margin-left: 40rpx;">{{newsDetail.createTime}}</view>
+			</view >
+			<view class="news-content" v-html="newsDetail.content">
+				 
+			</view>
+		</view>
+	</view>
+</template>
+
+<script>
+	import * as newsApi from '@/apis/pagejs/message.js'
+	
+	export default {
+		data() {
+			return {
+				id: '',
+				newsDetail: {
+					
+				},
+			}
+		},
+		onLoad(op) {
+			this.id =op.id;
+			
+			this.getNewsInfoDetail();
+		},
+		
+		methods: {
+			getNewsInfoDetail() {
+				uni.showLoading({
+					title: "加载中",
+					mask: true,
+				})
+				
+				newsApi.newsDetails({
+					id:this.id
+				}).then((res) => {
+					uni.hideLoading()					
+					this.newsDetail = res.data.newsInfo;
+					this.$nextTick(()=>{
+					    var list =document.getElementsByClassName("news-content")[0].getElementsByTagName("img");
+					    for(var i=0;i<list.length;i++){
+					        list[i].style='width: 100%;height: 100%;'
+					    }
+					})
+				}).catch(error => {
+					uni.showToast({
+						title: error,
+						icon: "none"
+					})
+				})
+			}
+		}
+	}	
+</script>
+
+<style lang="scss" scoped>
+	.main{
+		
+		margin: 0px 16px ;
+		padding-bottom: 34px;
+		.new-title{
+			color: #101010;
+			font-size: 18px;
+			height: 48px;
+			margin: 16px 0 35px;
+		}
+		.time{
+			display: flex;
+			justify-content: space-between;
+			color: #888888;
+			.num{
+				margin-left: 4px;
+			}
+			
+		}
+		.news-content{
+			margin-top: 13px;
+			font-size: 14px;
+			line-height: 28px;
+			color: #101010;
+		}
+	}
+</style>

+ 152 - 0
pages/message/knowledgeList.vue

@@ -0,0 +1,152 @@
+<template>
+	<view>
+		<u-navbar title="用电知识"  title-color="#101010" ></u-navbar>
+		
+		<view class="main"  >
+			<view class="item" v-for="(item,i) in list"
+			 
+			  @click="gotoUrlBtn(item)"
+			  
+			 :key="i">
+				<view class="item-message">
+					<view>{{item.title}}</view>
+				
+				</view>
+			
+				<view class="item-time" style="display: flex;">
+					  <!-- {{item.tenantName}} -->
+					
+					<view>{{item.createTime}}</view>
+					<view style="margin-left: 40rpx;">阅读量:{{item.readNum}}</view>
+				</view>
+			</view>
+			
+		</view>
+		<u-divider :isnone="list.length==0"   nonetext="没有找到相关内容"
+			border-color="#CFD2D5">已经到底了</u-divider>
+	</view>
+</template>
+
+<script>
+	import * as API from '@/apis/pagejs/message.js'
+	
+	export default {
+		data() {
+			return {
+				type:10,
+				formData:{
+					type:10,
+					pageIndex:1,
+					pageSize:20,
+				},
+				typeName:"",
+				list:[],
+				recordsTotal:0
+			}
+		},
+		computed:{
+			
+		},
+		onLoad(op) {
+			
+			
+			this.getList()
+		},
+		onReachBottom() {
+			
+			if (this.list.length < this.recordsTotal) {
+				this.myLoadmore();
+			}
+		},
+		methods: {
+			gotoUrlBtn(item){
+				uni.navigateTo({
+					url:"/pages/message/knowledge?id="+item.id
+				})
+			},
+			getList(){
+				this.getMessageList()
+				
+			},
+			myLoadmore() {
+				this.formData.pageIndex += 1;
+				this.getList()
+			},
+			getMessageList(){
+				uni.showLoading({
+					mask:true,title:'加载中...'
+				})
+				API.newsList(this.formData).then((res) => {
+					uni.hideLoading();
+					if(this.formData.pageIndex==1){
+						this.list = [
+							
+							...res.data.data
+						];
+					}else{
+						this.list = [
+							...this.list,
+							...res.data.data
+						];
+					}
+					this.recordsTotal = res.data.recordsTotal;
+					
+					//this.list=response.data.data;
+				}).catch(error => {
+					uni.hideLoading();
+					uni.showToast({
+						icon: "none",
+						title: error
+					})
+				})
+			},
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+	.main{
+		
+		margin-top: 24rpx;
+		.item-main{
+			display: flex;
+			align-items: center;
+			justify-content: space-between;
+		}
+		   
+		.item{
+			background-color: #fff;
+			margin: 32rpx;
+			padding: 32rpx;
+			border-bottom: 1px solid rgba(244,244,244,1);
+			border-radius: 8px;
+
+			box-shadow: 0px 2px 6px 0px rgba(0,61,146,0.05);
+			.item-message{
+				line-height: 44rpx;
+				font-weight: bold;
+				display: flex;
+				font-size: 28rpx;
+				justify-content: space-between;
+				color: rgba(51,51,51,1);
+				.billAmount{
+					    color: #F44336;
+				}
+				.gotoBtn{
+					color:#1677FF
+				}
+			}
+			.item-time2{
+				color: rgb(153,153,153);
+				font-size: 28rpx;
+				margin-top: 16rpx;
+			}
+			.item-time{
+				color: rgb(153,153,153);
+				font-size: 24rpx;
+				margin-top: 16rpx;
+			}
+		}
+	}
+
+</style>