<template>
  <view>
    <view class="camera_container">
      <camera flash="off" :device-position="useModel?.devicePosition?.value" style="width: 100%; height: 100%">
        <view class="watermark_preview">
          <view class="watermark_date">
            <view class="watermark_item"> {{ useModel?.time?.value }} </view>
            <view class="watermark_item_separator"> </view>
            <view class="watermark_item_info">
              <view class="watermark_day"> {{ useModel?.userInfo?.value?.name || '' }} </view>
              <view class="watermark_week">
                {{ useModel?.day?.value }} {{ useModel?.weekDay?.value }}
              </view>
            </view>
          </view>
          <view class="watermark_address">{{ useModel?.address?.value?.address ||
            useModel?.address?.value?.formatted_address || '' }}</view>
        </view>
      </camera>
    </view>
    <canvas canvas-id="watermark_camera" id="watermark_camera" style="width: 430px; height: 82vh"></canvas>
    <view class="footer_btn_group">
      <view @click="method?.takePhoto" class="take_photo_btn"></view>
      <view class="watermark_camera_witch_btn" @click="method?.handleWatermarkCameraSwitch">
        <view class="watermark_camera_witch_btn_content">
          <view class="watermark_camera_witch_btn_img">
            <image src="/static/svg/WatermarkCameraSwitch.svg" mode="aspectFit" />
          </view>
          <view class="watermark_camera_witch_text"> 切换 </view>
        </view>
      </view>
    </view>
  </view>
</template>
<script setup lang="ts">
import { getShowApiAddress } from '@/common/libraries/map'
import { onLoad } from '@dcloudio/uni-app'
import method from './method'
import useModel from './model'
onLoad(e => {
  let address = getShowApiAddress()
  useModel.source.value = e?.source || 'save'
  address.then((res: { address?: string, formatted_address?: string }) => {
    useModel.address.value = res
    console.log(res, '地址')
  })
})
</script>
<style lang="scss">
@import './style.scss';
</style>
