item.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <view class="">
  3. <u-toast ref="uToast" />
  4. <MeScroll :up="up" :down="down" @up="upFn" :fixed="false" @down="downFn" @init="initMeScroll">
  5. <!-- 审核通过 -->
  6. <user-card @deleteUserById="deleteUserById" v-if="i==0" :list="userList"></user-card>
  7. <apply-card v-if="i==1" :list="applyList"></apply-card>
  8. <audit-card v-if="i==2" :list="auditList"></audit-card>
  9. </MeScroll>
  10. </view>
  11. </template>
  12. <script>
  13. import MeScroll from '@/comps/mescroll-body/mescroll-uni.vue'
  14. import userCard from './user-card.vue'
  15. import applyCard from './apply-card.vue'
  16. import auditCard from './audit-card.vue'
  17. var app = getApp()
  18. export default {
  19. name: 'item',
  20. components: {
  21. MeScroll,
  22. userCard,
  23. applyCard,
  24. auditCard
  25. },
  26. provide() {
  27. return {
  28. reload: this.reload
  29. }
  30. },
  31. props: {
  32. //房间号
  33. roomId: String,
  34. i: Number,
  35. current: Number,
  36. item: Object,
  37. },
  38. data() {
  39. return {
  40. userList: [], //审核通过的数据列表
  41. applyList: [], //申请记录的数据列表
  42. auditList: [], //住户审核的数据列表
  43. isInit: false, // 是否初始化
  44. list: [], // 列表数据
  45. mescroll: null, // mescroll 对象
  46. // 上拉配置参数
  47. up: {
  48. noMoreSize: 3,
  49. auto: false,
  50. page: {
  51. page: 0,
  52. size: 10
  53. }
  54. },
  55. // 下拉配置参数
  56. down: {
  57. use: false,
  58. auto: false
  59. }
  60. }
  61. },
  62. watch: {
  63. current(val) {
  64. if (!this.isInit && val === this.i) {
  65. this.mescroll.resetUpScroll()
  66. }
  67. }
  68. },
  69. mounted() {
  70. if (!this.isInit && this.i === 0) {
  71. this.mescroll.resetUpScroll()
  72. }
  73. },
  74. created() {
  75. },
  76. methods: {
  77. reload() {
  78. this.mescroll.resetUpScroll()
  79. },
  80. /**
  81. * 删除用户
  82. */
  83. deleteUserById(id) {
  84. this.$dialog.showModal('确认删除该住户吗?').then(() => {
  85. let params = {
  86. user_id: id
  87. };
  88. this.$http.deleteUserById(params).then(res => {
  89. if (res.data.result_code == 1) {
  90. this.$u.toast(res.data.result_msg)
  91. this.mescroll.resetUpScroll()
  92. } else {
  93. app.globalData.oneFailHint(res.data.result_msg);
  94. }
  95. })
  96. })
  97. },
  98. /**
  99. * @param {Object} mescroll 初始化组件
  100. */
  101. initMeScroll(mescroll) {
  102. this.mescroll = mescroll
  103. },
  104. /**
  105. * @param {Object} mescroll 上拉回调
  106. */
  107. upFn(mescroll) {
  108. if (this.i == 0) {
  109. //审核通过的用户列表
  110. this.getUserListByMemberId(mescroll)
  111. } else if (this.i == 1) {
  112. //申请记录列表
  113. this.getApplyListByMemberId(mescroll)
  114. } else if (this.i == 2) {
  115. //审核通过列表
  116. this.getAuditListByMemberId(mescroll)
  117. }
  118. },
  119. /**
  120. * 下拉回调
  121. * */
  122. downFn(mescroll) {
  123. setTimeout(() => {
  124. this.$u.toast('刷新成功')
  125. this.mescroll.resetUpScroll()
  126. }, 1500)
  127. },
  128. /**
  129. * 通过memberid获取审核通过标签页下的所有成员
  130. * @param {Object} mescroll
  131. */
  132. getUserListByMemberId(mescroll) {
  133. let params = {
  134. query: {
  135. current: mescroll.num,
  136. size: mescroll.size,
  137. },
  138. "residentialId": uni.getStorageSync('residentialId'),
  139. };
  140. if (!this.$isEmpty(this.roomId)) {
  141. params.roomId = this.roomId
  142. }
  143. // let operation = 'user/getAllUserByMemberId';
  144. try {
  145. this.$http.getAllUserByMemberId(params).then(res => {
  146. if (res.data.success) {
  147. let data = res.data.data.records
  148. let total = res.data.data.total
  149. mescroll.endBySize(data.length, total);
  150. if (mescroll.num == 1) this.userList = [];
  151. this.userList = this.userList.concat(data); //追加新数据
  152. } else {
  153. this.$u.toast(res.data.msg)
  154. mescroll.endErr();
  155. }
  156. });
  157. } catch (e) {
  158. mescroll.endErr();
  159. }
  160. },
  161. /**
  162. * 获取申请列表
  163. */
  164. getApplyListByMemberId(mescroll) {
  165. let params = {
  166. "current": mescroll.num,
  167. "size": mescroll.size,
  168. "memberId": getApp().globalData.member.id,
  169. }
  170. try {
  171. this.$http.getAllApplyUserByMemberId(params).then(res => {
  172. console.log(res);
  173. if (res.data.success) {
  174. let data = res.data.data.records
  175. let total = res.data.data.total
  176. mescroll.endBySize(data.length, total);
  177. if (mescroll.num == 1) this.applyList = [];
  178. this.applyList = this.applyList.concat(data); //追加新数据
  179. } else {
  180. this.$u.toast(res.data.msg)
  181. mescroll.endErr();
  182. }
  183. })
  184. } catch (e) {
  185. mescroll.endErr();
  186. }
  187. },
  188. /**
  189. * 获取 住户审核列表
  190. * @param {Object} mescroll
  191. */
  192. getAuditListByMemberId(mescroll) {
  193. let room_ids = []
  194. let params = {
  195. "current": mescroll.num,
  196. "size": mescroll.size,
  197. "memberId": getApp().globalData.member.id
  198. }
  199. try {
  200. this.$http.getAuditListByMemberId(params).then(res => {
  201. if (res.data.success) {
  202. let data = res.data.data.records
  203. let total = res.data.data.total
  204. mescroll.endBySize(data.length, total);
  205. if (mescroll.num == 1) this.auditList = [];
  206. this.auditList = this.auditList.concat(data); //追加新数据
  207. } else {
  208. this.$u.toast(res.data.msg)
  209. mescroll.endErr();
  210. }
  211. })
  212. } catch (e) {
  213. console.log(e);
  214. mescroll.endErr();
  215. }
  216. },
  217. }
  218. }
  219. </script>
  220. <style lang="scss" scoped>
  221. view {
  222. box-sizing: border-box;
  223. }
  224. </style>