<template>
	<view class="sub" :style="'padding-top:'+padtop+'px'">
		<navbar :back="false" :title="title" :bgcolor="backgroundColor" color="#fff" fixed zIndex="1010" :center="true"	:custom='true' @getTop="getTop" back="true"/>
		<!-- 头部 使用指南-->
		<view class="gpd" v-if="type=='use'">
			<view class="guidtit" v-if="usedetail.useTitle">
				{{usedetail.useTitle}}
			</view>
			<view class="guidtime" v-if="usedetail.createTime">{{usedetail.createTime}}</view>
			<rich-text v-if="useContent" :nodes="useContent"></rich-text>
		</view>
		
		<!-- 正常福利 -->
		<view class="gpd" v-else>
			<view class="guidtit" v-if="detail.welfareTitle">
				{{detail.welfareTitle}}
			</view>
			<view class="guidtime" v-if="detail.createTime">{{detail.createTime}}</view>
			<rich-text v-if="welfareContent" :nodes="welfareContent"></rich-text>
		</view>
	</view>
</template>

<script>
	import url from "@/util/url";
	let {imgDomain} = url
	export default{
		data(){
			return{
				padtop:this.$http._GET.customBarH||0,
				backgroundColor: 'linear-gradient(90deg, #A00517, #E93030)',
				string:'',
				title:'使用指南',
				usedetail:{},
				detail:{},
				type:'use',
				useContent:'',
				welfareContent:'',
			}
		},
		onLoad(e) {
			this.type=e.type
			if(e.type=='use'){
				this.title='使用指南'
				this.getDatauseFn()
			}else{
				this.title='优惠福利'
				this.getDataFn()
			}
			
		},
		methods:{
			getTop(e){
				this.padtop=e
			},
			getDatauseFn(){
				var that=this;
				that.$http.get("system/use/new").then(res => {
					if (res.code == 200) {
						// /profile/upload/2022/07/14/微信截图_20220711151232_20220714145922A003.png
						if(res.data.useContent){
							var t='<img style="max-width: 100%;" src="'+imgDomain;
							var newhtml=res.data.useContent.replace(/\<img src="/gi, t);
							that.useContent=newhtml;
						}
						that.usedetail=res.data
					} else {
						uni.showToast({
							title: res.msg,
							duration: 1000,
							icon: 'none'
						});
				
					}
				})
			},
			getDataFn(){
				var that=this;
				that.$http.get("system/welfare/new").then(res => {
					if (res.code == 200) {
						if(res.data.welfareContent){
							var t='<img style="max-width: 100%;" src="'+imgDomain;
							var newhtml=res.data.welfareContent.replace(/\<img src="/gi, t);
							that.welfareContent=newhtml;
						}
						that.detail=res.data
					} else {
						uni.showToast({
							title: res.msg,
							duration: 1000,
							icon: 'none'
						});
				
					}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.sub{box-sizing: border-box;width: 100%;min-height: 100vh;}
	.gpd{padding:30rpx 26rpx;}
	.guidtit{font-size: 30rpx;font-weight: bold;color: #222222;margin-bottom: 32rpx;}
	.guidtime{font-size: 20rpx;color: #676767;margin-bottom: 60rpx;}
</style>
