Browse Source

图片上传

Hongxilin
hongxilin 5 months ago
parent
commit
f45288eb12
  1. 64
      vue/gold-system/src/views/recharge/addRecharge.vue

64
vue/gold-system/src/views/recharge/addRecharge.vue

@ -8,6 +8,9 @@ import { ElMessageBox } from "element-plus";
import API from "../../api/index.js"; import API from "../../api/index.js";
import moment from "moment"; import moment from "moment";
//
const imageUrl = ref("");
const Rate = ref();
const adminData = ref({}); const adminData = ref({});
const getAdminData = async function () { const getAdminData = async function () {
try { try {
@ -52,15 +55,16 @@ const add = async function () {
// //
ElMessage.success("添加成功"); ElMessage.success("添加成功");
// //
addRecharge.value = {
adminId: adminData.value.adminId,
area: adminData.value.area,
rechargeVoucher: "",
rechargeWay: "客服充值",
freeGold: Number(0),
rechargeGold: 1,
paidGold: "",
};
addRecharge.value = {};
addRecharge.value.adminId = adminData.value.adminId;
addRecharge.value.area = adminData.value.area;
addRecharge.value.rechargeVoucher = "";
addRecharge.value.rechargeWay = "客服充值";
addRecharge.value.freeGold = 0;
addRecharge.value.rechargeGold = 1;
addRecharge.value.paidGold = "";
imageUrl.value = "";
Rate.value = null;
user.value = {}; user.value = {};
// addRecharge.value.adminId = adminData.value.adminId; // addRecharge.value.adminId = adminData.value.adminId;
// addRecharge.value.area = adminData.value.area; // addRecharge.value.area = adminData.value.area;
@ -194,8 +198,7 @@ const getCurrency = async function () {
}; };
getCurrency(); getCurrency();
//
const imageUrl = ref("");
// //
const handleAvatarSuccess = (response, uploadFile) => { const handleAvatarSuccess = (response, uploadFile) => {
@ -211,16 +214,16 @@ const handleAvatarSuccess = (response, uploadFile) => {
// rechargeVoucher: base64data, // rechargeVoucher: base64data,
// }; // };
// JSON // JSON
axios
.post("http://192.168.8.93:10010/upload", data)
.then((res) => {
console.log("图片上传成功", res);
addRecharge.value.rechargeVoucher = `http://192.168.8.93:10010/upload/${response.data}`;
console.log("图片名称", addRecharge.value.rechargeVoucher);
})
.catch((error) => {
console.error("图片上传失败", error);
});
// axios
// .post("http://192.168.8.93:10010/upload",data)
// .then((res) => {
// console.log("", res);
// addRecharge.value.rechargeVoucher = `http://192.168.8.93:10010/upload/${response.data}`;
// console.log("", addRecharge.value.rechargeVoucher);
// })
// .catch((error) => {
// console.error("", error);
// });
}; };
// reader.readAsDataURL(uploadFile.raw); // reader.readAsDataURL(uploadFile.raw);
// imageUrl.value = URL.createObjectURL(uploadFile.raw); // imageUrl.value = URL.createObjectURL(uploadFile.raw);
@ -411,10 +414,10 @@ const calculatedFreeGold = computed(() => {
} }
}); });
const calculatedRechargeGold = computed(() => { const calculatedRechargeGold = computed(() => {
if (!addRecharge.value.rateId == 0) {
if (!Rate.value == 0) {
const paidGold = Number(addRecharge.value.paidGold) || 0; const paidGold = Number(addRecharge.value.paidGold) || 0;
const rateId = Number(addRecharge.value.rateId) || 1; // 0
return Math.ceil(paidGold * rateId);
const rate = Number(Rate.value) || 1; // 0
return Math.ceil(paidGold * rate);
} }
}); });
@ -576,10 +579,10 @@ const calculatedRowFreeGold = function (row) {
}; };
const calculatedRowRechargeGold = computed(() => { const calculatedRowRechargeGold = computed(() => {
if (!addRecharge.value.rateId == 0) {
if (!Rate.value == 0) {
const paidGold = Number(addRecharge.value.paidGold) || 0; const paidGold = Number(addRecharge.value.paidGold) || 0;
const rateId = Number(addRecharge.value.rateId) || 1; // 0
return Math.ceil(paidGold * rateId);
const rate = Number(Rate.value) || 1; // 0
return Math.ceil(paidGold * rate);
} }
}); });
@ -683,7 +686,7 @@ const batchAdd = function () {
<el-form-item prop="rechargeGold" label="充值金额"> <el-form-item prop="rechargeGold" label="充值金额">
<el-select <el-select
prop="rechargeGold" prop="rechargeGold"
v-model="addRecharge.rateId"
v-model="Rate"
placeholder="货币名称" placeholder="货币名称"
style="width: 95px; margin-right: 5px" style="width: 95px; margin-right: 5px"
> >
@ -727,6 +730,7 @@ const batchAdd = function () {
style="margin-bottom: 5px" style="margin-bottom: 5px"
> >
<el-upload <el-upload
action="http://192.168.8.93:10010/upload"
class="avatar-uploader" class="avatar-uploader"
:show-file-list="false" :show-file-list="false"
:on-success="handleAvatarSuccess" :on-success="handleAvatarSuccess"
@ -932,7 +936,7 @@ const batchAdd = function () {
v-if="scope.row.showInput" v-if="scope.row.showInput"
filterable filterable
clearable clearable
v-model="scope.row.rateId"
v-model="scope.row.rate"
placeholder="请选择币种" placeholder="请选择币种"
> >
<el-option <el-option
@ -943,7 +947,7 @@ const batchAdd = function () {
> >
</el-option> </el-option>
</el-select> </el-select>
<span v-else>{{ scope.row.rateId }}</span>
<span v-else>{{ scope.row.rate }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column property="rechargeGold" label="充值金额" width="110px"> <el-table-column property="rechargeGold" label="充值金额" width="110px">

Loading…
Cancel
Save