master
xy 1 year ago
parent 8255e09c44
commit daa62d000c

@ -2,5 +2,5 @@
ENV = 'production'
# base api
VUE_APP_BASE_API=http://knzg.ali251.langye.net
VUE_APP_UPLOAD_API=http://knzg.ali251.langye.net/api/admin/upload-file
VUE_APP_BASE_API=http://knzg.szftu.suzhou.com.cn
VUE_APP_UPLOAD_API=http://knzg.szftu.suzhou.com.cn/api/admin/upload-file

@ -14,6 +14,10 @@
</script>
<script type="text/javascript" src='https://webapi.amap.com/maps?v=1.4.11&key=795a757114c371f42cee1f8efa527684&plugin=AMap.PlaceSearch'></script>
<script src="https://webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>
<!-- <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>-->
<!-- <script>-->
<!-- var vConsole = new window.VConsole();-->
<!-- </script>-->
</head>
<body>
<noscript>

@ -31,3 +31,11 @@ export function updateLog (params) {
params
})
}
export function ossLogin (params) {
return request({
method: 'get',
url: '/api/mobile/user/oss',
params
})
}

@ -3,8 +3,9 @@ import store from './store'
import { Message } from 'element-ui'
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
import { getToken } from '@/utils/auth' // get token from cookie
import {getToken, setToken} from '@/utils/auth' // get token from cookie
import getPageTitle from '@/utils/get-page-title'
import { ossLogin } from "@/api/h5"
NProgress.configure({ showSpinner: false }) // NProgress Configuration
@ -17,8 +18,29 @@ router.beforeEach(async(to, from, next) => {
// set page title
document.title = getPageTitle(to.meta.title)
//osslogin
if (/^\/oss_login.*/.test(to.path)) {
if (to.query.token) {
const ossRes= await ossLogin({
oss_token: to.query.token
})
setToken(ossRes.user.bianma,"difficult_employee_token_h5")
next({
path: "/h5",
replace: true
})
}
return
}
// determine whether the user has logged in
let hasToken = getToken()
if (/^\/h5.*/.test(to.path)) {
hasToken = getToken("difficult_employee_token_h5")
} else {
hasToken = getToken()
}
console.log(hasToken)
if (whiteList.indexOf(to.path) !== -1) {
// in the free login whitelist, go directly
@ -75,6 +97,7 @@ router.beforeEach(async(to, from, next) => {
next()
} else {
// other pages that do not have permission to access are redirected to the login page.
next(`${/^\/h5.*/.test(to.path) ? '/h5/login' : '/login'}?redirect=${to.path}`)
NProgress.done()
}

@ -2,14 +2,14 @@ import Cookies from 'js-cookie'
import router from '@/router'
const TokenKey = 'difficult_employee_token'
const TokenKsy_h5 = 'difficult_employee_token_h5'
export function getToken() {
export function getToken(tokenName) {
let flag = /\/h5.*/.test(window.location.href)
return Cookies.get(flag ? TokenKsy_h5 : TokenKey)
return Cookies.get(tokenName ? tokenName : (flag ? TokenKsy_h5 : TokenKey))
}
export function setToken(token) {
export function setToken(token, tokenName) {
let flag = /\/h5.*/.test(window.location.href)
return Cookies.set(flag ? TokenKsy_h5 : TokenKey, token)
return Cookies.set(tokenName ? tokenName : (flag ? TokenKsy_h5 : TokenKey), token)
}
export function removeToken() {

@ -226,6 +226,7 @@ export default {
},
methods: {
async getUserInfo () {
console.log('gettoken', getToken())
const res = await userInfo({
bianma: getToken()
})
@ -280,7 +281,7 @@ export default {
});
},
destroyed() {
this.msInstance.destroy();
this.msInstance?.destroy();
},
created() {
//this.getUserInfo();

@ -42,10 +42,12 @@
</template>
<script>
import "jspdf/dist/polyfills.es"
import QRCode from 'qrcodejs2';
import html2canvas from "html2canvas";
import Jspdf from "jspdf";
import printJS from "print-js";
import { saveAs } from 'file-saver';
import { updateLog, userInfo } from "@/api/h5";
export default {
@ -184,12 +186,25 @@ export default {
//
//pdf.save(`-${this.info.name}.pdf`);
let file = pdf.output('blob',{
filename: `困难职工证明-${this.info.name}.pdf`
filename: `困难职工证明-${this.info.name}.pdf`,
type: 'application/pdf;charset=utf-8'
})
let a = document.createElement('a');
a.href = URL.createObjectURL(file);
a.download = `困难职工证明-${this.info.name}.pdf`;
a.click();
let blob = new Blob([file], {type: 'application/pdf'});
let reader = new FileReader();
let filename = `困难职工证明-${this.info.name}.pdf`
reader.onloadend = function() {
let a = document.createElement('a');
a.href = reader.result;
a.download = filename;
a.click();
}
reader.readAsDataURL(blob);
// console.log(file)
// saveAs(file,`-${this.info.name}.pdf`)
// let a = document.createElement('a');
// a.href = window.URL.createObjectURL(file);
// a.download = `-${this.info.name}.pdf`;
// a.click();
}).catch(err => {
this.isToImg = false;
})

Loading…
Cancel
Save