GroupUser.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <view v-if="show" class="page" style="position: fixed;z-index: 1000;top:0px;height: 100vh;width: 100vw;padding-top: 100upx;overflow-y: scroll;">
  3. <view class="header">
  4. <view class="showtitle" v-if="!showsearch">
  5. <view class="title">
  6. <uni-icons type='arrowleft' @tap="close()" color="#ffffff"></uni-icons>
  7. 选择要提醒的人
  8. </view>
  9. <view class="search-icon" @tap="showsearch=1">
  10. <uni-icons type="search" color="#ffffff" size="28" style="vertical-align: middle;"/>
  11. </view>
  12. </view>
  13. <view class="inputbar" v-else>
  14. <input placeholder="搜索" class="searchbox" v-model="name" @input="search( $event.detail.value);" />
  15. <view class="btn" @tap="showsearch=0;members=members1">取消</view>
  16. </view>
  17. </view>
  18. <v-contracts :items="members" @click="paramClick" @avatar="paramClick" v-if="members.length" />
  19. </view>
  20. </template>
  21. <script>
  22. import {
  23. mapState
  24. } from 'vuex';
  25. import api from '../library/index.js'
  26. import uniIcons from './uni-icons/uni-icons.vue'
  27. export default {
  28. components: {
  29. uniIcons
  30. },
  31. props: {
  32. groupid: {
  33. type: [Number,String],
  34. default: 0
  35. },
  36. show: {
  37. type: Number,
  38. default: 0
  39. },
  40. },
  41. data() {
  42. return {
  43. initializing: true,
  44. members:[],
  45. members1:[],
  46. showsearch:0
  47. }
  48. },
  49. computed: {
  50. },
  51. methods: {
  52. getGroupUsers() {
  53. api.getGroupUsers({
  54. group_id: this.groupid,
  55. userid: this.$store.state.userinfo.id,
  56. }).then(res => {
  57. uni.setStorageSync(this.groupid+'_group_members',res.data);
  58. this.members1=this.members=res.data
  59. this.initializing = false
  60. })
  61. },
  62. paramClick(e) {
  63. let page, params;
  64. const {
  65. id,
  66. nickname,
  67. avatar
  68. } = e;
  69. params = {
  70. id,
  71. nickname,
  72. avatar
  73. };
  74. this.$emit('atuser',params);
  75. },
  76. search(value){
  77. if(value.length>0){
  78. var arr=[];
  79. this.members1.forEach(item=>{
  80. if(item.nickname.indexOf(value)>-1) arr.push(item);
  81. })
  82. this.members=arr;
  83. }else{
  84. this.members=this.members1
  85. }
  86. },
  87. close(){
  88. this.$emit('atuser');
  89. },
  90. },
  91. mounted() {
  92. this.members1= this.members= uni.getStorageSync(this.groupid+'_group_members');
  93. this.getGroupUsers();
  94. uni.hideKeyboard();
  95. },
  96. onShow() {
  97. uni.hideKeyboard();
  98. }
  99. }
  100. function complement(a, b) {
  101. return a.filter(function(v) {
  102. return !(b.indexOf(v) > -1)
  103. })
  104. .concat(b.filter(function(v) {
  105. return !(a.indexOf(v) > -1)
  106. }))
  107. }
  108. </script>
  109. <style lang="scss">
  110. .inputbar {
  111. display: flex;
  112. align-items: center;
  113. height: 45px;
  114. background: -webkit-linear-gradient(left top, #01d9ff , #01a9fe);
  115. background: -o-linear-gradient(bottom right, #01d9ff, #01a9fe);
  116. box-sizing: border-box;
  117. padding: $uni-spacing-col-base $uni-spacing-row-base;
  118. input {
  119. background-color: #eee;
  120. border-radius: $uni-border-radius-base;
  121. height: 100%;
  122. padding: 0 $uni-spacing-row-base;
  123. flex: 1;
  124. &.disabled {
  125. background: -webkit-linear-gradient(left top, #01d9ff , #01a9fe);
  126. background: -o-linear-gradient(bottom right, #01d9ff, #01a9fe);
  127. background: -moz-linear-gradient(bottom right, #01d9ff, #01a9fe);
  128. background: linear-gradient(to right, #01d9ff , #01a9fe);
  129. border: 1upx solid #eee;
  130. }
  131. }
  132. .searchbox{
  133. background-color: #fff;
  134. color: #333;
  135. }
  136. .btn {
  137. padding-top: 0;
  138. padding-bottom: 0;
  139. height: 100%;
  140. display: flex;
  141. flex-direction: column;
  142. align-items: center;
  143. justify-content: center;
  144. margin-left: $uni-spacing-row-base;
  145. background: -webkit-linear-gradient(left top, #3388ff , #2319dc);
  146. background: -o-linear-gradient(bottom right, #3388ff, #2319dc);
  147. background: -moz-linear-gradient(bottom right, #3388ff, #2319dc);
  148. background: linear-gradient(to bottom right, #3388ff , #2319dc);
  149. color: #FFF;
  150. &:not(.btn-primary) {
  151. background-color: #eee;
  152. }
  153. }
  154. }
  155. .header{
  156. position: fixed;
  157. top:0px;
  158. width: 100vw;
  159. line-height: 45px;
  160. height: 45px;
  161. border-bottom: 1px #eee solid;
  162. color: #fff;z-index: 10000;
  163. background: -webkit-linear-gradient(left top, #01d9ff , #01a9fe);
  164. background: -o-linear-gradient(bottom right, #01d9ff, #01a9fe);
  165. background: -moz-linear-gradient(bottom right, #01d9ff, #01a9fe);
  166. background: linear-gradient(to right, #01d9ff , #01a9fe);
  167. }
  168. .header .title{
  169. font-size: 32upx;
  170. padding-left: 20upx;
  171. font-weight: 600;
  172. display: inline-block;
  173. }
  174. .header .search-icon{
  175. display: inline-block;
  176. float: right;
  177. justify-content: right;
  178. padding-right: 26upx;
  179. width: 80upx;
  180. text-align: right;
  181. }
  182. .header .search-icon image{
  183. height:40upx;width: 40upx;
  184. vertical-align: middle;
  185. }
  186. </style>