This commit is contained in:
gyq 2025-11-19 17:16:10 +08:00
commit 805236dc5d
9 changed files with 665 additions and 28 deletions

View File

@ -0,0 +1,312 @@
<template>
<view class="box">
<view class="u-m-t-32 container">
<view class="u-flex u-row-between u-m-b-16">
<text class="font-bold color-333">可用门店</text>
</view>
<my-shop-select
v-model:selShops="form.shopIdList"
v-model:useType="form.useType"
></my-shop-select>
</view>
<view class="u-m-t-32 container">
<view class="u-flex u-row-between">
<text class="font-bold color-333 u-m-b-16">适用用户</text>
</view>
<userTypes v-model="form.applicableUser"></userTypes>
</view>
<view class="u-m-t-32 container">
<view class="u-flex u-row-between">
<text class="font-bold color-333">返现类型</text>
</view>
<view class="u-m-t-16">
<up-radio-group v-model="form.cashbackType" placement="row">
<up-radio
v-for="item in cashbackTypes"
:key="item.value"
:name="item.value"
:label="item.label"
>
<template #label>
<text>
{{ item.label }}
</text>
</template>
</up-radio>
</up-radio-group>
</view>
<view class="u-flex u-row-between u-m-t-32">
<text class="font-bold color-333">阶梯设置</text>
</view>
<view
class="u-m-t-32 u-flex u-row-between gap-40"
v-for="(item, index) in form.cashbackStepList"
:key="index"
>
<view class="u-flex u-col-top">
<view class="no-wrap u-m-r-16 u-m-t-14">{{ returnName(index) }}</view>
<view class="u-flex-1">
<view class="u-flex">
<text class="u-m-r-24"> 返现门槛</text>
<input
class="my-input"
type="digit"
v-model="item.amount"
placeholder=""
/>
<text class="text-tips text-tips1"></text>
</view>
<view class="u-flex u-m-t-24">
<text class="u-m-r-24"> {{form.cashbackType === 'percentage' ? '返现比例' : '返现金额'}}</text>
<input
class="my-input"
type="number"
v-model="item.cashbackAmount"
@blur="inputBlur($event, index)"
:max="form.cashbackType === 'percentage' ? 100 : 999999"
placeholder=""
/>
<text class="text-tips text-tips1">{{ returnUnit }} </text>
<text class="color-red u-m-l-10" @click="deleteThreshold(index)"
>删除</text
>
</view>
</view>
</view>
</view>
<button class="add u-m-t-32" @click="addcashbackStepList">添加</button>
</view>
<my-bottom-btn-group @save="save" @cancel="cancel"></my-bottom-btn-group>
</view>
</template>
<script setup>
import { reactive, computed, onMounted } from "vue";
import userTypes from "./user-types.vue";
import * as consumeCashbackApi from "@/http/api/market/consumeCashback.js";
import {
onLoad,
onReady,
onShow,
onPageScroll,
onReachBottom,
onBackPress,
} from "@dcloudio/uni-app";
//
const cashbackTypes = [
{
value: "percentage",
label: "按比例返现",
},
{
value: "fix",
label: "固定金额",
},
];
const form = reactive({
isEnable: 0,
cashbackStepList: [],
shopIdList: [],
useType: "all",
applicableUser: "all",
cashbackType: "percentage",
});
function addcashbackStepList() {
form.cashbackStepList.push({
amount: 0,
cashbackAmount: 0,
});
}
function inputBlur(e, index) {
const value = e.detail.value;
if (form.cashbackType === "percentage") {
if (e.detail.value >= 100) {
form.cashbackStepList[index].cashbackAmount = 100;
} else if (e.detail.value < 0) {
form.cashbackStepList[index].cashbackAmount = 0;
} else {
form.cashbackStepList[index].cashbackAmount =e.detail.value;
}
} else {
if (e.detail.value < 0) {
form.cashbackStepList[index].cashbackAmount = 0;
} else if(e.detail.value > form.cashbackStepList[index].amount) {
form.cashbackStepList[index].cashbackAmount = form.cashbackStepList[index].amount;
} else {
form.cashbackStepList[index].cashbackAmount =e.detail.value;
}
}
}
async function save() {
console.log(form);
const submitData = {
...form,
};
const res = await consumeCashbackApi.update(submitData);
uni.showToast({
title: "更新成功",
icon: "none",
duration: 2000,
success: function () {},
});
}
function cancel() {
uni.navigateBack();
}
function deleteThreshold(index) {
form.cashbackStepList.splice(index, 1);
}
function setForm(data) {
data.cashbackStepList=data.cashbackStepList||[]
Object.assign(form, data);
console.log(form);
}
const returnUnit = computed(() => {
return form.cashbackType === "percentage" ? "%" : "元";
});
const numChineseMap = {
0: "零",
1: "一",
2: "二",
3: "三",
4: "四",
5: "五",
6: "六",
7: "七",
8: "八",
9: "九",
10: "十",
100: "百",
1000: "千",
};
//
function numberToChinese(n) {
if (n < 10) {
return numChineseMap[n];
}
// 10-99
if (n < 100) {
const ten = Math.floor(n / 10);
const unit = n % 10;
if (ten === 1) {
return unit === 0 ? "十" : `${numChineseMap[unit]}`;
} else {
return unit === 0
? `${numChineseMap[ten]}`
: `${numChineseMap[ten]}${numChineseMap[unit]}`;
}
}
// 100-999
if (n < 1000) {
const hundred = Math.floor(n / 100);
const remainder = n % 100;
if (remainder === 0) {
return `${numChineseMap[hundred]}`;
} else {
return `${numChineseMap[hundred]}${
remainder < 10 ? "零" : ""
}${numberToChinese(remainder)}`;
}
}
// 1000-9999
if (n < 10000) {
const thousand = Math.floor(n / 1000);
const remainder = n % 1000;
if (remainder === 0) {
return `${numChineseMap[thousand]}`;
} else {
return `${numChineseMap[thousand]}${
remainder < 100 ? "零" : ""
}${numberToChinese(remainder)}`;
}
}
// 亿
return n.toString(); //
}
//
function returnName(index) {
const groupNumber = index + 1; // 01
const chineseNumber = numberToChinese(groupNumber);
return `${chineseNumber}`;
}
async function getData() {
const res = await consumeCashbackApi.getConfig();
if (res) {
setForm(res);
}
}
onMounted(() => {
getData();
});
</script>
<style lang="scss" scoped>
page {
background: #f7f7f7;
}
.x-padding {
padding: 0 24rpx;
}
.text-tips {
color: #999999;
font-size: 14px;
padding: 0 28rpx;
border-radius: 6rpx 0 0 6rpx;
border: 2rpx solid #d9d9d9;
background-color: #f7f7fa;
line-height: 60rpx;
}
.text-tips1 {
border-radius: 0 6rpx 6rpx 0;
}
.gap-40 {
gap: 40rpx;
}
.my-input {
border: 2rpx solid #d9d9d9;
height: 60rpx;
border-right: none;
width: 240rpx;
text-align: center;
padding: 0 2px;
font-size: 14px;
}
.box {
padding: 0 28rpx;
font-size: 28rpx;
}
.container {
background: #fff;
padding: 32rpx 24rpx;
margin-top: 32rpx;
border-radius: 16rpx;
overflow: hidden;
}
.add {
padding: 8rpx 32rpx;
border-radius: 12rpx;
background: #318afe;
color: #ffffff;
font-size: 28rpx;
line-height: 56rpx;
margin: 0;
}
.color-red {
color: #ff2f2f;
}
</style>

View File

@ -0,0 +1,70 @@
<template>
<view>
<up-radio-group v-model="userType" placement="row">
<up-radio
v-for="item in userTypeList"
:key="item.value"
:name="item.value"
:label="item.label"
>
<template #label>
<text>
{{ item.label }}
</text>
<text v-if="item.desc" class="color-666 u-font-24">
{{ item.desc }}
</text>
</template>
</up-radio>
</up-radio-group>
</view>
</template>
<script setup>
import { onMounted, reactive, ref, watch } from "vue";
const userType = defineModel({
default: () => "all",
type: String,
});
const userTypeList = [
{
value: "all",
label: "全部用户",
},
{
value: "new",
label: "仅限新用户",
},
{
value: "vip",
label: "仅会员",
desc:'(分店需开启超级会员可用)'
},
];
</script>
<style lang="scss">
.box {
margin-top: 16rpx;
display: flex;
flex-direction: row;
align-items: top;
flex-wrap: wrap;
padding: 10rpx 24rpx;
border: 2rpx solid #e5e5e5;
position: relative;
.icon {
position: absolute;
top: 50%;
right: 24rpx;
transform: translateY(-50%);
}
}
.shop-item {
padding: 4rpx 8rpx 4rpx 16rpx;
border-radius: 4rpx;
border: 2rpx solid #f0f0f0;
background-color: #f5f5f5;
margin-bottom: 16rpx;
margin-left: 16rpx;
}
</style>

View File

@ -0,0 +1,221 @@
<template>
<view class="min-page">
<up-sticky>
<view class="bg-fff top">
<my-tabs v-model="active" :list="tabs" textKey="label"></my-tabs>
<view class="u-flex u-m-t-40" v-if="active == 1">
<view class="u-flex color-333" @click="showShopSelActionSheetFun">
<text class="u-line-1" style="max-width: 300rpx;">{{selShop.shopName || "全部门店"}}</text>
<up-icon name="arrow-down-fill" size="12" color="#333"></up-icon>
</view>
<view class="u-flex-1 u-p-l-16">
<up-search bgColor="#F9F9F9" height="60rpx" :showAction="false" placeholder="搜索订单号"
@search="search" @clear="search" v-model="searchText"></up-search>
</view>
</view>
</view>
</up-sticky>
<configVue v-if="active == 0"></configVue>
<view class="list u-font-28" v-if="active == 1">
<view class="u-m-t-32 item" v-for="item in list" :key="item.id">
<view class="u-flex u-row-between">
<view class="color-999 u-font-24">
<view> 关联订单:{{ item.orderNo }} </view>
<view class="u-m-t-14">
<text class="color-333 font-bold"> {{ item.shopName }}</text>
<text class="color-666 u-font-24">{{ item.createTime }}</text>
</view>
</view>
<text class="color-999 u-font-24"> ID:{{ item.id }} </text>
</view>
<view class="u-m-t-22">
<u-line></u-line>
</view>
<view class="color-333 u-flex u-row-between u-font-28" style="margin-top: 52rpx">
<view>
<view class="color-666">用户昵称</view>
<view class="color-333 u-m-t-24 u-line-1">{{ item.nickName }}</view>
</view>
<view class="u-flex u-text-center">
<view>
<view class="color-666">返现金额</view>
<view class="color-333 u-m-t-24">{{ item.cashbackAmount ||0 }}</view>
</view>
<view style="margin-left: 54rpx;">
<view class="color-666">支付金额</view>
<view class="color-333 u-m-t-24">{{ item.amount || 0 }}</view>
</view>
</view>
</view>
<view style="height: 32rpx;"></view>
</view>
<view class="u-p-30">
<up-loadmore :status="isEnd ? 'nomore' : 'loading'"></up-loadmore>
</view>
</view>
<!-- 选择门店 -->
<shopSelActionSheetVue @choose="chooseShop" v-model="showShopSelActionSheet" title="选择门店">
</shopSelActionSheetVue>
</view>
</template>
<script setup>
import {
onLoad,
onReady,
onShow,
onPageScroll,
onReachBottom,
onBackPress,
} from "@dcloudio/uni-app";
import {
ref,
onMounted,
watch
} from "vue";
import * as consumeCashbackApi from "@/http/api/market/consumeCashback.js";
import configVue from './components/config.vue'
import shopSelActionSheetVue from '@/pageMarket/components/shop-sel-action-sheet.vue'
const tabs = [{
label: "基本设置",
value: "basic"
},
{
label: "分销员",
value: "user"
},
{
label: "开通记录",
value: "recoders"
},
{
label: "分销明细",
value: "details"
},
];
const list = ref([]);
const pageNum = ref(1);
const isEnd = ref(false);
const selShop = ref({
shopId: "",
shopName: "",
})
const searchText = ref("");
function search() {
pageNum.value = 1;
getList();
}
function chooseShop(e) {
selShop.value = e;
}
watch(()=>selShop.value.shopId,(newval)=>{
pageNum.value = 1;
getList();
})
async function getList() {
const res = await consumeCashbackApi.getList({
pageNum: pageNum.value,
pageSize: 10,
shopId: selShop.value.shopId,
key: searchText.value,
});
if (res) {
if (pageNum.value == 1) {
list.value = res.records || [];
} else {
list.value = [...list.value, ...(res.records || [])];
}
isEnd.value = pageNum.value >= res.totalPage * 1 ? true : false;
console.log(isEnd.value);
}
}
//
const showShopSelActionSheet = ref(false);
function showShopSelActionSheetFun() {
showShopSelActionSheet.value = true;
}
const active = ref(0);
watch(
() => active.value,
(newval) => {
console.log(newval);
pageNum.value = 1;
getList();
}
);
onReachBottom(() => {
if (!isEnd.value) {
pageNum.value++;
getList();
}
});
onShow(() => {
pageNum.value = 1;
getList();
});
</script>
<style lang="scss" scoped>
.min-page {
background: #f7f7f7;
}
.box {}
.top {
padding: 32rpx 24rpx;
}
.list {
padding: 0 30rpx;
.item {
padding: 32rpx 24rpx;
border-radius: 14rpx;
background-color: #fff;
overflow: hidden;
}
}
.tag {
border-radius: 12rpx;
padding: 8rpx 22rpx;
font-size: 28rpx;
&.success {
background-color: #edfff0;
color: #5bbc6d;
}
&.end {
background-color: #f7f7f7;
color: #999;
}
}
.my-btn {
font-size: 28rpx;
line-height: 36rpx;
padding: 8rpx 32rpx;
border-radius: 12rpx;
margin: 0;
}
.edit-btn {
background: #e6f0ff;
color: $my-main-color;
}
.delete-btn {
background: #ffe7e6;
color: #ff1c1c;
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -632,6 +632,12 @@
"navigationBarTitleText": "限时折扣"
}
},
{
"pageId": "PAGES_MARKET_DISTRIBUTION_INDEX",
"path": "distribution/index",
"style": {
"navigationBarTitleText": "分销"}
},
{
"pageId": "PAGES_LIMIT_DISCOUNT_ADD",
"path": "limitDiscount/add",

View File

@ -75,7 +75,7 @@ const menuList = ref([
{
title: "分销",
icon: "",
pageUrl: "PAGES_PAY",
pageUrl: "PAGES_MARKET_DISTRIBUTION_INDEX",
intro: "用户成为业务员,可促进消费",
},
{

View File

@ -295,7 +295,7 @@
v-else-if="
isVip &&
item.lowMemberPrice &&
item.lowMemberPrice * 1 != item.lowPrice * 1
item.lowMemberPrice * 1 !=0
"
>
<text class="line-th color-999"
@ -427,9 +427,14 @@
v-if="orderCostSummary.totalDiscountAmount"
>
<view class="">优惠金额</view>
<view class="font-bold u-font-32"
<view class="font-bold u-font-32 u-m-r-16"
>{{ orderCostSummary.totalDiscountAmount }}</view
>
<up-icon
name="question-circle"
color="#666"
@click="showDiscountInfo = true"
></up-icon>
</view>
</view>
@ -477,6 +482,28 @@
:ref="setModel"
name="packNumber"
></pack-number>
<up-popup :show="showDiscountInfo" mode="center" round="16rpx" @close="showDiscountInfo = false" closeOnClickOverlay >
<view class="u-p-30 u-flex u-flex-col gap-20" style="min-width: 300rpx;">
<view class="u-flex gap-20 u-row-between w-full" v-if="orderCostSummary.goodsDiscountAmount">
<text>商品优惠</text>
<text class="color-red">-{{ orderCostSummary.goodsDiscountAmount }}</text>
</view>
<view class="u-flex gap-20 u-row-between w-full" v-if="orderCostSummary.newUserDiscount">
<text>新客立减</text>
<text class="color-red">-{{ orderCostSummary.newUserDiscount }}</text>
</view>
<view class="u-flex gap-20 u-row-between w-full" v-if="orderCostSummary.fullReduction.actualAmount">
<text>满减活动</text>
<text class="color-red">-{{ orderCostSummary.fullReduction.actualAmount }}</text>
</view>
<view class="u-flex gap-20 u-row-between w-full" v-if="orderCostSummary.vipDiscountAmount">
<text>会员折扣</text>
<text class="color-red">-{{ orderCostSummary.vipDiscountAmount }}</text>
</view>
</view>
</up-popup>
<!-- <edit-discount title="优惠金额" :ref="setModel" name="editMoney" :price="allPrice"></edit-discount> -->
</view>
</template>
@ -506,7 +533,6 @@ import { getSafeBottomHeight } from "@/commons/utils/safe-bottom.js";
import go from "@/commons/utils/go.js";
import { hasPermission } from "@/commons/utils/hasPermission.js";
import { getNowCart } from "@/pagesCreateOrder/util.js";
import { number } from "uview-plus/libs/function/test";
import { getShopInfo } from "@/http/api/shop.js";
import { getShopTableDetail } from "@/http/api/table.js";
@ -518,6 +544,9 @@ import BigNumber from "bignumber.js";
import * as limitTimeDiscountApi from "@/http/yskApi/limitTimeDiscount.js";
import yskUtils from "ysk-utils";
//
const showDiscountInfo = ref(false);
// import yskUtils from "@/lib/index";
const limitUtils = yskUtils.limitUtils;
provide("yskUtils", yskUtils);
@ -687,10 +716,6 @@ const $seatFee = reactive({
totalAmount: 0,
});
/**
* 判断是否是会员
*/
@ -703,7 +728,6 @@ const isVip = computed(() => {
);
});
/**
* init
*/
@ -724,7 +748,7 @@ function onMessage() {
websocketUtil.offMessage();
websocketUtil.onMessage((res) => {
let msg = JSON.parse(res);
console.log('msg===',msg);
console.log("msg===", msg);
let cartItem;
if (msg.msg_id) {
websocketUtil.send(
@ -742,9 +766,9 @@ function onMessage() {
switch (msg.operate_type) {
case "onboc_init":
goods.list = [];
console.log('msg.data', msg.data);
console.log("msg.data", msg.data);
msg.data.map((item) => {
console.log("item===",item)
console.log("item===", item);
cartItem = getNowCart(item, $goods, pageData.user);
console.log(cartItem);
if (cartItem.isGrounding || cartItem.is_temporary == 1) {
@ -895,6 +919,9 @@ async function getTableInfo(opt) {
//
getCart();
//
if(shopInfo.registerType==='before'){
return
}
getHistoryOrderDetail(opt.tableCode);
}
@ -1124,8 +1151,6 @@ function showModel(key, index, item) {
}
}
/**
* 更新就餐人数
*/
@ -1213,7 +1238,8 @@ async function createAnOrder() {
tableCode: pageData.table.tableCode, //
dineMode: pageData.eatTypes.active, // dine-in take-out take-away
remark: pageData.form.note, //
seatNum: pageData.eatTypes.active == "dine-in" ? seatFeeConfig.personCount : 0, //
seatNum:
pageData.eatTypes.active == "dine-in" ? seatFeeConfig.personCount : 0, //
packFee: orderCostSummary.value.packFee, //
originAmount: orderCostSummary.value.goodsRealAmount, //+
placeNum: placeNum, //
@ -1227,7 +1253,7 @@ async function createAnOrder() {
if (pageData.orderInfo && pageData.shopInfo.registerType != "before") {
par.orderId = pageData.orderInfo.id;
}
let res = null
let res = null;
if (goods.list.length) {
res = await createOrder(par);
console.log(res, "创建订单");
@ -1366,7 +1392,9 @@ const allGoodsList = computed(() => {
cur.map((v) => {
v.number = v.num;
v.salePrice = v.price;
v.discount_sale_amount=v.discount_sale_amount?v.discount_sale_amount*1:0;
v.discount_sale_amount = v.discount_sale_amount
? v.discount_sale_amount * 1
: 0;
});
prve.push(...cur);
return prve;
@ -1513,4 +1541,10 @@ watch(
z-index: 9;
color: #fff;
}
.u-row-between {
justify-content: space-between;
}
.w-full{
width: 100%;
}
</style>

View File

@ -13,17 +13,11 @@ export function getNowCart(carItem,goodsList,user) {
if(carItem.product_id == goodsItem.id){
goodsItem.skuList.map(item=>{
if(carItem.sku_id == item.id){
carItem.lowPrice = item.salePrice
carItem.lowPrice = item.lowPrice||item.salePrice
carItem.lowMemberPrice = item.memberPrice
carItem.memberPrice = item.memberPrice
carItem.specInfo = item.specInfo
carItem.salePrice = item.salePrice
if( uni.getStorageSync('shopInfo').isMemberPrice && user && user.id && user.isVip ){
carItem.salePrice = item.memberPrice
} else {
carItem.salePrice = item.salePrice
}
carItem.salePrice = item.lowPrice
}
})

View File

@ -441,7 +441,7 @@
let res = await discountActivity({
shopId: uni.getStorageSync("shopInfo").id||'',
});
if (res.code == 200) {
if (res) {
fullReductionActivities.value = res ? [res] : [];
}
}