<template>
  <view class="common-details-container" v-if="refuelInfo?.title">
    <view class="common-header-wrapper">
      <image :src="pathPre + content.image" mode="aspectFill" />
    </view>
    <view class="common-content-wrapper">
      <view class="common-card">
        <view class="common-card-title">{{ refuelInfo.title }}</view>
        <view class="common-sub-title">营业时间:{{ refuelInfo?.businessAt }}</view>
        <view class="common-sub-title">客服电话:{{ refuelInfo?.mobile }}</view>
      </view>
      <view class="common-card">
        <view class="common-card-title u-margin-bottom-20">当前油价</view>
        <HyStation type="2" v-for="(item, index) in list" :key="index" :item="item"></HyStation>
        <view class="common-card-title u-margin-top-45">温馨提示</view>
        <view class="common-card-content">
          <u-parse :html="content?.intro" />
        </view>
      </view>
    </view>
  </view>
  <view class="no-data-container" v-else>
    <u-empty />
  </view>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getParkServiceOil } from '@/api/home'
import { useGlobal } from '@/composables/index'

const { pathPre } = useGlobal()

// 我要加油
const refuelInfo = ref<any>({})
const content = ref<any>({})
const list = ref<any>([])
onLoad(async () => {
  const parkId = uni.getStorageSync('parkId')
  if (parkId) {
    const res = await getParkServiceOil(parkId)
    if (res.code === 200) {
      refuelInfo.value = res.data
      if (res.data) {
        content.value = JSON.parse(refuelInfo.value.content)
        const {
          oil92ActivityPrice,
          oil92OriginalPrice,
          oil95ActivityPrice,
          oil95OriginalPrice,
          oil89ActivityPrice,
          oil89OriginalPrice,
          dieselActivityPrice,
          dieselOriginalPrice
        } = content.value
        const _list = [
          { name: '92#', activityPrice: oil92ActivityPrice, originalPrice: oil92OriginalPrice },
          { name: '95#', activityPrice: oil95ActivityPrice, originalPrice: oil95OriginalPrice },
          { name: '89#', activityPrice: oil89ActivityPrice, originalPrice: oil89OriginalPrice },
          { name: '柴油#', activityPrice: dieselActivityPrice, originalPrice: dieselOriginalPrice }
        ]
        list.value = _list
      }
    }
  }
})
</script>

<style lang="scss" scoepd>
@import '../base.scss';
</style>
