index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view class="container">
  3. <uni-list :border="true">
  4. <view :id="item && item.residentId" class="delBox" v-for="(item, index) in list" :key="index" >
  5. <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">
  6. <view class="chat-custom-right">
  7. <text class="chat-custom-text">{{ item && item.status == 0 ? '未检' : '已检' }}</text>
  8. <!-- 需要使用 uni-icons 请自行引入 -->
  9. <!-- <uni-icons type="upload" color="#999" size="18"></uni-icons> -->
  10. <button type="primary" size="mini" :disabled="item && item.status == 1" @click="filing(item)">报备</button>
  11. </view>
  12. </uni-list-chat>
  13. <uni-icons @click="userbtn(item)" color="#fff" class="del compose" type="compose" size="28"></uni-icons>
  14. <uni-icons :class="{ left: isId !== item.residentId }" @click="delbtn(item)" color="#fff" class="del" type="trash-filled" size="28"></uni-icons>
  15. </view>
  16. </uni-list>
  17. </view>
  18. </template>
  19. <script>
  20. import requestFamily from '../../api/family.js';
  21. export default {
  22. data() {
  23. return {
  24. isId: '',
  25. startX: 0,
  26. extraIcon: {
  27. color: '#ff8319',
  28. size: '20',
  29. type: 'plusempty'
  30. },
  31. list: [],
  32. natTaskId: '',
  33. }
  34. },
  35. async mounted() {
  36. const task = await requestFamily.runningTask();
  37. if (task.code == 200) {
  38. this.natTaskId = task.data[0].natTaskId;
  39. this.query();
  40. }
  41. },
  42. onShow() {
  43. this.isId = '';
  44. },
  45. methods: {
  46. async query() {
  47. const { userId } = uni.getStorageSync('userinfo');
  48. const familyInfo = await requestFamily.getFamilyInfo({ userId });
  49. if (familyInfo.code == 200) {
  50. const membersStatus = await requestFamily.membersStatus({ userId, natTaskId: this.natTaskId });
  51. familyInfo.rows = familyInfo.rows.map(e => {
  52. const resident = membersStatus.data.find(j => j.residentId == e.residentId);
  53. return { ...e, status: resident?.status || 0 };
  54. })
  55. this.list = familyInfo.rows;
  56. }
  57. },
  58. // 报备
  59. async filing(e) {
  60. const res = await requestFamily.filing({ residentId: e.residentId, natTaskId: this.natTaskId });
  61. if (res.code == 200) {
  62. this.query();
  63. uni.showToast({
  64. title: '报备成功',
  65. duration: 2000,
  66. });
  67. }
  68. },
  69. // 删除
  70. async delbtn(e) {
  71. const res = await requestFamily.familyInfo({ ...e, reqType: '2' });
  72. if (res.code == 200) {
  73. this.isId = '';
  74. uni.showToast({
  75. title: '已提交审核',
  76. duration: 2000,
  77. });
  78. }
  79. },
  80. onClick() {
  81. uni.navigateTo({
  82. url: '/pages/user/familyInfo'
  83. })
  84. },
  85. userbtn(e) {
  86. console.log(e);
  87. uni.navigateTo({
  88. url: `/pages/user/familyInfo?residentId=${e.residentId}`
  89. })
  90. }
  91. }
  92. }
  93. </script>
  94. <style>
  95. .container {
  96. width: 100%;
  97. }
  98. .addUser {
  99. display: block;
  100. /* width: 90%; */
  101. margin: 5px auto;
  102. }
  103. .chat-custom-text {
  104. font-size: 12px;
  105. color: #999;
  106. width: 100%;
  107. text-align: center;
  108. display: block;
  109. }
  110. .addUser .uni-list-item__container {
  111. flex: none;
  112. margin: 0 auto;
  113. }
  114. .addUser .uni-list-item__content-title {
  115. color: #ff8319;
  116. }
  117. .delBox {
  118. display: flex;
  119. width: 100%;
  120. overflow: hidden;
  121. }
  122. .item {
  123. width: 100%;
  124. }
  125. .del {
  126. display: block;
  127. width: 50px;
  128. background: red;
  129. }
  130. .right {
  131. margin-right: -100px;
  132. }
  133. .uni-icons {
  134. display: block;
  135. width: 100%;
  136. text-align: center;
  137. line-height: 2.3em;
  138. }
  139. .left {
  140. margin-left: -100px;
  141. }
  142. .compose {
  143. background: #1aad19;
  144. }
  145. </style>