<template>
  <view class="edit-wrapper">
    <view class="edit-input flex-center">
      <uni-easyinput :inputBorder="false" clearable maxlength="12" v-model="vdata.formData.realname" type="text" :styles="styles" />
    </view>
    <view class="confirm-button flex-center" hover-class="touch-button" @tap="updateState">确认修改</view>
  </view>
</template>

<script setup>
import { reactive } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { $modifyUser } from '@/http/apiManager.js'
import infoBox from '@/commons/utils/infoBox.js'
import go from '@/commons/utils/go.js'
onLoad((options) => {
  Object.assign(vdata.formData, options)
})
const styles = reactive({
  backgroundColor: 'transparent',
  color: '#000',
  fontSize: '32rpx',
})
const vdata = reactive({
	formData: {}
})

function updateState() {
	if (!vdata.formData.realname) {
		return infoBox.showToast("请输入用户姓名")
	}
  $modifyUser(vdata.formData).then(() => {
		infoBox.showToast("保存成功").then(() => {
			go.back()
		})
	})
}
</script>

<style lang="scss" scoped>
.edit-input {
  padding: 0 20rpx;
  margin: 0 35rpx;
  margin-top: 150rpx;
  height: 120rpx;
  border-radius: 32rpx;
  background-color: #f7f7f7;
}
.tips {
  margin-top: 30rpx;
  text-align: center;
  font-size: 27rpx;
  color: #808080;
}
.confirm-button {
  margin: 0 auto;
  margin-top: 90rpx;
  width: 400rpx;
  height: 110rpx;
  border-radius: 20rpx;
  font-size: 33rpx;
  font-weight: 500;
  color: #fff;
  background: $jeepay-bg-primary;
}
</style>
