receive.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. <text class="notes">注:代领富裕街道家庭成员</text>
  9. <uni-list :border="true">
  10. <view :id="item && item.residentId" :name="item.reqStatus" class="delBox" @touchstart="touchStart" @touchend="touchEnd" v-for="(item, index) in list" :key="index" >
  11. <uni-list-chat
  12. :class="{ left: isId == item.residentId, is0: item.reqStatus == 0, is1: item.reqStatus == 1, is2: item.reqStatus == 2, }"
  13. class="item"
  14. :avatar="item.avatar || '/static/user1.png'"
  15. :title="item.name"
  16. :note="item.reqStatusText"
  17. badge-positon="left">
  18. <button type="primary" size="mini" @click="userbtn(item)">详情</button>
  19. </uni-list-chat>
  20. <!-- <uni-icons @click="userbtn(item)" color="#fff" class="del compose" type="compose" size="28"></uni-icons> -->
  21. <uni-icons :class="{ left: isId !== item.residentId }" @click="delbtn(item)" color="#fff" class="del" type="trash-filled" size="28"></uni-icons>
  22. </view>
  23. </uni-list>
  24. </view>
  25. </template>
  26. <script>
  27. import requestFamily from '../../api/family.js';
  28. export default {
  29. data() {
  30. return {
  31. isId: '',
  32. startX: 0,
  33. extraIcon: {
  34. color: '#ff8319',
  35. size: '20',
  36. type: 'plusempty'
  37. },
  38. list: [],
  39. // applylist: [],
  40. natTaskId: '',
  41. membersStatus: [],
  42. }
  43. },
  44. mounted() {},
  45. async onShow() {
  46. this.isId = '';
  47. this.query();
  48. },
  49. methods: {
  50. async query() {
  51. const familyInfo = await requestFamily.getFamilyInfo();
  52. const res = await requestFamily.getApplyUser();
  53. res.data.forEach(e => {
  54. const isTrue = familyInfo.rows.find(k => e.residentReqId == k.residentId);
  55. if (isTrue) {
  56. familyInfo.rows.map(j => {
  57. const data = e.residentReqId == j.residentId
  58. if (data) return { ...j, reqStatus: data.reqStatus };
  59. return j;
  60. })
  61. return;
  62. }
  63. familyInfo.rows.push({ ...e, residentId: e.residentReqId })
  64. })
  65. this.list = familyInfo.rows.map(e => {
  66. if (e.reqStatus == 0) e.reqStatusText = '待审核';
  67. if (e.reqStatus == 1) e.reqStatusText = '已通过';
  68. if (e.reqStatus == 2) e.reqStatusText = '已拒绝';
  69. return e;
  70. });
  71. },
  72. // 滑动开始
  73. touchStart(e) {
  74. if (e.touches.length == 1) {
  75. //设置触摸起始点水平方向位置
  76. this.startX=e.touches[0].clientX;
  77. }
  78. },
  79. // 滑动结束
  80. touchEnd(e) {
  81. const data = this.list.find(j => j.residentId == e.currentTarget.id);
  82. if (data.reqStatus !== '1') return;
  83. if (e.changedTouches.length == 1) {
  84. //手指移动结束后水平位置
  85. var endX = e.changedTouches[0].clientX;
  86. let diff = endX - this.startX;
  87. if(Math.abs(diff) > 20){
  88. if(diff < 0) {
  89. this.isId = e.currentTarget.id;
  90. }else{
  91. this.isId = '';
  92. }
  93. }
  94. }
  95. },
  96. // 删除
  97. async delbtn(e) {
  98. const res = await requestFamily.familyInfo({ ...e, reqType: '2' });
  99. if (res.code == 200) {
  100. this.isId = '';
  101. uni.showToast({
  102. title: '已提交审核',
  103. duration: 2000,
  104. });
  105. }
  106. this.query();
  107. },
  108. // 添加
  109. onClick() {
  110. uni.navigateTo({
  111. url: '/pages/user/familyInfo'
  112. })
  113. },
  114. // 修改
  115. userbtn(e) {
  116. if (e.reqStatus == '1') {
  117. uni.navigateTo({
  118. url: `/pages/user/familyInfo?residentId=${e.residentId}`
  119. })
  120. return;
  121. }
  122. uni.navigateTo({
  123. url: `/pages/user/familyInfo?residentReqId=${e.residentReqId}`
  124. })
  125. }
  126. }
  127. }
  128. </script>
  129. <style>
  130. .container {
  131. width: 100%;
  132. }
  133. .addUser {
  134. display: block;
  135. /* width: 90%; */
  136. margin: 5px auto;
  137. }
  138. .chat-custom-text {
  139. font-size: 12px;
  140. color: #999;
  141. width: 100%;
  142. text-align: center;
  143. display: block;
  144. }
  145. .addUser .uni-list-item__container {
  146. flex: none;
  147. margin: 0 auto;
  148. }
  149. .addUser .uni-list-item__content-title {
  150. color: #ff8319;
  151. }
  152. .delBox {
  153. display: flex;
  154. width: 100%;
  155. overflow: hidden;
  156. }
  157. .item {
  158. width: 100%;
  159. }
  160. .del {
  161. display: block;
  162. width: 70px;
  163. background: red;
  164. }
  165. .right {
  166. margin-right: -70px;
  167. }
  168. .uni-icons {
  169. display: block;
  170. width: 100%;
  171. text-align: center;
  172. line-height: 2.3em;
  173. }
  174. .left {
  175. margin-left: -70px;
  176. }
  177. .compose {
  178. background: #1aad19;
  179. }
  180. .notes {
  181. width: 90%;
  182. display: block;
  183. margin: 5px auto;
  184. color: #ff8319;
  185. font-size: 12px;
  186. }
  187. .is0 .uni-list-chat__content-note{
  188. color: #1aad19;
  189. }
  190. .is1 .uni-list-chat__content-note{
  191. color: #2979ff;
  192. }
  193. .is2 .uni-list-chat__content-note{
  194. color: red;
  195. }
  196. </style>