hongxilin 5 months ago
parent
commit
c6d043bb21
  1. 9
      vue/gold-system/src/api/index.js
  2. BIN
      vue/gold-system/src/assets/background.jpg
  3. 11
      vue/gold-system/src/router/index.js
  4. 32
      vue/gold-system/src/util/http.js
  5. 230
      vue/gold-system/src/views/consume/addConsume.vue
  6. 60
      vue/gold-system/src/views/index.vue
  7. 130
      vue/gold-system/src/views/login.vue
  8. 7
      vue/gold-system/src/views/recharge/addRecharge.vue
  9. 22
      vue/gold-system/src/views/refund/addRefund.vue
  10. 6
      vue/gold-system/src/views/refund/allRefund.vue

9
vue/gold-system/src/api/index.js

@ -0,0 +1,9 @@
import http from '../util/http.js';
const API={
post: function(url,data){
return http({url:url,method:'post',data:data})
},
};
export default API;

BIN
vue/gold-system/src/assets/background.jpg

After

Width: 928  |  Height: 1133  |  Size: 567 KiB

11
vue/gold-system/src/router/index.js

@ -3,9 +3,11 @@ import { createRouter,createWebHashHistory } from 'vue-router';
const router=createRouter({
history:createWebHashHistory(),
routes:[
{path:'/login', name:"login", component:()=>import("../views/login.vue")},
{path:'/',redirect:"/workspace"},
{path:'/test',component:()=>import("../views/z.vue")},
{
meta:{requireAuth:true},
path:'/index',component:()=>import("../views/index.vue"),
children:[
// 工作台
@ -40,4 +42,13 @@ const router=createRouter({
]
});
router.beforeEach((to,from,next)=>{
const token=localStorage.getItem("token");
if(to.name!="login"&&!token){
next({name:"login"});
}else{
next();
}
})
export default router;

32
vue/gold-system/src/util/http.js

@ -0,0 +1,32 @@
import axios from 'axios';
export default function (options) {
//配置每次发送请求都从localStorage中获取名字叫token的数据,
//添加到请求头部的Authorization属性中
//Object.assign用于合并对象的数据
options.headers = Object.assign(
{ Authorization: localStorage.getItem('token') },
options.headers || {}
);
//axios() 返回一个promise对象,用于异步请求
//options是一个对象,其中包含了许多用于配置请求的参数,
//例如请求的url、请求方法(GET、POST等)、请求头等
return axios(options)
.then(({ status, data, statusText }) => {
//该函数在请求成功并返回数据时被调用
//status:HTTP状态码,例如200表示请求成功。
//data:服务器返回的数据。
// statusText:HTTP状态文本,例如"OK"表示请求成功。
console.log(data);
if (status == 200) {
return data;
} else {
throw new Error(statusText);
}
})
.catch(e=>{
return Promise.reject(e);
//return Promise.reject(e.message);
});
}

230
vue/gold-system/src/views/consume/addConsume.vue

@ -6,14 +6,19 @@ import { Plus } from "@element-plus/icons-vue";
import axios from "axios";
import { ElMessageBox } from "element-plus";
//
const addConsume = ref({});
//
//
const addConsume = ref({
freeCoin: 0,
rechargeCoin: 0,
taskCoin: 0,
updateType: "消费",
});
//
const add = async function () {
try {
// POST
const result = await axios.post(
"http://192.168.8.93:10010/recharge/recharge/add",
"http://192.168.8.147:10030/consume/add",
addConsume.value
);
@ -59,7 +64,7 @@ const checkEndTime = function (rule, value, callback) {
};
const rules = reactive({
jwcode: [{ required: true, message: "请输入精网号", trigger: "blur" }],
refundGoods: [{ required: true, message: "请选择退款商品", trigger: "blur" }],
goods: [{ required: true, message: "请选择消费商品", trigger: "blur" }],
taskCoin: [{ required: true, message: "请输入任务金币", trigger: "blur" }],
freeCoin: [{ required: true, message: "请输入免费金币", trigger: "blur" }],
rechargeCoin: [
@ -94,97 +99,70 @@ const getUser = async function (jwcode) {
}
};
//
const activity = ref([]);
const getActivity = async function () {
//
const goods = ref([]);
const getGoods = async function () {
try {
// POST
const result = await axios.post(
"http://192.168.8.93:10010/recharge/activity/select",
{}
);
const result = await axios.post("http://192.168.8.93:10020/product", {});
//
console.log("请求成功", result);
//
activity.value = result.data.data;
console.log("活动信息", activity.value);
//
goods.value = result.data.data;
console.log("allData", allData.value);
console.log("地区", area.value);
} catch (error) {
console.log("请求失败", error);
//
}
};
getActivity();
getGoods();
//
const currency = ref([]);
const getCurrency = async function () {
//
const userGold = ref({});
const getUserGold = async function (jwcode) {
try {
// POST
const result = await axios.post(
"http://192.168.8.174:10010/rates/search",
{}
"http://192.168.8.147:10070/statistics/getMess/" + jwcode
);
//
console.log("货币请求成功", result);
//
currency.value = result.data.data;
console.log("tableData", currency.value);
// UI
console.log("请求成功", result);
//
userGold.value = result.data.data;
console.log("userGold", userGold.value);
} catch (error) {
console.log("请求失败", error);
//
}
};
getCurrency();
//
const imageUrl = ref("");
function calculateCoins() {
// allGold
const originalAllGold = addConsume.value.allGold;
//
const handleAvatarSuccess = (response, uploadFile) => {
imageUrl.value = URL.createObjectURL(uploadFile.raw);
console.log("图片上传成功", response, uploadFile);
addConsume.value.rechargeVoucher =
"http://192.168.8.93:10010/upload/" + response.data;
console.log("图片名称", addConsume.value.rechargeVoucher);
};
//
const beforeAvatarUpload = (rawFile) => {
if (rawFile.type !== "image/jpeg") {
ElMessage.error("Avatar picture must be JPG format!");
return false;
} else if (rawFile.size / 1024 / 1024 > 2) {
ElMessage.error("Avatar picture size can not exceed 2MB!");
return false;
}
return true;
};
// todayTasktodayFree
const todayTask =
typeof userGold.value.todayTask === "number" ? userGold.value.todayTask : 0;
const todayFree =
typeof userGold.value.todayFree === "number" ? userGold.value.todayFree : 0;
//
const options = [
{
value: "现金充值",
label: "现金充值",
},
{
value: "龙鳞卡",
label: "龙鳞卡",
},
{
value: "弘粉卡",
label: "弘粉卡",
},
];
//
addConsume.value.taskCoin = Math.min(originalAllGold, todayTask);
let remainingGold = originalAllGold - addConsume.value.taskCoin;
const calculatedFreeGold = computed(() => {
return addConsume.value.paidGold * addConsume.value.activityId;
});
addConsume.value.freeCoin = Math.min(remainingGold, todayFree);
remainingGold -= addConsume.value.freeCoin;
watch(calculatedFreeGold, (newVal) => {
addConsume.value.freeGold = newVal;
});
addConsume.value.rechargeCoin = remainingGold; //
// allGold
addConsume.value.allGold = originalAllGold;
// taskCoin, freeCoin, rechargeCoinNaN0
if (isNaN(addConsume.value.taskCoin)) addConsume.value.taskCoin = 0;
if (isNaN(addConsume.value.freeCoin)) addConsume.value.freeCoin = 0;
if (isNaN(addConsume.value.rechargeCoin)) addConsume.value.rechargeCoin = 0;
console.log("计算结果", addConsume.value);
}
</script>
<template>
@ -196,9 +174,14 @@ watch(calculatedFreeGold, (newVal) => {
:rules="rules"
label-width="auto"
style="max-width: 750px"
class="form-style"
>
<el-form-item prop="jwcode" label="精网号">
<el-input v-model="addConsume.jwcode" style="width: 220px" />
<el-input
v-model="addConsume.jwcode"
style="width: 220px"
@change="getUserGold(addConsume.jwcode)"
/>
<el-button
type="primary"
@click="getUser(addConsume.jwcode)"
@ -208,53 +191,59 @@ watch(calculatedFreeGold, (newVal) => {
</el-form-item>
<el-form-item prop="goods" label="商品名称">
<el-select
v-model="addConsume.goods"
v-model="addConsume.productId"
placeholder="请选择"
style="width: 300px"
>
<el-option
v-for="item in activity"
v-for="item in goods"
:key="item.value"
:label="item.activityName"
:value="item.rechargeRatio"
:label="item.name"
:value="item.productId"
/>
</el-select>
</el-form-item>
<el-form-item prop="allGold" label="消费金币总数">
<el-input v-model="addConsume.paidGold" style="width: 100px" />
</el-form-item>
<el-form-item prop="taskCoin" label="任务金币" style="float: left">
<el-input
disabled
v-model="addConsume.taskCoin"
style="width: 100px; margin-left: -5px"
/>
<p style="margin-right: 0px"></p>
</el-form-item>
<el-form-item
prop="freeCoin"
label="免费金币"
style="float: left; margin-left: -10px; margin-right: -10px"
>
<el-input
disabled
v-model="addConsume.freeCoin"
style="width: 100px; margin-left: -5px"
/>
<p style="margin-right: 0px"></p>
</el-form-item>
<el-form-item
prop="rechargeCoin"
label="充值金币"
style="margin-left: -20px"
>
<el-input
disabled
v-model="addConsume.rechargeCoin"
style="width: 100px; margin-left: -5px"
v-model="addConsume.allGold"
style="width: 100px"
@change="calculateCoins()"
/>
<p style="margin-right: 20px"></p>
</el-form-item>
<div style="display: flex; align-items: center">
<el-form-item prop="taskCoin" label="任务金币" style="float: left">
<el-input
disabled
v-model="addConsume.taskCoin"
style="width: 100px; margin-left: -5px"
/>
<p style="margin-right: 0px"></p>
</el-form-item>
<el-form-item
prop="freeCoin"
label="免费金币"
style="float: left; margin-left: -20px"
>
<el-input
disabled
v-model="addConsume.freeCoin"
style="width: 100px; margin-left: -5px"
/>
<p style="margin-right: 0px"></p>
</el-form-item>
<el-form-item
prop="rechargeCoin"
label="充值金币"
style="margin-left: -20px"
>
<el-input
disabled
v-model="addConsume.rechargeCoin"
style="width: 100px; margin-left: -5px"
/>
<p style="margin-right: 20px"></p>
</el-form-item>
</div>
<el-form-item prop="remark" label="备注">
<el-input
v-model="addConsume.remark"
@ -273,17 +262,14 @@ watch(calculatedFreeGold, (newVal) => {
placeholder="提交人姓名"
/>
</el-form-item>
<el-button @click="closeAddActivityVisible" style="margin-left: 280px"
>取消</el-button
>
<el-button type="primary" @click="addBefore"> 提交 </el-button>
</el-form>
<el-button @click="closeAddActivityVisible" style="margin-left: 280px"
>取消</el-button
>
<el-button type="primary" @click="addBefore"> 提交 </el-button>
<!-- 客户信息栏 -->
<el-card
style="width: 700px; float: right; margin-top: -330px; margin-right: 100px"
>
<el-card style="width: 700px; float: right" class="form-style2">
<el-form
:model="user"
label-width="auto"
@ -368,4 +354,12 @@ p {
height: 50px;
text-align: center;
}
.form-style {
margin-top: 50px;
max-width: 50%;
float: left;
}
.form-style2 {
max-width: 50%;
}
</style>

60
vue/gold-system/src/views/index.vue

@ -2,29 +2,47 @@
import { ref, onMounted, reactive, computed } from "vue";
import { useRouter } from "vue-router";
import ElementPlus from "element-plus";
import { VscGlobe } from 'vue-icons-plus/vsc'
import { VscGlobe } from "vue-icons-plus/vsc";
import { ElMessage } from "element-plus";
const router = useRouter();
//
const admin = ref({
adminId: 1,
name:'客服A',
area:'新加坡'
})
adminId: 1,
name: "客服A",
area: "新加坡",
});
function logout() {
localStorage.removeItem("token");
router.push("/login");
ElMessage.success("退出成功");
}
</script>
<template>
<div class="common-layout">
<el-container>
<el-aside style="width: 250px;">
<el-aside style="width: 250px">
<div class="logo">
<img src="../assets/金币管理系统logo.png" alt="logo" style="width: 30px;height: 30px;" />
<div style="font-size: 16px; font-weight: bold;">海外金币管理系统</div>
<img
src="../assets/金币管理系统logo.png"
alt="logo"
style="width: 30px; height: 30px"
/>
<div style="font-size: 16px; font-weight: bold">海外金币管理系统</div>
</div>
<el-menu router="true" background-color="#08193d" active-text-color="#ffd04b" text-color="white"
class="el-menu-vertical-demo" default-active="2" @open="handleOpen" @close="handleClose">
<el-menu
router="true"
background-color="#08193d"
active-text-color="#ffd04b"
text-color="white"
class="el-menu-vertical-demo"
default-active="2"
@open="handleOpen"
@close="handleClose"
>
<el-menu-item index="/workspace">
<el-icon>
<Folder />
@ -94,20 +112,28 @@ const admin = ref({
</el-icon>
客户金币明细
</el-menu-item>
</el-menu>
</el-aside>
<el-container>
<el-header>
<el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" :ellipsis="false"
@select="handleSelect">
<el-menu
:default-active="activeIndex"
class="el-menu-demo"
mode="horizontal"
:ellipsis="false"
@select="handleSelect"
>
<el-sub-menu index="1" class="admin">
<template #title>
<img style="width: 30px;height: 30px; border-radius: 50%;" src="../assets/金币管理系统logo.png" alt="出错了" />
<span style="margin-left: 10px;">{{ admin.name }}</span>
<img
style="width: 30px; height: 30px; border-radius: 50%"
src="../assets/金币管理系统logo.png"
alt="出错了"
/>
<span style="margin-left: 10px">{{ admin.name }}</span>
</template>
<el-menu-item index="1-1">查看个人信息</el-menu-item>
<el-menu-item index="1-2">退出登录</el-menu-item>
<el-menu-item index="1-2" @click="logout">退出登录</el-menu-item>
</el-sub-menu>
<el-menu-item index="2">
<VscGlobe />
@ -138,4 +164,4 @@ const admin = ref({
margin: 20px 0px 20px 20px;
display: flex;
}
</style>
</style>

130
vue/gold-system/src/views/login.vue

@ -0,0 +1,130 @@
<script setup>
import { ref, onMounted, reactive, computed } from "vue";
import { ElMessage } from "element-plus";
import axios from "axios";
import { useRouter } from "vue-router";
import { VscGlobe } from "vue-icons-plus/vsc";
const router = useRouter(); //
const form = ref({ name: "", password: "" });
//
const login = async function () {
try {
const result = await axios.post(
"http://192.168.8.93:10070/admin/login",
form.value
);
if (result.data.code == 200) {
localStorage.setItem("token", result.data.msg);
router.push("/");
ElMessage.success("登录成功");
console.log("请求成功", result);
} else {
form.value.password = "";
form.value.username = "";
ElMessage.error(result.data.msg);
}
} catch (error) {
console.log("请求失败", error);
ElMessage.error(result.data.msg);
//
}
};
</script>
<template>
<el-row class="login-page">
<img
:span="12"
src="../assets/background.jpg"
alt="logo"
class="bg"
fit="fit"
/>
<el-col :span="6" :offset="3" class="form">
<!-- 登录表单 -->
<el-form
:model="form"
size="large"
autocomplete="off"
@keyup.enter.native="login()"
>
<el-form-item>
<h1 style="color: #409eff">金币系统登录</h1>
</el-form-item>
<el-form-item prop="username">
<el-input
v-model="form.username"
placeholder="请输入用户名"
></el-input>
</el-form-item>
<el-form-item prop="password">
<el-input
v-model="form.password"
type="password"
placeholder="请输入密码"
/>
</el-form-item>
<el-form-item class="flex">
<div class="flex">
<el-checkbox>记住我</el-checkbox>
</div>
</el-form-item>
<!-- 登录按钮 -->
<el-form-item>
<el-button
class="button"
type="primary"
auto-insert-space
@click="login()"
>登录</el-button
>
</el-form-item>
</el-form>
</el-col>
</el-row>
</template>
<style scoped>
.bg {
border-radius: 0 20px 20px 0;
height: 100vh;
width: 50%;
object-fit: cover;
}
.background {
color: #fffdfd;
text-align: center;
font-size: 24px;
background-color: #08193d;
}
.form {
display: flex;
flex-direction: column;
justify-content: center;
user-select: none;
.title {
margin: 0 auto;
}
.button {
width: 100%;
}
.flex {
width: 100%;
display: flex;
justify-content: space-between;
}
}
/* .box {
padding: 20px;
border-radius: 10px;
background-color: #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
} */
</style>

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

@ -5,6 +5,7 @@ import { ElMessage } from "element-plus";
import { Plus } from "@element-plus/icons-vue";
import axios from "axios";
import { ElMessageBox } from "element-plus";
import API from "../../api/index.js";
//
const addRecharge = ref({
@ -19,7 +20,7 @@ const addRecharge = ref({
const add = async function () {
try {
// POST
const result = await axios.post(
const result = await API.post(
"http://192.168.8.93:10010/recharge/recharge/add",
addRecharge.value
);
@ -85,7 +86,7 @@ const user = ref({});
const getUser = async function (jwcode) {
try {
// POST
const result = await axios.post("http://192.168.8.93:10020/recharge/user", {
const result = await API.post("http://192.168.8.93:10020/recharge/user", {
jwcode: jwcode,
});
@ -111,7 +112,7 @@ const activity = ref([]);
const getActivity = async function () {
try {
// POST
const result = await axios.post(
const result = await API.post(
"http://192.168.8.93:10010/recharge/activity/select",
{}
);

22
vue/gold-system/src/views/refund/addRefund.vue

@ -13,6 +13,9 @@ const addRefund = ref({
allCoin: 0,
contactId: "",
refundGoods: "",
freeCoin: 0,
rechargeCoin: 0,
taskCoin: 0,
});
//
const add = async function () {
@ -37,9 +40,16 @@ const addBefore = () => {
if (valid) {
ElMessageBox.confirm("确认添加?")
.then(() => {
addRefund.value.freeCoin = Number(-addRefund.value.freeCoin);
addRefund.value.rechargeCoin = Number(-addRefund.value.rechargeCoin);
addRefund.value.taskCoin = Number(-addRefund.value.taskCoin);
add();
console.log("添加成功");
addRefund.value = {};
addRefund.value.allCoin = 0;
(addRefund.value.freeCoin = 0),
(addRefund.value.rechargeCoin = 0),
(addRefund.value.taskCoin = 0),
(addRefund.value = {});
})
.catch(() => {
console.log("取消添加");
@ -100,11 +110,11 @@ const getUser = async function (jwcode) {
}
};
const calculatedAllGold = computed(() => {
return (
addRefund.value.freeCoin +
addRefund.value.rechargeCoin +
addRefund.value.taskCoin
);
const sum =
Number(addRefund.value.freeCoin) +
Number(addRefund.value.rechargeCoin) +
Number(addRefund.value.taskCoin);
return !isNaN(sum) ? sum : 0;
});
watch(calculatedAllGold, (newVal) => {

6
vue/gold-system/src/views/refund/allRefund.vue

@ -418,19 +418,19 @@ getGoods();
<el-table-column prop="auditStatus" label="审核状态" width="120px">
<!-- 模板内容 -->
<template #default="scope">
<span v-if="scope.row.auditStatus === 1">
<span v-if="scope.row.auditStatus == 1">
<div class="status">
<span class="green-dot"></span>
<span>已通过</span>
</div>
</span>
<span v-if="scope.row.auditStatus === 0">
<span v-if="scope.row.auditStatus == 0">
<div class="status">
<span class="grey-dot"></span>
<span>待审核</span>
</div>
</span>
<span v-if="scope.row.auditStatus === 2">
<span v-if="scope.row.auditStatus == 2">
<div class="status">
<span class="red-dot"></span>
<span>已驳回</span>

Loading…
Cancel
Save