index.vue 6.0 KB

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