|
|
@@ -0,0 +1,197 @@
|
|
|
+<template>
|
|
|
+ <view class="ex-page">
|
|
|
+ <view class="title">
|
|
|
+ 活动状态:<switch style="transform: scale(0.8,0.8)" :checked="rechargeSwitch == 0 ? false : true" @change="rechargeChange" />
|
|
|
+ <text v-if="rechargeSwitch == 0">关闭</text><text v-else>开启</text>
|
|
|
+ <button class="admin-button-com middle blue" @click="addHb()">新增选项</button>
|
|
|
+ </view>
|
|
|
+ <view class="recharge-list">
|
|
|
+
|
|
|
+ <view v-for="(item, index) in recharge" :key="index">
|
|
|
+
|
|
|
+ <view class="item">
|
|
|
+
|
|
|
+ <view>充值金额:<input v-model="item.amount" @click="discount=''" placeholder-class="phcolor" class="tui-input" type="digit" style="width:180rpx;border:1px solid #ddd;display:inline-block;margin:0 10rpx 0 10rpx;" />元</view>
|
|
|
+ <view>赠送红包:<input v-model="item.num" @click="discount=''" placeholder-class="phcolor" class="tui-input" type="digit" style="width:180rpx;border:1px solid #ddd;display:inline-block;margin:0 10rpx 0 10rpx;" />个</view>
|
|
|
+ <view>每个红包:<input v-model="item.hbAmount" @click="discount=''" placeholder-class="phcolor" class="tui-input" type="digit" style="width:180rpx;border:1px solid #ddd;display:inline-block;margin:0 10rpx 0rpx 10rpx;" />元</view>
|
|
|
+ <view>最低消费:<input v-model="item.miniExpend" placeholder-class="phcolor" class="tui-input" type="digit" style="width:180rpx;border:1px solid #ddd;display:inline-block;margin:0 10rpx 0 10rpx;" />元可用</view>
|
|
|
+ <view>有效时长:<input v-model="item.valid" placeholder-class="phcolor" class="tui-input" type="digit" style="width:180rpx;border:1px solid #ddd;display:inline-block;margin:0 10rpx 0 10rpx;" />天
|
|
|
+ <button class="admin-button-com mini default" @click="delHb(item)" style="margin-left:150rpx;">删除</button>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ </view>
|
|
|
+
|
|
|
+ </view>
|
|
|
+
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <view class="footer">
|
|
|
+ <button class="admin-button-com big blue" @click="saveHb()">保存</button>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import { mapGetters } from "vuex";
|
|
|
+import { getRechargeHbDetail,saveRechargeHb } from "@/api/recharge";
|
|
|
+export default {
|
|
|
+ components: {},
|
|
|
+ mixins: [],
|
|
|
+ computed: {
|
|
|
+ ...mapGetters({ myShopInfo: "getMyShopInfo" }),
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ recharge:[],
|
|
|
+ rechargeSwitch:0
|
|
|
+ };
|
|
|
+ },
|
|
|
+ onPullDownRefresh() {
|
|
|
+
|
|
|
+ },
|
|
|
+ onLoad() {
|
|
|
+
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ rechargeChange(e) {
|
|
|
+ let value = e.target.value
|
|
|
+ if(value){
|
|
|
+ this.rechargeSwitch = 1
|
|
|
+ }else{
|
|
|
+ this.rechargeSwitch = 0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ init(){
|
|
|
+ this.getDetail()
|
|
|
+ },
|
|
|
+ getDetail(){
|
|
|
+ let that = this
|
|
|
+ getRechargeHbDetail().then(res => {
|
|
|
+ that.rechargeSwitch = res.data.recharge;
|
|
|
+ if(!this.$util.isEmpty(res.data.list)){
|
|
|
+ that.recharge = res.data.list.map(e=>{
|
|
|
+ return {amount:parseFloat(e.amount),num:e.num,hbAmount:parseFloat(e.hbAmount),miniExpend:parseFloat(e.miniExpend),valid:e.valid}
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ that.recharge = [
|
|
|
+ {amount:5000,num:2,hbAmount:5,miniExpend:200,valid:30}
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ delHb(item){
|
|
|
+ if(this.recharge.length <= 1){
|
|
|
+ this.$msg("最少需要保留一个")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ var index = this.recharge.indexOf(item);
|
|
|
+ if (index > -1) {
|
|
|
+ this.recharge.splice(index, 1)
|
|
|
+ this.$msg("删除成功")
|
|
|
+ }
|
|
|
+ },
|
|
|
+ addHb(){
|
|
|
+ if(this.recharge.length > 6){
|
|
|
+ this.$msg("最多只能设置6个")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ this.recharge.push({amount:'',num:'',hbAmount:'',miniExpend:'',valid:''})
|
|
|
+ },
|
|
|
+ saveHb(){
|
|
|
+ let amountGroup = []
|
|
|
+ let hasError = false
|
|
|
+ this.recharge.forEach(e => {
|
|
|
+ let currentAmount = parseFloat(e.amount)
|
|
|
+ if(amountGroup.indexOf(currentAmount) > -1){
|
|
|
+ this.$msg("充值金额"+currentAmount+"重复了")
|
|
|
+ hasError = true
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ amountGroup.push(currentAmount)
|
|
|
+
|
|
|
+ if(this.$util.isMoney(e.num) == false || e.num%1 !== 0){
|
|
|
+ this.$msg("请填写红包数量")
|
|
|
+ hasError = true
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ if(this.$util.isMoney(e.valid) == false || e.valid%1 !== 0){
|
|
|
+ this.$msg("请填写有效期")
|
|
|
+ hasError = true
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ if(this.$util.isMoney(e.hbAmount) == false){
|
|
|
+ this.$msg("请填写红包金额"+e.hbAmount)
|
|
|
+ hasError = true
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ if(this.$util.isMoney(e.miniExpend) == false){
|
|
|
+ this.$msg("请填写最低消费金额")
|
|
|
+ hasError = true
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if(Number(e.miniExpend) <= Number(e.hbAmount)){
|
|
|
+ uni.showToast({title: '最低消费金额要大于红包金额',duration: 3000,icon:"none"})
|
|
|
+ hasError = true
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if(hasError){
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ saveRechargeHb({data:JSON.stringify(this.recharge),rechargeSwitch:this.rechargeSwitch}).then(res=>{
|
|
|
+ if(res.code == 1){
|
|
|
+ this.$msg(res.msg)
|
|
|
+ setTimeout(() => {
|
|
|
+ this.$util.pageTo(1);
|
|
|
+ }, 1000);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.ex-page{
|
|
|
+ .title{
|
|
|
+ position: fixed;
|
|
|
+ z-index:999999;
|
|
|
+ padding-left:20rpx;
|
|
|
+ font-size:30rpx;
|
|
|
+ background:white;
|
|
|
+ width:100%;
|
|
|
+ button{
|
|
|
+ position: fixed;
|
|
|
+ right:10rpx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .recharge-list{
|
|
|
+ line-height:80px;
|
|
|
+ padding-left:20rpx;
|
|
|
+ font-size:30rpx;
|
|
|
+ padding-bottom:100rpx;
|
|
|
+ padding-top:110rpx;
|
|
|
+ .item{
|
|
|
+ margin-bottom:60rpx;
|
|
|
+ input{
|
|
|
+ height:18rpx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .footer{
|
|
|
+ margin-top:50rpx;
|
|
|
+ text-align: center;
|
|
|
+ position: fixed;
|
|
|
+ bottom:0;
|
|
|
+ width:100%;
|
|
|
+ background:#FFFFFF;
|
|
|
+ z-index:99999;
|
|
|
+ button{
|
|
|
+ width:90%;
|
|
|
+ margin:0 auto;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|