item.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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,userCard,applyCard,auditCard
  22. },
  23. props: {
  24. //房间号
  25. roomId:String,
  26. i: Number,
  27. current:Number,
  28. item:Object,
  29. },
  30. data() {
  31. return {
  32. userList:[],//审核通过的数据列表
  33. applyList:[],//申请记录的数据列表
  34. auditList:[],//住户审核的数据列表
  35. isInit: false, // 是否初始化
  36. list: [], // 列表数据
  37. mescroll: null, // mescroll 对象
  38. // 上拉配置参数
  39. up: {
  40. noMoreSize: 2,
  41. auto: false,
  42. page: {
  43. page: 0,
  44. size: 10
  45. }
  46. },
  47. // 下拉配置参数
  48. down: {
  49. use: false,
  50. auto: false
  51. }
  52. }
  53. },
  54. watch:{
  55. current(val) {
  56. if(!this.isInit && val === this.i) {
  57. this.mescroll.resetUpScroll()
  58. }
  59. }
  60. },
  61. mounted() {
  62. if(!this.isInit && this.i === 0) {
  63. this.mescroll.resetUpScroll()
  64. }
  65. },
  66. created() {
  67. },
  68. methods: {
  69. /**
  70. * 删除用户
  71. */
  72. deleteUserById(id){
  73. let that = this;
  74. app.globalData.twoFailHint("确认删除该住户吗?", function () {
  75. let params = {
  76. member_id:app.globalData.member.id,
  77. user_id:id
  78. };
  79. let operation = 'user/deleteUserById';
  80. app.globalData.postRequest(params, operation, function (res) {
  81. if (res.data.result_code == 1) {
  82. that.$u.toast(res.data.result_msg)
  83. that.mescroll.resetUpScroll()
  84. } else {
  85. app.globalData.oneFailHint(res.data.result_msg);
  86. }
  87. });
  88. });
  89. },
  90. /**
  91. * @param {Object} mescroll 初始化组件
  92. */
  93. initMeScroll(mescroll) {
  94. this.mescroll = mescroll
  95. },
  96. /**
  97. * @param {Object} mescroll 上拉回调
  98. */
  99. upFn(mescroll) {
  100. let that=this
  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 that = this;
  127. let params = {
  128. "pageNum":mescroll.num,
  129. "pageSize":mescroll.size,
  130. "member_id":getApp().globalData.member.id
  131. };
  132. if (!this.$isEmpty(this.roomId)) {
  133. params.roomId=this.roomId
  134. }
  135. let operation = 'user/getAllUserByMemberId';
  136. try{
  137. getApp().globalData.postRequest(params, operation, function (res) {
  138. if (res.data.result_code == 1) {
  139. let data=res.data.list
  140. mescroll.endByPage(data.length, res.data.pages);
  141. if(mescroll.num == 1) that.userList = [];
  142. that.userList=that.userList.concat(data); //追加新数据
  143. }else{
  144. that.$u.toast(res.data.msg)
  145. mescroll.endErr();
  146. }
  147. });
  148. }catch(e){
  149. mescroll.endErr();
  150. }
  151. },
  152. /**
  153. * 获取申请列表
  154. */
  155. getApplyListByMemberId(mescroll) {
  156. let that = this;
  157. let params = {
  158. "pageNum":mescroll.num,
  159. "pageSize":mescroll.size,
  160. "member_id":getApp().globalData.member.id
  161. };
  162. if (!this.$isEmpty(this.roomId)) {
  163. params.roomId=this.roomId
  164. }
  165. let operation = 'applyUser/getAllApplyUserByMemberId';
  166. try{
  167. getApp().globalData.postRequest(params, operation, function (res) {
  168. if (res.data.result_code == 1) {
  169. let data=res.data.list
  170. mescroll.endByPage(data.length, res.data.pages);
  171. if(mescroll.num == 1) that.applyList = [];
  172. that.applyList=that.applyList.concat(data); //追加新数据
  173. }else{
  174. that.$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. this.vuex_own_room_list.forEach(item=>{
  189. room_ids.push(item.id)
  190. })
  191. let that = this;
  192. let params = {
  193. "pageNum":mescroll.num.toString(),
  194. "pageSize":mescroll.size.toString(),
  195. "check_states":0,//审核状态
  196. "room_ids":room_ids
  197. };
  198. let operation = 'applyUser/getAllApplyUserByRoomIds'
  199. try{
  200. getApp().globalData.postRequest(params, operation, function (res) {
  201. if (res.data.result_code == 1) {
  202. let data=res.data.list
  203. mescroll.endByPage(data.length, res.data.pages);
  204. if(mescroll.num == 1) that.auditList = [];
  205. that.auditList=that.auditList.concat(data); //追加新数据
  206. }else{
  207. that.$u.toast(res.data.msg)
  208. mescroll.endErr();
  209. }
  210. })
  211. }catch(e){
  212. mescroll.endErr();
  213. }
  214. },
  215. }
  216. }
  217. </script>
  218. <style lang="scss" scoped>
  219. view{
  220. box-sizing: border-box;
  221. }
  222. </style>