给智慧充值添加开关按钮

This commit is contained in:
gyq
2025-12-04 16:54:40 +08:00
parent b9743fe268
commit e240f02e4a

View File

@@ -5,6 +5,17 @@
<myTabs :defaultIndex="tabsCurrent" :list="tabsList" @change="tabsChange"></myTabs>
</view>
</view>
<view class="switch-container">
<view class="switch-wrap">
<view class="title">
<text class="t">是否开启</text>
</view>
<view class="switch">
<!-- <u-switch size="large" v-model="isOpen" :active-value="1" :inactive-value="0"></u-switch> -->
<switch :checked="!!isOpen" foreColor="#33a0ff" color="#33a0ff" @change="isOpenChange"></switch>
</view>
</view>
</view>
<template v-if="tabsCurrent === 0">
<view class="u-p-30">
<view class="u-flex bg-fff u-p-30 border-r-12" @tap="toAddRecharge">
@@ -14,7 +25,6 @@
<view class="">添加充值面额</view>
</view>
</view>
<view class="u-p-30">
<view class="u-m-b-32" v-for="(item, index) in rechargeLists" :key="index">
<recharge-item @del="rechargeItemDel" :index="index" :data="item" :isCanEdit="isCanEdit"></recharge-item>
@@ -82,7 +92,7 @@
<script setup>
import { computed, reactive, ref } from 'vue';
import {onShow} from '@dcloudio/uni-app'
import { onShow } from '@dcloudio/uni-app';
import myTabs from '@/components/my-components/my-tabs.vue';
import myIcons from '@/components/my-components/my-icons.vue';
import mySwitch from '@/components/my-components/my-switch.vue';
@@ -95,11 +105,25 @@ import $util from '@/commons/utils/getDateArea.js';
import go from '@/commons/utils/go.js';
import { shopRechargePost, shopRechargeGet } from '@/http/api/market/index.js';
import { onLoad } from '@dcloudio/uni-app';
import { isMainShop } from "@/store/account.js";
import { isMainShop } from '@/store/account.js';
const isCanEdit=computed(()=>{
return isMainShop()
})
const isCanEdit = computed(() => {
return isMainShop();
});
const isOpen = ref(0);
async function isOpenChange(e) {
console.log(e);
isOpen.value = e.detail.value;
try {
const data = await shopRechargeGet();
data.isEnable = isOpen.value ? 1 : 0;
await shopRechargePost(data);
} catch (error) {
console.log(error);
}
}
const model = ref(null);
const modelData = reactive({
@@ -171,6 +195,7 @@ function useTypeChange(e) {
async function shopRechargeGetAjax() {
try {
const res = await shopRechargeGet();
isOpen.value = res.isEnable;
res.rechargeDetailList.forEach((item) => {
item.couponInfoList.forEach((val) => {
if (val.coupon && val.coupon !== null) {
@@ -259,6 +284,23 @@ onShow(() => {
</script>
<style lang="scss" scoped>
.switch-container {
padding: 28upx;
}
.switch-wrap {
background-color: #fff;
border-radius: 20upx;
padding: 28upx;
display: flex;
align-items: center;
justify-content: space-between;
.title {
.t {
font-size: 32upx;
color: #333;
}
}
}
.u-overflow-hide {
overflow: hidden;
}