<template>
	<view style="background-color: #fff;">
		<ujp-navbar :title="newsDetail.title">
			
		</ujp-navbar>
	<u-alert-tips type="warning"
	 :descStyle="{
		     fontSize: '28rpx',
		     color: '#ef7a30',
	 }" 
	 :show-icon="true"  description="阅读至底部进入绑定页面"></u-alert-tips>
		<view class="main">
			
			
			<view class="news-content" v-html="newsDetail.value">
				 
			</view>
		</view>
		<button class="btn" @click="submit">我已阅读并同意</button>
		
	</view>
</template>

<script>
	import * as newsApi from '@/apis/news.js'
	import * as API from '@/apis/finance.js'
	
	export default {
		data() {
			return {
				id: '',
				code:"",
				stationId:"",
				newsDetail: '',
				obj1:{},
			}
		},
		onLoad(op) {
			if(op.id){
				this.id=op.id
				
				this.getInfo()
			}
			if(op.stationId){
				this.stationId=op.stationId;
				
			}
		},
		methods: {
			submit(){
				var url="/pagesFinance/user/confirmBindingStep2?id="+this.id;
				if(this.stationId){
					url+="&stationId="+this.stationId;
				}
				uni.redirectTo({
					url:url
				})
			},
			getNewsInfoDetail() {
				uni.showLoading({
					title: "加载中",
					mask: true,
				})
				var list=["","buyType1","buyType2"]
				
				newsApi.findConfigureByKey({
					key:"buyType"+this.code
				}).then((res) => {
					uni.hideLoading()					
					this.newsDetail = res.data;
					this.$nextTick(()=>{
					    var list =document.getElementsByClassName("news-content")[0].getElementsByTagName("img");
						var table =document.getElementsByClassName("news-content")[0].getElementsByTagName("table");
						
					    for(var i=0;i<list.length;i++){
					        list[i].style='width: 100%;height: 100%;'
					    }
						for(var i=0;i<table.length;i++){
						   var t=table[i].style.width="100%;"
						   
						  t= t.replace("width:","width-1:")
						
						  table[i].style="width: 100%;"+t
						}
					})
				}).catch(error => {
					uni.showToast({
						title: error,
						icon: "none"
					})
				})
			},
			getInfo(){
				uni.showLoading({
					title: "加载中",
					mask: true,
				})
				var obj={
				
					deviceNo:this.id
				}
				
				
				API.findByDeviceNo(obj).then((res) => {
					this.obj1 = res.data.chargingDevice
					this.code=this.obj1.buyType
					if(this.code){
						this.getNewsInfoDetail();
					}else{
						this.submit()
					}
					
					uni.hideLoading()
					
				}).catch(error => {
					uni.showToast({
						title: error
					})
				})
			}
		}
	}	
</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;
		}
	}
	.btn{
		 width: 91.4%;
		 line-height: 44px;
		 border-radius: 8px;
		 background-color: rgba(24, 90, 198, 1);
		 color: rgba(255, 255, 255, 1);
		 font-size: 16px;
	}
</style>
