重新优化授权登录,黑名单判断验证

main
xuechunyuan 3 years ago
parent 5d61646bf8
commit 095677516c
  1. 16
      src/api/hospital.js
  2. 10
      src/store/index.js
  3. 10
      src/utils/aisdapp.js
  4. 12
      src/views/Guidance.vue
  5. 222
      src/views/HomeView.vue

@ -8,12 +8,22 @@ export const queryHosiptal = () => {
}) })
}; };
//根据医院id获取须知 //根据医院id获取须知
export const queryArticleDetail = (id) => { export const queryArticleDetail = (createDept) => {
return request({ return request({
url: '/api/blade-business/article/detail-by-id', url: '/api/blade-business/article/detail-publish',
method: 'get', method: 'get',
params:{ params:{
id createDept
}
})
};
//查询改用户是否在黑名单内
export const checkBacklist = (cupCardNo) => {
return request({
url: '/api/blade-business/blacklist/user-blacklist',
method: 'get',
params:{
cupCardNo
} }
}) })
}; };

@ -9,9 +9,19 @@ export default new Vuex.Store({
userInfo: sessionStorage.getItem('userInfo') || null userInfo: sessionStorage.getItem('userInfo') || null
} }
}, },
getters: {
getUserInfo: state => {
return state.userInfo
}
},
mutations: { mutations: {
setUserInfo(state,userInfo){ setUserInfo(state,userInfo){
state.userInfo = userInfo; state.userInfo = userInfo;
} }
}, },
actions: {
getInfo({commit},data) {
commit('setUserInfo',data)
}
},
}); });

@ -1,3 +1,4 @@
import store from "../store";
let urlCreatesign = urldomaincreatesign let urlCreatesign = urldomaincreatesign
let urlGateway = urldomaingateway let urlGateway = urldomaingateway
const appmark = "sdzwapp" const appmark = "sdzwapp"
@ -7,7 +8,7 @@ let userType = "1" //用户类型 1个人 2法人
/** /**
* 通过jssdk方法获取APP本地用户票据 * 通过jssdk方法获取APP本地用户票据
*/ */
export const getUserInfo = () => { export const getUserInfo = (callback) => {
lightAppJssdk.user.getTicket({ lightAppJssdk.user.getTicket({
success: function (data) { success: function (data) {
//成功回调 //成功回调
@ -112,6 +113,7 @@ export const getUserInfoByToken = (userToken) => {
if (data.retcode == "000000") { if (data.retcode == "000000") {
const userInfo = data.data const userInfo = data.data
sessionStorage.setItem('userInfo',userInfo); sessionStorage.setItem('userInfo',userInfo);
// store.commit('setUserInfo',userInfo);
location.reload(); location.reload();
// const userObj = JSON.parse(userInfo); // const userObj = JSON.parse(userInfo);
// lightAppJssdk.notification.alert({ // lightAppJssdk.notification.alert({
@ -146,8 +148,10 @@ export const findCorUserByToken = (userToken) => {
const data = JSON.parse(value) const data = JSON.parse(value)
if (data.retcode == "000000") { if (data.retcode == "000000") {
const userInfo = JSON.stringify(data.data) const userInfo = data.data;
document.getElementById("userinfo").innerText = userInfo sessionStorage.setItem('userInfo',userInfo);
store.commit('setUserInfo',userInfo);
// document.getElementById("userinfo").innerText = userInfo
} else { } else {
} }
}) })

@ -1,7 +1,7 @@
<template> <template>
<div class="guidance"> <div class="guidance">
<div class="guide_title">海慈医院体检预约须知</div> <div class="guide_title">{{ article.title }}</div>
<div v-html="article" class="guide_contant" ref="scrollView" id="scroll-view" ></div> <div v-html="article.content" class="guide_contant" ref="scrollView" id="scroll-view" ></div>
<div class="guide_btn"> <div class="guide_btn">
<div class="guide_actBtn" @click="doCancel">取消</div> <div class="guide_actBtn" @click="doCancel">取消</div>
<div class="guide_actBtn blue" @click="doRead">已阅读</div> <div class="guide_actBtn blue" @click="doRead">已阅读</div>
@ -15,7 +15,10 @@ export default {
data() { data() {
return { return {
isFlag: false,// isFlag: false,//
article:"",// article:{
title:'',
content:''
},//
} }
}, },
mounted() { mounted() {
@ -27,7 +30,10 @@ export default {
// //
queryAticle(id) { queryAticle(id) {
queryArticleDetail(id).then(res => { queryArticleDetail(id).then(res => {
if(JSON.stringify(res.data) != '{}'){
res.data.content = decodeURIComponent(res.data.content);
this.article = res.data; this.article = res.data;
}
}) })
}, },
// //

@ -1,39 +1,12 @@
<template> <template>
<div class="home"> <div class="home">
<div class="act_shoose"> <div class="act_shoose">
<div @click="doGuidance" class="act_btn active"> <div v-for="(item, index) in hospitalList" :key="'hospital' + index" @click="doGuidance(item.id)"
<img /> :class="choosedIndex == index ? 'act_btn active' : 'act_btn'">
<img :src="item.imgUrl" v-if="item.imgUrl" />
<div class="hospital_info"> <div class="hospital_info">
<div class="hospital_name">海慈医院</div> <div class="hospital_name">{{ item.fullName }}</div>
<div class="hospital_addr">青岛市市南区栖霞路18号</div> <div class="hospital_addr">{{ item.remark }}</div>
</div>
</div>
<div @click="doGuidance" class="act_btn">
<img />
<div class="hospital_info">
<div class="hospital_name">即墨人民医院</div>
<div class="hospital_addr">青岛市市南区栖霞路18号</div>
</div>
</div>
<div @click="doGuidance" class="act_btn">
<img />
<div class="hospital_info">
<div class="hospital_name">平度人民医院</div>
<div class="hospital_addr">青岛市市南区栖霞路18号</div>
</div>
</div>
<div @click="doGuidance" class="act_btn">
<img />
<div class="hospital_info">
<div class="hospital_name">胶州医院</div>
<div class="hospital_addr">青岛市市南区栖霞路18号</div>
</div>
</div>
<div @click="doGuidance" class="act_btn">
<img />
<div class="hospital_info">
<div class="hospital_name">莱西市立医院</div>
<div class="hospital_addr">青岛市市南区栖霞路18号</div>
</div> </div>
</div> </div>
</div> </div>
@ -57,9 +30,9 @@
</div> </div>
</template> </template>
<script> <script>
import { queryHosiptal } from "@/api/hospital"; import { queryHosiptal, checkBacklist } from "@/api/hospital";
import GuidanceVue from '@/components/Guidance.vue'; import GuidanceVue from '@/components/Guidance.vue';
import { getUserInfo } from '@/utils/aisdapp'; // import { getUserInfo } from '@/utils/aisdapp';
import { isMobile } from '@/utils'; import { isMobile } from '@/utils';
export default { export default {
name: "HomeView", name: "HomeView",
@ -68,25 +41,31 @@ export default {
}, },
data() { data() {
return { return {
hospitalList: [],
choosedIndex: -1,
guideShow: false, guideShow: false,
userInfo: null, userInfo: null,
errMsg: '由于您未及时进行报道,已被拉黑请于10日后再次进行预约', errMsg: '由于您未及时进行报到,已被拉黑请于10日后再次进行预约',
isShowError:false,// isShowError: false,//
//
urlCreatesign: urldomaincreatesign,
urlGateway: urldomaingateway,
appmark: "sdzwapp",
appword: "aKd20dbGdFvmuwrt",
userType: '1',// 1 2
} }
}, },
mounted() { mounted() {
this.queryHosiptal();
if (isMobile()) { if (isMobile()) {
let userInfo = sessionStorage.getItem('userInfo') ? JSON.parse(sessionStorage.getItem('userInfo')) : null; let userInfo = sessionStorage.getItem('userInfo') ? JSON.parse(sessionStorage.getItem('userInfo')) : null;
console.log(userInfo);
if (userInfo == null) { if (userInfo == null) {
getUserInfo(); this.getUserInfo();
} }
else { else{
this.userInfo = userInfo; this.userInfo = userInfo;
this.queryHosiptal();
} }
} else { } else {
this.queryHosiptal();
return false // alert('PC') return false // alert('PC')
} }
}, },
@ -94,7 +73,7 @@ export default {
// //
queryHosiptal() { queryHosiptal() {
queryHosiptal().then(res => { queryHosiptal().then(res => {
this.hospitalList = res.data;
}) })
}, },
// //
@ -119,9 +98,162 @@ export default {
this.guideShow = false; this.guideShow = false;
}, },
// //
doGuidance() { doGuidance(id) {
// this.guideShow = true; // this.guideShow = true;
this.$router.push({ name: 'guidance', query: { deptId: 1 } }) console.log(this.userInfo)
if(this.userInfo){
checkBacklist(this.userInfo.papersnumber).then(res => {
if(res.data){
this.errMsg = res.data;
this.isShowError = true;
}else{
this.$router.push({ name: 'guidance', query: { deptId: id } })
}
})
}
},
//
getUserInfo() {
lightAppJssdk.user.getTicket({
success: (data) => {
//
console.log(JSON.stringify(data))
if (data == "未登录") {
this.onLoginApp() //APP
} else {
var jsonData = JSON.parse(data)
if (jsonData.retcode == "000000") {
var dataValueObj = JSON.parse(jsonData.data)
var ticket = dataValueObj.ticket //
this.userType = dataValueObj.usertype //
this.getUserToken(ticket)
}
}
},
fail: function (data) {
//
console.log(JSON.stringify(data))
}
})
},
/**
* 使用jssdk调用登录页面
*/
onLoginApp() {
lightAppJssdk.user.loginapp({
success: (data) => {
if (data == "未登录") {
//
this.oncloseWindow()
} else {
var dataObj = JSON.parse(data)
if (dataObj.retcode == "000000") {
//
var dataValueObj = JSON.parse(dataObj.data)
this.getUserToken(dataValueObj.ticket) //
this.userType = jsonData.usertype //
} else {
//
this.oncloseWindow()
}
}
},
fail: function (data) {
//
oncloseWindow()
}
})
},
/**
* 通过用户票据获取用户的令牌数据票据使用一次后失效token时效性较长
*/
getUserToken(ticket) {
var params = '{"ticket":"' + ticket + '"}'
const interfaceContent = {
app_id: this.appmark,
servicename: "ticketValidate",
params: params
}
vaildInterfacefn("jisnzjk", "ticketvalidate", JSON.stringify(interfaceContent), "2", "https://" + this.urlCreatesign, "https://" + this.urlGateway).then((value) => {
const data = JSON.parse(value)
if (data.retcode == "000000") {
const userToken = JSON.parse(data.data).token
if (this.userType == "1") {
//
this.getUserInfoByToken(userToken)
} else {
//
this.findCorUserByToken(userToken)
}
} else {
lightAppJssdk.notification.alert({
title: "提示", //
message: data.msg,
buttonName: "确认",
success: function (data) {
this.oncloseWindow()
}
})
}
})
},
/**
* 根据令牌获取个人完整信息
*/
getUserInfoByToken(userToken) {
const params = '{"token":"' + userToken + '"}'
const interfaceContent = {
app_id: this.appmark,
servicename: "findOutsideUserByToken",
params: params
}
try {
vaildInterfacefn("jisnzjk", "findoutsideuserbytoken", JSON.stringify(interfaceContent), "2", "https://" + this.urlCreatesign, "https://" + this.urlGateway).then((value) => {
const data = JSON.parse(value)
if (data.retcode == "000000") {
const userInfo = data.data
sessionStorage.setItem('userInfo', userInfo);
this.userInfo = userInfo;
} else {
}
})
} catch (error) { }
},
/**
* 根据令牌获取完整法人信息
*/
findCorUserByToken(userToken) {
try {
const params = '{"token":"' + userToken + '"}'
const interfaceContent = {
app_id: this.appmark,
servicename: "findCorUserByToken",
params: params
}
vaildInterfacefn("jisnzjk", "findcoruserytoken", JSON.stringify(interfaceContent), "2", "https://" + this.urlCreatesign, "https://" + this.urlGateway).then((value) => {
const data = JSON.parse(value)
if (data.retcode == "000000") {
const userInfo = data.data;
sessionStorage.setItem('userInfo', userInfo);
this.userInfo = userInfo;
} else {
}
})
} catch (err) { }
},
/**
* 关闭容器
*/
oncloseWindow() {
lightAppJssdk.navigation.close({
success: function (data) { },
fail: function (data) { }
})
}, },
} }
}; };
@ -229,7 +361,7 @@ export default {
} }
.tip_txt { .tip_txt {
width:3.6rem; width: 3.6rem;
color: #666; color: #666;
font-size: 0.24rem; font-size: 0.24rem;
text-align: center; text-align: center;

Loading…
Cancel
Save