<template>
	<view :style="'background-color: '+theme.bg+';color: '+theme.text">
		<myNav :title="i18n.newWord.mytitle10"></myNav>
		
		<view class="topBox">
			<text class="font-40 numbold-font color-white">{{i18n.newWord.shequTitle1}}</text>
			<text class="font-24 color-white margin-t-20 text-center">{{i18n.newWord.shequTitle2}}</text>
		</view>
		
		<view class="boxborder" v-for="(item,index) in list" :key="index">
			<view class="flex align-center">
				<image class="width-32 height-32 margin-r-15" :src="item.logo_image" mode=""></image>
				<text class="font-30">{{item.name}}</text>
			</view>
			<text class="font-26">{{item.title}}</text>
			<view class="flex align-center">
				<text style="word-break:break-all;" class="font-26 flex-1">{{item.content}}</text>
				<image @click="copy(item.content)" class="width-22 height-24 margin-l-50" src="/static/imgs/my/COPY1@2x.png" mode=""></image>
			</view>
		</view>
	</view>
</template>

<script>
	import clipboard from "@/components/clipboard.js"
	export default {
		data() {
			return {
				list:[],
				theme:'',
			}
		},
		computed: {
			i18n() {
				return this.$t('message');
			},
		},
		onLoad() {
			this.get_shequ()
		},
		onShow() {
			if (uni.getStorageSync("theme") == "dark") {
				this.theme = this.$store.state.darkTheme
			}else{
				this.theme = this.$store.state.lightTheme
			}
		},
		methods: {
			get_shequ(){
				this.post('/my/get_shequ').then(res => {
					console.log('社区列表',res)
					if(res.code == 1){
						this.list = res.data
					}
				})
			},
			// 复制地址
			copy(data) {
				// #ifndef H5
				clipboard.setText(data);
				// #endif
				
				// #ifdef H5 
					  let result
				      let textarea = document.createElement("textarea")
				      textarea.value = data
				      textarea.readOnly = "readOnly"
				      document.body.appendChild(textarea)
				      textarea.select() // 选中文本内容
				      textarea.setSelectionRange(0, data.length) 
				      result = document.execCommand("copy") 
				      textarea.remove()    
				// #endif
				this.tos(this.i18n.mine.share.copySuceed)
			},
		}
	}
</script>

<style lang="scss">
	.topBox{
		width: 690rpx;
		height: 316rpx;
		margin: 20rpx auto;
		background-image: url('../../../static/imgs/my/joinshe2@2x.png');
		background-repeat: repeat;
		background-size: 100% 100%;
		padding: 30rpx 30rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}
	.boxborder{
		width: 100%;
		height: 200rpx;
		// background-color: #FFF;
		padding: 22rpx 30rpx;
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		justify-content: space-between;
		margin-bottom: 1rpx;
	}
</style>
