<template>
  <view class="page-wrapper">
    <JMainCard wrapPd="0 30rpx" pd="0">
      <JInput v-model:value="appInfo.appName" name="应用名称" place="请输入应用名称" :isBorder="true"></JInput>
    </JMainCard>
    <JButton pd="30rpx" @HandleTouch="saveApp" pdTop="30rpx">保存</JButton>
  </view>
</template>

<script setup>
import { reactive, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { $editApp } from '@/http/apiManager.js'
import JMainCard from '@/components/newComponents/JMainCard/JMainCard'
import JInput from '@/components/newComponents/JInput/JInput'
import JButton from '@/components/newComponents/JButton/JButton'
onLoad((options) => {
  appInfo.appName = options.appName
  appInfo.appId = options.appId
})
const appInfo = reactive({
  appName: '',
})
// 保存App
const saveApp = () => {
  $editApp(appInfo).then((res) => {
    // 修改成功 通知 详情页面更新
    uni.$emit('upDateAppDetails')
    uni.navigateBack({
      success: () => {
        uni.showToast({
          title: '保存成功',
        })
      },
    })
  })
}
</script>

<style lang="scss" scoped>
.page-wrapper {
  min-height: calc(100vh - 88rpx);
  background-color: #f7f7f7;
}
</style>
