index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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. uni.navigateBack({
  99. delta: 1
  100. })
  101. },
  102. userOperation(item) { //跳转用户信息页面
  103. item = JSON.stringify(item)
  104. uni.navigateTo({
  105. url: './useroperation?item=' + item,
  106. })
  107. },
  108. userloginbtn(item){
  109. this.userlogin(item.uid)
  110. },
  111. search() { //搜索用户
  112. this.userlists = []
  113. this.getState(this.argument)
  114. },
  115. searchinput() {
  116. this.argument.page = 1
  117. Debounce(() => {
  118. this.userlists = []
  119. this.getState(this.argument)
  120. }, 1000)()
  121. },
  122. top() {
  123. uni.pageScrollTo({
  124. scrollTop: 0,
  125. duration: 500
  126. })
  127. }
  128. }, //user.login.users_info
  129. onLoad() {
  130. this.getState(this.argument)
  131. uni.getStorage({
  132. key:"jurisdiction",
  133. success:(res)=>{
  134. console.log(JSON.parse(res.data))
  135. let items = JSON.parse(res.data).filter((item)=>{
  136. return item.pur_id == 28//"系统管理"
  137. })
  138. let items2 = items[0].children.filter((item)=>{
  139. return item.pur_id == 29//"用户管理"
  140. })
  141. var arr = items2[0].children
  142. console.log(arr)
  143. for(var i =0;i<arr.length;i++){
  144. switch (arr[i].pur_id){
  145. case 116://"添加用户"
  146. this.addtf = true
  147. break
  148. }
  149. }
  150. },
  151. })
  152. },
  153. onReachBottom() {
  154. this.argument.page++
  155. this.getState(this.argument)
  156. },
  157. onPullDownRefresh() {
  158. this.getState(this.argument)
  159. setTimeout(function() {
  160. uni.stopPullDownRefresh(); //停止下拉刷新动画
  161. }, 1000);
  162. },
  163. onBackPress(options) {
  164. if (options.from === 'navigateBack') {
  165. return false;
  166. }
  167. this.clickLeft();
  168. return true;
  169. },
  170. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  171. if (e.scrollTop > 200) { //距离大于200时显示
  172. this.isTop = true
  173. } else { //距离小于200时隐藏
  174. this.isTop = false
  175. }
  176. },
  177. }
  178. </script>
  179. 1
  180. <style lang="scss">
  181. /deep/.uni-icons {
  182. font-size: 40rpx !important;
  183. }
  184. .uinput-box {
  185. position: fixed;
  186. top: 84px;
  187. z-index: 100;
  188. background-color: white;
  189. width: 100%;
  190. display: flex;
  191. justify-content: center;
  192. align-items: center;
  193. .uinputs {
  194. width: 95%;
  195. position: relative;
  196. .search {
  197. position: absolute;
  198. top: 40rpx;
  199. left: 200rpx;
  200. }
  201. }
  202. }
  203. .userlists {
  204. width: 100%;
  205. position: relative;
  206. top: 180rpx;
  207. .userlist-li {
  208. width: 46%;
  209. height: 300rpx;
  210. margin: 20rpx 0 0 20rpx;
  211. float: left;
  212. box-shadow: 0 0 10rpx #bcb9ca;
  213. text-align: center;
  214. image {
  215. width: 80rpx;
  216. height: 80rpx;
  217. margin: 40rpx 0 20rpx;
  218. }
  219. .userlist-li-city{
  220. overflow: hidden;//溢出隐藏
  221. white-space: nowrap;//禁止换行
  222. text-overflow: ellipsis;//...
  223. }
  224. .loginbox{
  225. display: flex;
  226. }
  227. .loginp {
  228. width: 130rpx;
  229. padding: 6rpx;
  230. font-size: 25rpx;
  231. background-color: #18B566;
  232. color: #FFF;
  233. margin: 20rpx auto;
  234. border-radius: 31rpx;
  235. }
  236. .logininfo{
  237. width: 130rpx;
  238. padding: 6rpx;
  239. font-size: 25rpx;
  240. background-color: #fbb309;
  241. color: #FFF;
  242. margin: 20rpx auto;
  243. border-radius: 31rpx;
  244. }
  245. }
  246. }
  247. .addindent {
  248. width: 100%;
  249. position: fixed;
  250. bottom: 0;
  251. left: 0;
  252. height: 80rpx;
  253. text-align: center;
  254. line-height: 80rpx;
  255. background-color: #71cd9a;
  256. color: #ffffff;
  257. font-size: 16px;
  258. }
  259. .top {
  260. position: fixed;
  261. right: 30px;
  262. bottom: 100px;
  263. z-index: 100;
  264. image {
  265. width: 100rpx;
  266. height: 100rpx;
  267. }
  268. }
  269. </style>