<template>
  <view class="search" :style="{ background: background }">
    <wd-icon name="thin-arrow-left" class="icon" @tap="back" :style="{ color: backIcon }"></wd-icon>
    <slot></slot>
    <view class="searchBox">
      <image
        class="magnifyingGlass"
        src="../../static/index/magnifyingGlass.png"
        mode="aspectFit|aspectFill|widthFix"
      />
      <input type="text" :value="test" class="text" @confirm="search" confirm-type="搜索" />
    </view>
  </view>
</template>

<script setup>
import { useCountStore } from '@/store';
import { onMounted, defineProps } from 'vue';
const props = defineProps({
  background: {
    type: String,
    default: '',
  },
  backIcon: {
    type: String,
    default: 'white',
  },
});
const emit = defineEmits(['toSearch']);
const title = ref('小程序平台');
const { countInfo, addCount } = useCountStore();
const test = ref('');
onMounted(() => {
  // xma.xh.getUserProfile({
  //   range: ['ACCOUNT', 'MOBILE', 'CITIZEN'],
  //   async success(info) {
  //     const info2 = JSON.stringify(info);
  //     test.value = info2;
  //   },
  // });
});

const search = (res) => {
  const keyword = res.detail.value;
  emit('toSearch', keyword);
};
const test2 = () => {
  xma.navigateTo({
    url: '/pages/shop/shop',
  });
};

// 返回上一级
const back = () => {
  xma.navigateBack({
    delta: 1,
  });
};
function toUIComponentsDoc() {
  window.open('https://wot-design-uni.netlify.app/component/button.html');
}

function onHandleClick() {
  addCount();
}
</script>

<style lang="scss">
.search {
  width: 710rpx;
  height: 80rpx;
  // background: rgba(255, 255, 255, 0.8);
  border-radius: 16rpx 16rpx 16rpx 16rpx;
  opacity: 0.8;
  margin: 0 auto;
  margin-top: 44rpx;
  display: flex;
  align-items: center;
  padding-left: 20rpx;
  box-sizing: border-box;
  .arrow {
    width: 15rpx;
    height: 24rpx;
  }
  .icon {
    font-size: 28rpx;
  }
  .searchBox {
    opacity: 1;
    width: 256rpx;
    height: 56rpx;
    background: #ffffff;
    border-radius: 28rpx 28rpx 28rpx 28rpx;
    display: flex;
    align-items: center;
    padding-left: 20rpx;
    margin-left: 20rpx;
    .magnifyingGlass {
      width: 26rpx;
      height: 26rpx;
    }
    .text {
      margin-left: 10rpx;
      font-size: 24rpx;
    }
  }
}
</style>
