<template>
  <div class="outer-layer search-page">
    <div class="root">
      <searchList
        :searchResultPageSize="10"
        :listLimit="false"
        :apiRequest="ServeTalkRecord"
        :apiParams="state.apiParams"
        :searchText="state.searchText"
        :isPagination="true"
        :searchRecordDetail="true"
      ></searchList>
    </div>
  </div>
</template>
<script setup>
import searchList from '../components/searchList.vue'
import { onLoad } from '@dcloudio/uni-app'
import { ServeTalkRecord } from '@/api/search/index'
import { reactive } from 'vue'

const state = reactive({
  apiParams: String,
  searchText: String,
})

onLoad((options) => {
  console.log(options)
  let talk_type = 0
  if (options.talk_type) {
    talk_type = Number(options.talk_type)
  }
  let receiver_id = 0
  if (options.receiver_id) {
    receiver_id = Number(options.receiver_id)
  }
  state.apiParams = encodeURIComponent(
    JSON.stringify({
      talk_type: talk_type, //1私聊2群聊
      receiver_id: receiver_id, //查详情的时候需传入
      last_group_id: 0, //最后一条群id
      last_member_id: 0, //最后一条用户id
    }),
  )
  if (options.searchText) {
    state.searchText = options.searchText
  }

  console.log(JSON.parse(decodeURIComponent(state.apiParams)))
})
</script>
<style scoped lang="scss"></style>
