item.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. let that = this;
  77. app.globalData.twoFailHint("确认删除该住户吗?", function() {
  78. let params = {
  79. user_id: id
  80. };
  81. // let operation = 'user/deleteUserById';
  82. that.$http.deleteUserById(params).then(res =>{
  83. if (res.data.result_code == 1) {
  84. that.$u.toast(res.data.result_msg)
  85. that.mescroll.resetUpScroll()
  86. } else {
  87. app.globalData.oneFailHint(res.data.result_msg);
  88. }
  89. });
  90. });
  91. },
  92. /**
  93. * @param {Object} mescroll 初始化组件
  94. */
  95. initMeScroll(mescroll) {
  96. this.mescroll = mescroll
  97. },
  98. /**
  99. * @param {Object} mescroll 上拉回调
  100. */
  101. upFn(mescroll) {
  102. let that = this
  103. if (this.i == 0) {
  104. //审核通过的用户列表
  105. this.getUserListByMemberId(mescroll)
  106. } else if (this.i == 1) {
  107. //申请记录列表
  108. this.getApplyListByMemberId(mescroll)
  109. } else if (this.i == 2) {
  110. //审核通过列表
  111. this.getAuditListByMemberId(mescroll)
  112. }
  113. },
  114. /**
  115. * 下拉回调
  116. * */
  117. downFn(mescroll) {
  118. setTimeout(() => {
  119. this.$u.toast('刷新成功')
  120. this.mescroll.resetUpScroll()
  121. }, 1500)
  122. },
  123. /**
  124. * 通过memberid获取审核通过标签页下的所有成员
  125. * @param {Object} mescroll
  126. */
  127. getUserListByMemberId(mescroll) {
  128. let that = this;
  129. let params = {
  130. query:{
  131. current:mescroll.num,
  132. size:mescroll.size,
  133. },
  134. "residentialId":uni.getStorageSync('residentialId'),
  135. "id": getApp().globalData.member.id
  136. };
  137. if (!this.$isEmpty(this.roomId)) {
  138. params.roomId = this.roomId
  139. }
  140. // let operation = 'user/getAllUserByMemberId';
  141. try {
  142. that.$http.getAllUserByMemberId(params).then(res => {
  143. if (res.data.success) {
  144. let data = res.data.data.records
  145. let total=res.data.data.total
  146. mescroll.endBySize(data.length, total);
  147. if (mescroll.num == 1) that.userList = [];
  148. that.userList = that.userList.concat(data); //追加新数据
  149. } else {
  150. that.$u.toast(res.data.msg)
  151. mescroll.endErr();
  152. }
  153. });
  154. } catch (e) {
  155. mescroll.endErr();
  156. }
  157. },
  158. /**
  159. * 获取申请列表
  160. */
  161. getApplyListByMemberId(mescroll) {
  162. let that = this;
  163. let params = {
  164. "pageNum": mescroll.num,
  165. "pageSize": mescroll.size,
  166. "member_id": getApp().globalData.member.id
  167. };
  168. if (!this.$isEmpty(this.roomId)) {
  169. params.roomId = this.roomId
  170. }
  171. // let operation = 'applyUser/getAllApplyUserByMemberId';
  172. try {
  173. that.$http.getAllApplyUserByMemberId(params).then(res => {
  174. if (res.data.success) {
  175. let data = res.data.list
  176. mescroll.endByPage(data.length, res.data.pages);
  177. if (mescroll.num == 1) that.applyList = [];
  178. that.applyList = that.applyList.concat(data); //追加新数据
  179. } else {
  180. that.$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. this.vuex_own_room_list.forEach(item => {
  195. room_ids.push(item.id)
  196. })
  197. if (this.$isEmpty(room_ids)) {
  198. //就算没有自己的房屋,也要传room_ids,不然后台报错
  199. room_ids = ['-1']
  200. }
  201. let that = this;
  202. let params = {
  203. "pageNum": mescroll.num.toString(),
  204. "pageSize": mescroll.size.toString(),
  205. "check_states": 0, //审核状态
  206. "room_ids": room_ids
  207. };
  208. // let operation = 'applyUser/getAllApplyUserByRoomIds'
  209. try {
  210. that.$http.getAllApplyUserByRoomIds(params).then(res =>{
  211. if (res.data.result_code == 1) {
  212. let data = res.data.list
  213. mescroll.endByPage(data.length, res.data.pages);
  214. if (mescroll.num == 1) that.auditList = [];
  215. that.auditList = that.auditList.concat(data); //追加新数据
  216. } else {
  217. that.$u.toast(res.data.msg)
  218. mescroll.endErr();
  219. }
  220. })
  221. } catch (e) {
  222. mescroll.endErr();
  223. }
  224. },
  225. }
  226. }
  227. </script>
  228. <style lang="scss" scoped>
  229. view {
  230. box-sizing: border-box;
  231. }
  232. </style>