receive.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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 v-if="item.reqStatus == 1" :class="{ left: isId !== item.residentId }" @click="delbtn(item)" color="#fff" class="del" type="trash-filled" size="28"></uni-icons>
  22. <uni-icons v-else :class="{ left: isId !== item.residentId }" @click="delbtn(item)" color="#fff" class="del cancel" type="undo-filled" size="28"></uni-icons>
  23. </view>
  24. </uni-list>
  25. </view>
  26. </template>
  27. <script>
  28. import requestFamily from '../../api/family.js';
  29. export default {
  30. data() {
  31. return {
  32. isId: '',
  33. startX: 0,
  34. extraIcon: {
  35. color: '#ff8319',
  36. size: '20',
  37. type: 'plusempty'
  38. },
  39. list: [],
  40. // applylist: [],
  41. natTaskId: '',
  42. membersStatus: [],
  43. }
  44. },
  45. mounted() {},
  46. async onShow() {
  47. this.isId = '';
  48. this.query();
  49. },
  50. methods: {
  51. async query() {
  52. this.list = [];
  53. const familyInfo = await requestFamily.getFamilyInfo();
  54. const res = await requestFamily.getApplyUser();
  55. res.data.forEach(e => {
  56. const data = familyInfo.data.find(k => e.residentId == k.residentId);
  57. if (!data) familyInfo.data.push(e);
  58. })
  59. familyInfo.data.forEach(e => {
  60. const data = res.data.find(j => j.residentId == e.residentId);
  61. let reqStatusText = '';
  62. if (data && data.reqStatus == 0) reqStatusText = '待审核';
  63. if (data && data.reqStatus == 2) reqStatusText = '已拒绝';
  64. let obj = {};
  65. if (data) {
  66. obj = { ...data, reqStatusText }
  67. }else {
  68. obj = { ...e, reqStatusText, reqStatus: 1 };
  69. }
  70. this.$set(this.list, this.list.length, obj);
  71. });
  72. },
  73. // 滑动开始
  74. touchStart(e) {
  75. if (e.touches.length == 1) {
  76. //设置触摸起始点水平方向位置
  77. this.startX=e.touches[0].clientX;
  78. }
  79. },
  80. // 滑动结束
  81. touchEnd(e) {
  82. const data = this.list.find(j => j.residentId == e.currentTarget.id);
  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. console.log(e, 'eee')
  99. let msg = '';
  100. if (e.reqStatus == 1) {
  101. // 提交删除申请
  102. const res = await requestFamily.familyInfo({ ...e, reqType: '2' });
  103. if (res.code == 200) {
  104. msg = '已提交审核';
  105. }
  106. } else {
  107. // 取消审核信息
  108. const res = await requestFamily.removeApply({ residentReqId: e.residentReqId });
  109. if (res.code == 200) {
  110. msg = '已取消申请信息';
  111. }
  112. }
  113. this.isId = '';
  114. uni.showToast({
  115. title: msg,
  116. duration: 2000,
  117. });
  118. this.query();
  119. },
  120. // 添加
  121. onClick() {
  122. uni.navigateTo({
  123. url: '/pages/user/familyInfo'
  124. })
  125. },
  126. // 修改
  127. userbtn(e) {
  128. if (!e.reqStatus || e.reqStatus == '1') {
  129. uni.navigateTo({
  130. url: `/pages/user/familyInfo?residentId=${e.residentId}`
  131. })
  132. return;
  133. }
  134. uni.navigateTo({
  135. url: `/pages/user/familyInfo?residentReqId=${e.residentReqId}`
  136. })
  137. }
  138. }
  139. }
  140. </script>
  141. <style>
  142. .container {
  143. width: 100%;
  144. }
  145. .addUser {
  146. display: block;
  147. /* width: 90%; */
  148. margin: 5px auto;
  149. }
  150. .chat-custom-text {
  151. font-size: 12px;
  152. color: #999;
  153. width: 100%;
  154. text-align: center;
  155. display: block;
  156. }
  157. .addUser .uni-list-item__container {
  158. flex: none;
  159. margin: 0 auto;
  160. }
  161. .addUser .uni-list-item__content-title {
  162. color: #ff8319;
  163. }
  164. .delBox {
  165. display: flex;
  166. width: 100%;
  167. overflow: hidden;
  168. }
  169. .item {
  170. width: 100%;
  171. }
  172. .del {
  173. display: block;
  174. width: 70px;
  175. background: red;
  176. }
  177. .cancel {
  178. background: #d6d8da;
  179. }
  180. .right {
  181. margin-right: -70px;
  182. }
  183. .uni-icons {
  184. display: block;
  185. width: 100%;
  186. text-align: center;
  187. line-height: 2.3em;
  188. }
  189. .left {
  190. margin-left: -70px;
  191. }
  192. .compose {
  193. background: #1aad19;
  194. }
  195. .notes {
  196. width: 90%;
  197. display: block;
  198. margin: 5px auto;
  199. color: #ff8319;
  200. font-size: 12px;
  201. }
  202. .is0 .uni-list-chat__content-note{
  203. color: #1aad19;
  204. }
  205. .is1 .uni-list-chat__content-note{
  206. color: #2979ff;
  207. }
  208. .is2 .uni-list-chat__content-note{
  209. color: red;
  210. }
  211. </style>