调整部分框架
This commit is contained in:
		| @@ -14,7 +14,7 @@ const getFileInfo = (app, file) => { | ||||
|   if (/^App/.test(app.name)) { | ||||
|     let {name, label} = app, | ||||
|         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 => { | ||||
|   | ||||
							
								
								
									
										48
									
								
								src/App.vue
									
									
									
									
									
								
							
							
						
						
									
										48
									
								
								src/App.vue
									
									
									
									
									
								
							| @@ -9,6 +9,8 @@ export default { | ||||
|   }, | ||||
|   onLaunch: function () { | ||||
|     this.repairWxSDK() | ||||
|     this.initLoginBtn() | ||||
|     this.getApps() | ||||
|   }, | ||||
|   onShow: function () { | ||||
|     this.initWaterMarker() | ||||
| @@ -19,7 +21,7 @@ export default { | ||||
|     ...mapState(['token', 'user']), | ||||
|   }, | ||||
|   methods: { | ||||
|     ...mapMutations(['initWaterMarker', 'logout', 'getConfig']), | ||||
|     ...mapMutations(['initWaterMarker', 'logout', 'getConfig', 'setApps']), | ||||
|     goto(params, cb) { | ||||
|       let {path: url, query: {app}} = this.$route | ||||
|       params.query = {app, ...(params.query || {})} | ||||
| @@ -32,7 +34,28 @@ export default { | ||||
|     }, | ||||
|     repairWxSDK() { | ||||
|       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> | ||||
| @@ -51,13 +74,14 @@ uni-page-body { | ||||
|   background: #f5f5f5; | ||||
|   position: relative; | ||||
| } | ||||
|   .text-hover { | ||||
|     opacity: 0.7; | ||||
|   } | ||||
|  | ||||
|   .bg-hover { | ||||
| .text-hover { | ||||
|   opacity: 0.7; | ||||
| } | ||||
|  | ||||
| .bg-hover { | ||||
|   background: #eee; | ||||
|   } | ||||
| } | ||||
|  | ||||
| div[bottom] { | ||||
|   position: fixed; | ||||
| @@ -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 { | ||||
|   0% { | ||||
|     transform: scale(.5); | ||||
|   | ||||
| @@ -13,16 +13,15 @@ instance.interceptors.request.use(config => { | ||||
|   if (/AppCountryAlbum/.test(location.pathname)) { | ||||
|     config.baseURL = '/aca' | ||||
|     config.url = config.url.replace(/(app|auth|admin)\//, "api/") | ||||
|   } | ||||
|   if (/\/grid\//.test(location.pathname)) { | ||||
|   } else if (/\/node\//.test(config.url)) { | ||||
|     config.baseURL = '/ns' | ||||
|   } else if (/\/grid\//.test(location.pathname)) { | ||||
|     config.baseURL = '/wangge' | ||||
|   } | ||||
|   if (/\/project\/police\//.test(location.pathname)) { | ||||
|   } else if (/\/project\/police\//.test(location.pathname)) { | ||||
|     config.baseURL = '/hnjc' | ||||
|     config.url = config.url.replace(/(app|auth|admin)\//, "api/") | ||||
|   } | ||||
|   if (sessionStorage.getItem("prj") == "saas") { | ||||
|     config.url = config.url.replace(/(app|auth|admin)\//, "api/") | ||||
|   } else if (sessionStorage.getItem("prj") == "saas") { | ||||
|     config.baseURL = '/online' | ||||
|   } | ||||
|   if (!config.withoutToken && store.state.token) { | ||||
|     config.headers["Authorization"] = store.state.token | ||||
| @@ -50,7 +49,7 @@ instance.interceptors.response.use(res => { | ||||
|       return res.data | ||||
|     } else if (res.data.code == 401) { | ||||
|       store.commit("logout"); | ||||
|       uni.navigateTo({url: "/pages/login"}) | ||||
|       uni.showToast({title: "请登录用户!"}) | ||||
|     } else { | ||||
|       console.error(res.data.msg || "请求失败!") | ||||
|       return Promise.reject(res.data.msg) | ||||
|   | ||||
| @@ -65,6 +65,13 @@ | ||||
|             "^/wangge": "/" | ||||
|           } | ||||
|         }, | ||||
|         "/ns": { | ||||
|           "target": "http://192.168.1.87:12525", | ||||
|           "changeOrigin": true, | ||||
|           "pathRewrite": { | ||||
|             "^/ns": "/" | ||||
|           } | ||||
|         }, | ||||
|         "/hnjc": { | ||||
|           "target": "http://192.168.1.87:12001/", | ||||
|           "changeOrigin": true, | ||||
|   | ||||
| @@ -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: "欢迎进入开发应用", | ||||
|     } | ||||
|   | ||||
| @@ -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> | ||||
|   | ||||
| @@ -13,9 +13,13 @@ const store = new Vuex.Store({ | ||||
|     corpId: "", | ||||
|     openUser: {}, | ||||
|     user: {}, | ||||
|     config: {} | ||||
|     config: {}, | ||||
|     apps: [] | ||||
|   }, | ||||
|   mutations: { | ||||
|     setApps(state, apps) { | ||||
|       state.apps = apps | ||||
|     }, | ||||
|     login(state, token) { | ||||
|       state.token = token | ||||
|     }, | ||||
| @@ -208,9 +212,10 @@ const store = new Vuex.Store({ | ||||
|     }, | ||||
|     getAccount(state) { | ||||
|       //获取企业微信后台账号信息 | ||||
|       return http.post("/admin/user/info").then(res => { | ||||
|       return http.post("/admin/user/detail-phone").then(res => { | ||||
|         if (res?.code == 0) { | ||||
|           state.commit('setUser', res.data) | ||||
|           action.getGridInfo() | ||||
|         } | ||||
|       }) | ||||
|     }, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user