userInfoList.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view class="container">
  3. <view class="uni-padding-wrap uni-common-mt">
  4. <uni-segmented-control :current="current" :values="items" :style-type="styleType" :active-color="activeColor" @clickItem="onClickItem" />
  5. </view>
  6. <!-- 居民信息 -->
  7. <view v-if="current == 0">
  8. <uni-card class="addUser">
  9. <uni-list :border="false">
  10. <uni-list-item :showExtraIcon="true" :extra-icon="extraIcon" title="添加居民信息" clickable @click="onClick"></uni-list-item>
  11. </uni-list>
  12. </uni-card>
  13. <uni-list :border="true">
  14. <view :id="item && item.residentId" class="delBox" @touchstart="touchStart" @touchend="touchEnd" v-for="(item, index) in list" :key="index" >
  15. <uni-list-chat :class="{ left: isId == item.residentId }" class="item" :avatar="item.avatar || '/static/user1.png'" :title="item.name" :note="item.phone" badge-positon="left">
  16. </uni-list-chat>
  17. <uni-icons @click="userbtn(item)" color="#fff" class="del compose" type="compose" size="28"></uni-icons>
  18. <uni-icons :class="{ left: isId !== item.residentId }" @click="delbtn(item)" color="#fff" class="del" type="trash-filled" size="28"></uni-icons>
  19. </view>
  20. </uni-list>
  21. </view>
  22. <!-- 居民审核信息 -->
  23. <view v-if="current == 1">
  24. <uni-list :border="true">
  25. <view :id="item && item.residentId" class="delBox" @touchstart="touchStart" @touchend="touchEnd" v-for="(item, index) in list" :key="index" >
  26. <uni-list-chat :class="{ left: isId == item.residentId }" class="item" :avatar="item.avatar || '/static/user1.png'" :title="item.name" :note="item.phone" badge-positon="left">
  27. <text class="chat-custom-text">{{ item && item.status }}</text>
  28. </uni-list-chat>
  29. <uni-icons @click="userbtn(item)" color="#fff" class="del compose" type="compose" size="28"></uni-icons>
  30. <uni-icons :class="{ left: isId !== item.residentId }" @click="delbtn(item)" color="#fff" class="del" type="trash-filled" size="28"></uni-icons>
  31. </view>
  32. </uni-list>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import request from '../../api/resident.js';
  38. export default {
  39. data() {
  40. return {
  41. isId: '',
  42. startX: 0,
  43. extraIcon: {
  44. color: '#ff8319',
  45. size: '20',
  46. type: 'plusempty'
  47. },
  48. list: [],
  49. natTaskId: '',
  50. membersStatus: [],
  51. // 选项卡参数
  52. items: ['居民信息', '居民审核信息'],
  53. activeColor: '#dd524d',
  54. styleType: 'text',
  55. current: 0
  56. }
  57. },
  58. async mounted() {
  59. this.onClickItem(0);
  60. },
  61. onShow() {
  62. this.isId = '';
  63. },
  64. methods: {
  65. // 标签页点击
  66. async onClickItem(e) {
  67. if (this.current !== e.currentIndex) {
  68. this.current = e.currentIndex
  69. }
  70. let res;
  71. if (e.currentIndex == 1) {
  72. res = request.getApplyUser();
  73. } else {
  74. res = request.getUser();
  75. }
  76. this.list = res.data;
  77. },
  78. // 滑动开始
  79. touchStart(e) {
  80. if (e.touches.length == 1) {
  81. //设置触摸起始点水平方向位置
  82. this.startX=e.touches[0].clientX;
  83. }
  84. },
  85. // 滑动结束
  86. touchEnd(e) {
  87. if (e.changedTouches.length == 1) {
  88. //手指移动结束后水平位置
  89. var endX = e.changedTouches[0].clientX;
  90. let diff = endX - this.startX;
  91. if(Math.abs(diff) > 20){
  92. if(diff < 0) {
  93. this.isId = e.currentTarget.id;
  94. }else{
  95. this.isId = '';
  96. }
  97. }
  98. }
  99. },
  100. // 删除
  101. async delbtn(e) {
  102. const res = await request.delUser({ ...e, reqType: '2' });
  103. if (res.code == 200) {
  104. this.isId = '';
  105. uni.showToast({
  106. title: '删除成功',
  107. duration: 2000,
  108. });
  109. }
  110. },
  111. // 添加
  112. onClick() {
  113. uni.navigateTo({
  114. url: '/pages/resident/userAddr'
  115. })
  116. },
  117. // 修改
  118. userbtn(e) {
  119. console.log(e);
  120. uni.navigateTo({
  121. url: `/pages/resident/userAddr?residentId=${e.residentId}`
  122. })
  123. }
  124. }
  125. }
  126. </script>
  127. <style>
  128. .container {
  129. width: 100%;
  130. }
  131. .addUser {
  132. display: block;
  133. /* width: 90%; */
  134. margin: 5px auto;
  135. }
  136. .chat-custom-text {
  137. font-size: 12px;
  138. color: #999;
  139. width: 100%;
  140. text-align: center;
  141. display: block;
  142. }
  143. .addUser .uni-list-item__container {
  144. flex: none;
  145. margin: 0 auto;
  146. }
  147. .addUser .uni-list-item__content-title {
  148. color: #ff8319;
  149. }
  150. .delBox {
  151. display: flex;
  152. width: 100%;
  153. overflow: hidden;
  154. }
  155. .item {
  156. width: 100%;
  157. }
  158. .del {
  159. display: block;
  160. width: 50px;
  161. background: red;
  162. }
  163. .right {
  164. margin-right: -100px;
  165. }
  166. .uni-icons {
  167. display: block;
  168. width: 100%;
  169. text-align: center;
  170. line-height: 2.3em;
  171. }
  172. .left {
  173. margin-left: -100px;
  174. }
  175. .compose {
  176. background: #1aad19;
  177. }
  178. </style>