<template>
    <view class="container" style="paddingBottom:1rpx;">
      <u-navbar
		leftIconSize="40rpx"
		leftIconColor="#333333"
		title="账户交易记录"
	>
	</u-navbar>
      <view class="section">
        <view class="section-title">{{ title}}</view>
        <view class="form-view">
          <u--form labelPosition="left" :model="form" :rules="rules" ref="uForm" label-width="180rpx"
            :labelStyle="{ color: '#333333', fontSize: '30rpx', marginRight: '24rpx' }">
            <u-form-item label="记账类型" prop="typeName" required @click="handleAccountType">
              <view class="input-with-arrow">
                <u--input v-model="form.typeName" readonly disabledColor="#ffffff" placeholder="请选择记账类型"
                  inputAlign="left" :customStyle="inputBaseStyle"></u--input>
                <text class="arrow-icon">▼</text>
              </view>
            </u-form-item>
            <u-form-item label="储蓄账户类型" v-show="debitTypeShow" prop="tempDebitTypeName" @click="handleDebitType">
              <view class="input-with-arrow">
                <u--input v-model="tempDebitTypeName" readonly disabledColor="#ffffff" placeholder="请选择储蓄账户类型"
                  inputAlign="left" :customStyle="inputBaseStyle"></u--input>
                <text class="arrow-icon">▼</text>
              </view>
            </u-form-item>
            <u-form-item label="记账账户" prop="accountName" required @click="handleAccountName">
              <view class="input-with-arrow">
                <u--input v-model="form.accountName" readonly disabledColor="#ffffff" placeholder="请选择记账账户"
                  inputAlign="left" :customStyle="inputBaseStyle"></u--input>
                <text class="arrow-icon">▼</text>
              </view>
            </u-form-item>
            <u-form-item label="交易类型" prop="dealTypeName" required @click="handleDealType">
              <view class="input-with-arrow">
                <u--input v-model="form.dealTypeName" readonly disabledColor="#ffffff" placeholder="请选择交易类型"
                  inputAlign="left" :customStyle="inputBaseStyle"></u--input>
                <text class="arrow-icon">▼</text>
              </view>
            </u-form-item>
            <u-form-item label="交易时间" prop="createTime" required @click="selectDate()">
              <view class="input-with-arrow">
                <u--input v-model="form.createTime" readonly disabledColor="#ffffff" placeholder="请选择交易时间"
                  inputAlign="left" :customStyle="inputBaseStyle"></u--input>
                <text class="arrow-icon">▼</text>
              </view>
            </u-form-item>
            <u-form-item label="交易金额" prop="amount" required>
              <u--input v-model="form.amount" type="number" placeholder="请填写交易金额"
                inputAlign="left" :customStyle="inputBaseStyle"></u--input>
            </u-form-item>
            <u-form-item label="交易类别" prop="dealCategoryName" required @click="handleDealCategory">
              <view class="input-with-arrow">
                <u--input v-model="form.dealCategoryName" readonly disabledColor="#ffffff" placeholder="请选择交易类别"
                  inputAlign="left" :customStyle="inputBaseStyle"></u--input>
                <text class="arrow-icon">▼</text>
              </view>
            </u-form-item>
            <u-form-item label="交易子类别" v-show="childCategoryShow" prop="childCategoryName" required @click="handleChildCategory">
              <view class="input-with-arrow">
                <u--input v-model="form.childCategoryName" readonly disabledColor="#ffffff" placeholder="请选择交易子类别"
                  inputAlign="left" :customStyle="inputBaseStyle"></u--input>
                <text class="arrow-icon">▼</text>
              </view>
            </u-form-item>
            <u-form-item label="交易地点" prop="locationAddress" labelPosition="top">
              <view class="location-field">
                <view class="location-main">
                  <u--input v-model="form.locationAddress" placeholder="未记录地点，可手动填写或点击定位"
                    inputAlign="left" :customStyle="inputBaseStyle"></u--input>
                  <text v-if="form.locationName" class="location-name">{{ form.locationName }}</text>
                  <text v-if="hasCoordinate" class="location-coord">经纬度：{{ form.longitude }}，{{ form.latitude }}</text>
                </view>
                <view class="location-actions">
                  <u-button size="mini" type="primary" plain text="定位" :loading="locationLoading" @click="loadCurrentLocation"></u-button>
                  <u-button v-if="hasLocation" size="mini" type="error" plain text="清除" @click="clearLocation"></u-button>
                </view>
              </view>
            </u-form-item>
            <u-form-item label="备注" prop="remark" labelPosition="top">
              <u--textarea v-model="form.remark" placeholder="请填写备注" autoHeight inputAlign="left" count
                maxlength="20000" style="border: 2rpx solid #dcdfe6 !important; height: 160rpx;"></u--textarea>
            </u-form-item>
          </u--form>
          <view class="form-btn">
            <u-button type="primary" text="提交" @click="submit"></u-button>
          </view>
        </view>
      </view>
      <u-toast ref="uToast"></u-toast>
      <u-picker itemHeight="88" :show="showAccountType" :columns="accountTypeList" keyName="dictLabel" @cancel="handleAccountTypeCancel"
        @confirm="handleAccountTypeConfirm"></u-picker>
        <u-picker itemHeight="88" :show="showDebitType" :columns="debitTypeList" keyName="dictLabel" @cancel="handleDebitTypeCancel"
        @confirm="handleDebitTypeConfirm"></u-picker>
        <u-picker itemHeight="88" :show="showAccountName" :columns="accountNameList" keyName="nameCodeAvailableLimit" @cancel="handleAccountNameCancel"
        @confirm="handleAccountNameConfirm"></u-picker>
        <u-picker itemHeight="88" :show="showDealCategory" :columns="dealCategoryList" keyName="dictLabel" @cancel="handleDealCategoryCancel"
        @confirm="handleDealCategoryConfirm"></u-picker>

        <u-picker itemHeight="88" :show="showChildCategory" :columns="childCategoryList" keyName="dictLabel" @cancel="handleChildCategoryCancel"
        @confirm="handleChildCategoryConfirm"></u-picker>

        <u-picker itemHeight="88" :show="showDealType" :columns="dealTypeList" keyName="dictLabel" @cancel="handleDealTypeCancel"
        @confirm="handleDealTypeConfirm"></u-picker>
        <u-datetime-picker
			:show="datePickShow"
			mode="datetime"
      ref="createTimeRef" 
			@cancel="datePickShow=false"
			@confirm="datePickConfirm"
			itemHeight="88"
		></u-datetime-picker>
    </view>
  </template>
  
  <script setup>
  import {getAccountDealRecord, addAccountDealRecord, updateAccountDealRecord } from '@/api/invest/accountDealRecord'
  import { getDicts } from '@/api/system/dict/data.js'
  import { listAccounts } from '@/api/invest/accounts'
  const { proxy } = getCurrentInstance()
  import dayjs from 'dayjs'
  import {onLoad,onReady} from "@dcloudio/uni-app";
    // 计算属性与监听属性是在vue中而非uniap中 需要注意！！！
import {reactive ,toRefs,ref,computed ,getCurrentInstance }from "vue";
const datePickShow = ref(false)
const showAccountType = ref(false)
const showAccountName = ref(false)
const showDealCategory = ref(false)
const showChildCategory = ref(false)
const showDealType = ref(false)
const showDebitType = ref(false)
const title = ref("账户交易记录")
const accountTypeList = ref([])
const accountNameList = ref([])
const dealCategoryList = ref([])
const childCategoryList = ref([])
const debitTypeList = ref([])
const childCategoryShow = ref(true)
const debitTypeShow = ref(false)
const flag = ref('add')
const dealTypeList = ref([])
const locationLoading = ref(false)
// 临时变量，仅用于前端筛选，不保存到数据库
const tempDebitType = ref(null)
const tempDebitTypeName = ref(null)
// 统一输入框样式（参考 health-weixin 分支）
const inputBaseStyle = {
  background: '#ffffff',
  border: '2rpx solid #dcdfe6',
  borderRadius: '8rpx',
  padding: '0 24rpx',
  height: '68rpx',
  width: '100%',
  boxSizing: 'border-box'
}
const data = reactive({
  form: {
    id: null,
    name: null,
    type: '1',
    accountId: null,
    amount: 0,
    dealType: '2',
    createBy: null,
    createTime: null,
    updateBy: null,
    updateTime: null,
    delFlag: null,
    remark: null,
    currentBalance: null,
    dealCategory: '1',
    childCategory: null,
    locationName: null,
    locationAddress: null,
    longitude: null,
    latitude: null
  },
  queryAccountParams: {
    pageNum: 1,
   status: '1', 
    type: '1',
    debitType: null,
    pageSize: 1000
  },
  rules: {
    typeName: [{ required: true, message: '记账类型不能为空', trigger:['change', 'blur'] }],
    tempDebitTypeName: [{ required: false, message: '储蓄账户类型不能为空', trigger: ['change', 'blur'] }],
    accountName: [{ required: true, message: '记账账户不能为空', trigger: ['change', 'blur'] }],
    amount: [{type: 'number', required: true, message: '交易金额不能为空', trigger: ['change', 'blur'] }],
    dealTypeName: [{ required: true, message: '交易类型不能为空', trigger:['change', 'blur'] }],
    dealCategoryName: [{ required: true, message: '交易类别不能为空', trigger: ['change', 'blur'] }],
    childCategoryName: [{ required: false, message: '交易子类别不能为空', trigger: ['change', 'blur'] }],
    createTime: [{ required: true, message: '交易时间不能为空', trigger: ['change', 'blur'] }]
  }
})
const { form, queryAccountParams, rules} = toRefs(data)
const hasLocation = computed(() => {
  return !!(form.value.locationName || form.value.locationAddress || hasCoordinate.value)
})
const hasCoordinate = computed(() => {
  return form.value.longitude !== null && form.value.longitude !== undefined
    && form.value.latitude !== null && form.value.latitude !== undefined
})


onLoad((option) => {
       form.value.id = option.id
       flag.value = option.flag
       
       // 接收从沉睡账户列表传递的参数
       if (option.accountId) {
         form.value.accountId = option.accountId
       }
       if (option.accountType) {
         form.value.type = option.accountType
       }
       if (option.debitType) {
         tempDebitType.value = option.debitType
       }
       
     if(flag.value==null){
      if(form.value.id!=null){
      title.value="账户交易记录-修改"
     }else{
      title.value="账户交易记录-新增"
     }
     }else{
      title.value="账户交易记录-复制"
     }
     
  })
  onReady(() => {
    form.value.createTime = dayjs(new Date().getTime()).format("YYYY-MM-DD HH:mm:ss")
    // 新增时默认显示储蓄账户类型筛选（因为默认就是储蓄卡）
    // 但如果是从其他页面跳转过来且指定了非储蓄账户类型，则不显示
    if(form.value.id == null && flag.value == null && form.value.type === '1') {
      debitTypeShow.value = true
    }
    getData()
  })
  function  getData() {
   
        // 类型
        getDicts('account_type').then(res => {
        accountTypeList.value =[res.data] 
      })
       // 储蓄账户类型
       getDicts('debit_type').then(res => {
        debitTypeList.value =[res.data] 
      })
       // 类型
       getDicts('deal_type').then(res => {
        dealTypeList.value =[res.data] 
      })
       // 类型
       getDicts('deal_category').then(res => {
        dealCategoryList.value =[res.data] 
      })
       // 子类型
       getDicts('daily_expenses').then(res => {
        childCategoryList.value =[res.data] 
      })

      // 如果没有ID（新增模式）
      if(form.value.id == null) {
        // 如果有储蓄卡类型，先设置查询参数
        if (tempDebitType.value) {
          queryAccountParams.value.debitType = tempDebitType.value
          debitTypeShow.value = true
        }
        
        // 设置账户类型查询参数
        if (form.value.type) {
          queryAccountParams.value.type = form.value.type
        }
        
        listAccounts(queryAccountParams.value).then((response) => {
          accountNameList.value = [response.rows]
          
          // 如果有预设的accountId，自动填充账户名称
          if (form.value.accountId && response.rows.length > 0) {
            const selectedAccount = response.rows.find(item => item.id === form.value.accountId)
            if (selectedAccount) {
              form.value.accountName = selectedAccount.nameCodeAvailableLimit
            }
          }
        })
        
        // 如果有储蓄卡类型，回填储蓄卡类型名称
        if (tempDebitType.value) {
          getDicts('debit_type').then(result => {
            tempDebitTypeName.value = dictStr(tempDebitType.value, result.data)
          })
        }
        
        // 回填记账类型名称
        if (form.value.type) {
          getDicts('account_type').then(result => {
            form.value.typeName = dictStr(form.value.type, result.data)
          })
        }
                // 回填交易类型名称（默认值'2'）
        if (form.value.dealType) {
          getDicts('deal_type').then(result => {
            form.value.dealTypeName = dictStr(form.value.dealType, result.data)
          })
        }
        
        // 回填交易类别名称（默认值'1'）
        if (form.value.dealCategory) {
          getDicts('deal_category').then(result => {
            form.value.dealCategoryName = dictStr(form.value.dealCategory, result.data)
          })
        }
      } else {
        // 编辑或复制模式 - 先加载数据，再处理账户列表
        getAccountDealRecord(form.value.id).then(res => {
          form.value = res.data
          
          // 处理交易子类别显示
          if (form.value.dealCategory === '1') {
            childCategoryShow.value = true
            getDicts('daily_expenses').then(result => {
              form.value.childCategoryName = dictStr(form.value.childCategory, result.data)
            })
          } else {
            form.value.childCategoryName = form.value.dealCategory
            form.value.childCategory = form.value.dealCategory
            childCategoryShow.value = false
          }
          
          // 回填各字典标签
          getDicts('deal_category').then(result => {
            form.value.dealCategoryName = dictStr(form.value.dealCategory, result.data)
          })
          getDicts('account_type').then(result => {
            form.value.typeName = dictStr(form.value.type, result.data)
          })
          getDicts('deal_type').then(result => {
            form.value.dealTypeName = dictStr(form.value.dealType, result.data)
          })
          
          // 如果是复制模式，重置交易时间
          if(flag.value != null) {
            form.value.createTime = dayjs(new Date().getTime()).format("YYYY-MM-DD HH:mm:ss")
          }
          
          // 根据账户类型加载对应的账户列表
          if(form.value.type === '1') {
            // 储蓄账户 - 显示储蓄账户类型筛选
            debitTypeShow.value = true
            queryAccountParams.value.type = '1'
            
            // 从账户列表中查找当前账户的储蓄账户类型
            listAccounts({pageNum: 1, pageSize: 1000, type: '1', status: '1'}).then((response) => {
              const currentAccount = response.rows.find(item => item.id === form.value.accountId)
              if(currentAccount && currentAccount.debitType) {
                tempDebitType.value = currentAccount.debitType
                queryAccountParams.value.debitType = currentAccount.debitType
                getDicts('debit_type').then(result => {
                  tempDebitTypeName.value = dictStr(currentAccount.debitType, result.data)
                })
                // 只筛选匹配储蓄账户类型的账户
                accountNameList.value = [response.rows.filter(item => item.debitType === tempDebitType.value)]
              } else {
                // 如果没有找到储蓄账户类型，显示所有储蓄账户
                accountNameList.value = [response.rows]
              }
            })
          } else if(form.value.type === '2') {
            // 信用卡账户
            debitTypeShow.value = false
            tempDebitType.value = null
            tempDebitTypeName.value = null
            queryAccountParams.value.type = '2'
            queryAccountParams.value.debitType = null
            listAccounts({pageNum: 1, pageSize: 1000, type: '2', status: '1'}).then((response) => {
              accountNameList.value = [response.rows]
            })
          } else {
            // 其他类型账户
            debitTypeShow.value = false
            tempDebitType.value = null
            tempDebitTypeName.value = null
            queryAccountParams.value.type = form.value.type
            queryAccountParams.value.debitType = null
            listAccounts({pageNum: 1, pageSize: 1000, type: form.value.type, status: '1'}).then((response) => {
              accountNameList.value = [response.rows]
            })
          }
        })
      }
      
      console.log(form.value)
  }
  function dictStr(val, arr) {
      let str = ''
      arr.map(item => {
        if (item.dictValue === val) {
          str = item.dictLabel
        }
      })
      return str
    }

  function handleAccountType() {
        if (accountTypeList.value[0].length === 0) {
          proxy.$refs['uToast'].show({
            message: '记账类型为空  ', type: 'warning'
          })
        } else {
          showAccountType.value = true
        }
     }
  function   handleAccountTypeConfirm(e) {
        form.value.typeName = e.value[0].dictLabel
        form.value.type = e.value[0].dictValue
        queryAccountParams.value.type = form.value.type
        form.value.accountId = null
        form.value.accountName = null
        tempDebitType.value = null
        tempDebitTypeName.value = null
        queryAccountParams.value.debitType = null
        
        // 如果是储蓄账户(type='1')，显示储蓄账户类型选择
        // 编辑模式(id不为null且flag为null)时不需要显示，因为已经在getData中处理
        if (form.value.type === '1' && !(form.value.id != null && flag.value == null)) {
          debitTypeShow.value = true
        } else {
          debitTypeShow.value = false
          listAccounts(queryAccountParams.value).then((response) => {
            accountNameList.value = [response.rows] 
          })
        }
        showAccountType.value = false
        
  }
 function handleAccountTypeCancel() {
       showAccountType.value = false
      }
      
      function handleDebitType() {
        if (debitTypeList.value[0].length === 0) {
          proxy.$refs['uToast'].show({
            message: '储蓄账户类型为空', type: 'warning'
          })
        } else {
          showDebitType.value = true
        }
      }
      
      function handleDebitTypeConfirm(e) {
        tempDebitTypeName.value = e.value[0].dictLabel
        tempDebitType.value = e.value[0].dictValue
        queryAccountParams.value.debitType = tempDebitType.value
        form.value.accountId = null
        form.value.accountName = null
        listAccounts(queryAccountParams.value).then((response) => {
          accountNameList.value = [response.rows] 
        })
        showDebitType.value = false
      }
      
      function handleDebitTypeCancel() {
        showDebitType.value = false
      }
      
      function handleAccountName() {
        if (accountNameList.value[0].length === 0) {
          proxy.$refs['uToast'].show({
            message: '记账账户为空  ', type: 'warning'
          })
        } else {
          showAccountName.value = true
        }
     }
  function   handleAccountNameConfirm(e) {
        form.value.accountName = e.value[0].nameCodeAvailableLimit
        form.value.accountId = e.value[0].id
        showAccountName.value = false
  }
 function handleAccountNameCancel() {
       showAccountName.value = false
  }
  function handleDealCategory() {
        if (dealCategoryList.value[0].length === 0) {
          proxy.$refs['uToast'].show({
            message: '交易类别为空  ', type: 'warning'
          })
        } else {
          showDealCategory.value = true
        }
     }
  function   handleDealCategoryConfirm(e) {
        form.value.dealCategoryName = e.value[0].dictLabel
        form.value.dealCategory = e.value[0].dictValue
         //1表示日常支出，如果是日常支出，选择子类别，否则不显示子类别，且子类别与类别相同
  if (form.value.dealCategory === '1') {
    form.value.childCategory = null
    childCategoryShow.value = true
  } else {
    childCategoryShow.value = false
    form.value.childCategory = form.value.dealCategory
    form.value.childCategoryName = form.value.dealCategory
  }
        showDealCategory.value = false
  }
 function handleDealCategoryCancel() {
      showDealCategory.value = false
      }

      function handleChildCategory() {
        if (childCategoryList.value[0].length === 0) {
          proxy.$refs['uToast'].show({
            message: '交易子类别为空  ', type: 'warning'
          })
        } else {
          showChildCategory.value = true
        }
     }
  function   handleChildCategoryConfirm(e) {
        form.value.childCategoryName = e.value[0].dictLabel
        form.value.childCategory = e.value[0].dictValue
        showChildCategory.value = false
  }
 function handleChildCategoryCancel() {
  showChildCategory.value = false
      }

  function handleDealType() {
        if (dealTypeList.value[0].length === 0) {
          proxy.$refs['uToast'].show({
            message: '交易类型为空  ', type: 'warning'
          })
        } else {
          showDealType.value = true
        }
     }
  function   handleDealTypeConfirm(e) {
        form.value.dealTypeName = e.value[0].dictLabel
        form.value.dealType = e.value[0].dictValue
        showDealType.value = false
  }
 function handleDealTypeCancel() {
       showDealType.value = false
      }
  function  selectDate() {
				datePickShow.value = true
        proxy.$refs['createTimeRef'].innerValue = new Date().getTime()
		}
	function datePickConfirm(e) {
				form.value.createTime = dayjs(e.value).format("YYYY-MM-DD HH:mm:ss")
				datePickShow.value = false
		}
  function normalizeCoordinate(value) {
    const coordinate = Number(value)
    return Number.isFinite(coordinate) ? Number(coordinate.toFixed(8)) : null
  }

  function applyLocationResult(res) {
    form.value.locationName = res.name || null
    form.value.locationAddress = res.address || res.name || null
    form.value.longitude = normalizeCoordinate(res.longitude)
    form.value.latitude = normalizeCoordinate(res.latitude)
  }

  function clearLocation() {
    form.value.locationName = null
    form.value.locationAddress = null
    form.value.longitude = null
    form.value.latitude = null
  }

  function stopLocationLoading() {
    locationLoading.value = false
  }

  function loadCurrentCoordinate() {
    if (typeof uni.getLocation !== 'function') {
      stopLocationLoading()
      proxy.$refs['uToast'].show({
        message: '当前端暂不支持定位', type: 'warning'
      })
      return
    }

    // 超时保护：10秒后强制结束 loading
    const timer = setTimeout(() => {
      stopLocationLoading()
      proxy.$refs['uToast'].show({
        message: '定位超时，请检查定位权限或网络后重试', type: 'warning'
      })
    }, 10000)

    uni.getLocation({
      type: 'gcj02',
      isHighAccuracy: true,
      success(res) {
        clearTimeout(timer)
        applyLocationResult(res)
        proxy.$refs['uToast'].show({
          message: '已获取当前位置坐标，可补充地点名称', type: 'success'
        })
      },
      fail(err) {
        clearTimeout(timer)
        const msg = (err && err.errMsg) ? err.errMsg : ''
        if (msg.indexOf('auth') !== -1 || msg.indexOf('deny') !== -1 || msg.indexOf('permission') !== -1) {
          proxy.$refs['uToast'].show({
            message: '定位权限被拒绝，请到系统设置中开启定位权限', type: 'warning'
          })
        } else {
          proxy.$refs['uToast'].show({
            message: '定位失败，请检查GPS或网络后重试', type: 'warning'
          })
        }
      },
      complete() {
        clearTimeout(timer)
        stopLocationLoading()
      }
    })
  }

  function loadCurrentLocation() {
    if (locationLoading.value) {
      return
    }
    locationLoading.value = true

    // 总体超时保护：15秒后强制重置 loading 状态，防止按钮永久卡住
    const safeTimer = setTimeout(() => {
      if (locationLoading.value) {
        stopLocationLoading()
        proxy.$refs['uToast'].show({
          message: '定位服务响应超时，已自动重置，请重试', type: 'warning'
        })
      }
    }, 15000)

    if (typeof uni.chooseLocation !== 'function') {
      clearTimeout(safeTimer)
      loadCurrentCoordinate()
      return
    }

    uni.chooseLocation({
      success(res) {
        clearTimeout(safeTimer)
        applyLocationResult(res)
        proxy.$refs['uToast'].show({
          message: '定位成功', type: 'success'
        })
        stopLocationLoading()
      },
      fail(err) {
        clearTimeout(safeTimer)
        const errMsg = (err && err.errMsg) ? err.errMsg : ''
        // 用户取消选择，直接重置 loading，不降级
        if (errMsg.indexOf('cancel') !== -1) {
          stopLocationLoading()
          return
        }
        // 其他失败降级到坐标定位
        loadCurrentCoordinate()
      }
    })
  }

  function submit() {
     if (!form.value.dealCategory === '1') {
          form.value.childCategory = form.value.dealCategory
          form.value.childCategoryName = form.value.dealCategory
        }
        proxy.$refs['uForm'].validate().then(() => {
          if (form.value.id != null) {
            if(flag.value==null){
            updateAccountDealRecord(form.value).then(res => {
            proxy.$refs['uToast'].show({
            message: '修改成功', complete() {
              uni.navigateBack()
            }
          })
        })
          }else {
            form.value.id == null
            addAccountDealRecord(form.value).then(res => {
            proxy.$refs['uToast'].show({
            message: '新增成功', complete() {
              uni.navigateBack()
            }
          })
        })
          }
          }else {
            addAccountDealRecord(form.value).then(res => {
              proxy.$refs['uToast'].show({
              message: '新增成功', complete() {
                uni.navigateBack()
              }
            })
          })
          }
        })
      }
  </script>
  
  <style lang="scss" scoped>
.section {
  margin: 24rpx;
  padding: 0;
  background-color: #fff;
  border-radius: 16rpx;
  box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
  overflow: hidden;

  .section-title {
    padding: 16rpx 24rpx;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    line-height: 1.2;
    font-size: 28rpx;
    font-weight: 600;
    display: flex;
    align-items: center;
    
    &::before {
      content: '';
      width: 6rpx;
      height: 28rpx;
      background: #ffffff;
      border-radius: 3rpx;
      margin-right: 12rpx;
    }
  }

  .form-view {
    padding: 24rpx;

    // 带箭头的输入框容器
    .input-with-arrow {
      position: relative;
      width: 100%;

      .arrow-icon {
        position: absolute;
        right: 20rpx;
        top: 50%;
        transform: translateY(-50%);
        color: #c0c4cc;
        font-size: 20rpx;
        pointer-events: none;
        z-index: 10;
      }
    }

    .location-field {
      width: 100%;
      display: flex;
      align-items: flex-start;
      gap: 16rpx;
      padding: 8rpx 0 18rpx;

      .location-main {
        flex: 1;
        min-width: 0;
      }

      .location-name,
      .location-coord {
        display: block;
        margin-top: 8rpx;
        color: #909399;
        font-size: 24rpx;
        line-height: 1.4;
        word-break: break-all;
      }

      .location-actions {
        display: flex;
        flex-shrink: 0;
        gap: 12rpx;
        padding-top: 4rpx;
      }
    }

    .form-btn {
      padding-top: 16rpx;
    }
  }
}
  </style>
  
  <style lang="scss">
  .form-btn .u-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border: none !important;
    border-radius: 24rpx !important;
    height: 80rpx !important;
    box-shadow: 0 4rpx 16rpx rgba(102, 126, 234, 0.4) !important;
  }
  
  .form-btn .u-button__text {
    font-size: 30rpx !important;
    font-weight: 500 !important;
    letter-spacing: 2rpx !important;
  }
  </style>
