<template>
	<view :style="'background-color: '+theme.bg+';color: '+theme.text" style="height: 100vh;">
		<myNav :title="i18n.mine.introduce.updataName" :isRightext="true" :rightText="i18n.mine.introduce.ok" rightextColor="#0165EE" @Jump="updataName"></myNav>
		
		<view class="width-100b padding-w-40 flex direction-column justify-around"
		:style="'background-color: '+theme.fu_bg" >
			<input class="width-100b height-96 font-30 bold-font" :placeholder="i18n.mine.introduce.inputname"
				 type="text" v-model="name" />
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				name:'',
				flag:true,
				theme:''
			}
		},
		computed: {
		    i18n() {
		        return this.$t('message');
		    }
		},
		onShow() {
			if (uni.getStorageSync("theme") == "dark") {
				this.theme = this.$store.state.darkTheme
			}else{
				this.theme = this.$store.state.lightTheme
			}
		},
		methods: {
			updataName(){
				if(!this.flag) return
				if (this.name == '') {
					this.tos(this.i18n.mine.introduce.nullname);
					return
				}
				this.flag = false
				uni.showLoading()
				this.post('/my/profile',{nickname:this.name}).then((res) => {
					console.log('修改昵称',res);
					this.flag = true
					uni.hideLoading()
					if (res.code == 1) {
						this.tos(res.msg)
						setTimeout(()=>{
							uni.navigateBack()
						},500)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
</style>
