增加状态管理持久化插件,提取日期选择,时间选择,周期选择为公共组件

This commit is contained in:
2025-11-19 09:36:34 +08:00
parent 82fb096092
commit 6376557149
10 changed files with 231 additions and 174 deletions

View File

@@ -7,6 +7,9 @@ import dict from '@/commons/utils/dict.js'
import {utils} from '@/commons/utils/index.js'
import uviewPlus from 'uview-plus'
import * as Pinia from 'pinia';
import {
createUnistorage
} from "pinia-plugin-unistorage";
// 设置node环境
envConfig.changeEnv(storageManage.env())
@@ -39,7 +42,9 @@ export function createApp() {
const app = createSSRApp(App)
app.use(uviewPlus)
app.use(Pinia.createPinia());
const store = Pinia.createPinia();
store.use(createUnistorage());
app.use(store)
app.config.globalProperties.$appName = appConfig.appName
uni.$appName = appConfig.appName
app.config.globalProperties.$utils = utils

View File

@@ -9,6 +9,7 @@
"jsbn": "^1.1.0",
"jsencrypt": "^3.3.2",
"lodash": "^4.17.21",
"pinia-plugin-unistorage": "^0.1.2",
"to-arraybuffer": "^1.0.1",
"uview-plus": "^3.3.32",
"ysk-utils": "^1.0.78"

View File

@@ -41,10 +41,10 @@
<view class="u-flex u-row-between u-m-b-32">
<text class="font-bold color-333">活动日期</text>
</view>
<timeArea
<my-time-area
v-model:startDate="form.validStartTime"
v-model:endDate="form.validEndTime"
></timeArea>
></my-time-area>
</view>
<view class="u-m-t-32">
<up-line ></up-line>
@@ -53,7 +53,7 @@
<view class="u-flex u-row-between">
<text class="font-bold color-333 u-m-b-32">可用周期</text>
</view>
<weekSel v-model="form.useDays"></weekSel>
<my-week-sel v-model="form.useDays"></my-week-sel>
</view>
</view>
@@ -61,11 +61,11 @@
<view class="u-flex u-row-between">
<text class="font-bold color-333 u-m-b-32">指定时间段</text>
</view>
<hourSel
<my-hour-area
v-model:useTimeType="form.useTimeType"
v-model:startValue="form.useStartTime"
v-model:endValue="form.useEndTime"
></hourSel>
></my-hour-area>
</view>
<view class="u-m-t-32 container">
<view class="u-flex u-row-between">
@@ -144,15 +144,11 @@
></up-switch>
</view>
</view>
<bottomBtnGroup @save="save" @cancel="cancel"></bottomBtnGroup>
<my-bottom-btn-group @save="save" @cancel="cancel"></my-bottom-btn-group>
</view>
</template>
<script setup>
import timeArea from "./components/time-area.vue";
import weekSel from "./components/week-sel.vue";
import hourSel from "./components/hour-area.vue";
import bottomBtnGroup from "./components/bottom-btn-group.vue";
import { reactive } from "vue";
import * as discountActivityApi from "@/http/api/market/discountActivity.js";
import {

View File

@@ -1,29 +0,0 @@
<template>
<view>
<view style="height: 180rpx"></view>
<view class="fixed-bottom u-flex gap-20">
<view class="u-flex-1">
<my-button type="primary" @click="save" shape="circle">
保存
</my-button>
</view>
<view class="u-flex-1">
<my-button bgColor="#fff" type="default" @click="cancel" shape="circle">
取消
</my-button>
</view>
</view>
</view>
</template>
<script setup>
const emit= defineEmits(["save", "cancel"]);
function save() {
emit("save");
}
function cancel() {
emit("cancel");
}
</script>

View File

@@ -1,12 +1,17 @@
<template>
<view class="container">
<view class="row" v-for="(item, index) in menuList" :key="index">
<view class="row" v-for="(item, index) in computedMenus" :key="index">
<view class="header">
<text class="t">{{ item.label }}</text>
</view>
<view class="menu-wrap">
<view class="item" v-for="(val, i) in item.menus" :key="i" @click="go.to(val.pageUrl)">
<image :src="`/static/applocation/${val.icon}.png`" mode="aspectFit" class="icon"></image>
<view
class="item"
v-for="(val, i) in item.menus"
:key="i"
@click="go.to(val.pageUrl)"
>
<image :src="val.icon" mode="aspectFit" class="icon"></image>
<view class="info">
<view class="title">
<text class="t">{{ val.title }}</text>
@@ -22,78 +27,147 @@
</template>
<script setup>
import { ref, computed } from 'vue';
import go from '@/commons/utils/go.js';
import { useMenusStore } from '@/store/menus.js';
import { ref, computed } from "vue";
import go from "@/commons/utils/go.js";
import { useMenusStore } from "@/store/menus.js";
const menusStore = useMenusStore();
const menuList = ref([
{
label: '营销',
label: "营销",
menus: [
{
icon: 'xszk',
pageUrl: 'PAGES_LIMIT_DISCOUNT',
title: '限时折扣',
intro: '批量设置商品折扣'
title: "霸王餐",
icon: "",
intro: "设置充值消费的N倍当前订单立即免单",
pageUrl: "PAGES_BWC",
},
{
icon: 'czdhm',
pageUrl: 'LIMIT_DISCOUNT',
title: '充值兑换码',
intro: '兑换码直充余额,可当作礼品赠送'
},
{
title: '优惠券',
icon: '/static/indexImg/icon-order.svg',
pageUrl: 'PAGES_ORDER_INDEX'
title: "积分锁客",
icon: "",
pageUrl: "",
intro: "设置充值消费的N倍当前订单立即免单",
},
{
title: '霸王餐',
icon: '/static/indexImg/icon-order.svg',
pageUrl: 'PAGES_ORDER_INDEX'
title: "弹窗广告",
icon: "",
pageUrl: "PAGES_ORDER_INDEX",
intro: "设置弹窗广告",
},
{
title: '邀请裂变',
icon: '/static/indexImg/icon-order.svg',
pageUrl: 'PAGES_ORDER_INDEX'
title: "超级会员",
icon: "",
pageUrl: "PAGES_ORDER_INDEX",
intro: "用户会员管理设置",
},
{
title: '积分锁客',
icon: '/static/indexImg/icon-order.svg',
pageUrl: 'PAGES_ORDER_INDEX'
title: "新客立减",
icon: "",
pageUrl: "PAGES_ORDER_INDEX",
intro: "首单下单减免金额",
},
{
title: '满减活动',
icon: '/static/indexImg/icon-order.svg',
pageUrl: 'PAGES_MARKET_DISCOUNT_ACTIVITY'
title: "智慧充值",
icon: "",
pageUrl: "PAGES_ORDER_INDEX",
intro: "允许客户充值并使用余额支付",
},
{
title: '私域引流',
icon: '/static/indexImg/icon-order.svg',
pageUrl: 'PAGES_MARKET_DRAINAGE_CONFIG'
title: "分销",
icon: "",
pageUrl: "PAGES_PAY",
intro: "用户成为业务员,可促进消费",
},
{
title: '消费返现',
icon: '/static/indexImg/icon-order.svg',
pageUrl: 'PAGES_MARKET_CONSUME_CASHBACK'
title: "消费返现",
icon: "",
pageUrl: "PAGES_MARKET_CONSUME_CASHBACK",
intro: "用户下单后返现一定的金额到余额,可促进复购",
},
{
title: '分销',
icon: '/static/indexImg/icon-order.svg',
pageUrl: 'PAGES_PAY'
}
]
}
title: "私域引流",
icon: "",
pageUrl: "PAGES_MARKET_DRAINAGE_CONFIG",
intro: "可设置用户下单成功后的群二维码",
},
{
title: "满减活动",
icon: "",
pageUrl: "PAGES_MARKET_DISCOUNT_ACTIVITY",
intro: "达到指定支付金额享受减价",
},
{
title: "生日有礼",
icon: "",
pageUrl: "",
intro: "用户生日管理设置",
},
{
title: "点餐智能推荐",
icon: "",
pageUrl: "",
intro: "进入点单页X秒未点自动推荐商品此推荐设置启用即生效",
},
{
title: "超值券包",
icon: "",
pageUrl: "",
intro: "下单加购",
},
{
title: "套餐推广",
icon: "",
pageUrl: "",
intro: "下单通过用户邀请好友减免金额的方式裂变宣传套餐加购",
},
{
title: "充值兑换码",
icon: "",
pageUrl: "",
intro: "兑换码直充余额,可当作礼品赠送",
},
{
title: "券兑换码",
icon: "",
pageUrl: "",
intro: "可添加多券组合兑换",
},
{
icon: "xszk",
pageUrl: "PAGES_LIMIT_DISCOUNT",
title: "限时折扣",
intro: "批量设置商品折扣",
},
{
icon: "xszk",
pageUrl: "PAGES_LIMIT_DISCOUNT",
title: "商品拼团",
intro: "拼团",
},
],
},
]);
console.log(menusStore.adminPages);
const computedMenus = computed(() => {
const arr = menusStore.adminPages.filter((v) => {
return navList.find((navItem) => navItem.title == v.title);
// const arr = menusStore.adminPages.filter((v) => {
// return navList.find((navItem) => navItem.title == v.title);
// });
return menuList.value.map((v) => {
v.menus = v.menus.filter((menu) => {
const hasPermission = menusStore.adminPages.find(
(navItem) => navItem.title == menu.title
);
console.log("hasPermission", hasPermission);
if (hasPermission) {
menu.icon = hasPermission.miniIcon;
console.log(menu);
}
return hasPermission;
});
return v;
});
console.log(arr);
return arr;
});
</script>

8
pnpm-lock.yaml generated
View File

@@ -35,6 +35,9 @@ importers:
lodash:
specifier: ^4.17.21
version: 4.17.21
pinia-plugin-unistorage:
specifier: ^0.1.2
version: 0.1.2
to-arraybuffer:
specifier: ^1.0.1
version: 1.0.1
@@ -534,6 +537,9 @@ packages:
resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==}
engines: {node: '>=8.6'}
pinia-plugin-unistorage@0.1.2:
resolution: {integrity: sha512-WXit2cGnm5rG6CDTcLSLehNWhyJS/Yq7WEeeXAapZbCnqoPJxlszqg7rT8S+OP47az0h5nlajGo+LuyMxUQ2uw==}
punycode@2.3.1:
resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
engines: {node: '>=6'}
@@ -1147,6 +1153,8 @@ snapshots:
picomatch@2.3.1: {}
pinia-plugin-unistorage@0.1.2: {}
punycode@2.3.1: {}
queue-microtask@1.2.3: {}

View File

@@ -64,4 +64,6 @@ export const useMenusStore = defineStore('menus', {
}
},
});
unistorage: true, // 开启后对 state 的数据读写都将持久化
}
);