<template>
  <view class="container">


    <view class="selector">
      <picker @change="onPickerChange" :value="pickerIndex" :range="paperTypes">
        <view class="picker">
          {{ paperTypes[pickerIndex] }}
          <text class="arrow">▼</text>
        </view>
      </picker>
    </view>

    <scroll-view scroll-y class="table-container">
      <image class="table-image" :src="currentImage" mode="widthFix"></image>
    </scroll-view>

    <view class="contact-btn" @click="goToContactPage">一键联系</view>
  </view>
</template>

<script setup>
import { ref, computed } from 'vue'

const paperTypes = ['瓦楞纸', '卫生纸']
const pickerIndex = ref(0)

const images = {
  '瓦楞纸': 'https://leaseraycos.oss-cn-shanghai.aliyuncs.com/document/20240912211537_06a2792b4e49f11b8ee1e1e372f9f0e1_1182344_3168_5468.jpg',
  '卫生纸': 'https://leaseraycos.oss-cn-shanghai.aliyuncs.com/document/20240913094914_18e718fc39e02503f31aa4b8f3cdb4f.jpg'
}

const goToContactPage = () =>{
	 uni.navigateTo({
	     url: '/pages/oil-recommendation/contact'
	  })
}

const currentImage = computed(() => {
  return images[paperTypes[pickerIndex.value]]
})

const onPickerChange = (e) => {
  pickerIndex.value = e.detail.value
}
</script>

<style>
.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: #f0f0f0;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #1296db;
  color: white;
  padding: 10px 20px;
}

.back-icon, .right-icons {
  font-size: 20px;
}

.circle {
  margin-left: 10px;
}

.selector {
  background-color: #fff;
  padding: 10px 20px;
  margin: 10px;
  border-radius: 5px;
}

.picker {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.arrow {
  color: #999;
}

.table-container {
  flex: 1;
  margin: 0 5px;
}

.table-image {
  width: 100%;
  height: auto;
  padding-bottom: 100px;
}

.contact-btn {
  background-color: #1296db;
  color: white;
  text-align: center;
  padding: 10px;
  margin: 10px;
  border-radius: 20px;
  width: 50%;
  margin: 10px auto;
  position: fixed;
  left: 25%;
  bottom: 3%;
  
}
</style>