diff --git a/src/apps/AppMonitoringObject/Add.vue b/src/apps/AppMonitoringObject/Add.vue index 9ff6ad68..a262f194 100644 --- a/src/apps/AppMonitoringObject/Add.vue +++ b/src/apps/AppMonitoringObject/Add.vue @@ -5,7 +5,7 @@
-
+
@@ -588,7 +588,7 @@ export default { methods: { rules() { return { - houseType: '请选择户类型', + // houseType: '请选择户类型', objectType: '请选择监测对象类型', name: '请输入户主姓名', idNumber: '请输入身份证号', @@ -630,8 +630,6 @@ export default { } } - - if (!this.form.idNumber) { return this.$u.toast('请输入身份证号') } diff --git a/src/apps/AppMonitoringObject/MonitorAddView.vue b/src/apps/AppMonitoringObject/MonitorAddView.vue index 02620a2c..7ec6a4f6 100644 --- a/src/apps/AppMonitoringObject/MonitorAddView.vue +++ b/src/apps/AppMonitoringObject/MonitorAddView.vue @@ -56,26 +56,28 @@ export default { submit() { var url = '' var params = { - pass: this.pass || '', - opinion: this.opinion, - files: this.filesList, - id: this.id, - riskType: this.riskType, - riskEliminationMethod: this.riskEliminationMethod, - } + pass: this.pass || '', + opinion: this.opinion, + files: this.filesList, + id: this.id, + riskType: this.riskType, + riskEliminationMethod: this.riskEliminationMethod, + } + // 0:待纳入、1:监测中、2:待解除、3:已解除、4:已驳回 if(this.pass == 1) { // 网格长 - if(!this.riskEliminationMethod) { + if(this.status == 1) { + if(!this.riskEliminationMethod) { return this.$u.toast('请选择风险消除方式') } - if(this.status == 1) { url = '/app/apppreventionreturntopoverty/relieve' // 解除 - } else if (this.status == 4 || this.status == 3) { + } else if (this.status == 3 || this.status == 4) { if(!this.riskType) { return this.$u.toast('请选择风险因素') } url = `/app/apppreventionreturntopoverty/examine` // 纳入监测 } - } else { // 网格员 + } + if (this.pass == '') { // 网格员 if(this.status == '0' || this.status == '3' || this.status == '4') { if(!this.riskType) { return this.$u.toast('请选择风险因素') @@ -103,19 +105,19 @@ export default { var formData = new FormData() for (let key in params) { - formData.append(key, params[key]) + formData.append(key, params[key]) } this.$http.post(url , formData).then(res => { - if (res.code === 0) { - this.$u.toast('提交成功') - uni.$emit('reload') - setTimeout(() => { - uni.navigateBack({ - delta: 2 - }) - },600) - } - }) + if (res.code === 0) { + this.$u.toast('提交成功') + uni.$emit('reload') + setTimeout(() => { + uni.navigateBack({ + delta: 2 + }) + },600) + } + }) } }, } diff --git a/src/common/modules.js b/src/common/modules.js index 674e0d6c..3b788873 100644 --- a/src/common/modules.js +++ b/src/common/modules.js @@ -10,12 +10,7 @@ export const config = { mutations: { getConfig(state, params) { for (const key in params) { - Vue.set(state, key, user[key]) - } - }, - clearConfig(state) { - for (const key in state) { - delete state[key] + Vue.set(state, key, params[key]) } } }, @@ -26,7 +21,6 @@ export const config = { if (state.agentSignURL == url) { return Promise.resolve() } else { - commit("clearConfig") commit("getConfig", {agentSignURL: url}) let action = "/app/wxcp/portal/agentSign" if (!!params?.action) { @@ -59,18 +53,22 @@ export const config = { } }, getCode({state, dispatch}, tryAgentSign = false) { - let {corpId} = state, url = location.href, REDIRECT_URI = encodeURIComponent(url), scope = "snsapi_base" + let {corpid: corpId, suiteId} = state, url = location.href, REDIRECT_URI = encodeURIComponent(url), scope = "snsapi_base" if (/\/AppForm\//.test(location.search)) { scope = "snsapi_userinfo" + } else if (suiteId) { + corpId = suiteId + scope = "snsapi_privateinfo" } return new Promise((resolve, reject) => { if (corpId && scope) { - location.replace('https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE#wechat_redirect' - .replace(/APPID/g, cid) + let oauthURL = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE#wechat_redirect' + .replace(/APPID/g, corpId) .replace(/REDIRECT_URI/g, REDIRECT_URI) - .replace(/SCOPE/g, scope)) + .replace(/SCOPE/g, scope) + location.replace(oauthURL) } else if (!tryAgentSign) { - dispatch("agentSign").then(() => dispatch("getCode", true)) + dispatch("agentSign").then(() => dispatch("getCode", true)).then(() => resolve()) } else reject("URL缺少必要参数(corpId)") }) }, @@ -90,8 +88,11 @@ export const config = { return encrypted.toString(); } } - let {module} = params - return http.post("/auth/oauth/token", null, { + let {module, code} = params, action = "/auth/oauth/token" + if (!!code) { + action = "/auth/wechatcp/token" + } + return http.post(action, params, { withoutToken: true, module, params: { @@ -104,9 +105,7 @@ export const config = { }).then(res => { if (res?.access_token) { return [res?.token_type, res?.access_token].join(" ").trim() - } - }).catch(err => { - uni.showToast({title: err, icon: 'none'}) + } else return Promise.reject(res.msg) }) } } diff --git a/src/pages/login.vue b/src/pages/login.vue index 8bb3de12..acd17344 100644 --- a/src/pages/login.vue +++ b/src/pages/login.vue @@ -46,7 +46,7 @@ export default { } }, methods: { - ...mapActions(['getToken','getAccount']), + ...mapActions(['getToken', 'getAccount', 'getCode']), ...mapMutations(['login', 'logout']), handleLogin() { this.$refs.loginForm.validate(v => { @@ -61,7 +61,7 @@ export default { } this.getToken({...this.form, module, corpId}).then(token => { this.login(token) - if( module != 'AppCountryAlbum'){ + if (module != 'AppCountryAlbum') { this.getAccount({module}) } this.target ? uni.reLaunch({url: this.target}) : uni.navigateBack({}) @@ -74,7 +74,37 @@ export default { } }, onShow() { - this.handleLogout() + if (/wxwork/.test(navigator.userAgent)) { + //在企微端 + if (this.$route.query.code) { + let {name: module, libPath} = this.currentApp, + corpId = 'ww596787bb70f08288' + if (/\/project\/police\//.test(libPath)) { + module = 'hnjc' + } else if (/\/project\/beta\//.test(libPath)) { + corpId = 'ww2a667717a70164f1' + module = 'wangge' + } + let {code} = this.$route.query + this.getToken({code}).then(token => { + if (token) { + this.login(token) + if (module != 'AppCountryAlbum') { + this.getAccount({module}) + } + this.target ? uni.reLaunch({url: this.target}) : uni.navigateBack({}) + } + }).catch(err => { + this.err = err + }) + } else { + this.getCode().catch(err => { + this.err = err + }) + } + } else { + this.handleLogout() + } }, mounted() { this.$refs.loginForm.setRules(this.rules)