item.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. "pageNum": mescroll.num,
  131. "pageSize": mescroll.size,
  132. "member_id": getApp().globalData.member.id
  133. };
  134. if (!this.$isEmpty(this.roomId)) {
  135. params.roomId = this.roomId
  136. }
  137. // let operation = 'user/getAllUserByMemberId';
  138. try {
  139. that.$http.getAllUserByMemberId(params).then(res => {
  140. if (res.data.result_code == 1) {
  141. let data = res.data.list
  142. mescroll.endByPage(data.length, res.data.pages);
  143. if (mescroll.num == 1) that.userList = [];
  144. that.userList = that.userList.concat(data); //追加新数据
  145. } else {
  146. that.$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 that = this;
  159. let params = {
  160. "pageNum": mescroll.num,
  161. "pageSize": mescroll.size,
  162. "member_id": getApp().globalData.member.id
  163. };
  164. if (!this.$isEmpty(this.roomId)) {
  165. params.roomId = this.roomId
  166. }
  167. // let operation = 'applyUser/getAllApplyUserByMemberId';
  168. try {
  169. that.$http.getAllApplyUserByMemberId(params).then(res => {
  170. if (res.data.result_code == 1) {
  171. let data = res.data.list
  172. mescroll.endByPage(data.length, res.data.pages);
  173. if (mescroll.num == 1) that.applyList = [];
  174. that.applyList = that.applyList.concat(data); //追加新数据
  175. } else {
  176. that.$u.toast(res.data.msg)
  177. mescroll.endErr();
  178. }
  179. })
  180. } catch (e) {
  181. mescroll.endErr();
  182. }
  183. },
  184. /**
  185. * 获取 住户审核列表
  186. * @param {Object} mescroll
  187. */
  188. getAuditListByMemberId(mescroll) {
  189. let room_ids = []
  190. this.vuex_own_room_list.forEach(item => {
  191. room_ids.push(item.id)
  192. })
  193. if (this.$isEmpty(room_ids)) {
  194. //就算没有自己的房屋,也要传room_ids,不然后台报错
  195. room_ids = ['-1']
  196. }
  197. let that = this;
  198. let params = {
  199. "pageNum": mescroll.num.toString(),
  200. "pageSize": mescroll.size.toString(),
  201. "check_states": 0, //审核状态
  202. "room_ids": room_ids
  203. };
  204. // let operation = 'applyUser/getAllApplyUserByRoomIds'
  205. try {
  206. that.$http.getAllApplyUserByRoomIds(params).then(res =>{
  207. if (res.data.result_code == 1) {
  208. let data = res.data.list
  209. mescroll.endByPage(data.length, res.data.pages);
  210. if (mescroll.num == 1) that.auditList = [];
  211. that.auditList = that.auditList.concat(data); //追加新数据
  212. } else {
  213. that.$u.toast(res.data.msg)
  214. mescroll.endErr();
  215. }
  216. })
  217. } catch (e) {
  218. mescroll.endErr();
  219. }
  220. },
  221. }
  222. }
  223. </script>
  224. <style lang="scss" scoped>
  225. view {
  226. box-sizing: border-box;
  227. }
  228. </style>