index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <view class="">
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 64px;">
  5. <view style="position: fixed;z-index: 100;">
  6. <uni-nav-bar left-icon="back" left-text="返回" right-icon="plus" title="用户管理" @clickRight="clickRight" @clickLeft="clickLeft"></uni-nav-bar>
  7. </view>
  8. <view class="uinput-box">
  9. <view class="uinputs">
  10. <u-input v-model="argument.username" :type="type" :border="border" placeholder="请输入用户名称" input-align="center"
  11. :clearable="border" :custom-style="uinputstyle" @input="searchinput" />
  12. <u-icon name="search" class="search" size="30" @click="search"></u-icon>
  13. </view>
  14. </view>
  15. <view class="userlists">
  16. <view class="userlist-li" v-for="(item,index) in userlists" :kex="index" @click="userOperation(userlists[index])">
  17. <image :src="'http://static.yfpyx.com/bigdata_app'+'/image/fourMoodBase/touxiang.png'" mode=""></image>
  18. <p class="userlist-li-city">{{item.username}}</p>
  19. <p class="userlist-li-eamil">{{item.mobile}}</p>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="top" v-if="isTop" @click="top">
  24. <image :src="'http://static.yfpyx.com/bigdata_app'+'/image/6209a98f0cb3b5086f2ca36152c9269.png'" mode=""></image>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import {
  30. Debounce,
  31. Throttle
  32. } from "../../../util/anitthro.js"
  33. export default {
  34. data() {
  35. return {
  36. value: '',
  37. type: 'text',
  38. border: false,
  39. uinputstyle: {
  40. "margin": "16rpx 0",
  41. 'background': "#f3f3f3",
  42. "border-radius": "25px"
  43. },
  44. userlists: [],
  45. argument: {
  46. page: 1,
  47. page_size: 10,
  48. username: ''
  49. },
  50. isTop:false,
  51. addtf:false
  52. }
  53. },
  54. methods: {
  55. async getState(argument) {
  56. const res = await this.$myRequest({
  57. url: '/api/api_gateway?method=user.login.users_info',
  58. data: {
  59. page: argument.page,
  60. page_size: argument.page_size,
  61. username: argument.username
  62. }
  63. })
  64. this.userlists = this.userlists.concat(res.data)
  65. },
  66. clickRight() { //跳转增加用户页面
  67. if(this.addtf){
  68. uni.navigateTo({
  69. url: './addusers',
  70. })
  71. }else{
  72. uni.showToast({
  73. title: "您暂无权限进行此操作,如有需要,请联系管理员",
  74. icon: "none"
  75. })
  76. }
  77. },
  78. clickLeft(){
  79. uni.switchTab({
  80. url:"../../index/index"
  81. })
  82. },
  83. userOperation(item) { //跳转用户信息页面
  84. item = JSON.stringify(item)
  85. uni.navigateTo({
  86. url: './useroperation?item=' + item,
  87. })
  88. },
  89. search() { //搜索用户
  90. this.userlists = []
  91. this.getState(this.argument)
  92. },
  93. searchinput() {
  94. this.argument.page=1
  95. Debounce(() => {
  96. this.userlists = []
  97. this.getState(this.argument)
  98. }, 1000)()
  99. },
  100. top() {
  101. uni.pageScrollTo({
  102. scrollTop: 0,
  103. duration: 500
  104. })
  105. }
  106. }, //user.login.users_info
  107. onLoad() {
  108. this.getState(this.argument)
  109. uni.getStorage({
  110. key:"jurisdiction",
  111. success:(res)=>{
  112. console.log(JSON.parse(res.data))
  113. let items = JSON.parse(res.data).filter((item)=>{
  114. return item.purview_name == "系统管理"
  115. })
  116. let items2 = items[0].children.filter((item)=>{
  117. return item.purview_name == "用户管理"
  118. })
  119. var arr = items2[0].children
  120. console.log(arr)
  121. for(var i =0;i<arr.length;i++){
  122. switch (arr[i].purview_name){
  123. case "添加用户":
  124. this.addtf = true
  125. break
  126. }
  127. }
  128. },
  129. })
  130. },
  131. onReachBottom() {
  132. this.argument.page++
  133. this.getState(this.argument)
  134. },
  135. onPullDownRefresh() {
  136. this.getState(this.argument)
  137. setTimeout(function() {
  138. uni.stopPullDownRefresh(); //停止下拉刷新动画
  139. }, 1000);
  140. },
  141. onBackPress(options) {
  142. if (options.from === 'navigateBack') {
  143. return false;
  144. }
  145. this.clickLeft();
  146. return true;
  147. },
  148. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  149. if (e.scrollTop > 200) { //距离大于200时显示
  150. this.isTop = true
  151. } else { //距离小于200时隐藏
  152. this.isTop = false
  153. }
  154. },
  155. }
  156. </script>
  157. 1
  158. <style lang="scss">
  159. /deep/.uni-icons{
  160. font-size: 40rpx !important;
  161. }
  162. .uinput-box {
  163. position: fixed;
  164. top: 108px;
  165. z-index: 100;
  166. background-color: white;
  167. width: 100%;
  168. display: flex;
  169. justify-content: center;
  170. align-items: center;
  171. .uinputs {
  172. width: 95%;
  173. position: relative;
  174. .search {
  175. position: absolute;
  176. top: 40rpx;
  177. left: 200rpx;
  178. }
  179. }
  180. }
  181. .userlists {
  182. width: 100%;
  183. position: relative;
  184. top: 180rpx;
  185. .userlist-li {
  186. width: 46%;
  187. height: 270rpx;
  188. margin: 20rpx 0 0 20rpx;
  189. float: left;
  190. box-shadow: 0 0 10rpx #bcb9ca;
  191. text-align: center;
  192. image {
  193. width: 80rpx;
  194. height: 80rpx;
  195. margin: 40rpx 0 20rpx;
  196. }
  197. }
  198. }
  199. .top {
  200. position: fixed;
  201. right: 30px;
  202. bottom: 100px;
  203. z-index: 100;
  204. image{
  205. width: 100rpx;
  206. height: 100rpx;
  207. }
  208. }
  209. </style>