<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<!-- 引入 vue 入口文件 -->
<script type="module" src="./main.js"></script>
</head>
<body>
<div id="app"></div>
</body>
</html>
index.html
main.js
App.vue
package.json
现在支持上传本地图片了!
index.html
main.js
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
createApp(App).use(ElementPlus).mount('#app')
编辑器加载中
App.vue
<template>
<div style="margin: 50px 0;">
<el-text tag="b" type="success" size="large" style="font-size: 6vh;">Hello 欢迎使用</el-text>
</div>
<div style="margin: 50px 0;">
<el-text tag="b" type="primary" size="large" style="margin: 0 20px;">请输入你的游戏总价</el-text>
<el-input-number v-model="a" :min="0" :max="1000" :controls="false" style="auto">
<template #suffix>
<span>RMB</span>
</template>
</el-input-number>
</div>
<div class="re">
<div>
<el-text type="info" size="large">95折优惠后:</el-text>
<el-text tag="b" type="primary" size="large">{{ (a * 0.95).toFixed(2) }} 元</el-text>
</div>
<div style="display: flex;justify-content: center;width: 100%;gap:40px">
<div style="margin: 20px">
<el-text type="info" size="large">方案一:叠加95折优惠后 </el-text>
<el-text tag="b" type="success" size="large"> {{ (a * 0.9025).toFixed(2) }} 元</el-text>
<el-progress :percentage=" a === 0 ? 0 :((a * 0.9025).toFixed(2) / a).toFixed(2) * 100" :stroke-width="24" :text-inside="true" status="success" striped striped-flow :duration="15" />
</div>
<div style="margin: 20px">
<el-text type="info" size="large">方案二:每满25-1.5立减后 </el-text>
<el-text tag="b" type="success" size="large"> {{ (a * 0.95 - Math.floor(a / 25) * 1.5).toFixed(2) }} 元</el-text>
<el-progress :percentage=" a === 0 ? 0 :((a * 0.95 - Math.floor(a / 25) * 1.5).toFixed(2) / a).toFixed(2) * 100" :stroke-width="24" :text-inside="true" status="success" striped striped-flow :duration="15" />
</div>
</div>
</div>
<div class="re">
<el-text tag="b" type="primary" size="large" style="margin-top: 40px">最优惠的方案</el-text>
<div>
<el-text tag="b" type="success" size="large">{{ (a * 0.95 - Math.floor(a / 25) * 1.5).toFixed(2) >= (a * 0.9025).toFixed(2)
? "方案一 "
: "方案二 "}}</el-text>
<el-text tag="b" type="warning" size="large">
{{ (a * 0.95 - Math.floor(a / 25) * 1.5).toFixed(2) >= (a * 0.9025).toFixed(2)
? (a * 0.9025).toFixed(2)
: (a * 0.95 - Math.floor(a / 25) * 1.5).toFixed(2) }} 元</el-text>
</div>
<el-text v-show="a > 100" size="small" type="danger" tag="i">总价较高请提前联系我,以防预备的余额不足!</el-text>
</div>
</template>
<script setup>
import {
ref,
watch
} from "vue"
let a = ref(0);
watch(a, () => {
if(a.value === null) {
a.value = 0;
}
})
</script>
<style>
html,
body {
background-color: #fefefe;
text-align: center;
padding: 20px 0;
margin: 0 auto;
width: 100%
}
.re {
display: flex;
justify-content: center;
flex-direction: column;
gap:20px;
}
</style>
编辑器加载中
package.json
注意:新添加的依赖包首次加载可能会报错,稍后再次刷新即可
{
"dependencies": {
"vue": "3.5.15",
"element-plus": "2.9.4",
"@element-plus/icons-vue": "2.3.1"
}
}
编辑器加载中
预览页面