item.vue 5.6 KB

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