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

View File

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

View File

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

View File

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

View File

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

View File

@ -52,6 +52,19 @@
</el-dialog>
</template>
<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 {
props: {
title: {
@ -113,9 +126,7 @@ export default {
this.form.reduceMoney = money;
}
this.form.curretnMoney = (money - this.form.reduceMoney).toFixed(2);
this.form.discount = ((this.form.curretnMoney / money) * 100).toFixed(
2
);
this.form.discount =toFixedNoRounding(((this.form.curretnMoney / money) * 100).toFixed(3) )
return;
}
if (key == "discount") {
@ -145,10 +156,8 @@ export default {
this.$message.error("实收金额不能大于总金额");
this.form.curretnMoney = 0;
}
this.form.reduceMoney = (money - this.form.curretnMoney).toFixed(2);
this.form.discount = ((this.form.curretnMoney / money) * 100).toFixed(
2
);
this.form.reduceMoney = (money - this.form.curretnMoney).toFixed(2);
this.form.discount =toFixedNoRounding( ((this.form.curretnMoney / money) * 100).toFixed(3) );
return;
}
this.form.curretnMoney = ((money * discount) / 100).toFixed(2);
@ -165,7 +174,7 @@ export default {
open(data) {
console.log(data);
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.init();
},

View File

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