index.vue 7.1 KB

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