index.vue 7.4 KB

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