detail.uvue 2.0 KB
Newer Older
taohebin@dcloud.io's avatar
taohebin@dcloud.io 已提交
1
<template>
DCloud-WZF's avatar
DCloud-WZF 已提交
2 3 4 5 6 7 8 9 10 11 12
	<!-- #ifdef APP -->
	<scroll-view style="flex: 1">
		<!-- #endif -->
		<view>
			<view class="banner">
				<image class="banner-img" :src="cover"></image>
				<text class="banner-title">{{title}}</text>
			</view>
			<view class="article-content">
				<text>{{htmlNodes}}</text>
			</view>
taohebin@dcloud.io's avatar
taohebin@dcloud.io 已提交
13
		</view>
DCloud-WZF's avatar
DCloud-WZF 已提交
14 15 16
		<!-- #ifdef APP -->
	</scroll-view>
	<!-- #endif -->
taohebin@dcloud.io's avatar
taohebin@dcloud.io 已提交
17 18 19 20 21 22 23
</template>

<script>
	export default {
		data() {
			return {
				htmlNodes: "",
Y
yurj26 已提交
24 25
				pageVisible: false,
				title: '',
DCloud-WZF's avatar
DCloud-WZF 已提交
26 27
				cover: "",
				post_id: "",
taohebin@dcloud.io's avatar
taohebin@dcloud.io 已提交
28 29
			}
		},
Y
yurj26 已提交
30
		onLoad(event) {
taohebin@dcloud.io's avatar
taohebin@dcloud.io 已提交
31
			this.pageVisible = true;
Y
yurj26 已提交
32 33 34
			this.post_id = event["post_id"] ?? "";
			this.cover = event["cover"] ?? "";
			this.title = event["title"] ?? "";
taohebin@dcloud.io's avatar
taohebin@dcloud.io 已提交
35
			this.getDetail();
Y
yurj26 已提交
36 37 38
		},
		onUnload() {
			this.pageVisible = false;
taohebin@dcloud.io's avatar
taohebin@dcloud.io 已提交
39 40 41 42 43
		},
		methods: {
			getDetail() {
				uni.request({
					url: 'https://unidemo.dcloud.net.cn/api/news/36kr/' + this.post_id,
Y
yurj26 已提交
44
					success: (data) => {
DCloud-WZF's avatar
DCloud-WZF 已提交
45
						if (this.pageVisible) {
Y
yurj26 已提交
46 47
							if (data.statusCode == 200) {
								const result = data.data as UTSJSONObject
48
								this.htmlNodes = result["content"] as string;
Y
yurj26 已提交
49
							}
taohebin@dcloud.io's avatar
taohebin@dcloud.io 已提交
50 51 52 53 54 55
						}
					},
					fail: () => {
						console.log('fail');
					}
				});
Y
yurj26 已提交
56
			},
taohebin@dcloud.io's avatar
taohebin@dcloud.io 已提交
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
		}
	}
</script>

<style>
	.banner {
		height: 360rpx;
		overflow: hidden;
		position: relative;
		background-color: #ccc;
	}

	.banner-img {
		width: 100%;
	}

	.banner-title {
		max-height: 84rpx;
		overflow: hidden;
		position: absolute;
		left: 30rpx;
		bottom: 30rpx;
		width: 90%;
		font-size: 32rpx;
		font-weight: 400;
		line-height: 42rpx;
		color: white;
Y
yurj26 已提交
84
		/* z-index: 11; */
taohebin@dcloud.io's avatar
taohebin@dcloud.io 已提交
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
	}

	.article-meta {
		padding: 20rpx 40rpx;
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		color: gray;
	}

	.article-text {
		font-size: 26rpx;
		line-height: 50rpx;
		margin: 0 20rpx;
	}

	.article-author,
	.article-time {
		font-size: 30rpx;
	}

	.article-content {
		padding: 0 30rpx;
		overflow: hidden;
		font-size: 30rpx;
		margin-bottom: 30rpx;
	}
DCloud-WZF's avatar
DCloud-WZF 已提交
112
</style>