index.vue 6.0 KB

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