add.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <view class="page">
  3. <uni-status-bar></uni-status-bar>
  4. <view class="header">
  5. <view class="input-view">
  6. <image style="width: 16px;height: 16px;" src="/static/img/search.png" mode="widthFix"></image>
  7. <input class="input" type="text" placeholder="搜索" @input="handleInput" :focus="true" />
  8. </view>
  9. <view class="" @click="toBack">
  10. <text>取消</text>
  11. </view>
  12. </view>
  13. <view class="search-main" v-if="keyword">
  14. <view class="search-main-errtitle" v-if="hasNoData">无搜索结果</view>
  15. <view class="uni-list">
  16. <view class="uni-list-cell" hover-class="none" v-for="(item,index) of list" @tap="handleClick(item.id)"
  17. :key="index">
  18. <view class="uni-media-list">
  19. <view class="uni-media-list-logo">
  20. <image :src="staticPhoto + item.photo" :lazy-load="true"></image>
  21. </view>
  22. <view class="uni-media-list-body">
  23. <view class="uni-list-cell-navigate">{{item.nickname}}</view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import uniIcon from '../../components/uni-ui/uni-icon/uni-icon.vue';
  33. import _get from '../../common/_get';
  34. import _hook from '../../common/_hook';
  35. import _data from '../../common/_data';
  36. import uniStatusBar from '@/components/uni-ui/uni-status-bar/uni-status-bar.vue'
  37. export default {
  38. components: {
  39. uniIcon,
  40. uniStatusBar
  41. },
  42. data() {
  43. return {
  44. is_type: 0,
  45. keyword: '',
  46. list: [],
  47. timer: null
  48. }
  49. },
  50. onShow() {
  51. _hook.routeSonHook();
  52. },
  53. computed: {
  54. hasNoData() {
  55. return !this.list.length;
  56. },
  57. staticPhoto() {
  58. return _data.staticPhoto();
  59. },
  60. },
  61. watch: {
  62. keyword(new_val, old_val) {
  63. let _this = this;
  64. if (_this.timer) {
  65. clearTimeout(_this.timer);
  66. }
  67. if (!new_val) {
  68. _this.list = [];
  69. return
  70. }
  71. _this.timer = setTimeout(() => {
  72. _this.$httpSend({
  73. path: '/im/get/searchUser',
  74. data: {
  75. val: new_val
  76. },
  77. success(data) {
  78. _this.list = data.data;
  79. _this.is_type = data.is_type;
  80. }
  81. });
  82. }, 100);
  83. }
  84. },
  85. methods: {
  86. toBack() {
  87. uni.navigateBack({
  88. })
  89. },
  90. handleInput(e) {
  91. this.keyword = e.detail.value
  92. },
  93. handleClick(id) {
  94. uni.navigateTo({
  95. url: ('../details/index?user_id=' + id + '&is_type=' + this.is_type),
  96. });
  97. }
  98. }
  99. }
  100. </script>
  101. <style>
  102. page {
  103. background: #fff;
  104. }
  105. .search-main {
  106. height: 100%;
  107. padding-bottom: 20upx;
  108. background-color: #fff;
  109. overflow: hidden;
  110. }
  111. .search-main-errtitle {
  112. width: 100%;
  113. height: 92upx;
  114. line-height: 92upx;
  115. font-size: 32upx;
  116. padding: 0 20upx;
  117. border-bottom: 1px solid #e5e5e5;
  118. }
  119. .header {
  120. display: flex;
  121. flex-direction: row;
  122. padding: 10px 15px;
  123. align-items: center;
  124. }
  125. .input-view {
  126. display: flex;
  127. align-items: center;
  128. flex-direction: row;
  129. background-color: #f7f7f7;
  130. height: 36px;
  131. border-radius: 18px;
  132. padding: 0 10px;
  133. flex: 1;
  134. margin-right: 10rpx;
  135. }
  136. .input {
  137. flex: 1;
  138. padding: 0 5px;
  139. height: 24px;
  140. line-height: 24px;
  141. font-size: 14px;
  142. }
  143. </style>