给智慧充值添加开关按钮
This commit is contained in:
@@ -5,6 +5,17 @@
|
|||||||
<myTabs :defaultIndex="tabsCurrent" :list="tabsList" @change="tabsChange"></myTabs>
|
<myTabs :defaultIndex="tabsCurrent" :list="tabsList" @change="tabsChange"></myTabs>
|
||||||
</view>
|
</view>
|
||||||
</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">
|
<template v-if="tabsCurrent === 0">
|
||||||
<view class="u-p-30">
|
<view class="u-p-30">
|
||||||
<view class="u-flex bg-fff u-p-30 border-r-12" @tap="toAddRecharge">
|
<view class="u-flex bg-fff u-p-30 border-r-12" @tap="toAddRecharge">
|
||||||
@@ -14,7 +25,6 @@
|
|||||||
<view class="">添加充值面额</view>
|
<view class="">添加充值面额</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="u-p-30">
|
<view class="u-p-30">
|
||||||
<view class="u-m-b-32" v-for="(item, index) in rechargeLists" :key="index">
|
<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>
|
<recharge-item @del="rechargeItemDel" :index="index" :data="item" :isCanEdit="isCanEdit"></recharge-item>
|
||||||
@@ -82,7 +92,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, reactive, ref } from 'vue';
|
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 myTabs from '@/components/my-components/my-tabs.vue';
|
||||||
import myIcons from '@/components/my-components/my-icons.vue';
|
import myIcons from '@/components/my-components/my-icons.vue';
|
||||||
import mySwitch from '@/components/my-components/my-switch.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 go from '@/commons/utils/go.js';
|
||||||
import { shopRechargePost, shopRechargeGet } from '@/http/api/market/index.js';
|
import { shopRechargePost, shopRechargeGet } from '@/http/api/market/index.js';
|
||||||
import { onLoad } from '@dcloudio/uni-app';
|
import { onLoad } from '@dcloudio/uni-app';
|
||||||
import { isMainShop } from "@/store/account.js";
|
import { isMainShop } from '@/store/account.js';
|
||||||
|
|
||||||
const isCanEdit = computed(() => {
|
const isCanEdit = computed(() => {
|
||||||
return isMainShop()
|
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 model = ref(null);
|
||||||
const modelData = reactive({
|
const modelData = reactive({
|
||||||
@@ -171,6 +195,7 @@ function useTypeChange(e) {
|
|||||||
async function shopRechargeGetAjax() {
|
async function shopRechargeGetAjax() {
|
||||||
try {
|
try {
|
||||||
const res = await shopRechargeGet();
|
const res = await shopRechargeGet();
|
||||||
|
isOpen.value = res.isEnable;
|
||||||
res.rechargeDetailList.forEach((item) => {
|
res.rechargeDetailList.forEach((item) => {
|
||||||
item.couponInfoList.forEach((val) => {
|
item.couponInfoList.forEach((val) => {
|
||||||
if (val.coupon && val.coupon !== null) {
|
if (val.coupon && val.coupon !== null) {
|
||||||
@@ -259,6 +284,23 @@ onShow(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<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 {
|
.u-overflow-hide {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user