调整部分框架

This commit is contained in:
aixianling
2022-05-30 18:46:49 +08:00
parent 16beb074f6
commit 8e9a7de387
7 changed files with 112 additions and 59 deletions

View File

@@ -5,13 +5,12 @@
<!-- <div class="iconfont iconfont-iconLogo"/>-->
<ai-result v-if="result.tips" v-bind="result"/>
<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 v-for="(op,i) in libs" :key="i" :name="op.dir">{{ op.label }}</u-radio>
</u-radio-group>
<input class="codeText" v-model="search" placeholder="搜索要查找的应用"/>
<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>
</section>
</template>
@@ -26,12 +25,12 @@ export default {
components: {AiSelect, AiResult},
inject: ['root'],
computed: {
...mapState(['token', 'openUser', 'user']),
...mapState(['token', 'openUser', 'user', 'apps']),
appsList() {
let {search, currentLib} = this
return this.apps.filter(e => {
return (currentLib == "apps" && e.path.indexOf("project") > -1) || e.path.indexOf(currentLib) > -1
}).filter(e => !!search ? e.name.indexOf(search) > -1 : true) || []
return (currentLib == "apps" && e.libPath.indexOf("project") > -1) || e.libPath.indexOf(currentLib) > -1
}).filter(e => !!search ? e.label.indexOf(search) > -1 : true) || []
},
currentApp() {
return this.apps.find(e => e.key == this.$route.query.app) || {}
@@ -40,7 +39,6 @@ export default {
data() {
return {
result: {},
apps: [],
libs: [
{label: "通用版", dir: "apps"},
{label: "上架版", dir: "saas"},
@@ -50,42 +48,21 @@ export default {
}
},
methods: {
...mapMutations(['logout']),
...mapMutations(['logout', 'setApps']),
...mapActions(['agentSign']),
handleGotoApp(app) {
uni.navigateTo({url: `${app.path}`})
},
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')})
}
})
uni.navigateTo({url: `${app.libPath}`})
},
handleSwitchSystem() {
this.changeConfig()
sessionStorage.setItem("prj", this.currentLib)
this.getApps()
this.logout()
},
changeConfig() {
this.$http.defaults.baseURL = this.currentLib == "apps" ? "/lan" :
this.currentLib == "saas" ? "/online" : "/"
}
},
onLoad() {
this.currentLib = sessionStorage.getItem("prj") || "apps"
this.changeConfig()
this.agentSign(this.$route.query)
},
onShow() {
this.getApps()
this.result = {
tips: "欢迎进入开发应用",
}

View File

@@ -1,31 +1,40 @@
<template>
<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-item label="账号" prop="username">
<u-input v-model="form.username" placeholder="请输入手机号"/>
<input v-model="form.username" placeholder="请输入手机号"/>
</u-form-item>
<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>
<div bottom>
<u-button type="primary" @tap="handleLogin">登录</u-button>
</div>
<div class="btn" @tap="handleLogin">登录</div>
</section>
</template>
<script>
import {mapActions, mapMutations} from "vuex";
import {mapActions, mapMutations, mapState} from "vuex";
export default {
name: "login",
inject: ['root'],
computed: {
...mapState(['apps']),
rules() {
return {
username: [{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() {
@@ -40,7 +49,7 @@ export default {
this.$refs.loginForm.validate(v => {
if (v) {
this.getToken(this.form).then(() => {
uni.navigateBack({})
this.target ? uni.reLaunch({url: this.target}) : uni.navigateBack({})
}).catch(() => 0)
}
})
@@ -60,9 +69,29 @@ export default {
box-sizing: border-box;
height: 100%;
.vcode {
color: $uni-color-primary;
cursor: pointer;
.btn {
position: fixed;
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>