item.vue 5.3 KB

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