xiaol 10 kuukautta sitten
vanhempi
commit
3eebf4e7f3
5 muutettua tiedostoa jossa 182 lisäystä ja 5 poistoa
  1. 15 0
      api/notice.js
  2. 18 0
      pages.json
  3. 15 5
      pages/index/index.vue
  4. 74 0
      pages/index/notice.vue
  5. 60 0
      pages/index/noticeDetails.vue

+ 15 - 0
api/notice.js

@@ -0,0 +1,15 @@
+import request from '@/utils/request'
+
+export function getArtList(id) {
+	return request({
+		url: '/api/article/list/' + id,
+		method: 'get',
+	});
+}
+
+export function getDetail(id) {
+	return request({
+		url: '/api/article/details/' + id,
+		method: 'get'
+	});
+}

+ 18 - 0
pages.json

@@ -107,6 +107,24 @@
 				"navigationBarTextStyle": "white"
 			}
 		},
+		{
+			"path": "pages/index/notice",
+			"style": {
+				"navigationBarTitleText": "公告列表",
+				"enablePullDownRefresh": false,
+				"navigationBarBackgroundColor": "#051137",
+				"navigationBarTextStyle": "white"
+			}
+		},
+		{
+			"path": "pages/index/noticeDetails",
+			"style": {
+				"navigationBarTitleText": "公告详情",
+				"enablePullDownRefresh": false,
+				"navigationBarBackgroundColor": "#051137",
+				"navigationBarTextStyle": "white"
+			}
+		},
 		{
 			"path": "pages/index/personal",
 			"style": {

+ 15 - 5
pages/index/index.vue

@@ -15,13 +15,13 @@
 		<view class="swiper-box">
 			<u-swiper :list="swiperList" indicator indicatorMode="line" height="280rpx" circular></u-swiper>
 		</view>
-		<!-- <view class="flex noteBox">
+		<view class="flex noteBox" @click="openurl('/pages/index/notice')">
 			<view class="flex_item noteTpl">
 				<image src="/static/image/img04.png" style="width: 42rpx;height: 34rpx;" mode="widthFix"></image>
-				<view class="clamp textTpl">上线活动的公告等等公告内容上线活动的公告等等公告内容等上线活动的公告等等公告内容等</view>
+				<view class="clamp textTpl">{{noticeList.title}}</view>
 			</view>
-			<view class="tip"></view>
-		</view> -->
+			<!-- <view class="tip"></view> -->
+		</view>
 		<view class="flex navList">
 			<view class="navTpl" @click="openurl('/pages/index/recharge')">
 				<image src="/static/image/img06.png" style="width: 123rpx;height: 73rpx;" mode="widthFix"></image>
@@ -143,6 +143,7 @@
 		saveUrl,
 		interceptor
 	} from '@/utils/loginUtils.js';
+	import { getArtList} from '@/api/notice.js';
 	import {
 		mapState,
 		mapActions,
@@ -158,7 +159,8 @@
 				baseData:{
 					ok_price:0,
 					us_price:0
-				}
+				},
+				noticeList:''
 			}
 		},
 		computed: {
@@ -194,11 +196,19 @@
 		},
 		onShow() {
 			this.loadData();
+			this.getNotice()
 		},
 		methods: {
 			...mapActions({
 				setLang: "setLang",
 			}),
+			getNotice(){
+				let obj = this;
+				getArtList('1').then(function(e) {
+					obj.noticeList = e.data[0]
+					console.log(obj.noticeList,'obj.noticeList');
+				})
+			},
 			openurl(url){
 				if(!this.hasLogin){
 					saveUrl();

+ 74 - 0
pages/index/notice.vue

@@ -0,0 +1,74 @@
+<template>
+	<view class="container">
+		<view v-if="noticeList.length == 0" class="no-data">——暂无数据——</view>
+		<view class="listBox" v-else v-for="item,index in noticeList" :key="index" @click="notice(item)">
+			<view class="listTpl">
+				<view class="name">{{item.title}}</view>
+				<view class="time">{{item.add_time}}</view>
+			</view>
+		</view>
+	</view>
+</template>
+
+<script>
+	import { getArtList} from '@/api/notice.js';
+	export default {
+		data() {
+			return {
+				noticeList:[]
+			};
+		},
+		onLoad() {
+			this.loadData()
+		},
+		methods: {
+			//获取公告列表数据
+			async loadData() {
+				let obj = this;
+				getArtList('1').then(function(e) {
+					obj.noticeList = e.data
+					console.log(obj.noticeList,'obj.noticeList');
+				})
+			},
+			//公告详情
+			notice(item){
+				let id = item.id;
+				uni.navigateTo({
+					url: `/pages/index/noticeDetails?id=${id}`
+				});
+			}
+		}
+	};
+</script>
+
+<style lang="scss">
+	.container{
+		width: 100%;
+		color: #FFFFFF;
+		background-color: #051137;
+	}
+	.listBox{
+		background-color: #1F2A4A;
+		.listTpl{
+			border-bottom: 1rpx solid #919295;
+			padding: 25rpx 25rpx;
+			.name{
+				font-size: 28rpx;
+				color: #FFFFFF;
+			}
+			.time{
+				font-size: 22rpx;
+				color: #999999;
+				padding-top: 15rpx;
+			}
+		}
+	}
+	.no-data{
+		color:#A2A5B8;
+		font-size: 26rpx;
+		padding: 25rpx 0rpx;
+		width: 100%;
+		text-align: center;
+		background-color: #051137;
+	}
+</style>

+ 60 - 0
pages/index/noticeDetails.vue

@@ -0,0 +1,60 @@
+<template>
+	<view class="notice-item">
+		<view class="notice_name">{{info.title}}</view>
+		<view class="flex notice_text">
+			<text class="">作者:{{info.author}}</text>
+			<text class="">{{info.createtime}}</text>
+		</view>
+		<view class="notice_content" v-html="info.content"></view>
+	</view>
+</template>
+<script>
+import { getDetail } from '@/api/notice.js';
+export default {
+	data() {
+		return {
+			id:'',
+			info:""
+		};
+	},
+	onLoad(options) {
+		this.id = options.id;
+		this.loadData();
+	},
+	methods: {
+		// 公告信息
+		async loadData() {
+			let obj = this;
+			getDetail(obj.id).then(function(e) {
+				obj.info = e.data
+			})
+		}
+	}
+};
+</script>
+
+<style lang="scss">
+.container{
+		width: 100%;
+		color: #FFFFFF;
+		background-color: #051137;
+	}
+.notice_name {
+	font-size: 31rpx;
+	color: #ffffff;
+}
+.notice-item {
+	color: #fff;
+	padding: 35rpx 35rpx;
+}
+.notice_text {
+	// border-bottom: 1px solid #1b1f43;
+	padding: 30rpx 0rpx;
+}
+.notice_content {
+	font-size: 28rpx;
+	padding: 25rpx 0rpx;
+	color: #fff;
+	line-height: 45rpx;
+}
+</style>