<template>
	<view :style="'background-color: '+theme.bg+';color: '+theme.text">
		<myNav :title="i18n.newWord.mytitle5"></myNav>
		<view class="width-750 padding-w-30 padding-t-20">
			<view @click="setRateid(item)" v-for="(item,index) in list" :key="index" class="topBox"
			:style="'background-color: '+theme.fu_bg+';color: '+theme.text">
				<view class="width-60 flex align-center justify-center">
					<u-icon v-if="rateid==item.id" name="checkbox-mark" color="#3ECEB2" size="30"></u-icon>
				</view>
				<view class="flex-2 text-center">
					<text class="font-36 numbold-font">1 USD</text>
				</view>
				<text class="font-36 bold-font">≈</text>
				<view class="flex-3 text-center">
					<text class="font-36 numbold-font">{{item.exchange}} {{item.name_sx}}</text>
				</view>
			</view>
		</view>
		<view class="width-100b padding-w-30 padding-b-40" v-html="huilv_text"></view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				huilv_text: '',
				list: [],
				rateid: '',
				ratename:'',
				ratenum:'',
				
				theme: '',
			}
		},
		computed: {
			i18n() {
				return this.$t('message');
			},
		},
		onLoad() {
			this.getInfo()
			this.getlist()
		},
		onShow() {
			if (uni.getStorageSync("theme") == "dark") {
				this.theme = this.$store.state.darkTheme
			} else {
				this.theme = this.$store.state.lightTheme
			}
		},
		methods: {
			setRateid(item) {
				this.rateid = item.id
				uni.setStorageSync('rateid', item.id)
				uni.setStorageSync('ratename', item.name_sx)
				uni.setStorageSync('ratenum', item.exchange)
			},
			getlist() {
				this.post('/publics/exchange_list').then(res => {
					if (res.code == 1) {
						this.list = res.data
						if (uni.getStorageSync('rateid')) {
							this.rateid = uni.getStorageSync('rateid')
						} else {
							uni.setStorageSync('rateid', this.list[0].id)
							this.rateid = uni.getStorageSync('rateid')
						}
					}
				})
			},
			getInfo() {
				this.post('/publics/new_common_data').then(res => {
					console.log('文案说明', res)
					if (res.code == 1) {
						this.huilv_text = res.data.huilv_text
					}
				})
			}
		}
	}
</script>

<style>
	.topBox {
		width: 690rpx;
		height: 100rpx;
		padding: 0 30rpx;
		margin-bottom: 20rpx;
		/* background: rgba(255, 255, 255); */
		border-radius: 10rpx;
		display: flex;
		align-items: center;
	}
</style>
