index.vue 6.2 KB

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