This commit is contained in:
yanran200730
2022-06-14 09:00:40 +08:00
4 changed files with 76 additions and 47 deletions

View File

@@ -5,7 +5,7 @@
</div> </div>
<div class="form" v-show="current == 0 || isEdit"> <div class="form" v-show="current == 0 || isEdit">
<div class="form-group"> <div class="form-group">
<div class="form-item"> <!-- <div class="form-item">
<div class="form-item__wrapper"> <div class="form-item__wrapper">
<div class="left"> <div class="left">
<i>*</i> <i>*</i>
@@ -15,7 +15,7 @@
<AiSelect dict="fpHouseType" v-model="form.houseType"></AiSelect> <AiSelect dict="fpHouseType" v-model="form.houseType"></AiSelect>
</div> </div>
</div> </div>
</div> </div> -->
<div class="form-item" v-if="!isEdit"> <div class="form-item" v-if="!isEdit">
<div class="form-item__wrapper"> <div class="form-item__wrapper">
<div class="left"> <div class="left">
@@ -588,7 +588,7 @@ export default {
methods: { methods: {
rules() { rules() {
return { return {
houseType: '请选择户类型', // houseType: '请选择户类型',
objectType: '请选择监测对象类型', objectType: '请选择监测对象类型',
name: '请输入户主姓名', name: '请输入户主姓名',
idNumber: '请输入身份证号', idNumber: '请输入身份证号',
@@ -630,8 +630,6 @@ export default {
} }
} }
if (!this.form.idNumber) { if (!this.form.idNumber) {
return this.$u.toast('请输入身份证号') return this.$u.toast('请输入身份证号')
} }

View File

@@ -56,26 +56,28 @@ export default {
submit() { submit() {
var url = '' var url = ''
var params = { var params = {
pass: this.pass || '', pass: this.pass || '',
opinion: this.opinion, opinion: this.opinion,
files: this.filesList, files: this.filesList,
id: this.id, id: this.id,
riskType: this.riskType, riskType: this.riskType,
riskEliminationMethod: this.riskEliminationMethod, riskEliminationMethod: this.riskEliminationMethod,
} }
// 0待纳入、1监测中、2待解除、3已解除、4已驳回
if(this.pass == 1) { // 网格长 if(this.pass == 1) { // 网格长
if(!this.riskEliminationMethod) { if(this.status == 1) {
if(!this.riskEliminationMethod) {
return this.$u.toast('请选择风险消除方式') return this.$u.toast('请选择风险消除方式')
} }
if(this.status == 1) {
url = '/app/apppreventionreturntopoverty/relieve' // 解除 url = '/app/apppreventionreturntopoverty/relieve' // 解除
} else if (this.status == 4 || this.status == 3) { } else if (this.status == 3 || this.status == 4) {
if(!this.riskType) { if(!this.riskType) {
return this.$u.toast('请选择风险因素') return this.$u.toast('请选择风险因素')
} }
url = `/app/apppreventionreturntopoverty/examine` // 纳入监测 url = `/app/apppreventionreturntopoverty/examine` // 纳入监测
} }
} else { // 网格员 }
if (this.pass == '') { // 网格员
if(this.status == '0' || this.status == '3' || this.status == '4') { if(this.status == '0' || this.status == '3' || this.status == '4') {
if(!this.riskType) { if(!this.riskType) {
return this.$u.toast('请选择风险因素') return this.$u.toast('请选择风险因素')
@@ -103,19 +105,19 @@ export default {
var formData = new FormData() var formData = new FormData()
for (let key in params) { for (let key in params) {
formData.append(key, params[key]) formData.append(key, params[key])
} }
this.$http.post(url , formData).then(res => { this.$http.post(url , formData).then(res => {
if (res.code === 0) { if (res.code === 0) {
this.$u.toast('提交成功') this.$u.toast('提交成功')
uni.$emit('reload') uni.$emit('reload')
setTimeout(() => { setTimeout(() => {
uni.navigateBack({ uni.navigateBack({
delta: 2 delta: 2
}) })
},600) },600)
} }
}) })
} }
}, },
} }

View File

@@ -10,12 +10,7 @@ export const config = {
mutations: { mutations: {
getConfig(state, params) { getConfig(state, params) {
for (const key in params) { for (const key in params) {
Vue.set(state, key, user[key]) Vue.set(state, key, params[key])
}
},
clearConfig(state) {
for (const key in state) {
delete state[key]
} }
} }
}, },
@@ -26,7 +21,6 @@ export const config = {
if (state.agentSignURL == url) { if (state.agentSignURL == url) {
return Promise.resolve() return Promise.resolve()
} else { } else {
commit("clearConfig")
commit("getConfig", {agentSignURL: url}) commit("getConfig", {agentSignURL: url})
let action = "/app/wxcp/portal/agentSign" let action = "/app/wxcp/portal/agentSign"
if (!!params?.action) { if (!!params?.action) {
@@ -59,18 +53,22 @@ export const config = {
} }
}, },
getCode({state, dispatch}, tryAgentSign = false) { 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)) { if (/\/AppForm\//.test(location.search)) {
scope = "snsapi_userinfo" scope = "snsapi_userinfo"
} else if (suiteId) {
corpId = suiteId
scope = "snsapi_privateinfo"
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (corpId && scope) { 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' 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, cid) .replace(/APPID/g, corpId)
.replace(/REDIRECT_URI/g, REDIRECT_URI) .replace(/REDIRECT_URI/g, REDIRECT_URI)
.replace(/SCOPE/g, scope)) .replace(/SCOPE/g, scope)
location.replace(oauthURL)
} else if (!tryAgentSign) { } else if (!tryAgentSign) {
dispatch("agentSign").then(() => dispatch("getCode", true)) dispatch("agentSign").then(() => dispatch("getCode", true)).then(() => resolve())
} else reject("URL缺少必要参数(corpId)") } else reject("URL缺少必要参数(corpId)")
}) })
}, },
@@ -90,8 +88,11 @@ export const config = {
return encrypted.toString(); return encrypted.toString();
} }
} }
let {module} = params let {module, code} = params, action = "/auth/oauth/token"
return http.post("/auth/oauth/token", null, { if (!!code) {
action = "/auth/wechatcp/token"
}
return http.post(action, params, {
withoutToken: true, withoutToken: true,
module, module,
params: { params: {
@@ -104,9 +105,7 @@ export const config = {
}).then(res => { }).then(res => {
if (res?.access_token) { if (res?.access_token) {
return [res?.token_type, res?.access_token].join(" ").trim() return [res?.token_type, res?.access_token].join(" ").trim()
} } else return Promise.reject(res.msg)
}).catch(err => {
uni.showToast({title: err, icon: 'none'})
}) })
} }
} }

View File

@@ -46,7 +46,7 @@ export default {
} }
}, },
methods: { methods: {
...mapActions(['getToken','getAccount']), ...mapActions(['getToken', 'getAccount', 'getCode']),
...mapMutations(['login', 'logout']), ...mapMutations(['login', 'logout']),
handleLogin() { handleLogin() {
this.$refs.loginForm.validate(v => { this.$refs.loginForm.validate(v => {
@@ -61,7 +61,7 @@ export default {
} }
this.getToken({...this.form, module, corpId}).then(token => { this.getToken({...this.form, module, corpId}).then(token => {
this.login(token) this.login(token)
if( module != 'AppCountryAlbum'){ if (module != 'AppCountryAlbum') {
this.getAccount({module}) this.getAccount({module})
} }
this.target ? uni.reLaunch({url: this.target}) : uni.navigateBack({}) this.target ? uni.reLaunch({url: this.target}) : uni.navigateBack({})
@@ -74,7 +74,37 @@ export default {
} }
}, },
onShow() { 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() { mounted() {
this.$refs.loginForm.setRules(this.rules) this.$refs.loginForm.setRules(this.rules)