index.vue 7.1 KB

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