users.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <page-meta :page-font-size="fontValue+'px'" :root-font-size="fontValue+'px'"></page-meta>
  3. <cu-custom bgImage="/static/bg.png" :isBack="true">
  4. <template v-slot:content>
  5. <text class="text-black">通讯录</text>
  6. </template>
  7. </cu-custom>
  8. <view class="cu-bar margin-left">
  9. <uni-easyinput placeholder="请输入姓名或者手机号搜索" type="search" v-model="keyword" :clearable="true" />
  10. <view class="action">
  11. <button class="cu-btn block bg-gray" style="height: 2.2rem" @tap="handleSearch">
  12. <text class="cuIcon-search"></text>
  13. </button>
  14. </view>
  15. </view>
  16. <view class="cu-list menu">
  17. <view class="cu-item no-padding" v-for="(user) in users" :key="user.id" @tap="handleUser(user.id)">
  18. <vim-avatar :img="user.avatar" :name="user.name" />
  19. <view class="content padding-left">
  20. <view class="text-grey">{{ user.name }}</view>
  21. </view>
  22. <view class="action">
  23. <text class="cuIcon cuIcon-more"></text>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script setup lang="ts">
  29. import VimAvatar from "@/components/VimAvatar.vue";
  30. import UserApi from "@/api/UserApi";
  31. import {ref} from "vue";
  32. import type User from "@/mode/User";
  33. import {onLoad} from "@dcloudio/uni-app";
  34. import CuCustom from "@/colorui/components/cu-custom.vue";
  35. import UniEasyinput from "@/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue";
  36. import MessageUtils from "@/utils/MessageUtils";
  37. import Auth from "@/api/Auth";
  38. const fontValue=ref(Auth.getfontSize());
  39. const users = ref<Array<User>>([])
  40. const keyword = ref<string>('')
  41. const handleSearch = () => {
  42. if(keyword.value.trim() !== ''){
  43. UserApi.search(keyword.value.trim()).then((res) => {
  44. users.value = res.data;
  45. });
  46. }else {
  47. MessageUtils.message('请输入用户名或手机号')
  48. }
  49. }
  50. const handleUser = (id:string) => {
  51. uni.navigateTo({
  52. url: '/pages/pub/user?id=' + id
  53. })
  54. }
  55. onLoad((opt)=>{
  56. keyword.value = opt?.keyword
  57. handleSearch()
  58. })
  59. </script>
  60. <style scoped>
  61. </style>