This commit is contained in:
caoyuchun 2024-06-18 15:53:13 +08:00
parent 958282b84b
commit 5542e7f6bb
5 changed files with 119 additions and 6 deletions

View File

@ -162,7 +162,7 @@
</svg>
</div>
<!-- <div class="ant-result-title">404</div>-->
<div class="ant-result-subtitle" style="text-align: center;margin-top: 20px"><h2>无数据</h2></div>
<div class="ant-result-subtitle" style="text-align: center;margin-top: 20px"><h2>{{ msg }}</h2></div>
<!-- <div class="ant-result-extra"><a href="/">-->
<!-- <button type="button" class="ant-btn ant-btn-primary"><span role="img" aria-label="home"-->
<!-- class="anticon anticon-home"><svg-->
@ -183,7 +183,7 @@ export default {
data() {
return {}
},
props: [],
props: ['msg'],
// computed: mapState([
// 'itemNum', //

View File

@ -25,7 +25,7 @@ router.beforeEach((to,from,next)=>{
var apikey = to.query.apikey
var userId = to.query.userId
var userType = to.query.userType
if (apikey){
setStore('apikey',apikey)
@ -37,6 +37,12 @@ router.beforeEach((to,from,next)=>{
console.log(userId)
}
if (userType){
setStore('userType',userType)
console.log(userType)
}
if (apikey){
@ -44,6 +50,10 @@ router.beforeEach((to,from,next)=>{
if (userId){
delete to.query.userId
}
if (userType){
delete to.query.userType
}
next({
path:to.path,
query:{...to.query}

View File

@ -1,3 +1,6 @@
import Md5 from "crypto-js/md5";
/**
* 存储localStorage
*/
@ -274,3 +277,61 @@ export const animate = (element, target, duration = 400, mode = 'ease-out', call
})
}, 20);
}
export const processReuestData =(data)=>{
// 发请求前 业务处理
// 设置公共报文逻辑
let time = Date.parse(new Date());
let keys = ["apikey", "sign", "time"];
for (const keysKey in data) {
keys.push(keysKey);
}
data.isTest = 1;
//
let key1 = keys.sort();
let key2 = key1.join("&");
let key3 = key2 + "&" + time + "&" + "HuaTeng987!@#";
// console.log(key3)
// console.log(data)
let sign = Md5(key3).toString();
//
let apikey = getStore("apikey");
if (apikey !== null) {
data.apikey = apikey;
} else {
data.apikey = "HT_6d671a62c1d668161552616453";
}
console.log('apikey=='+data.apikey)
// userId
let userId = getStore("userId");
if (userId !== null) {
data.userId = userId;
}
// 参数
data.sign = sign;
data.time = time;
return data
}

View File

@ -123,6 +123,11 @@ export default async (options = { method: "GET" }) => {
headers: myheaders,
});
// code == 200 报错
if(res.data.code !== 200){
return new Promise((resolve,reject)=>reject(res.data.msg));
}
return new Promise((resolve,reject)=>resolve(res.data.data))
} catch (error) {

View File

@ -35,6 +35,7 @@
@settingChange="settingChange"
:action = "action"
:headers = "headers"
:data = "extradata"
:isShowTeacherResource="true"
:continueReading="true"
:basisPath="basisPath"
@ -43,7 +44,7 @@
/>
</div>
<div v-show="showError">
<no-data></no-data>
<no-data :msg="errormsg"></no-data>
</div>
</div>
@ -52,6 +53,7 @@
<script>
import {LOCAL_VIEW_DETAIL,LOCAL_VIEW_CATALOG,LOCAL_VIEW_DATA} from "../seed/mock"
import NoData from "../components/noData.vue"
import {getStore,processReuestData} from '../utils/mUtils'
import {bookApi} from "../service/getData"
export default {
components:{
@ -71,12 +73,14 @@ export default {
bookId: '',
show:false,
showError:false,
errormsg:'无数据',
location: '',
basisPath: 'https://smile-ebook.oss-cn-qingdao.aliyuncs.com/newjc/',
pageType: 'pc',
isTrial: false,
isTrialIndex: 10,
userType: 'teacher',
extradata :{},
data: {
notes: {
list: []
@ -97,7 +101,20 @@ export default {
created() {
this.bookId = this.$route.query.bookId
this.userType = this.$route.query.userType || 'student'
// this.userType = this.$route.query.userType || 'student'
var userType = getStore("userType")
this.extradata = processReuestData({})
// var uploadUrl = "https://local.xinsiketang.com"
var uploadUrl = ""
uploadUrl = uploadUrl+'/api/smile/uploadResources'
this.action = uploadUrl
if (userType){
this.userType = userType
}
if (this.$route.query.type) {
this.pageType = this.$route.query.type
// this.isTrialIndex = Number(this.$route.query.isTrialIndex)
@ -125,7 +142,15 @@ export default {
// var locationData = await bookApi.userAction.getReadLocation({bookId:this.bookId})
// this.location = locationData.location
try {
this.textBookData = await bookApi.bookinfo.detail({bookId:this.bookId})
} catch (error) {
this.show= false
this.showError = true
this.errormsg = error
this.$message.error(error);
}
this.basisPath = this.textBookData.basisPath
this.catalogList = await bookApi.bookinfo.category({bookId:this.bookId})
this.looseLeafData = await bookApi.bookinfo.data({bookId:this.bookId})
@ -336,14 +361,26 @@ export default {
//
addResources(e) {
bookApi.resource.add({
bookId:this.bookId,
data:JSON.stringify(e)
})
this.addData('resources', e)
},
//
deleteResource(e) {
bookApi.resource.delete({
bookId:this.bookId,
data:JSON.stringify(e)
})
this.deleteData('resources', e)
},
//
editResources(e) {
bookApi.resource.edit({
bookId:this.bookId,
data:JSON.stringify(e)
})
this.updateData('resources', e)
}
}