Merge branch 'test' of e.coding.net:g-cphe0354/yinshoukeguanliduan/management into gyq

This commit is contained in:
gyq 2024-09-05 16:19:08 +08:00
commit 97530fa0cf
8 changed files with 140 additions and 48 deletions

View File

@ -0,0 +1,29 @@
// 最新的一个请求
let cancel = null
// 所有请求
let cancelTokenList = []
function setToken(cancelToken) {
cancel = cancelToken
cancelTokenList.push(cancelToken)
}
function cancelToken() {
cancel && cancel()
cancelTokenList.pop()
}
function clearAllToken() {
while (cancelTokenList.length > 0) {
let cancel = cancelTokenList.pop()
console.log(cancel, 'cancel')
cancel && cancel()
}
}
export {
setToken,
cancelToken,
clearAllToken,
}

View File

@ -5,7 +5,7 @@ import store from '../store'
import { getToken } from '@/utils/auth' import { getToken } from '@/utils/auth'
import Config from '@/settings' import Config from '@/settings'
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
import { setToken } from '@/utils/globalCancelToken.js'
// 创建axios实例 // 创建axios实例
const service = axios.create({ const service = axios.create({
// baseURL: process.env.NODE_ENV === 'production' ? process.env.VUE_APP_BASE_API : '/', // baseURL: process.env.NODE_ENV === 'production' ? process.env.VUE_APP_BASE_API : '/',
@ -23,6 +23,8 @@ service.interceptors.request.use(
config.headers['loginName'] = 'admin' config.headers['loginName'] = 'admin'
config.headers['token'] = 'eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyVHlwZSI6Ik1HIiwiZXhwIjoxNjkwMTgwNzE2LCJ1c2VySWQiOiIyNDQiLCJpYXQiOjE2ODg3MDk0ODcsImxvZ2luTmFtZSI6ImFkbWluIn0.lqxxvv2-FcecQngMBorz4MpkB3mIJQDG-IUULQyV-KQ' config.headers['token'] = 'eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyVHlwZSI6Ik1HIiwiZXhwIjoxNjkwMTgwNzE2LCJ1c2VySWQiOiIyNDQiLCJpYXQiOjE2ODg3MDk0ODcsImxvZ2luTmFtZSI6ImFkbWluIn0.lqxxvv2-FcecQngMBorz4MpkB3mIJQDG-IUULQyV-KQ'
config.headers["userId"] = '244' config.headers["userId"] = '244'
// 添加可取消请求配置
config.cancelToken = new axios.CancelToken(c => setToken(c))
return config return config
}, },
error => { error => {
@ -37,6 +39,15 @@ service.interceptors.response.use(
}, },
error => { error => {
console.log(error); console.log(error);
if (axios.isCancel(error)) {
console.log('请求已取消')
Notification.error({
title: '请求已取消',
duration: 5000
})
return Promise.reject('请求已取消')
}
// 兼容blob下载出错json提示 // 兼容blob下载出错json提示
if (error.response.data instanceof Blob && error.response.data.type.toLowerCase().indexOf('json') !== -1) { if (error.response.data instanceof Blob && error.response.data.type.toLowerCase().indexOf('json') !== -1) {
const reader = new FileReader() const reader = new FileReader()

View File

@ -40,7 +40,7 @@
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="更新提示内容" prop="message"> <el-form-item label="更新提示内容" prop="message">
<el-input type="textarea" v-model="form.message"></el-input> <el-input type="textarea" :autosize="{ minRows: 2, maxRows: 6}" v-model="form.message"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="版本文件"> <el-form-item label="版本文件">
@ -58,6 +58,7 @@
<script> <script>
import uploadFile from "./upload-file"; import uploadFile from "./upload-file";
import { $uploadVersionFile, $version } from "@/api/version"; import { $uploadVersionFile, $version } from "@/api/version";
import { cancelToken, clearAllToken } from '@/utils/globalCancelToken.js'
const form = { const form = {
source: "PC", source: "PC",
@ -105,10 +106,12 @@ export default {
this.form = { ...form }; this.form = { ...form };
this.loadingText='' this.loadingText=''
this.loading=false this.loading=false
this.$refs.uploadFile.clearFiles();
}, },
diaClose() { diaClose() {
this.$refs.uploadFile.clearFiles();
this.restForm(); this.restForm();
cancelToken()
}, },
uploadSuccess(res) { uploadSuccess(res) {
this.form.img = res[0]; this.form.img = res[0];
@ -126,8 +129,9 @@ export default {
const { version } = this.form; const { version } = this.form;
let fileRes='' let fileRes=''
const file = this.$refs.uploadFile.getFileList(); const file = this.$refs.uploadFile.getFileList();
if(!this.hasUpload&&file){ console.log(file);
this.loadingText='文件上传中,请耐心等待。。。!' if(!this.hasUpload&&file&&file.status!='finished'){
this.loadingText='文件上传中,请耐心等待...'
this.loading = true; this.loading = true;
fileRes = await $uploadVersionFile(file, { name:version }); fileRes = await $uploadVersionFile(file, { name:version });
this.loading = false; this.loading = false;
@ -178,6 +182,7 @@ export default {
this.$refs.uploadFile.fileList = [{ this.$refs.uploadFile.fileList = [{
url: obj.url, url: obj.url,
name: obj.url, name: obj.url,
status: 'finished',
}] }]
}) })
} }

View File

@ -56,11 +56,11 @@ export default {
}, },
methods: { methods: {
beforeUpload(file) { beforeUpload(file) {
// const isExe = file.name.endsWith(".exe"); const isExe = file.name.endsWith(".exe");
// if (!isExe) { if (!isExe) {
// this.$message.error(".exe"); this.$message.error("只允许上传.exe文件");
// return false; // return false; //
// } }
return true; // return true; //
}, },
uploadVersionFile(e) { uploadVersionFile(e) {
@ -113,6 +113,7 @@ export default {
this.$emit("remove", arr); this.$emit("remove", arr);
}, },
clearFiles() { clearFiles() {
this.fileList=[];
this.$refs.upload.clearFiles(); this.$refs.upload.clearFiles();
}, },
}, },

View File

@ -72,7 +72,7 @@
<el-table-column label="下载地址" prop="url"> <el-table-column label="下载地址" prop="url">
<template v-slot="scope"> <template v-slot="scope">
<a :href="scope.row.url">{{ scope.row.url }}</a> <a class="a" :href="scope.row.url">{{ scope.row.url }}</a>
</template> </template>
</el-table-column> </el-table-column>
@ -174,10 +174,7 @@ export default {
// //
resetHandle() { resetHandle() {
this.query.name = ""; this.query.version = "";
this.query.categoryId = "";
this.query.typeEnum = "";
this.query.productId = "";
this.tableData.page = 0; this.tableData.page = 0;
this.getTableData(); this.getTableData();
}, },
@ -232,7 +229,13 @@ export default {
cursor: grab; cursor: grab;
} }
} }
.a{
color: #409eff;
text-decoration: underline;
}
a:focus, a:hover{
opacity: .7;
}
.shop_info { .shop_info {
display: flex; display: flex;

View File

@ -50,7 +50,7 @@ export default {
}, },
async init() { async init() {
const res = await $getPayType(); const res = await $getPayType();
this.list = res; this.list = res.filter(v=>v.isDisplay);
console.log(res[0]); console.log(res[0]);
this.sel = this.sel ? this.sel : res[0].payType; this.sel = this.sel ? this.sel : res[0].payType;
}, },

View File

@ -52,6 +52,19 @@
</el-dialog> </el-dialog>
</template> </template>
<script> <script>
function toFixedNoRounding(num) {
//
var numStr = num.toString();
//
var parts = numStr.split('.');
// 2
if (parts[1] && parts[1].length > 2) {
parts[1] = parts[1].slice(0, 2);
}
//
return parts.join('.');
}
export default { export default {
props: { props: {
title: { title: {
@ -113,9 +126,7 @@ export default {
this.form.reduceMoney = money; this.form.reduceMoney = money;
} }
this.form.curretnMoney = (money - this.form.reduceMoney).toFixed(2); this.form.curretnMoney = (money - this.form.reduceMoney).toFixed(2);
this.form.discount = ((this.form.curretnMoney / money) * 100).toFixed( this.form.discount =toFixedNoRounding(((this.form.curretnMoney / money) * 100).toFixed(3) )
2
);
return; return;
} }
if (key == "discount") { if (key == "discount") {
@ -145,10 +156,8 @@ export default {
this.$message.error("实收金额不能大于总金额"); this.$message.error("实收金额不能大于总金额");
this.form.curretnMoney = 0; this.form.curretnMoney = 0;
} }
this.form.reduceMoney = (money - this.form.curretnMoney).toFixed(2); this.form.reduceMoney = (money - this.form.curretnMoney).toFixed(2);
this.form.discount = ((this.form.curretnMoney / money) * 100).toFixed( this.form.discount =toFixedNoRounding( ((this.form.curretnMoney / money) * 100).toFixed(3) );
2
);
return; return;
} }
this.form.curretnMoney = ((money * discount) / 100).toFixed(2); this.form.curretnMoney = ((money * discount) / 100).toFixed(2);
@ -165,7 +174,7 @@ export default {
open(data) { open(data) {
console.log(data); console.log(data);
this.form.money = data.amount; this.form.money = data.amount;
this.form.discount = data.discount||100; this.form.discount = data.discount?toFixedNoRounding(data.discount.toFixed(3)):100;
this.show = true; this.show = true;
this.init(); this.init();
}, },

View File

@ -950,8 +950,16 @@
<!-- 支付时的键盘弹窗 --> <!-- 支付时的键盘弹窗 -->
<money-keyboard ref="refMoneyKeyboard" :title="moneyKeyboard.title"> <money-keyboard ref="refMoneyKeyboard" :title="moneyKeyboard.title">
</money-keyboard> </money-keyboard>
<!-- 扫码支付 -->
<!-- 扫码支付 --> <scan-pay
ref="refWxScanCode"
defaultTips="请使用扫码枪扫描微信/支付宝收款码"
title="扫码支付"
:openSwitch="false"
:price="createOrder.data.amount * createOrder.discount"
@confirm="scanPayConfirm"
></scan-pay>
<!-- 储值卡支付 -->
<scan-pay <scan-pay
ref="refScanCode" ref="refScanCode"
title="扫码支付" title="扫码支付"
@ -1410,14 +1418,26 @@ export default {
// //
scanPayConfirm(code) { scanPayConfirm(code) {
this.createOrder.code = code; this.createOrder.code = code;
this.payOrder(); if(!code){
return this.$message.error("请输入或扫付款码")
}
this.pays();
}, },
payTypeItemClick(item) { payTypeItemClick(item) {
console.log(item); console.log(item);
if (item.payType == "deposit") { console.log(this.vipUser.id);
// if(item.payType=='vipPay'){
this.refToggle("refScanCode", true); return this.refChooseUserOpen()
} }
if (item.payType == "deposit") {
//
return this.refToggle("refScanCode", true);
}
if (item.payType == "scanCode") {
//
return this.refToggle("refWxScanCode", true);
}
}, },
ChangeDiscount(discount) { ChangeDiscount(discount) {
this.createOrder.discount = discount; this.createOrder.discount = discount;
@ -1513,29 +1533,43 @@ export default {
refNoteShow() { refNoteShow() {
this.$refs.refOrderNote.open(this.note.content); this.$refs.refOrderNote.open(this.note.content);
}, },
// //
async payOrder() { async payOrder() {
if(this.order.payType=='vipPay'&&!this.vipUser.id){
return this.refChooseUserOpen()
}
if(this.order.payType=='scanCode'){
return this.refToggle("refWxScanCode", true);
}
if(this.order.payType=='deposit'){
return this.refToggle("refScanCode", true);
}
console.log({ console.log({
orderId: this.createOrder.data.id, orderId: this.createOrder.data.id,
payType: this.order.payType, payType: this.order.payType,
}); });
this.loading = true; this.pays()
try {
const res = await $payOrder({
tableId: this.table.tableId,
masterId: this.masterId,
orderId: this.createOrder.data.id,
payType: this.order.payType,
vipUserId: this.vipUser.id,
discount: this.createOrder.discount,
code: this.createOrder.code,
});
this.loading = false;
this.payOrderSuccess();
} catch (error) {
this.loading = false;
}
}, },
//
async pays() {
this.loading = true;
try {
const res = await $payOrder({
tableId: this.table.tableId,
masterId: this.masterId,
orderId: this.createOrder.data.id,
payType: this.order.payType,
vipUserId: this.vipUser.id,
discount: this.createOrder.discount,
code: this.createOrder.code,
});
this.loading = false;
this.payOrderSuccess();
} catch (error) {
this.loading = false;
}
},
payOrderSuccess() { payOrderSuccess() {
this.$notify({ this.$notify({
title: "支付成功", title: "支付成功",