调整部分框架
This commit is contained in:
@@ -14,7 +14,7 @@ const getFileInfo = (app, file) => {
|
|||||||
if (/^App/.test(app.name)) {
|
if (/^App/.test(app.name)) {
|
||||||
let {name, label} = app,
|
let {name, label} = app,
|
||||||
path = app.path.replace(/.+[\\\/]([^\\\/]+)[\\\/]([^\\\/]+)$/g, `/apps/$1/$2`)
|
path = app.path.replace(/.+[\\\/]([^\\\/]+)[\\\/]([^\\\/]+)$/g, `/apps/$1/$2`)
|
||||||
apps.list.push({id: name, name, label, path, libPath: file.replace(/\\/g, '/').replace(/^src(\/.+)\.vue/, '$1'), type: 'wxwork'})
|
apps.list.push({id: file.replace(/\.\/?(vue)?/g, '')?.replace(/[\\\/]/g,'_'), name, label, path, libPath: file.replace(/\\/g, '/').replace(/^src(\/.+)\.vue/, '$1'), type: 'wxwork'})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const saveApps = app => {
|
const saveApps = app => {
|
||||||
|
|||||||
38
src/App.vue
38
src/App.vue
@@ -9,6 +9,8 @@ export default {
|
|||||||
},
|
},
|
||||||
onLaunch: function () {
|
onLaunch: function () {
|
||||||
this.repairWxSDK()
|
this.repairWxSDK()
|
||||||
|
this.initLoginBtn()
|
||||||
|
this.getApps()
|
||||||
},
|
},
|
||||||
onShow: function () {
|
onShow: function () {
|
||||||
this.initWaterMarker()
|
this.initWaterMarker()
|
||||||
@@ -19,7 +21,7 @@ export default {
|
|||||||
...mapState(['token', 'user']),
|
...mapState(['token', 'user']),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations(['initWaterMarker', 'logout', 'getConfig']),
|
...mapMutations(['initWaterMarker', 'logout', 'getConfig', 'setApps']),
|
||||||
goto(params, cb) {
|
goto(params, cb) {
|
||||||
let {path: url, query: {app}} = this.$route
|
let {path: url, query: {app}} = this.$route
|
||||||
params.query = {app, ...(params.query || {})}
|
params.query = {app, ...(params.query || {})}
|
||||||
@@ -32,7 +34,28 @@ export default {
|
|||||||
},
|
},
|
||||||
repairWxSDK() {
|
repairWxSDK() {
|
||||||
wx = jWeixin
|
wx = jWeixin
|
||||||
|
},
|
||||||
|
initLoginBtn() {
|
||||||
|
let btn = document.createElement("div")
|
||||||
|
btn.id = "__loginBtn"
|
||||||
|
btn.innerText = "登录"
|
||||||
|
btn.addEventListener("click", () => {
|
||||||
|
if (location.pathname == "/pages/login") {
|
||||||
|
return this.$u.toast("已在登录页!")
|
||||||
|
} else uni.navigateTo({url: "/pages/login?back=" + encodeURIComponent(location.href?.replace(location.origin, ""))})
|
||||||
|
})
|
||||||
|
document.body.appendChild(btn)
|
||||||
|
},
|
||||||
|
getApps() {
|
||||||
|
this.setApps([])
|
||||||
|
this.$http.post("/node/wechatapps/list", null, {
|
||||||
|
params: {size: 999, type: 'wxwork'}
|
||||||
|
}).then(res => {
|
||||||
|
if (res?.data) {
|
||||||
|
this.setApps(res.data.records)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -51,6 +74,7 @@ uni-page-body {
|
|||||||
background: #f5f5f5;
|
background: #f5f5f5;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-hover {
|
.text-hover {
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
}
|
}
|
||||||
@@ -153,6 +177,18 @@ uni-button {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#__loginBtn {
|
||||||
|
position: fixed;
|
||||||
|
right: 16px;
|
||||||
|
top: 20px;
|
||||||
|
background-color: $uni-color-primary;
|
||||||
|
color: #fff;
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 24px;
|
||||||
|
box-shadow: 0 0 0.61538462em rgb(0 0 0 / 40%);
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes mapWarn {
|
@keyframes mapWarn {
|
||||||
0% {
|
0% {
|
||||||
transform: scale(.5);
|
transform: scale(.5);
|
||||||
|
|||||||
@@ -13,16 +13,15 @@ instance.interceptors.request.use(config => {
|
|||||||
if (/AppCountryAlbum/.test(location.pathname)) {
|
if (/AppCountryAlbum/.test(location.pathname)) {
|
||||||
config.baseURL = '/aca'
|
config.baseURL = '/aca'
|
||||||
config.url = config.url.replace(/(app|auth|admin)\//, "api/")
|
config.url = config.url.replace(/(app|auth|admin)\//, "api/")
|
||||||
}
|
} else if (/\/node\//.test(config.url)) {
|
||||||
if (/\/grid\//.test(location.pathname)) {
|
config.baseURL = '/ns'
|
||||||
|
} else if (/\/grid\//.test(location.pathname)) {
|
||||||
config.baseURL = '/wangge'
|
config.baseURL = '/wangge'
|
||||||
}
|
} else if (/\/project\/police\//.test(location.pathname)) {
|
||||||
if (/\/project\/police\//.test(location.pathname)) {
|
|
||||||
config.baseURL = '/hnjc'
|
config.baseURL = '/hnjc'
|
||||||
config.url = config.url.replace(/(app|auth|admin)\//, "api/")
|
config.url = config.url.replace(/(app|auth|admin)\//, "api/")
|
||||||
}
|
} else if (sessionStorage.getItem("prj") == "saas") {
|
||||||
if (sessionStorage.getItem("prj") == "saas") {
|
config.baseURL = '/online'
|
||||||
config.url = config.url.replace(/(app|auth|admin)\//, "api/")
|
|
||||||
}
|
}
|
||||||
if (!config.withoutToken && store.state.token) {
|
if (!config.withoutToken && store.state.token) {
|
||||||
config.headers["Authorization"] = store.state.token
|
config.headers["Authorization"] = store.state.token
|
||||||
@@ -50,7 +49,7 @@ instance.interceptors.response.use(res => {
|
|||||||
return res.data
|
return res.data
|
||||||
} else if (res.data.code == 401) {
|
} else if (res.data.code == 401) {
|
||||||
store.commit("logout");
|
store.commit("logout");
|
||||||
uni.navigateTo({url: "/pages/login"})
|
uni.showToast({title: "请登录用户!"})
|
||||||
} else {
|
} else {
|
||||||
console.error(res.data.msg || "请求失败!")
|
console.error(res.data.msg || "请求失败!")
|
||||||
return Promise.reject(res.data.msg)
|
return Promise.reject(res.data.msg)
|
||||||
|
|||||||
@@ -65,6 +65,13 @@
|
|||||||
"^/wangge": "/"
|
"^/wangge": "/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/ns": {
|
||||||
|
"target": "http://192.168.1.87:12525",
|
||||||
|
"changeOrigin": true,
|
||||||
|
"pathRewrite": {
|
||||||
|
"^/ns": "/"
|
||||||
|
}
|
||||||
|
},
|
||||||
"/hnjc": {
|
"/hnjc": {
|
||||||
"target": "http://192.168.1.87:12001/",
|
"target": "http://192.168.1.87:12001/",
|
||||||
"changeOrigin": true,
|
"changeOrigin": true,
|
||||||
|
|||||||
@@ -5,13 +5,12 @@
|
|||||||
<!-- <div class="iconfont iconfont-iconLogo"/>-->
|
<!-- <div class="iconfont iconfont-iconLogo"/>-->
|
||||||
<ai-result v-if="result.tips" v-bind="result"/>
|
<ai-result v-if="result.tips" v-bind="result"/>
|
||||||
<input v-if="!!$route.query.code" class="codeText" :value="$route.query.code"/>
|
<input v-if="!!$route.query.code" class="codeText" :value="$route.query.code"/>
|
||||||
<div class="codeBtn" @click="handleLogin">去登录</div>
|
|
||||||
<u-radio-group v-model="currentLib" @change="handleSwitchSystem">
|
<u-radio-group v-model="currentLib" @change="handleSwitchSystem">
|
||||||
<u-radio v-for="(op,i) in libs" :key="i" :name="op.dir">{{ op.label }}</u-radio>
|
<u-radio v-for="(op,i) in libs" :key="i" :name="op.dir">{{ op.label }}</u-radio>
|
||||||
</u-radio-group>
|
</u-radio-group>
|
||||||
<input class="codeText" v-model="search" placeholder="搜索要查找的应用"/>
|
<input class="codeText" v-model="search" placeholder="搜索要查找的应用"/>
|
||||||
<div flex class="appsPane wrap">
|
<div flex class="appsPane wrap">
|
||||||
<b v-for="app in appsList" :key="app.path" @tap="handleGotoApp(app)">{{ app.name }}</b>
|
<b v-for="app in appsList" :key="app.id" @tap="handleGotoApp(app)">{{ app.label }}({{ app.name }})</b>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
@@ -26,12 +25,12 @@ export default {
|
|||||||
components: {AiSelect, AiResult},
|
components: {AiSelect, AiResult},
|
||||||
inject: ['root'],
|
inject: ['root'],
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['token', 'openUser', 'user']),
|
...mapState(['token', 'openUser', 'user', 'apps']),
|
||||||
appsList() {
|
appsList() {
|
||||||
let {search, currentLib} = this
|
let {search, currentLib} = this
|
||||||
return this.apps.filter(e => {
|
return this.apps.filter(e => {
|
||||||
return (currentLib == "apps" && e.path.indexOf("project") > -1) || e.path.indexOf(currentLib) > -1
|
return (currentLib == "apps" && e.libPath.indexOf("project") > -1) || e.libPath.indexOf(currentLib) > -1
|
||||||
}).filter(e => !!search ? e.name.indexOf(search) > -1 : true) || []
|
}).filter(e => !!search ? e.label.indexOf(search) > -1 : true) || []
|
||||||
},
|
},
|
||||||
currentApp() {
|
currentApp() {
|
||||||
return this.apps.find(e => e.key == this.$route.query.app) || {}
|
return this.apps.find(e => e.key == this.$route.query.app) || {}
|
||||||
@@ -40,7 +39,6 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
result: {},
|
result: {},
|
||||||
apps: [],
|
|
||||||
libs: [
|
libs: [
|
||||||
{label: "通用版", dir: "apps"},
|
{label: "通用版", dir: "apps"},
|
||||||
{label: "上架版", dir: "saas"},
|
{label: "上架版", dir: "saas"},
|
||||||
@@ -50,42 +48,21 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations(['logout']),
|
...mapMutations(['logout', 'setApps']),
|
||||||
...mapActions(['agentSign']),
|
...mapActions(['agentSign']),
|
||||||
handleGotoApp(app) {
|
handleGotoApp(app) {
|
||||||
uni.navigateTo({url: `${app.path}`})
|
uni.navigateTo({url: `${app.libPath}`})
|
||||||
},
|
|
||||||
handleLogin() {
|
|
||||||
uni.navigateTo({url: "./login"})
|
|
||||||
},
|
|
||||||
getApps() {
|
|
||||||
this.apps = []
|
|
||||||
let applications = require.context('../', true, /\.(\/.+)\/App[^\/]+\.vue$/)
|
|
||||||
applications.keys().map(path => {
|
|
||||||
if (applications(path).default) {
|
|
||||||
let {name: key, appName: name} = applications(path).default
|
|
||||||
this.apps.push({key, name, path: path.replace(/^\.(.+).vue$/g, '$1')})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
handleSwitchSystem() {
|
handleSwitchSystem() {
|
||||||
this.changeConfig()
|
|
||||||
sessionStorage.setItem("prj", this.currentLib)
|
sessionStorage.setItem("prj", this.currentLib)
|
||||||
this.getApps()
|
|
||||||
this.logout()
|
this.logout()
|
||||||
},
|
},
|
||||||
changeConfig() {
|
|
||||||
this.$http.defaults.baseURL = this.currentLib == "apps" ? "/lan" :
|
|
||||||
this.currentLib == "saas" ? "/online" : "/"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.currentLib = sessionStorage.getItem("prj") || "apps"
|
this.currentLib = sessionStorage.getItem("prj") || "apps"
|
||||||
this.changeConfig()
|
|
||||||
this.agentSign(this.$route.query)
|
this.agentSign(this.$route.query)
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
this.getApps()
|
|
||||||
this.result = {
|
this.result = {
|
||||||
tips: "欢迎进入开发应用",
|
tips: "欢迎进入开发应用",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,40 @@
|
|||||||
<template>
|
<template>
|
||||||
<section class="login">
|
<section class="login">
|
||||||
|
<div v-if="appPath" class="gotoApp">
|
||||||
|
<b v-text="appPath"/>
|
||||||
|
<div>正在登录...</div>
|
||||||
|
</div>
|
||||||
<u-form :model="form" ref="loginForm" label-width="140" :rules="rules">
|
<u-form :model="form" ref="loginForm" label-width="140" :rules="rules">
|
||||||
<u-form-item label="账号" prop="username">
|
<u-form-item label="账号" prop="username">
|
||||||
<u-input v-model="form.username" placeholder="请输入手机号"/>
|
<input v-model="form.username" placeholder="请输入手机号"/>
|
||||||
</u-form-item>
|
</u-form-item>
|
||||||
<u-form-item label="密码" prop="password">
|
<u-form-item label="密码" prop="password">
|
||||||
<u-input type="password" v-model="form.password" placeholder="请输入密码"/>
|
<input type="password" v-model="form.password" placeholder="请输入密码" @confirm="handleLogin"/>
|
||||||
</u-form-item>
|
</u-form-item>
|
||||||
</u-form>
|
</u-form>
|
||||||
<div bottom>
|
<div class="btn" @tap="handleLogin">登录</div>
|
||||||
<u-button type="primary" @tap="handleLogin">登录</u-button>
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {mapActions, mapMutations} from "vuex";
|
import {mapActions, mapMutations, mapState} from "vuex";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "login",
|
name: "login",
|
||||||
inject: ['root'],
|
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapState(['apps']),
|
||||||
rules() {
|
rules() {
|
||||||
return {
|
return {
|
||||||
username: [{required: true, message: "请输入 手机号"}],
|
username: [{required: true, message: "请输入 手机号"}],
|
||||||
password: [{required: true, message: "请输入 密码"}],
|
password: [{required: true, message: "请输入 密码"}],
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
target() {
|
||||||
|
return decodeURIComponent(this.$route.query.back) || ""
|
||||||
|
},
|
||||||
|
appPath() {
|
||||||
|
let app = this.apps.find(e => this.target.indexOf(e.libPath) > -1)
|
||||||
|
return app?.label || ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@@ -40,7 +49,7 @@ export default {
|
|||||||
this.$refs.loginForm.validate(v => {
|
this.$refs.loginForm.validate(v => {
|
||||||
if (v) {
|
if (v) {
|
||||||
this.getToken(this.form).then(() => {
|
this.getToken(this.form).then(() => {
|
||||||
uni.navigateBack({})
|
this.target ? uni.reLaunch({url: this.target}) : uni.navigateBack({})
|
||||||
}).catch(() => 0)
|
}).catch(() => 0)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -60,9 +69,29 @@ export default {
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
.vcode {
|
.btn {
|
||||||
color: $uni-color-primary;
|
position: fixed;
|
||||||
cursor: pointer;
|
left: 0;
|
||||||
|
bottom: 0;
|
||||||
|
width: 100vw;
|
||||||
|
background: $uni-color-primary;
|
||||||
|
color: #fff;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 96px;
|
||||||
|
font-size: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.gotoApp {
|
||||||
|
background: #fff;
|
||||||
|
text-align: center;
|
||||||
|
padding: 32px;
|
||||||
|
|
||||||
|
b {
|
||||||
|
display: block;
|
||||||
|
font-size: 40px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -13,9 +13,13 @@ const store = new Vuex.Store({
|
|||||||
corpId: "",
|
corpId: "",
|
||||||
openUser: {},
|
openUser: {},
|
||||||
user: {},
|
user: {},
|
||||||
config: {}
|
config: {},
|
||||||
|
apps: []
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
|
setApps(state, apps) {
|
||||||
|
state.apps = apps
|
||||||
|
},
|
||||||
login(state, token) {
|
login(state, token) {
|
||||||
state.token = token
|
state.token = token
|
||||||
},
|
},
|
||||||
@@ -208,9 +212,10 @@ const store = new Vuex.Store({
|
|||||||
},
|
},
|
||||||
getAccount(state) {
|
getAccount(state) {
|
||||||
//获取企业微信后台账号信息
|
//获取企业微信后台账号信息
|
||||||
return http.post("/admin/user/info").then(res => {
|
return http.post("/admin/user/detail-phone").then(res => {
|
||||||
if (res?.code == 0) {
|
if (res?.code == 0) {
|
||||||
state.commit('setUser', res.data)
|
state.commit('setUser', res.data)
|
||||||
|
action.getGridInfo()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user