index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view class="">
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 40px;">
  5. <view style="position: fixed;z-index: 100;">
  6. <uni-nav-bar left-icon="back" left-text="返回" title="用户管理" @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="请输入用户名称"
  11. input-align="center" :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">
  17. <image :src="$imageURL+'/bigdata_app'+'/image/fourMoodBase/touxiang.png'" mode="">
  18. </image>
  19. <p class="userlist-li-city">{{item.username}}</p>
  20. <p class="userlist-li-eamil">{{item.mobile}}</p>
  21. <view class="loginbox">
  22. <p class="loginp" @click="userloginbtn(item)">一键登录</p>
  23. <!-- <p class="logininfo" @click="userOperation(item)">查看详情</p> -->
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="top" v-if="isTop" @click="top">
  29. <image :src="$imageURL+'/bigdata_app'+'/image/6209a98f0cb3b5086f2ca36152c9269.png'"
  30. mode=""></image>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import {
  36. Debounce,
  37. Throttle
  38. } from "../../../util/anitthro.js"
  39. export default {
  40. data() {
  41. return {
  42. value: '',
  43. type: 'text',
  44. border: false,
  45. uinputstyle: {
  46. "margin": "16rpx 0",
  47. 'background': "#f3f3f3",
  48. "border-radius": "25px"
  49. },
  50. userlists: [],
  51. argument: {
  52. page: 1,
  53. page_size: 10,
  54. username: ''
  55. },
  56. isTop: false,
  57. addtf: false
  58. }
  59. },
  60. methods: {
  61. async getState(argument) {
  62. const res = await this.$myRequest({
  63. url: '/api/api_gateway?method=user.login.users_info',
  64. data: {
  65. page: argument.page,
  66. page_size: argument.page_size,
  67. username: argument.username
  68. }
  69. })
  70. this.userlists = this.userlists.concat(res.data)
  71. },
  72. async userlogin(uid) {
  73. const res = await this.$myRequest({
  74. url: '/api/api_gateway?method=user.login.auto_login',
  75. data: {
  76. uid
  77. }
  78. })
  79. let session_key = res.session_key
  80. uni.setStorage({
  81. key: 'session_key',
  82. data: session_key,
  83. success: () => {
  84. uni.switchTab({
  85. url: "../../index/index"
  86. })
  87. uni.showToast({
  88. title: "登录成功!",
  89. icon: "none"
  90. })
  91. }
  92. })
  93. },
  94. clickLeft() {
  95. uni.switchTab({
  96. url: "../../index/index"
  97. })
  98. },
  99. userOperation(item) { //跳转用户信息页面
  100. item = JSON.stringify(item)
  101. uni.navigateTo({
  102. url: './useroperation?item=' + item,
  103. })
  104. },
  105. userloginbtn(item){
  106. this.userlogin(item.uid)
  107. },
  108. search() { //搜索用户
  109. this.userlists = []
  110. this.getState(this.argument)
  111. },
  112. searchinput() {
  113. this.argument.page = 1
  114. Debounce(() => {
  115. this.userlists = []
  116. this.getState(this.argument)
  117. }, 1000)()
  118. },
  119. top() {
  120. uni.pageScrollTo({
  121. scrollTop: 0,
  122. duration: 500
  123. })
  124. }
  125. }, //user.login.users_info
  126. onLoad() {
  127. this.getState(this.argument)
  128. uni.getStorage({
  129. key:"jurisdiction",
  130. success:(res)=>{
  131. console.log(JSON.parse(res.data))
  132. let items = JSON.parse(res.data).filter((item)=>{
  133. return item.pur_id == 28//"系统管理"
  134. })
  135. let items2 = items[0].children.filter((item)=>{
  136. return item.pur_id == 29//"用户管理"
  137. })
  138. var arr = items2[0].children
  139. console.log(arr)
  140. for(var i =0;i<arr.length;i++){
  141. switch (arr[i].pur_id){
  142. case 116://"添加用户"
  143. this.addtf = true
  144. break
  145. }
  146. }
  147. },
  148. })
  149. },
  150. onReachBottom() {
  151. this.argument.page++
  152. this.getState(this.argument)
  153. },
  154. onPullDownRefresh() {
  155. this.getState(this.argument)
  156. setTimeout(function() {
  157. uni.stopPullDownRefresh(); //停止下拉刷新动画
  158. }, 1000);
  159. },
  160. onBackPress(options) {
  161. if (options.from === 'navigateBack') {
  162. return false;
  163. }
  164. this.clickLeft();
  165. return true;
  166. },
  167. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  168. if (e.scrollTop > 200) { //距离大于200时显示
  169. this.isTop = true
  170. } else { //距离小于200时隐藏
  171. this.isTop = false
  172. }
  173. },
  174. }
  175. </script>
  176. 1
  177. <style lang="scss">
  178. /deep/.uni-icons {
  179. font-size: 40rpx !important;
  180. }
  181. .uinput-box {
  182. position: fixed;
  183. top: 84px;
  184. z-index: 100;
  185. background-color: white;
  186. width: 100%;
  187. display: flex;
  188. justify-content: center;
  189. align-items: center;
  190. .uinputs {
  191. width: 95%;
  192. position: relative;
  193. .search {
  194. position: absolute;
  195. top: 40rpx;
  196. left: 200rpx;
  197. }
  198. }
  199. }
  200. .userlists {
  201. width: 100%;
  202. position: relative;
  203. top: 180rpx;
  204. .userlist-li {
  205. width: 46%;
  206. height: 300rpx;
  207. margin: 20rpx 0 0 20rpx;
  208. float: left;
  209. box-shadow: 0 0 10rpx #bcb9ca;
  210. text-align: center;
  211. image {
  212. width: 80rpx;
  213. height: 80rpx;
  214. margin: 40rpx 0 20rpx;
  215. }
  216. .userlist-li-city{
  217. overflow: hidden;//溢出隐藏
  218. white-space: nowrap;//禁止换行
  219. text-overflow: ellipsis;//...
  220. }
  221. .loginbox{
  222. display: flex;
  223. }
  224. .loginp {
  225. width: 130rpx;
  226. padding: 6rpx;
  227. font-size: 25rpx;
  228. background-color: #18B566;
  229. color: #FFF;
  230. margin: 20rpx auto;
  231. border-radius: 31rpx;
  232. }
  233. .logininfo{
  234. width: 130rpx;
  235. padding: 6rpx;
  236. font-size: 25rpx;
  237. background-color: #fbb309;
  238. color: #FFF;
  239. margin: 20rpx auto;
  240. border-radius: 31rpx;
  241. }
  242. }
  243. }
  244. .addindent {
  245. width: 100%;
  246. position: fixed;
  247. bottom: 0;
  248. left: 0;
  249. height: 80rpx;
  250. text-align: center;
  251. line-height: 80rpx;
  252. background-color: #71cd9a;
  253. color: #ffffff;
  254. font-size: 16px;
  255. }
  256. .top {
  257. position: fixed;
  258. right: 30px;
  259. bottom: 100px;
  260. z-index: 100;
  261. image {
  262. width: 100rpx;
  263. height: 100rpx;
  264. }
  265. }
  266. </style>