<template>
	<view class="contents">
		<view class="title"><text>{{item.title}}</text></view>
		<view class="ly">
			<text>{{item.author}}</text>
			<text class="day">4天前</text>
		</view>
		<view>
			<view class="fwb">
				<u-parse :html="item.content"></u-parse>
			</view>
			<view class="mt10">
				<view class="">来源：作者名称</view>
				<view class="">编辑丨编辑名称</view>
				<view class="">责编丨初审名称</view>
				<view class="">审核丨终审名称</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			ip: this.$http.urls.ip,
			item: {}
		};
	},
	onLoad(e) {
		this.$http.request({
			url: this.$http.urls.getContentInfo+ e.id,
			success: res => {
				console.log("asd:"+JSON.stringify(res));
				this.item = res.data.data.info;
				//this.item.contents = res.data.data.contents.replace(/\<img/gi, '<img style=width:100%;height:auto');
			}
		});
	},
	methods: {
		//购物车
		car() {
			uni.switchTab({
				url: 'shopcar'
			});
		},
		//添加购物车
		add() {
			this.$http.request({
				url: this.$http.urls.cart_add,
				method: 'POST',
				data: { goodsId: this.item.id, userId: this.$getUser().id },
				success: res => {
					uni.showToast({ title: '已加入购物车', icon: 'none' });
				}
			});
		},
		//直接购买服务
		buy() {
			let list = [{ goodsId: this.item.id, goods: { title: this.item.title, price: this.item.price, pic: this.item.pic } }];
			uni.navigateTo({ url: 'pay?list=' + JSON.stringify(list) });
		}
	}
};
</script>

<style lang="scss">
.contents {
	padding: 20px;
	.ly {
		font-size: 14px;
		margin-bottom: 15px;
		color: #2196f3;
		.day {
			color: #818184;
			padding-left: 10px;
		}
	}
	.title {
		padding-top: 20px;
		font-size: 23px;
		font-weight: 400;
		margin-bottom: 20px;
	}
	.pic {
		width: 100%;
		border-radius: 3px;
		margin-top: 3px;
	}
	.fwb {
		margin-top: 15px;
		color: #909090;
	}
}
</style>
