receive.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view class="container">
  3. <uni-card class="addUser">
  4. <uni-list :border="false">
  5. <uni-list-item :showExtraIcon="true" :extra-icon="extraIcon" title="添加成员" clickable @click="onClick"></uni-list-item>
  6. </uni-list>
  7. </uni-card>
  8. <uni-list :border="true">
  9. <view :id="item && item.residentId" class="delBox" @touchstart="touchStart" @touchend="touchEnd" v-for="(item, index) in list" :key="index" >
  10. <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">
  11. </uni-list-chat>
  12. <uni-icons @click="userbtn(item)" color="#fff" class="del compose" type="compose" size="28"></uni-icons>
  13. <uni-icons :class="{ left: isId !== item.residentId }" @click="delbtn(item)" color="#fff" class="del" type="trash-filled" size="28"></uni-icons>
  14. </view>
  15. </uni-list>
  16. </view>
  17. </template>
  18. <script>
  19. import requestFamily from '../../api/family.js';
  20. export default {
  21. data() {
  22. return {
  23. isId: '',
  24. startX: 0,
  25. extraIcon: {
  26. color: '#ff8319',
  27. size: '20',
  28. type: 'plusempty'
  29. },
  30. list: [],
  31. natTaskId: '',
  32. membersStatus: []
  33. }
  34. },
  35. async mounted() {
  36. this.query();
  37. },
  38. onShow() {
  39. this.isId = '';
  40. },
  41. methods: {
  42. async query() {
  43. const { userId } = uni.getStorageSync('userinfo');
  44. const familyInfo = await requestFamily.getFamilyInfo({ userId });
  45. if (familyInfo.code == 200) {
  46. this.list = familyInfo.rows;
  47. }
  48. },
  49. // 滑动开始
  50. touchStart(e) {
  51. if (e.touches.length == 1) {
  52. //设置触摸起始点水平方向位置
  53. this.startX=e.touches[0].clientX;
  54. }
  55. },
  56. // 滑动结束
  57. touchEnd(e) {
  58. if (e.changedTouches.length == 1) {
  59. //手指移动结束后水平位置
  60. var endX = e.changedTouches[0].clientX;
  61. let diff = endX - this.startX;
  62. if(Math.abs(diff) > 20){
  63. if(diff < 0) {
  64. this.isId = e.currentTarget.id;
  65. }else{
  66. this.isId = '';
  67. }
  68. }
  69. }
  70. },
  71. // 报备
  72. async filing(e) {
  73. const res = await requestFamily.filing({ residentId: e.residentId, natTaskId: this.natTaskId });
  74. if (res.code == 200) {
  75. this.query();
  76. uni.showToast({
  77. title: '报备成功',
  78. duration: 2000,
  79. });
  80. }
  81. },
  82. // 删除
  83. async delbtn(e) {
  84. const res = await requestFamily.familyInfo({ ...e, reqType: '2' });
  85. if (res.code == 200) {
  86. this.isId = '';
  87. uni.showToast({
  88. title: '已提交审核',
  89. duration: 2000,
  90. });
  91. }
  92. },
  93. onClick() {
  94. uni.navigateTo({
  95. url: '/pages/family/familyInfo'
  96. })
  97. },
  98. userbtn(e) {
  99. console.log(e);
  100. uni.navigateTo({
  101. url: `/pages/family/familyInfo?residentId=${e.residentId}`
  102. })
  103. }
  104. }
  105. }
  106. </script>
  107. <style>
  108. .container {
  109. width: 100%;
  110. }
  111. .addUser {
  112. display: block;
  113. /* width: 90%; */
  114. margin: 5px auto;
  115. }
  116. .chat-custom-text {
  117. font-size: 12px;
  118. color: #999;
  119. width: 100%;
  120. text-align: center;
  121. display: block;
  122. }
  123. .addUser .uni-list-item__container {
  124. flex: none;
  125. margin: 0 auto;
  126. }
  127. .addUser .uni-list-item__content-title {
  128. color: #ff8319;
  129. }
  130. .delBox {
  131. display: flex;
  132. width: 100%;
  133. overflow: hidden;
  134. }
  135. .item {
  136. width: 100%;
  137. }
  138. .del {
  139. display: block;
  140. width: 50px;
  141. background: red;
  142. }
  143. .right {
  144. margin-right: -100px;
  145. }
  146. .uni-icons {
  147. display: block;
  148. width: 100%;
  149. text-align: center;
  150. line-height: 2.3em;
  151. }
  152. .left {
  153. margin-left: -100px;
  154. }
  155. .compose {
  156. background: #1aad19;
  157. }
  158. </style>