企微考试用的值班信息

This commit is contained in:
aixianling
2023-12-18 15:17:10 +08:00
parent 484aec974c
commit e77b525c1d

View File

@@ -1,5 +1,6 @@
<script> <script>
import {mapActions, mapMutations, mapState} from "vuex"; import {mapMutations, mapState} from "vuex";
import qs from 'query-string'
export default { export default {
name: "AppDutyInfo", name: "AppDutyInfo",
@@ -12,8 +13,7 @@ export default {
{label: '值班人员', prop: 'dutyUserName'}, {label: '值班人员', prop: 'dutyUserName'},
{label: '开始时间', prop: 'dutyStartTime'}, {label: '开始时间', prop: 'dutyStartTime'},
{label: '结束时间', prop: 'dutyEndTime'}, {label: '结束时间', prop: 'dutyEndTime'},
], ]
typeList: [{value: '1', label: '陈锐-超管'}]
} }
}, },
computed: { computed: {
@@ -23,15 +23,44 @@ export default {
document.title = '值班信息' document.title = '值班信息'
if (this.user.token) { if (this.user.token) {
this.getList() this.getList()
} else if (this.$route.query.code) {
this.getToken().then(this.getList)
} else this.getCode().then(this.getToken).then(this.getList) } else this.getCode().then(this.getToken).then(this.getList)
}, },
methods: { methods: {
...mapMutations(['setToken']), ...mapMutations(['setToken']),
...mapActions(['getCode']), getCode() {
/**
* 构建oauth2链接获取code
*/
const oauth2Weixin = params => {
const redirect = qs.parseUrl(location.href)
delete redirect.query.code
delete redirect.query.state
return qs.stringifyUrl({
url: "https://open.weixin.qq.com/connect/oauth2/authorize",
query: {
response_type: 'code',
redirect_uri: qs.stringifyUrl(redirect),
...params
},
fragmentIdentifier: "wechat_redirect"
})
}
const oauthURL = oauth2Weixin({
appid: "ww596787bb70f08288",
agentid: "1000211",
scope: "snsapi_privateinfo"
})
location.replace(oauthURL)
},
getToken() { getToken() {
return this.$http.post("/node/wxtest/token", null, {withoutToken: 1}).then(res => { const {code} = this.$route.query
return this.$http.post("/node/wxtest/token", null, {withoutToken: 1, params: {code}}).then(res => {
if (res?.data) { if (res?.data) {
return this.setToken(res.data.data) return this.setToken(res.data.data)
} else if (res?.err?.errcode == 40029) {
this.getCode().then(this.getToken).then(this.getList)
} }
}) })
}, },
@@ -53,7 +82,6 @@ export default {
<div class="select" @click="show=true">艾贤凌 <div class="select" @click="show=true">艾贤凌
<u-icon name="arrow-down" color="#999" size="24"/> <u-icon name="arrow-down" color="#999" size="24"/>
</div> </div>
<u-select v-model="show" :list="typeList"/>
<u-table> <u-table>
<u-tr> <u-tr>
<u-th width="33%" v-for="column in columns" :key="column.prop">{{ column.label }}</u-th> <u-th width="33%" v-for="column in columns" :key="column.prop">{{ column.label }}</u-th>