From fbdc9fd53ce80d89b70184db67258f7b3b3a2ebb Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Fri, 27 Oct 2023 14:51:58 +0800
Subject: [PATCH] 登录、切换角色
---
pages/login/login-account.vue | 353 +++++++++++++++++++++++
/dev/null | 140 ---------
pages/user/center.vue | 58 ++-
pages/home/index.vue | 50 +-
mixin/loginMixin.js | 43 ++
pages.json | 14
subPackage/user/components/roleList.vue | 40 ++
subPackage/user/role/index.vue | 109 ++++---
common/setting.js | 2
components/tabBar/tabBar.vue | 43 --
http/api.js | 36 --
11 files changed, 567 insertions(+), 321 deletions(-)
diff --git a/common/setting.js b/common/setting.js
index c428539..19c5960 100644
--- a/common/setting.js
+++ b/common/setting.js
@@ -10,7 +10,7 @@
version: '2.0.0',
// 开发环境接口Url
// devUrl: 'https://sk.hubeishuiyi.cn',
- devUrl: 'http://172.16.13.129:9528',
+ devUrl: 'http://192.168.1.133:9528',
// 数据中台接口url
// dataCenterUrl: 'http://10.10.2.192/services',
dataCenterUrl: 'https://sk.hubeishuiyi.cn/services',
diff --git a/components/tabBar/tabBar.vue b/components/tabBar/tabBar.vue
index 0949fdb..0c23be8 100644
--- a/components/tabBar/tabBar.vue
+++ b/components/tabBar/tabBar.vue
@@ -2,10 +2,7 @@
<view>
<u-tabbar class="custom-tabbar" zIndex="100" :value="currentTab" :fixed="true" :active-color="activeColor"
:inactive-color="inactiveColor" @change='change'>
- <u-tabbar-item v-for="(item,index) in curTabList" :key="index" :text="item.name"
- :badge="item.badge>0?item.badge:0">
- <image class="u-page_item_slot_icon" slot="active-icon" :src="item.iconPathSelected" />
- <image class="u-page_item_slot_icon" slot="inactive-icon" :src="item.iconPath" />
+ <u-tabbar-item v-for="(item,index) in curTabList" :icon="item.icon" :key="index" :text="item.name">
</u-tabbar-item>
</u-tabbar>
</view>
@@ -18,29 +15,25 @@
export default {
props: {
currentTab: {},
- tabList: {
- type: Array,
- default: () => []
- }
},
data() {
return {
inactiveColor: '#909399',
activeColor: '#328CFA',
- //10分钟
- getMessageTime: 1000 * 60 * 10,
-
- curTabList: [
- {
+
+
+ curTabList: [{
name: '首页',
iconPathSelected: '',
iconPath: '',
+ icon: "home",
url: '/pages/home/index'
},
{
name: '个人中心',
iconPathSelected: '',
iconPath: '',
+ icon: "account-fill",
url: '/pages/user/center'
}
]
@@ -68,8 +61,7 @@
// this.getMessage()
},
destroyed() {
- this.$intv && clearInterval(this.$intv)
- this.$intv = null
+
},
methods: {
change(e) {
@@ -83,27 +75,6 @@
this.$u.func.updateTabbar(res.data)
})
},
-
- getMessage() {
- let params = {
- recipient: this.userInfo.user_id,
- status: 0
- }
-
- messageCount(params).then(res => {
- this.$u.func.updateTabbar(res.data)
- })
-
- this.$intv = setInterval(() => {
- let params = {
- recipient: this.userInfo.user_id,
- status: 0
- }
- messageCount(params).then(res => {
- this.$u.func.updateTabbar(res.data)
- })
- }, this.getMessageTime)
- }
}
}
diff --git a/http/api.js b/http/api.js
index 3204a5b..de859da 100644
--- a/http/api.js
+++ b/http/api.js
@@ -19,8 +19,9 @@
config.header['Authorization'] = 'Basic ' + Base64.encode(clientId + ':' + clientSecret);
}
if (config.custom.Authorization == true) {
- console.log(config.custom,"==========")
- config.header['Authorization']="Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiJBRE1JTiIsIlVzZXJJZCI6IjEiLCJzY29wZSI6WyJhbGwiXSwiVXNlclJlYWxOYW1lIjoi6LaF57qn566h55CG5ZGYIiwiVXNlclh6cWhkbSI6IjQyMDUiLCJleHAiOjI1MTk3NzIwMTAsImp0aSI6ImExNTcxYzk1LTBkNjMtNDkyYi1iOWEyLTE2ZTIzNTQ5ZTY1ZiIsImNsaWVudF9pZCI6InVzZXItc2VydmljZSJ9.ebNVZrw9LbhKaj2w6RR8b2wccQiDkhvBeq79SxxCK-yWiOlIFqBkotTN4TNJg8umcpyYvLILwvqXWRJhffEtgi25sX2y6MqLIWM4kMZ9d8ptdnSmTpBPhltSiQOM0KFa1kl5nSDCBwYOLn-pESJglam76cjpgZNoC88x3iNHacdiXDItY0rtY85HrQ26uyJu9UovKtmYmZRHsIbGMpDta5Q1p4vfaCIr-YUayDrCweZJiQDEEcOSpWJ7O7RMk3pRkX_4UmPHFzrOI2lMp1jQIhxnSTE7EVAz_4z8h8r46muSkpF54Ic4XSawHKqdSLHx8T05LB0MpvOzWMPS6c1uHA"
+ console.log(config.custom, "==========")
+ config.header['Authorization'] =
+ "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiJBRE1JTiIsIlVzZXJJZCI6IjEiLCJzY29wZSI6WyJhbGwiXSwiVXNlclJlYWxOYW1lIjoi6LaF57qn566h55CG5ZGYIiwiVXNlclh6cWhkbSI6IjQyMDUiLCJleHAiOjI1MTk3NzIwMTAsImp0aSI6ImExNTcxYzk1LTBkNjMtNDkyYi1iOWEyLTE2ZTIzNTQ5ZTY1ZiIsImNsaWVudF9pZCI6InVzZXItc2VydmljZSJ9.ebNVZrw9LbhKaj2w6RR8b2wccQiDkhvBeq79SxxCK-yWiOlIFqBkotTN4TNJg8umcpyYvLILwvqXWRJhffEtgi25sX2y6MqLIWM4kMZ9d8ptdnSmTpBPhltSiQOM0KFa1kl5nSDCBwYOLn-pESJglam76cjpgZNoC88x3iNHacdiXDItY0rtY85HrQ26uyJu9UovKtmYmZRHsIbGMpDta5Q1p4vfaCIr-YUayDrCweZJiQDEEcOSpWJ7O7RMk3pRkX_4UmPHFzrOI2lMp1jQIhxnSTE7EVAz_4z8h8r46muSkpF54Ic4XSawHKqdSLHx8T05LB0MpvOzWMPS6c1uHA"
config.header["Content-Type"] = "application/json";
}
if (accessToken) {
@@ -72,35 +73,6 @@
return response.data
}
- //对该区域做处理
- if (response.data.resultList && response.data.resultList.length > 0) {
- response.data.resultList = response.data.resultList.map(item => {
- if (item.city_nm && item.city_nm == '恩施土家族苗族自治州') {
- item.city_nm = '恩施州'
- }
-
- if (item.ad_nm && item.ad_nm == '恩施土家族苗族自治州') {
- item.ad_nm = '恩施州'
- }
-
- if (item.ad_name && item.ad_name == '恩施土家族苗族自治州') {
- item.ad_name = '恩施州'
- }
- return item
- })
- }
-
- //对该区域做处理
- if (response.data.data && (response.data.data instanceof Array) && response.data.data.length > 0) {
- response.data.data = response.data.data.map(item => {
- if (item.c_name && item.c_name == '恩施土家族苗族自治州') {
- item.c_name = '恩施州'
- }
- return item
- })
- }
-
-
// 服务端返回的状态码不等于200,则reject()
if (response.data.code) {
if (response.data.code !== 200) {
@@ -143,7 +115,7 @@
success: res => {
if (res.confirm) {
uni.redirectTo({
- url: `/pages/login/index?redirect=/${currentPage.route}`
+ url: `/pages/login/login-account?redirect=/${currentPage.route}`
})
} else if (res.cancel) {
console.log('用户点击取消');
diff --git a/mixin/loginMixin.js b/mixin/loginMixin.js
new file mode 100644
index 0000000..3a6df83
--- /dev/null
+++ b/mixin/loginMixin.js
@@ -0,0 +1,43 @@
+export default {
+ data() {
+ return {
+ radioGroupValue: '', //当前 radioGroup 选中的值
+ radioValue: '', // 当前 radio 的值
+ num: 0, //用于区分是否是重复选中
+ }
+ },
+ methods: {
+ isPrivacyCheck() {
+ if (this.radioValue != "check") {
+ uni.showToast({
+ title: "请先同意隐私政策",
+ icon: "none",
+ complete: () => {
+ return false
+ }
+ })
+ } else {
+ return true
+ }
+ },
+ groupChange(n) {
+ if (n == this.radioValue && this.num == 0) {
+ // 第一次相等即执行以下代码
+ this.num++
+ } else {
+ // 第一次后相等即执行以下代码
+ // 置空 radioGroupValue 即取消选中的值
+ this.radioGroupValue = ''
+ this.radioValue = ''
+ // 初始化 num
+ this.num = 0
+ }
+ },
+ // 当切换其他选项的时候此方法才会执行
+ radioChange(n) {
+ this.radioValue = n
+ // 切换选项后需要初始化 num
+ this.num = 0
+ },
+ }
+}
\ No newline at end of file
diff --git a/pages.json b/pages.json
index c5ca68c..4609b3a 100644
--- a/pages.json
+++ b/pages.json
@@ -12,15 +12,6 @@
"navigationStyle": "custom"
}
},
- //巡查首页
- {
- "path": "pages/home/patrolIndex",
- "style": {
- "navigationBarTitleText": "首页",
- "enablePullDownRefresh": true,
- "navigationStyle": "custom"
- }
- },
{
"path": "pages/user/center",
"style": {
@@ -30,7 +21,7 @@
}
},
{
- "path": "pages/login/index",
+ "path": "pages/login/login-account",
"style": {
// "navigationBarTitleText": "",
"enablePullDownRefresh": false,
@@ -393,9 +384,6 @@
"backgroundColor": "#ffffff",
"list": [{
"pagePath": "pages/home/index"
- },
- {
- "pagePath": "pages/home/patrolIndex"
},
{
"pagePath": "pages/user/center"
diff --git a/pages/home/index.vue b/pages/home/index.vue
index 78401bc..a80f0f6 100644
--- a/pages/home/index.vue
+++ b/pages/home/index.vue
@@ -1,45 +1,45 @@
<template>
<view class="container">
- <u-navbar height="48" bgColor="#5887f9" :autoBack="false" safeAreaInsetTop placeholder>
+ <u-navbar height="48" bgColor="#5887f9" :autoBack="false" safeAreaInsetTop placeholder>
<view slot="left">
<u--text color="#ffffff" text="基层智治" size="18" />
</view>
</u-navbar>
-
+
<view class="main">
<view class="main-bg">
-
+
</view>
-
+
<view class="main-select">
<u-icon name="map" color="#fff"></u-icon>
<view>
当前场所:暂无绑定场所信息
</view>
</view>
-
+
<view class="main-btn">
-
+
</view>
-
+
<view class="main-phone">
<view></view>
<view></view>
<view></view>
</view>
-
+
<view class="main-bt">
<view class="main-live">
-
+
</view>
-
+
<view class="main-taska">
-
+
</view>
</view>
</view>
- <tabBar @change='change' :currentTab="0-0" :tabList="tabList"></tabBar>
+ <tabBar @change='change' :currentTab="0" :tabList="tabList"></tabBar>
</view>
</template>
@@ -57,6 +57,10 @@
}
},
+ onShow() {
+ uni.hideTabBar()
+ },
+
methods: {
change(index) {
let url = index
@@ -70,23 +74,23 @@
.container {
width: 100%;
height: 100%;
-
+
display: flex;
flex-direction: column;
background: #F9F9FA;
color: #fff;
-
+
.main {
position: relative;
height: 0;
flex: 1;
overflow-y: auto;
-
+
.main-bg {
height: 36%;
background: royalblue;
}
-
+
.main-select {
margin: 0 6%;
position: absolute;
@@ -94,7 +98,7 @@
display: flex;
align-items: center;
}
-
+
.main-btn {
margin: 0 6%;
position: absolute;
@@ -104,32 +108,32 @@
background: #fff;
border-radius: 10rpx;
}
-
+
.main-phone {
display: flex;
position: absolute;
top: 52%;
width: 100%;
height: 12%;
-
+
view {
margin: 0 16rpx;
flex: 1;
- background: linear-gradient( to right, #407BE9, #73A2F9);
+ background: linear-gradient(to right, #407BE9, #73A2F9);
border-radius: 10rpx;
}
}
-
+
.main-bt {
position: absolute;
top: 66%;
width: 100%;
-
+
.main-live {
height: 180rpx;
background: #fff;
}
-
+
.main-taska {
margin-top: 16rpx;
height: 240rpx;
diff --git a/pages/home/patrolIndex.vue b/pages/home/patrolIndex.vue
deleted file mode 100644
index a459309..0000000
--- a/pages/home/patrolIndex.vue
+++ /dev/null
@@ -1,768 +0,0 @@
-<template>
- <view class="container">
- <view class="head">
- <view class="top-nav-bar">
- <u-navbar leftText="返回" bgColor="#5887f9" :autoBack="false">
- <view slot="left">
- <u--text color="#ffffff" text="荆楚水库" size="18" />
- </view>
- </u-navbar>
- </view>
-
- <view class="search">
- </view>
- </view>
- <view class="place" style="height: 100rpx; background-color: #5887f9;"></view>
- <view class="main">
- <!--导航-->
- <view class="service-box">
- <u-grid col="5" :border="false">
- <u-grid-item v-for="(item,index) in serviceList" :key="index">
- <view @click="navigatorService(item)" class="service-item">
- <image :src="item.img" mode="widthFix" class="img"></image>
- <view class="name">{{ item.name }}</view>
- </view>
- </u-grid-item>
- </u-grid>
- </view>
- <!--预警消息-->
- <view class="notice">
- <u-notice-bar direction="row" :text="noticeList" @click="navigatorMessage"></u-notice-bar>
- </view>
-
-
- <!--我的待办-->
- <view class="card-view">
- <card>
- <view class="card-head" slot="insideHead">
- <view class="left">
- <view class="icon_item">
- <image class="img-icon" :src="imgList.ssxq"></image>
- </view>
- <view>
- <text class="text">我的待办</text>
- </view>
- </view>
- </view>
- <view class="card-content" slot="content">
- <view class="tab_title flex a_g_c">
- <view class="tab_item flex a_g_c j_c_e" :class="{active:tabIndex==1}" @click="changeTab(1)">
- <view class="name" :class="{boder:tabIndex==1}">巡查任务</view>
- <view class="curcle"><span class="curcle_name">{{xcList.length}}</span></view>
- </view>
- </view>
- <view class="box_content" v-show="tabIndex==1">
- <view v-if="xcList.length>0">
- <view class="box_item" v-for="item in xcList" :key="item.id">
- <view class="title">
- {{item.label}}
- </view>
- <view class="button">
- <text v-if="item.state ==1" @click="startPatrol(item)">开始任务</text>
- <text v-if="item.state ==2" @click="startPatrol(item)">继续任务</text>
- <text v-if="item.state ==3" @click="startPatrol(item)">巡查处理</text>
- </view>
- </view>
- </view>
- <view v-else>
- <u-empty mode="data" />
- </view>
- </view>
-
- <view class="box_content" v-show="tabIndex==2">
- <view v-if="jcsbList.length>0">
- <view class="box_item" v-for="item in jcsbList" :key="item.id">
- <view class="title">
- {{item.label}}
- </view>
- <view class="button">
- <text @click="solveReport(item)">处理</text>
- </view>
- </view>
- </view>
- <view v-else>
- <u-empty mode="data" />
- </view>
- </view>
- <view style="padding-top: 20rpx;"></view>
- </view>
- </card>
- </view>
-
- <!--我的水库-->
- <view class="card-view">
- <card>
- <view class="card-head" slot="insideHead">
- <view class="left">
- <view class="icon_item">
- <image class="img-icon" :src="imgList.rbgl"></image>
- </view>
- <view class="text">
- <text>我的责任水库</text>
- </view>
- </view>
- </view>
- <view class="card-content my-reservoir" slot="content">
- <List :list="skList" />
- </view>
- </card>
- </view>
-
-
- </view>
- <tabBar @change="change" :currentTab="tabList.length==2?0-0:1-0" :tabList="tabList"></tabBar>
- </view>
-</template>
-
-<script>
- import tabBar from "@/components/tabBar/tabBar.vue"
- import card from "@/components/my-components/card.vue"
- import List from "./components/List.vue"
- import {
- reservoirList
- } from "@/api/dataCenter/reservoir/reservoir"
- import {
- convertTimestampToDate
- } from "@/utils/date"
- import {
- updatePatrolTask
- } from "@/api/patrol/patrol"
-
- import {
- dateFormat
- } from "@/utils/date"
- import {
- getAll
- } from "@/api/jcsb/dangerReport/dangerReport"
- import shareMixin from "@/mixin/shareMixin"
- import {
- taskTodoList
- } from "@/api/patrol/patrolTask"
- import {
- getMessageList
- } from "@/api/system/message";
- export default {
- mixins: [shareMixin],
- components: {
- tabBar,
- card,
- List
- },
- data() {
- return {
- noticeList: "暂无预警信息",
- tabList: uni.getStorageSync("tabBarList"),
- tabBarIndex: uni.getStorageSync("tabbarIndex"),
- tabIndex: 1,
- imgList: {
- rbgl: "https://sk.hubeishuiyi.cn/business/xcxImg/homeImg/skPoint.png",
- ssxq: "https://sk.hubeishuiyi.cn/business/xcxImg/homeImg/db.png",
- _24Rain: "https://sk.hubeishuiyi.cn/business/xcxImg/homeImg/24rain.png",
- responsible: "https://sk.hubeishuiyi.cn/business/xcxImg/homeImg/responsible.png",
- importantPart: "https://sk.hubeishuiyi.cn/business/xcxImg/homeImg/importantPart.png",
- warn: "https://sk.hubeishuiyi.cn/business/xcxImg/homeImg/warn.png",
- plate: "https://sk.hubeishuiyi.cn/business/xcxImg/homeImg/plate.png",
- },
- xcList: [],
- patrolTotal: "0",
- jcsbList: [],
- reportTotal: "0",
- serviceList: [{
- name: "安全巡检",
- img: "https://sk.hubeishuiyi.cn/business/xcxImg/homeImg/patrol.png",
- url: "/subPackage/patrol/patrol"
- },
- {
- name: "水库调度",
- img: "https://sk.hubeishuiyi.cn/business/xcxImg/homeImg/ddmk.png",
- url: "/subPackage/jcsb/modules/scheduling"
- },
- {
- name: "水库管护",
- img: "https://sk.hubeishuiyi.cn/business/xcxImg/homeImg/gh.png",
- url: "/subPackage/jcsb/manageProtect/index"
- },
- {
- name: "险情上报",
- img: "https://sk.hubeishuiyi.cn/business/xcxImg/homeImg/jcsb.png",
- url: "/subPackage/jcsb/jcsb/index"
- },
- {
- name: "监测上报",
- img: "https://sk.hubeishuiyi.cn/business/xcxImg/homeImg/jcsb.png",
- url: "/subPackage/jcsb/db/index"
- },
- ],
- skList: [],
- reservoirList: [],
- resIds: "",
- publicPath: "https://sk.hubeishuiyi.cn/business/",
- }
- },
- onReady() {
- uni.hideTabBar()
- },
- onLoad() {
- // #ifdef MP-WEIXIN
- this.userIsLogin()
- // #endif
- },
- onShow() {
- this.tabList = uni.getStorageSync("tabBarList")
- this.tabBarIndex = uni.getStorageSync("tabbarIndex")
- this.init()
- this.getMessage()
- },
- onPullDownRefresh() {
- if (this.tabIndex == 2) {
- // this.getJcsbList()
- } else if (this.tabIndex == 1) {
- this.getXcList()
- }
- },
- methods: {
-
- getMessage() {
- let params = {
- recipient: uni.getStorageSync("userInfo").user_id,
- isPage: 0,
- createTime: dateFormat(new Date(), "yyyy-MM-dd hh:mm:ss")
- }
-
- getMessageList(params).then(res => {
- let data = res.data
- if (data.length > 0) {
- this.noticeList = ""
- data.forEach(e => {
- this.noticeList = this.noticeList + e.content
- })
- }
- })
- },
- navigatorMessage() {
- let url = "/subPackage/user/message/index"
- this.$u.func.globalNavigator(url, "navTo")
- },
-
-
- userIsLogin() {
- if (this.userInfo.access_token) {
-
- } else {
- uni.showModal({
- title: "提示",
- content: "请登录",
- showCancel: false,
- success: res => {
- if (res.confirm) {
- this.$u.func.globalNavigator("/pages/login/index", "redTo")
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- }
- })
- }
- },
- changeTab(index) {
- this.tabIndex = index
- },
- change(index) {
- let url = this.tabList[index].path
- this.$u.func.globalNavigator(url, "switchTab")
- },
- init() {
- //去重
- let arr = this.userInfo.detail.resIds.split(",")
- var filterArr = arr.filter(function(item, index) {
- return arr.indexOf(item) === index; // 因为indexOf 只能查找到第一个
- });
- this.resIds = filterArr.map(e => `'${e}'`).join(",")
- this.getReservoirList()
- this.getXcList()
- this.getJcsbList()
- },
- //获取水库列表数据
- async getReservoirList() {
- if (this.resIds == "") return
- let resIds = this.resIds
- const res = await reservoirList(100, 1, {
- res_cds: resIds
- })
- const {
- data
- } = res
- this.skList = []
- data.data.forEach(item => {
- //处理传回来的数据
- if (item.tm) {
- item.tm = convertTimestampToDate(item.tm, "MM-dd hh:mm")
- }
- item.regionName = this.convertRegion(item)
- item.current_site_image = ''
- item.current_site_image_index = ''
- item.imagesArray = []
-
- if (item.station_image && item.station_image.trim().length > 0) {
-
- let arr = []
-
- if (item.station_image.indexOf(',') != -1) {
- arr = item.station_image.split(',').map(arrItem => {
- if (arrItem.indexOf('~') != -1) {
- if (arrItem.split('~').length > 2) {
- arrItem = arrItem.split('~')
- } else {
- let cur = arrItem.split('~')
- cur.push(this.publicPath + 'img/emptyImg.514374af.png')
- arrItem = cur
- }
- }
-
- return arrItem
- })
- } else {
- if (item.station_image.indexOf('~') != -1) {
- if (item.station_image.split('~').length > 2) {
- arr = [item.station_image.split('~')]
- } else {
- let cur = item.station_image.split('~')
- cur.push(this.publicPath + 'img/emptyImg.514374af.png')
- arr = [cur]
- }
- }
- }
-
- if (arr && arr.length > 0) {
- arr.forEach(arrItem => {
-
- let urlStr = arrItem[2]
-
- if (urlStr.indexOf(
- 'http://183.95.190.143:9096/images') !=
- -
- 1) {
- urlStr = urlStr.replace(
- 'http://183.95.190.143:9096/images',
- 'https://sk.hubeishuiyi.cn/imgWLW/images')
- }
-
- if (urlStr.indexOf(
- 'http://223.75.53.106:8891/skjgimages') != -
- 1) {
- urlStr = urlStr.replace(
- `http://223.75.53.106:8891/skjgimages`,
- `https://sk.hubeishuiyi.cn/imgLK/skjgimages`
- )
- }
-
- item.imagesArray.push({
- title: arrItem[1],
- url: urlStr
- })
- })
- }
-
- item.current_site_image = item.imagesArray.length > 0 ? item.imagesArray[0] : ''
-
- item.current_site_image_index = item.imagesArray.length > 0 ? 0 : ''
- item.current_site_image.url = item.current_site_image.url.replace(/\\/g, "/");
- }
-
- if (item.rz && item.rz_1h) {
- item.powerIconShow = true
-
- if (item.rz - item.rz_1h > 0) {
- item.iconClass = 'icon-wendushangsheng'
- } else if (item.rz - item.rz_1h < 0) {
- item.iconClass = 'icon-wenduxiajiang'
- }
-
- } else {
- item.powerIconShow = false
- }
- })
- this.skList = data.data
- },
- //行政区划转换
- convertRegion(item) {
- let arr = []
- if (item.city_nm) {
- arr.push(item.city_nm)
- }
- if (item.county_nm) {
- arr.push(item.county_nm)
- }
- if (item.town_nm) {
- arr.push(item.town_nm)
- }
- return arr.join("-")
- },
- //获取巡查列表
- async getXcList() {
- this.xcList = []
- let params = {
- currentUserId: this.userInfo.user_id,
- // finish: '2',
- }
- const res = await taskTodoList(1, 1000, params)
- let data = res.data.records
- let index = 1
- data.forEach(e => {
- e.label = index + "、" + e.title
- this.xcList.push(e)
- index++
- })
- uni.stopPullDownRefresh()
- },
- //获取险情上报列表
- async getJcsbList() {
- this.jcsbList = []
- let params = {
- toUser: this.userInfo.user_id,
- status: 2
- }
- const res = await getAll(params)
- let data = res.data
- data.forEach((e, index) => {
- e.label = ++index + "、" + convertTimestampToDate(e.createTime, "MM-dd hh:mm") + e
- .reservoirName + "险情上报"
- this.jcsbList.push(e)
- })
- uni.stopPullDownRefresh()
- },
- navigatorPatrol() {
- let url = "/subPackage/patrol/patrol"
- this.$u.func.globalNavigator(url, "navTo")
- },
- //服务跳转
- navigatorService(item) {
- if (item.url) {
- if (item.name == "安全巡检") {
- if (this.xcList.length == 0) {
- uni.showModal({
- title: "提示",
- content: "当前暂无任务",
- showCancel: false
- })
- return
-
- }
- //判断是否有进行中的任务
- let isStarted = this.xcList.filter(e => e.state == "2")
- if (isStarted.length > 0) {
- //有则跳到进行中的任务
- let url = "/subPackage/patrol/patrolReport?task=" + JSON.stringify(isStarted[0])
- this.$u.func.globalNavigator(url, "navTo", item.name)
- } else {
- let filter = this.xcList.filter(e => {
- return e.state == 1
- })
-
- if (filter.length > 0) {
- //没有就拿第一个任务开始,并更新状态
- filter[0].state = "2"
- let date = new Date()
- let realStartTime = dateFormat(date)
- updatePatrolTask({
- id: filter[0].id,
- state: filter[0].state,
- realStartTime: realStartTime
- })
- let url = "/subPackage/patrol/patrolReport?task=" + JSON.stringify(this.xcList[0])
- this.$u.func.globalNavigator(url, "navTo", item.name)
- } else {
- //提示暂无巡查任务
- uni.showModal({
- title: "提示",
- content: "当前暂无任务",
- showCancel: false
- })
- return
- }
-
-
- }
- } else {
- this.$u.func.globalNavigator(item.url, "navTo", item.name)
- }
- } else {
- uni.showModal({
- title: "提示",
- content: "功能开发中!",
- showCancel: false
- })
- }
- },
- //开始巡查或继续巡查
- startPatrol(item) {
- if (item.state == "1") {
- //判断是否有已经开始的任务
- let isStarted = this.xcList.some(e => e.state == "2")
- if (isStarted) {
- //有已经开始的任务;提示需要完成进行中的任务
- this.$u.func.showToast({
- title: "请完成已经进行中的任务"
- })
- return
- } else {
- //没有已经开始的任务,开始该任务,修改任务状态
- item.state = "2"
- let date = new Date()
- let realStartTime = dateFormat(date)
- updatePatrolTask({
- id: item.id,
- state: item.state,
- realStartTime: realStartTime
- })
- let url = "/subPackage/patrol/patrolReport?task=" + JSON.stringify(item)
- this.$u.func.globalNavigator(url, "navTo")
- }
- } else if (item.state == '2') {
- let url = "/subPackage/patrol/patrolReport?task=" + JSON.stringify(item)
- this.$u.func.globalNavigator(url, "navTo")
- } else if (item.state == '3') {
- let url = "/subPackage/patrol/patrolHandle?task=" + JSON.stringify(item)
- this.$u.func.globalNavigator(url, "navTo")
- }
-
-
- },
- //解决险情上报
- solveReport(item) {
- let url = "/subPackage/jcsb/jcsb/index?dangerReport=" + JSON.stringify(item)
- this.$u.func.globalNavigator(url, "navTo")
- }
- }
- }
-</script>
-
-<style scoped lang="scss">
- .container {
- display: flex;
- flex-direction: column;
- min-height: 100vh;
- overflow: hidden;
- background-color: #f9f9fa;
- }
-
- .active {
- color: #4593F2 !important;
- }
-
- .boder {
- border-bottom: 4rpx solid #4593F2;
- color: #4593F2 !important;
- }
-
- .border::after {
- content: "";
- padding-top: 4rpx;
- }
-
- .tab_title {
- justify-content: space-evenly;
- font-size: 28rpx;
-
- .name {
- font-weight: 700;
- color: #BBBBBB;
- padding-bottom: 10rpx;
- }
-
- .curcle {
- margin-left: 10rpx;
- width: 38rpx;
- height: 38rpx;
- background: #FF1919;
- border-radius: 50%;
- font-size: 20rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-bottom: 10rpx;
-
- .curcle_name {
- font-size: 20rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #FFFFFF;
- }
-
- }
- }
-
- .box_content {
- width: 680rpx;
- margin: 20rpx auto;
- background: #F9F9FA;
-
- .box_item {
- display: flex;
- justify-content: space-between;
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: 500;
- padding-top: 26rpx;
- padding-left: 36rpx;
- padding-right: 36rpx;
- color: #333333;
-
- .button {
- color: #55aaff;
- }
- }
-
-
- .box_item:last-child {
- padding-bottom: 26rpx;
- }
- }
-
- .flex {
- display: flex;
- }
-
- .a_g_c {
- align-items: center;
- }
-
- .j_c_e {
- justify-content: space-evenly;
- }
-
- .main {
- position: relative;
- top: -44rpx;
- flex: 1;
- }
-
- .top-nav-bar {
- height: 81rpx;
- }
-
- .search {
- height: 20rpx;
- display: flex;
- background-color: #5887f9;
- padding: 30rpx;
- }
-
- .record {
- padding: 20rpx 0 40rpx 0;
-
- .item {
- font-size: 24rpx;
- font-weight: bold;
- color: #333333;
- width: 254rpx;
- height: 120rpx;
- border-radius: 14rpx;
- justify-content: center;
- }
-
- .bg_blue {
- background-color: #EFF6FD;
- }
-
- .bg_skyyel {
- background-color: #FCF7EE;
- }
- }
-
- .record_img {
- width: 74rpx;
- height: 74rpxF;
- }
-
- .service-box {
- background: #ffffff;
- padding: 30rpx 0 10rpx 0;
- border-radius: 20rpx 20rpx 0px 0px;
- width: 100%;
- display: flex;
- flex-direction: column;
- justify-content: space-around;
-
-
- .service-item {
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- align-items: center;
- width: 100%;
- font-size: 26rpx;
- font-weight: 500;
- color: #585b61;
- padding: 5px 0;
-
- .img {
- width: 88rpx;
- height: 88rpx;
- }
-
- .name {
- height: 13px;
- font-size: 13px;
- font-weight: bold;
- color: #333333;
- padding: 20rpx 0 34rpx 0;
- }
- }
- }
-
- .card-head {
- display: flex;
- justify-content: space-between;
- padding: 12rpx;
-
- .left {
- display: flex;
- align-items: center;
-
- .icon_item {
- font-size: 0;
- }
-
- .img-icon {
- width: 32rpx;
- height: 40rpx;
- }
-
- .text {
- font-family: PingFang-SC-Bold;
- font-weight: Bold;
- color: #333333;
- font-size: 40rpx;
- margin-left: 20rpx;
- }
- }
-
- .right {
- display: flex;
- align-items: center;
- font-weight: Bold;
- color: #4593f2;
- font-size: 20px;
-
- .img-icon {
- width: 20rpx;
- height: 14rpx;
- }
- }
-
- }
-
- .card-content {
- border-radius: 20rpx;
-
- .btn-group {
- display: flex;
- padding: 20rpx;
-
- .btn-active {
- background-color: #e7e7e7;
- color: #4593F2;
- }
- }
- }
-</style>
\ No newline at end of file
diff --git a/pages/login/login-account.vue b/pages/login/login-account.vue
new file mode 100644
index 0000000..62fcd42
--- /dev/null
+++ b/pages/login/login-account.vue
@@ -0,0 +1,353 @@
+<template>
+ <view class="container">
+ <view class="logo">
+ <!-- <image src="https://sk.hubeishuiyi.cn/business/xcxImg/wxlogo.png" lazy-load show-menu-by-longpress
+ style="width: 100rpx;height: 100rpx;"></image> -->
+ <view class="title">基层智治</view>
+ </view>
+ <view class="content">
+ <view class="top">
+ <u--form labelPosition="top" labelWidth="60" :model="form" :rules="rules" ref="form">
+ <view class="cell">
+ <u-form-item label="账号:" borderBottom ref="phone">
+ <u-input v-model="form.phone" border="none" placeholder="请输入登录账号"></u-input>
+ </u-form-item>
+ </view>
+ <view class="cell">
+ <u-form-item label="密码:" prop="password" borderBottom ref="password">
+ <view style="display: flex; width: 100%;">
+ <!-- #ifdef MP-WEIXIN -->
+ <u-input v-if="passwordProps.passwordType == 'password'" type="password"
+ v-model="form.password" border="none" placeholder="请输入密码">
+ </u-input>
+ <u-input v-else type="text" v-model="form.password" border="none" placeholder="请输入密码">
+ </u-input>
+ <u-icon @click="showPassword" :name="passwordProps.passwordIcon" color="#000000"
+ size="25"></u-icon>
+ <!-- #endif -->
+ <!-- #ifdef APP-PLUS-->
+ <u-input :type="passwordProps.passwordType" v-model="form.password" border="none"
+ placeholder="请输入密码"></u-input>
+ <u-icon @click="showPassword" :name="passwordProps.passwordIcon" color="#000000"
+ size="25"></u-icon>
+ <!-- #endif -->
+ <!-- #ifdef H5-->
+ <u-input v-if="passwordProps.passwordType == 'password'" type="password"
+ v-model="form.password" border="none" placeholder="请输入密码">
+ </u-input>
+ <u-input v-else type="text" v-model="form.password" border="none" placeholder="请输入密码">
+ </u-input>
+ <u-icon @click="showPassword" :name="passwordProps.passwordIcon" color="#000000"
+ size="25"></u-icon>
+ <!-- #endif -->
+ </view>
+ </u-form-item>
+ </view>
+ </u--form>
+
+ <button class="submit" @click="submit" :disabled="disabled">登录</button>
+ <view class="page-change">
+ </view>
+ </view>
+ </view>
+ </view>
+</template>
+
+<script>
+ import md5 from '@/utils/md5.js'
+ import loginMixin from '@/mixin/loginMixin'
+ export default {
+ onLoad(option) {
+ const {
+ redirect
+ } = option
+ if (redirect) this.redirect = redirect
+ },
+ mixins: [loginMixin],
+ data() {
+ return {
+ tenantId: '000000',
+ form: {
+ phone: "",
+ password: ""
+ },
+ rules: {
+ 'phone': [{
+ type: 'string',
+ required: true,
+ message: '请填写手机号',
+ trigger: ['blur', 'change']
+ },
+ {
+ validator: (rule, value, callback) => {
+ return uni.$u.test.mobile(value);
+ },
+ message: '手机号码不正确',
+ trigger: ['change', 'blur'],
+ }
+ ],
+ 'password': {
+ type: 'string',
+ required: true,
+ message: '请输入密码',
+ trigger: ['blur', 'change']
+ }
+ },
+ disabled: false,
+ redirect: '',
+ passwordProps: {
+ passwordIcon: "eye-off",
+ passwordType: "password"
+ }
+ }
+ },
+ methods: {
+ submit() {
+ const that = this
+ this.$refs.form.validate().then(res => {
+ this.$u.api
+ .token(this.tenantId, this.form.phone, md5(this.form.password))
+ .then(data => {
+ this.$u.func.login(data)
+ })
+ .catch(err => {
+ this.$u.func.showToast({
+ title: err.data.error_description
+ })
+ })
+ })
+ },
+ handleInputCheck() {
+ this.disabled = false
+ },
+ showPassword() {
+ this.passwordProps.passwordIcon == "eye-off" ? this.$set(this.passwordProps, "passwordIcon", "eye-fill") :
+ this.$set(this.passwordProps, "passwordIcon", "eye-off")
+ this.passwordProps.passwordType == "password" ? this.$set(this.passwordProps, "passwordType", "text") :
+ this.$set(this.passwordProps, "passwordType", "password")
+ }
+ }
+ }
+</script>
+
+<style lang="scss">
+ .privacy-policy {
+ width: 100%;
+ padding: 40rpx 40rpx 0 80rpx;
+ font-size: 28rpx;
+ }
+
+ .container {
+ min-height: 100vh;
+ overflow: hidden;
+ // background: url("https://sk.hubeishuiyi.cn/business/xcxImg/reservoirImg/default.jpg") no-repeat;
+ background-size: 100% 100%;
+
+ .set-icon {
+ vertical-align: middle;
+ width: 41rpx;
+ height: auto;
+ margin-right: 35rpx;
+ }
+ }
+
+ .logo {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ padding: 200rpx 0;
+
+ image {
+ box-shadow: 4rpx 4rpx 20rpx #fafafa;
+ }
+
+ .title {
+ margin-top: 40rpx;
+ font-weight: 700;
+ font-size: 32rpx;
+ }
+ }
+
+ .content {
+ display: flex;
+ flex-direction: column;
+ justify-content: space-around;
+ align-items: center;
+
+ // height: 90vh;
+ width: 100%;
+
+ .top {
+ width: 100%;
+ width: 100%;
+ background: #fff;
+ padding: 20px 0;
+ position: fixed;
+ bottom: 0px;
+ }
+
+ .logo {
+ display: block;
+ width: 281rpx;
+ height: auto;
+ margin: 0 auto 120rpx;
+ }
+
+ .cell {
+ width: 100%;
+ padding: 0 85rpx;
+ box-sizing: border-box;
+ margin-top: 36rpx;
+
+ .name {
+ font-size: 22rpx;
+ font-family: Source Han Sans CN;
+ font-weight: 400;
+ color: #3e4a59;
+ line-height: 30rpx;
+ opacity: 0.72;
+ }
+
+ .input-box {
+ padding: 30rpx 0;
+ border-bottom: 2rpx solid #f6f6f6;
+ display: flex;
+ align-items: center;
+
+ .code {
+ font-size: 22rpx;
+ font-family: Source Han Sans CN;
+ font-weight: 400;
+ color: #0d0d0d;
+ line-height: 30rpx;
+
+ text {
+ color: #5f88ff;
+ }
+ }
+
+ .ipt {
+ flex: 1;
+ font-size: 24rpx;
+ }
+
+ .hold {
+ font-size: 26rpx;
+ font-family: Source Han Sans CN;
+ font-weight: 400;
+ color: #3e4a59;
+ line-height: 30px;
+ opacity: 0.45;
+ }
+ }
+ }
+
+ .agree {
+ margin: 27rpx 95rpx 0;
+ font-size: 22rpx;
+ font-family: Adobe Heiti Std;
+ font-weight: normal;
+ color: #cacaca;
+ line-height: 34rpx;
+
+ .a {
+ color: #000000;
+ }
+ }
+
+ .submit {
+ margin: 60rpx 90rpx 0;
+ border: none;
+ width: 572rpx;
+ height: 86rpx;
+ line-height: 86rpx;
+ box-sizing: border-box;
+ border-radius: 15rpx;
+ background-color: #5f88ff;
+ color: #ffffff;
+
+ &::after {
+ content: none;
+ }
+
+ &::before {
+ content: none;
+ }
+
+ &[disabled='true'] {
+ background: #e4e4e4;
+ font-size: 36rpx;
+ font-family: Source Han Sans CN;
+ font-weight: 500;
+ color: #ffffff;
+ }
+ }
+
+ .tip {
+ margin-top: 30rpx;
+ text-align: center;
+ font-size: 22rpx;
+ font-family: Adobe Heiti Std;
+ font-weight: normal;
+ color: #cacaca;
+ line-height: 34rpx;
+ }
+
+ .change {
+ margin-top: 20rpx;
+ text-align: center;
+ font-size: 22rpx;
+ font-family: Adobe Heiti Std;
+ font-weight: normal;
+ color: #5f88ff;
+ line-height: 34rpx;
+ }
+
+ .tag {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ font-size: 22rpx;
+ font-family: Adobe Heiti Std;
+ font-weight: normal;
+ color: #9f9f9f;
+ line-height: 34rpx;
+
+ &::before {
+ content: '';
+ display: block;
+ width: 160rpx;
+ height: 1px;
+ background: #d8d8d8;
+ opacity: 0.86;
+ }
+
+ &::after {
+ content: '';
+ display: block;
+ width: 160rpx;
+ height: 1px;
+ background: #d8d8d8;
+ opacity: 0.86;
+ }
+ }
+
+ .chat-arr {
+ margin-top: 50rpx;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+
+ .icon {
+ width: 73rpx;
+ height: 73rpx;
+ }
+ }
+
+ .page-change {
+ display: flex;
+ justify-content: space-evenly;
+ }
+ }
+</style>
\ No newline at end of file
diff --git a/pages/user/center.vue b/pages/user/center.vue
index d1d33e7..7d90422 100644
--- a/pages/user/center.vue
+++ b/pages/user/center.vue
@@ -1,32 +1,29 @@
<template>
<view class="container">
- <u-navbar height="48" bgColor="#5887f9" :autoBack="false" safeAreaInsetTop placeholder>
+ <u-navbar height="48" bgColor="#5887f9" :autoBack="false" safeAreaInsetTop placeholder>
<view slot="left">
<u--text color="#ffffff" text="基层智治" size="18" />
</view>
</u-navbar>
-
+
<view class="main">
<view class="main-bg">
-
+
</view>
-
-
+
+
<view class="main-cell">
<view class="cell-content">
<u-cell-group :border="false">
- <u-cell :isLink="true"
- v-for="(item, index) in cellGroupData" :icon="item.icon" :title="item.title"
- :url="item.url"
- :key="index" :border="false"
- ></u-cell>
+ <u-cell @click="navigator(item)" v-for="(item, index) in cellGroupData" :icon="item.icon"
+ :title="item.title" :key="index" :border="false"></u-cell>
</u-cell-group>
</view>
</view>
-
+
</view>
- <tabBar @change='change' :currentTab="0-0" :tabList="tabList"></tabBar>
+ <tabBar @change='change' :currentTab="1"></tabBar>
</view>
</template>
@@ -40,9 +37,7 @@
data() {
return {
- tabList: uni.getStorageSync("tabBarList") || [],
- cellGroupData: [
- {
+ cellGroupData: [{
title: '我的家人',
icon: 'account-fill',
url: ''
@@ -65,11 +60,32 @@
]
}
},
+ onShow() {
+ uni.hideTabBar()
+ },
methods: {
change(index) {
let url = index
this.$u.func.globalNavigator(url, "switchTab")
+ },
+
+ navigator(item) {
+
+ if (item.title == '退出登录') {
+ this.logOut()
+ } else {
+ this.$u.func.globalNavigator(item.url)
+ }
+
+ },
+
+ logOut() {
+ uni.setStorageSync("responIndex", 0)
+ uni.clearStorageSync()
+ uni.reLaunch({
+ url: "/pages/login/login-account"
+ })
},
}
}
@@ -79,31 +95,31 @@
.container {
width: 100%;
height: 100%;
-
+
display: flex;
flex-direction: column;
background: #F9F9FA;
-
+
.main {
position: relative;
height: 0;
flex: 1;
overflow-y: auto;
-
+
.main-bg {
height: 36%;
background: royalblue;
}
-
+
.main-cell {
position: absolute;
top: 34%;
width: 100%;
height: 66%;
- border-radius: 10rpx 10rpx 0 0 ;
+ border-radius: 10rpx 10rpx 0 0;
z-index: 11;
background: #fff;
-
+
.cell-content {
margin-top: 240rpx;
}
diff --git a/subPackage/user/components/roleList.vue b/subPackage/user/components/roleList.vue
index f484e7f..18d35fa 100644
--- a/subPackage/user/components/roleList.vue
+++ b/subPackage/user/components/roleList.vue
@@ -1,15 +1,15 @@
<template>
<view class="role-container">
- <view v-for="(item, index) in roleData">
+ <view @click="activeRole(item)" v-for="(item, index) in roleData" :key="index" :class="item.active?'active':''">
<view class="l">
<u-icon :name="item.iconName"></u-icon>
<view class="role-name">
{{item.roleName}}
</view>
</view>
-
- <view class="r">
- <u-icon name="checkmark"></u-icon>
+
+ <view v-if="item.active" class="r">
+ <u-icon name="checkmark" color="#2979ff"></u-icon>
</view>
</view>
</view>
@@ -22,13 +22,33 @@
type: Array,
default: () => []
}
- }
+ },
+ data() {
+ return {}
+ },
+
+ methods: {
+
+ //启用角色
+ activeRole(item) {
+ this.roleData.forEach(role => {
+ if (role.id == item.id) {
+ role.active = true
+ } else {
+ role.active = false
+ }
+ })
+
+ this.$emit("select", item)
+
+ },
+ },
}
</script>
<style lang="scss" scoped>
.role-container {
- & > view {
+ &>view {
display: flex;
justify-content: flex-start;
align-items: center;
@@ -36,16 +56,20 @@
padding: 0 16rpx;
background: #fff;
height: 80rpx;
-
+
.l {
flex: 1;
display: flex;
align-items: center;
-
+
.role-name {
margin-left: 16rpx;
}
}
}
}
+
+ .active {
+ background-color: #e8effb !important;
+ }
</style>
\ No newline at end of file
diff --git a/subPackage/user/role/index.vue b/subPackage/user/role/index.vue
index 0b59059..853c0ea 100644
--- a/subPackage/user/role/index.vue
+++ b/subPackage/user/role/index.vue
@@ -1,70 +1,85 @@
<template>
<view class="container">
<view>
- <role-list :roleData="roleData"></role-list>
+ <role-list :roleData="roleData" @select="select"></role-list>
</view>
-
+
<view class="cur-btn">
- <u-button type="primary" text="确定"></u-button>
+ <u-button @click="submit" type="primary" text="确定"></u-button>
</view>
+
+ <u-loading-page :loading="loading"></u-loading-page>
</view>
</template>
<script>
+ import store from "@/store/index.js"
import roleList from "@/subPackage/user/components/roleList.vue"
-
+ import {
+ dynamicMenu,
+ getRoleListByIds,
+ } from "@/api/system/role.js"
export default {
components: {
roleList
},
-
+
data() {
return {
- cellGroupData: [
- {
- title: '我的家人',
- icon: 'account-fill',
- url: ''
- },
- {
- title: '切换角色',
- icon: 'account-fill',
- url: ''
- },
- {
- title: '修改密码',
- icon: 'account-fill',
- url: ''
- },
- {
- title: '退出登录',
- icon: 'account-fill',
- url: ''
- }
- ],
- roleData: [
- {
- roleName: '居民',
- iconName: 'account-fill'
- },
- {
- roleName: '场所负责人',
- iconName: 'account-fill'
- },
- {
- roleName: '网格员',
- iconName: 'account-fill'
- },
- {
- roleName: '系统管理员',
- iconName: 'account-fill'
- },
- ]
+ roleData: [],
+ selectRole: {},
+
+ loading: false,
}
+ },
+ created() {
+ this.getUserRole()
},
methods: {
-
+ //获取当前角色的所有权限列表
+ async getUserRole() {
+ this.loading = !this.loading
+
+ const res = await getRoleListByIds({
+ roleIds: this.userInfo.role_id
+ })
+ this.roleData = []
+ let data = res.data
+ console.log(data)
+ data.forEach(e => {
+
+ this.roleData.push({
+ id: e.id,
+ iconName: 'account-fill',
+ roleName: e.roleName,
+ active: e.id == this.activeRoleId ? true : false
+ })
+ })
+
+ this.loading = !this.loading
+
+ },
+
+ select(item) {
+ this.selectRole = item
+ },
+
+ async submit() {
+ //保存当前激活的角色
+ store.commit("setActiveRoleId", this.selectRole.id)
+
+ //获取角色菜单
+ const res = await dynamicMenu(this.selectRole.id)
+
+ //把菜单存入store中
+ let data = res.data
+ const appMenu = data.filter(e => e.name == 'app')[0]
+ console.log("菜单:", appMenu)
+
+
+ this.$u.func.showToast("切换角色成功")
+ }
}
}
</script>
@@ -77,7 +92,7 @@
display: flex;
flex-direction: column;
background: #F9F9FA;
-
+
.cur-btn {
margin: 0 20rpx;
position: absolute;
diff --git a/subPackage/user/views/roleSelect.vue b/subPackage/user/views/roleSelect.vue
deleted file mode 100644
index 6a35f75..0000000
--- a/subPackage/user/views/roleSelect.vue
+++ /dev/null
@@ -1,140 +0,0 @@
-<template>
- <view class="container">
- <view class="main">
- <view @click="activeRole(item)" v-for="(item,index) in roleList" :key="index" class="df-ac cell"
- :class="item.active?'active':''">
-
- <view class="df-ac prefix">
- <u-icon name="account-fill" color="#2979ff" size="28"></u-icon>
- <view class="label">{{item.roleName}}</view>
- </view>
-
- <view v-if="item.active" class="suffix">
- <u-icon name="checkbox-mark" color="#2979ff" size="22"></u-icon>
- </view>
-
- </view>
-
- </view>
-
- <view class="submit-btn">
- <u-button @click="submit" type="primary" text="确认"></u-button>
- </view>
-
-
- </view>
-</template>
-
-<script>
- import store from "@/store/index.js"
- import {
- dynamicMenu,
- getRoleListByIds,
- } from "@/api/system/role.js"
- export default {
- data() {
- return {
- roleList: [],
- selectRole: {},
- }
- },
- created() {
- this.getUserRole()
-
- console.log(this.activeRoleId)
- },
- mounted() {
-
- },
- onLoad(option) {
-
- },
- onShow() {
-
- },
- methods: {
- //获取当前角色的所有权限列表
- async getUserRole() {
- const res = await getRoleListByIds({
- roleIds: this.userInfo.role_id
- })
-
- let data = res.data
- data.forEach(e => {
- if (e.id == this.activeRoleId) {
- e.active = true
- } else {
- e.active = false
- }
- })
-
- this.roleList = res.data
- },
-
- //启用角色
- activeRole(item) {
- this.selectRole = item
- this.roleList.forEach(role => {
- if (role.id == item.id) {
- role.active = true
- } else {
- role.active = false
- }
- })
- },
-
- async submit() {
- //保存当前激活的角色
- store.commit("setActiveRoleId", this.selectRole.id)
-
- //获取角色菜单
- const res = await dynamicMenu(this.selectRole.id)
-
- console.log(res, "--------------")
- this.$u.func.showToast("切换角色成功")
-
- }
- }
- }
-</script>
-
-<style scoped lang="scss">
- .container {
- background-color: #fafafa;
- height: 100%;
- display: flex;
- flex-direction: column;
-
- .main {
-
- .cell {
- background-color: #ffffff;
- margin: 20rpx 0;
- padding: 30rpx 20rpx;
- justify-content: space-between;
- height: 30rpx;
-
- .label {
- font-size: 28rpx;
- }
- }
- }
-
- .submit-btn {
- padding: 30rpx;
- position: relative;
- top: 50%;
- }
-
-
- }
-
- .df-ac {
- display: flex;
- align-items: center;
- }
-
- .active {
- background-color: #e8effb !important;
- }
-</style>
\ No newline at end of file
--
Gitblit v1.9.3