index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view class="container">
  3. <uni-section :title="task !== null ? task.name : '当前无关爱行动'" type="line">
  4. <uni-list :border="true" v-if="list.length > 0">
  5. <view :id="item && item.residentId" class="delBox" v-for="(item, index) in list" :key="index" >
  6. <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">
  7. <view class="chat-custom-right">
  8. <text class="chat-custom-text">{{ item && item.status == 0 ? '未报平安' : '已报平安' }}</text>
  9. <button type="primary" size="mini" :disabled="item && item.status == 1" @click="filing(item)">报平安</button>
  10. </view>
  11. </uni-list-chat>
  12. </view>
  13. </uni-list>
  14. <text v-if="list.length <= 0 && task !== null" class="chat-custom-text msgText">请完善成员信息 / 家庭成员审核中</text>
  15. </uni-section>
  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. task: null
  33. }
  34. },
  35. async mounted() {
  36. const task = await requestFamily.runningTask();
  37. if (task.code == 200 && task.data.length > 0) {
  38. this.task = task.data[0];
  39. this.natTaskId = task.data[0].natTaskId;
  40. this.query();
  41. }
  42. },
  43. onShow() {
  44. this.isId = '';
  45. },
  46. methods: {
  47. async query() {
  48. const residentIds = [];
  49. const familyInfo = await requestFamily.getUserAll();
  50. console.log(familyInfo)
  51. familyInfo.data.forEach(e => residentIds.push(e.residentId))
  52. if (familyInfo.code == 200) {
  53. const membersStatus = await requestFamily.membersStatus({ residentIds, natTaskId: this.natTaskId });
  54. familyInfo.data = familyInfo.data.map(e => {
  55. const resident = membersStatus.data.find(j => j.residentId == e.residentId);
  56. return { ...e, status: resident?.status || 0 };
  57. })
  58. console.log(familyInfo.data)
  59. this.list = familyInfo.data;
  60. }
  61. },
  62. // 报备
  63. async filing(e) {
  64. const res = await requestFamily.filing({ residentId: e.residentId, natTaskId: this.natTaskId });
  65. if (res.code == 200) {
  66. this.query();
  67. uni.showToast({
  68. title: '已报平安',
  69. duration: 2000,
  70. });
  71. }
  72. }
  73. }
  74. }
  75. </script>
  76. <style>
  77. .container {
  78. width: 100%;
  79. }
  80. .addUser {
  81. display: block;
  82. /* width: 90%; */
  83. margin: 5px auto;
  84. }
  85. .chat-custom-text {
  86. font-size: 12px;
  87. color: #999;
  88. width: 100%;
  89. text-align: center;
  90. display: block;
  91. }
  92. .addUser .uni-list-item__container {
  93. flex: none;
  94. margin: 0 auto;
  95. }
  96. .addUser .uni-list-item__content-title {
  97. color: #ff8319;
  98. }
  99. .delBox {
  100. display: flex;
  101. width: 100%;
  102. overflow: hidden;
  103. }
  104. .item {
  105. width: 100%;
  106. }
  107. .del {
  108. display: block;
  109. width: 50px;
  110. background: red;
  111. }
  112. .right {
  113. margin-right: -100px;
  114. }
  115. .uni-icons {
  116. display: block;
  117. width: 100%;
  118. text-align: center;
  119. line-height: 2.3em;
  120. }
  121. .left {
  122. margin-left: -100px;
  123. }
  124. .compose {
  125. background: #1aad19;
  126. }
  127. .msgText {
  128. padding-bottom: 20px;
  129. }
  130. </style>