index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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">
  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. uni.switchTab({
  118. url: '../../index/index',
  119. });
  120. uni.showToast({
  121. title: '登录成功!',
  122. icon: 'none',
  123. });
  124. },
  125. });
  126. },
  127. clickRight() {
  128. //跳转增加用户页面
  129. if (this.addtf) {
  130. uni.navigateTo({
  131. url: './addusers',
  132. });
  133. } else {
  134. uni.showToast({
  135. title: '您暂无权限进行此操作,如有需要,请联系管理员',
  136. icon: 'none',
  137. });
  138. }
  139. },
  140. clickLeft() {
  141. uni.switchTab({
  142. url: '../../index/index',
  143. });
  144. },
  145. userOperation(item) {
  146. //跳转用户信息页面
  147. item = JSON.stringify(item);
  148. uni.navigateTo({
  149. url: './useroperation?item=' + item,
  150. });
  151. },
  152. userloginbtn(item) {
  153. //一键登录
  154. this.userlogin(item.uid);
  155. },
  156. search() {
  157. //搜索用户
  158. this.userlists = [];
  159. this.getState(this.argument);
  160. },
  161. searchinput() {
  162. this.argument.page = 1;
  163. Debounce(() => {
  164. this.userlists = [];
  165. this.getState(this.argument);
  166. }, 1000)();
  167. },
  168. top() {
  169. uni.pageScrollTo({
  170. scrollTop: 0,
  171. duration: 500,
  172. });
  173. },
  174. }, //user.login.users_info
  175. onLoad() {
  176. this.getState(this.argument);
  177. uni.getStorage({
  178. key: 'jurisdiction',
  179. success: (res) => {
  180. console.log(JSON.parse(res.data));
  181. let items = JSON.parse(res.data).filter((item) => {
  182. return item.pur_id == 28; //"系统管理"
  183. });
  184. let items2 = items[0].children.filter((item) => {
  185. return item.pur_id == 29; //"用户管理"
  186. });
  187. var arr = items2[0].children;
  188. console.log(arr);
  189. for (var i = 0; i < arr.length; i++) {
  190. switch (arr[i].pur_id) {
  191. case 116: //"添加用户"
  192. this.addtf = true;
  193. break;
  194. }
  195. }
  196. },
  197. });
  198. },
  199. onReachBottom() {
  200. this.argument.page++;
  201. this.getState(this.argument);
  202. },
  203. onPullDownRefresh() {
  204. this.getState(this.argument);
  205. setTimeout(function () {
  206. uni.stopPullDownRefresh(); //停止下拉刷新动画
  207. }, 1000);
  208. },
  209. onBackPress(options) {
  210. if (options.from === 'navigateBack') {
  211. return false;
  212. }
  213. this.clickLeft();
  214. return true;
  215. },
  216. onPageScroll(e) {
  217. //nvue暂不支持滚动监听,可用bindingx代替
  218. if (e.scrollTop > 200) {
  219. //距离大于200时显示
  220. this.isTop = true;
  221. } else {
  222. //距离小于200时隐藏
  223. this.isTop = false;
  224. }
  225. },
  226. };
  227. </script>
  228. 1
  229. <style lang="scss">
  230. ::v-deep .uni-icons {
  231. font-size: 40rpx !important;
  232. }
  233. .uinput-box {
  234. position: fixed;
  235. top: 88px;
  236. z-index: 100;
  237. background-color: white;
  238. width: 100%;
  239. display: flex;
  240. justify-content: center;
  241. align-items: center;
  242. .uinputs {
  243. width: 95%;
  244. position: relative;
  245. .search {
  246. position: absolute;
  247. top: 40rpx;
  248. left: 200rpx;
  249. }
  250. }
  251. }
  252. .userlists {
  253. width: 100%;
  254. position: relative;
  255. top: 180rpx;
  256. .userlist-li {
  257. width: 46%;
  258. height: 300rpx;
  259. margin: 20rpx 0 0 20rpx;
  260. float: left;
  261. box-shadow: 0 0 10rpx #bcb9ca;
  262. text-align: center;
  263. .userlist-li-city {
  264. overflow: hidden; //溢出隐藏
  265. white-space: nowrap; //禁止换行
  266. text-overflow: ellipsis; //...
  267. }
  268. image {
  269. width: 80rpx;
  270. height: 80rpx;
  271. margin: 40rpx 0 20rpx;
  272. }
  273. .loginbox {
  274. display: flex;
  275. }
  276. .loginp {
  277. width: 130rpx;
  278. padding: 6rpx;
  279. font-size: 25rpx;
  280. background-color: #18b566;
  281. color: #fff;
  282. margin: 20rpx auto;
  283. border-radius: 31rpx;
  284. }
  285. .logininfo {
  286. width: 130rpx;
  287. padding: 6rpx;
  288. font-size: 25rpx;
  289. background-color: #fbb309;
  290. color: #fff;
  291. margin: 20rpx auto;
  292. border-radius: 31rpx;
  293. }
  294. }
  295. }
  296. .top {
  297. position: fixed;
  298. right: 30px;
  299. bottom: 100px;
  300. z-index: 100;
  301. image {
  302. width: 100rpx;
  303. height: 100rpx;
  304. }
  305. }
  306. </style>