item.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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("确认删除该住户吗?", ()=>{
  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. "current": mescroll.num,
  160. "size": mescroll.size,
  161. "memberId": getApp().globalData.member.id,
  162. 'residentialId':uni.getStorageSync('residentialId')
  163. }
  164. try {
  165. this.$http.getAllApplyUserByMemberId(params).then(res => {
  166. console.log(res);
  167. if (res.data.success) {
  168. let data = res.data.data.records
  169. let total=res.data.data.total
  170. mescroll.endBySize(data.length, total);
  171. if (mescroll.num == 1) this.applyList = [];
  172. this.applyList = this.applyList.concat(data); //追加新数据
  173. } else {
  174. this.$u.toast(res.data.msg)
  175. mescroll.endErr();
  176. }
  177. })
  178. } catch (e) {
  179. mescroll.endErr();
  180. }
  181. },
  182. /**
  183. * 获取 住户审核列表
  184. * @param {Object} mescroll
  185. */
  186. getAuditListByMemberId(mescroll) {
  187. let room_ids = []
  188. let params = {
  189. "current": mescroll.num,
  190. "size": mescroll.size,
  191. "memberId": getApp().globalData.member.id
  192. }
  193. try {
  194. this.$http.getAuditListByMemberId(params).then(res =>{
  195. if (res.data.success) {
  196. let data = res.data.data.records
  197. let total=res.data.data.total
  198. mescroll.endBySize(data.length, total);
  199. if (mescroll.num == 1) this.auditList = [];
  200. this.auditList = this.auditList.concat(data); //追加新数据
  201. } else {
  202. this.$u.toast(res.data.msg)
  203. mescroll.endErr();
  204. }
  205. })
  206. } catch (e) {
  207. console.log(e);
  208. mescroll.endErr();
  209. }
  210. },
  211. }
  212. }
  213. </script>
  214. <style lang="scss" scoped>
  215. view {
  216. box-sizing: border-box;
  217. }
  218. </style>