item.vue 5.3 KB

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