增加转盘抽奖页面和编辑

This commit is contained in:
YeMingfei666 2024-12-04 13:51:52 +08:00
parent 00280e133a
commit d558c99018
5 changed files with 938 additions and 771 deletions

View File

@ -27,7 +27,7 @@ function get(id) {
params: data params: data
}) })
} }
function update(updatedata) { function update(data) {
return $http({ return $http({
url: 'discSpinning/updateDiscSpinning', url: 'discSpinning/updateDiscSpinning',
method: 'post', method: 'post',

View File

@ -0,0 +1,92 @@
<template>
<el-upload
class="avatar-uploader"
v-model="url"
action=""
:auto-upload="false"
:http-request="onFileSubmit"
:onChange="onFileChange"
:show-file-list="false"
>
<video
v-if="url"
:src="url"
class="avatar"
controls="controls"
style="width: 200px; height: 148px"
>
您的浏览器不支持视频播放
</video>
<i v-else class="el-icon-plus avatar-uploader-icon iconss"></i>
<el-progress
type="circle"
v-if="percentage > 0 && percentage <= 100"
:percentage="percentage"
color="#efefef"
></el-progress>
</el-upload>
</template>
<script>
import OSS from "@/utils/oss-upload.js";
import { $getCredentials } from "@/api/oss.js";
export default {
data() {
return {
url: "",
ossClient: undefined,
percentage: 0,
};
},
mounted() {
this.initOssClient();
},
methods: {
async onFileChange(data) {
console.log(data);
const date = new Date();
const start =
date.getFullYear() +
"" +
(date.getMonth() * 1 + 1) +
"" +
date.getDate();
const houzhui = "." + data.name.substr(data.name.lastIndexOf(".") + 1);
const name = start + "/" + getUUID() + houzhui;
const fileRes = await this.ossClient.partUpload(name, data.raw, (p) => {
this.percentage = Math.floor(p * 100);
// UI
});
console.log(fileRes);
if (!fileRes) {
this.percentage = 0;
this.$notify({
title: "失败",
message: `上传阿里云失败`,
type: "error",
});
return;
}
if (fileRes.name == "cancel") {
return;
}
this.url = fileRes.replace(
"https://djvideo.oss-cn-shanghai.aliyuncs.com/",
"https://duanju.hnsiyao.cn/"
);
},
onFileSubmit(data) {
console.log("data");
console.log(data);
},
async initOssClient() {
console.log("initOssClient");
const { data } = await $getCredentials();
if (data.code == 0) {
const res = data.data;
console.log(res);
this.ossClient = new OSS({ ...res, stsToken: res.securityToken });
}
},
},
};
</script>

View File

@ -7,21 +7,21 @@
:close-on-click-modal="true" :close-on-click-modal="true"
> >
<el-form :model="form" label-width="100px"> <el-form :model="form" label-width="100px">
<el-form-item label="描述"> <el-form-item label="名称" required>
<el-input v-model="form.name"></el-input> <el-input v-model="form.name"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="类型" required> <el-form-item label="类型" required>
<el-radio-group v-model="form.type"> <el-radio-group v-model="form.type">
<el-radio label="1">谢谢惠顾</el-radio> <el-radio :label="1">谢谢惠顾</el-radio>
<el-radio label="2">红包</el-radio> <el-radio :label="2">红包</el-radio>
<el-radio label="9">其他</el-radio> <el-radio :label="3">物品</el-radio>
<!-- <el-radio label="9">其他</el-radio> -->
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="红包金额比例" v-if="form.type=='2'">
<el-input-number v-model="form.ratio"></el-input-number> <el-form-item label="中奖概率" required>
</el-form-item> <el-input-number :min="0" :max="100" v-model="form.odds"></el-input-number>
<el-form-item label="中奖概率" v-if="form.type=='2'"> <span>%</span>
<el-input-number v-model="form.odds"></el-input-number>
</el-form-item> </el-form-item>
<el-form-item label="图片上传"> <el-form-item label="图片上传">
<el-upload <el-upload
@ -32,11 +32,7 @@
:on-success="uploadSuccess" :on-success="uploadSuccess"
> >
<div class="upload-file-box"> <div class="upload-file-box">
<img <img v-if="form.url" :src="form.url" class="avatar" />
v-if="form.url"
:src="form.url"
class="avatar"
/>
<i v-else class="el-icon-plus avatar-uploader-icon iconss"></i> <i v-else class="el-icon-plus avatar-uploader-icon iconss"></i>
</div> </div>
</el-upload> </el-upload>
@ -61,9 +57,8 @@ export default {
form: { form: {
name: "", name: "",
url: "", url: "",
ratio:1, type: 1,
type:'1', odds: 0,
odds:0
}, },
}; };
}, },
@ -72,18 +67,36 @@ export default {
this.form.url = file.data; this.form.url = file.data;
}, },
open(item) { open(item) {
console.log(item);
this.dialogVisible = true; this.dialogVisible = true;
this.item = item; this.item = item;
this.form = {
...item,
};
}, },
diaClose() { diaClose() {
this.dialogVisible = false; this.dialogVisible = false;
this.form = {
name: "",
url: "",
type: 1,
odds: 0,
};
}, },
async confirm() { async confirm() {
if (!this.form.name) { if (!this.form.name) {
return this.$message.error("描述不能为空"); return this.$message.error("名称不能为空");
}
if (this.form.odds === "") {
return this.$message.error("中奖概率不能为空!");
}
const { name, url, type, odds, id } = this.form;
const { data } = await $disc.update({ name, url, type, odds, id });
if (data.code == 0) {
this.$message.success("修改成功");
this.$emit("refresh");
this.diaClose();
} }
const res = await $disc.add(this.form);
console.log(res);
}, },
}, },
}; };
@ -95,13 +108,19 @@ export default {
::v-deep .el-form-item__label { ::v-deep .el-form-item__label {
text-align: left; text-align: left;
} }
.upload-file-box{ .upload-file-box {
border-radius: 6px; width: 148px; height: 148px; border-radius: 6px;
display: flex; justify-content: center; align-items: center; width: 148px;
height: 148px;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden; overflow: hidden;
border: 1px solid #c0c4cc; border: 1px solid #c0c4cc;
img{ img {
width: 100%; height: 100%; object-fit: cover; width: 100%;
height: 100%;
object-fit: cover;
} }
} }
</style> </style>

View File

@ -48,7 +48,10 @@
@click="phoneSelect" @click="phoneSelect"
style="position: absolute; right: 18px; top: 8px" style="position: absolute; right: 18px; top: 8px"
> >
<icon-svg name="shousuo" class="site-sidebar__menu-icon"></icon-svg> <icon-svg
name="shousuo"
class="site-sidebar__menu-icon"
></icon-svg>
</span> </span>
</div> </div>
<div style="position: relative; display: inline-block"> <div style="position: relative; display: inline-block">
@ -64,7 +67,10 @@
@click="phoneSelect" @click="phoneSelect"
style="position: absolute; right: 18px; top: 8px" style="position: absolute; right: 18px; top: 8px"
> >
<icon-svg name="shousuo" class="site-sidebar__menu-icon"></icon-svg> <icon-svg
name="shousuo"
class="site-sidebar__menu-icon"
></icon-svg>
</span> </span>
</div> </div>
<div style="position: relative; display: inline-block"> <div style="position: relative; display: inline-block">
@ -80,7 +86,10 @@
@click="phoneSelect" @click="phoneSelect"
style="position: absolute; right: 18px; top: 8px" style="position: absolute; right: 18px; top: 8px"
> >
<icon-svg name="shousuo" class="site-sidebar__menu-icon"></icon-svg> <icon-svg
name="shousuo"
class="site-sidebar__menu-icon"
></icon-svg>
</span> </span>
</div> </div>
<div style="position: relative; display: inline-block"> <div style="position: relative; display: inline-block">
@ -252,7 +261,9 @@
<el-button <el-button
size="mini" size="mini"
type="primary" type="primary"
:disabled="!isAuth('financeList:refund') || scope.row.state != 0" :disabled="
!isAuth('financeList:refund') || scope.row.state != 0
"
@click="refund(scope.row)" @click="refund(scope.row)"
>拒绝 >拒绝
</el-button> </el-button>
@ -286,7 +297,9 @@
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false"> </el-button> <el-button @click="dialogFormVisible = false"> </el-button>
<el-button type="primary" @click="refundNoticeTo()"> </el-button> <el-button type="primary" @click="refundNoticeTo()"
> </el-button
>
</div> </div>
</el-dialog> </el-dialog>
</el-tab-pane> </el-tab-pane>
@ -451,7 +464,9 @@
<div class="box_num"> <div class="box_num">
<div class="box_color">充值总金额</div> <div class="box_color">充值总金额</div>
<div class="text_color"> <div class="text_color">
<span>{{ rechgeData.sumMoney ? rechgeData.sumMoney : 0 }}</span <span>{{
rechgeData.sumMoney ? rechgeData.sumMoney : 0
}}</span
> >
</div> </div>
</div> </div>
@ -503,7 +518,9 @@
<div class="box_color">支付APP充值金额</div> <div class="box_color">支付APP充值金额</div>
<div class="text_color"> <div class="text_color">
<span>{{ <span>{{
rechgeData.zhiFuBaoAppMoney ? rechgeData.zhiFuBaoAppMoney : 0 rechgeData.zhiFuBaoAppMoney
? rechgeData.zhiFuBaoAppMoney
: 0
}}</span }}</span
> >
</div> </div>
@ -552,7 +569,9 @@
<div class="box_num"> <div class="box_num">
<div class="box_color">苹果充值金额</div> <div class="box_color">苹果充值金额</div>
<div class="text_color"> <div class="text_color">
<span>{{ rechgeData.iosMoney ? rechgeData.iosMoney : 0 }}</span <span>{{
rechgeData.iosMoney ? rechgeData.iosMoney : 0
}}</span
> >
</div> </div>
</div> </div>
@ -771,26 +790,59 @@
<div class=""> <div class="">
<!-- <el-button type="primary" @click="refAddZhuanpanOpen">添加抽奖项</el-button> --> <!-- <el-button type="primary" @click="refAddZhuanpanOpen">添加抽奖项</el-button> -->
<el-table :border="true" :data="zhuanpanData"> <el-table :border="true" :data="zhuanpanData">
<el-table-column label="名称" prop="name" ></el-table-column> <el-table-column label="名称" prop="name"></el-table-column>
<el-table-column label="类型" > <el-table-column label="图片">
<template slot-scope="scope">
<img style="width: 50px; height: 50px" v-if="scope.row.url" :src="scope.row.url" />
</template>
</el-table-column>
<el-table-column label="类型">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ returnTypeName(scope.row.type) }}</span> <span>{{ returnTypeName(scope.row.type) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="数量">
<template slot-scope="scope">
<span>{{ scope.row.number }}</span>
</template>
</el-table-column>
<!-- <el-table-column label="红包金额比例" >
<template slot-scope="scope">
<span>{{ scope.row.ratio }}</span>
</template>
</el-table-column> -->
<el-table-column label="中奖概率">
<template slot-scope="scope">
<span>{{ scope.row.odds }}%</span>
</template>
</el-table-column>
<el-table-column label="编辑">
<template slot-scope="scope">
<el-button
type="text"
size="mini"
@click="refAddZhuanpanOpen(scope.row)"
>编辑</el-button
>
</template>
</el-table-column>
</el-table> </el-table>
</div> </div>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
<pop-add-zhuanpan ref="refAddZhuanpan"></pop-add-zhuanpan> <pop-add-zhuanpan
</div> ref="refAddZhuanpan"
@refresh="zhuanPanRefresh"
></pop-add-zhuanpan>
</div>
</template> </template>
<script> <script>
import $disc from '@/api/disc-spinning.js' import $disc from "@/api/disc-spinning.js";
import popAddZhuanpan from './components/pop-add-zhuanpan.vue' import popAddZhuanpan from "./components/pop-add-zhuanpan.vue";
export default { export default {
components:{popAddZhuanpan}, components: { popAddZhuanpan },
data() { data() {
return { return {
// //
@ -919,17 +971,22 @@ export default {
}; };
}, },
methods: { methods: {
returnTypeName(type){ zhuanPanRefresh() {
this.page = 1;
this.limit = 10;
this.zhuanPanInit();
},
returnTypeName(type) {
const $types = { const $types = {
'1':'谢谢惠顾', 1: "谢谢惠顾",
'2':'现金红包', 2: "现金红包",
'3':'物品', 3: "物品",
} };
return $types[type]?$types[type]:'' return $types[type] ? $types[type] : "";
}, },
// show // show
refAddZhuanpanOpen(){ refAddZhuanpanOpen(item) {
this.$refs.refAddZhuanpan.open() this.$refs.refAddZhuanpan.open(item);
}, },
// //
updates(userId) { updates(userId) {
@ -1235,12 +1292,12 @@ export default {
this.rechargeSelect(); this.rechargeSelect();
}, },
// //
async zhuanPanInit(){ async zhuanPanInit() {
const {data}=await $disc.getList({ const { data } = await $disc.getList({
page:this.page, page: this.page,
limit:this.limit limit: this.limit,
}) });
this.zhuanpanData = data.data.records this.zhuanpanData = data.data.records;
}, },
handleClick(tab, event) { handleClick(tab, event) {
this.orderId = ""; this.orderId = "";

View File

@ -1726,7 +1726,6 @@
<script> <script>
import OSS from "@/utils/oss-upload.js"; import OSS from "@/utils/oss-upload.js";
import { $getCredentials } from "@/api/oss.js"; import { $getCredentials } from "@/api/oss.js";
import md5 from "js-md5";
// aa888a86dca6e9d5ae216c23070e8c47 // aa888a86dca6e9d5ae216c23070e8c47
import { quillEditor } from "vue-quill-editor"; import { quillEditor } from "vue-quill-editor";