diff --git a/App.vue b/App.vue
index 490e8d3..fb56dc9 100644
--- a/App.vue
+++ b/App.vue
@@ -12,56 +12,78 @@ import {
import { APP_ID } from '@/config'
// 检查更新逻辑
-const checkUpdate = () => {
- // 兼容性检查(非必须,但建议)
- if (!uni.canIUse('getUpdateManager')) {
- uni.showModal({
- title: '提示',
- content: '当前微信版本过低,请升级后使用',
- showCancel: false
- });
- return;
- }
-
- const updateManager = uni.getUpdateManager();
-
- // 检测是否有新版本
- updateManager.onCheckForUpdate((res) => {
- if (res.hasUpdate) {
- uni.showLoading({ title: '检测到新版本,下载中...' });
- }
- });
-
- // 新版本下载完成
- updateManager.onUpdateReady(() => {
- uni.hideLoading();
- uni.showModal({
- title: '更新提示',
- content: '新版本已准备好,立即重启应用?',
- showCancel: false,
- success: (res) => {
- if (res.confirm) {
- // 强制应用新版本并重启
- updateManager.applyUpdate();
- }
+const autoUpdate = () => {
+ // 获取小程序更新机制兼容
+ if (uni.canIUse("getUpdateManager")) {
+ // 获取更新管理器
+ const updateManager = uni.getUpdateManager();
+ //1. 检查小程序是否有新版本发布,向小程序后台请求完新版本信息
+ updateManager.onCheckForUpdate((res) => {
+ // 请求完新版本信息的回调
+ if (res.hasUpdate) {
+ //检测到新版本,需要更新,给出提示
+ uni.showModal({
+ title: "更新提示",
+ content: "检测到新版本,是否下载新版本并重启小程序?",
+ success: (res) => {
+ if (res.confirm) {
+ //2. 用户确定下载更新小程序,小程序下载及更新静默进行
+ downLoadAndUpdate(updateManager);
+ } else if (res.cancel) {
+ //用户点击取消按钮的处理,如果需要强制更新,则给出二次弹窗,如果不需要,则这里的代码都可以删掉了
+ uni.showModal({
+ title: "温馨提示",
+ content: "本次版本更新涉及到新的功能添加,旧版本无法正常访问的哦",
+ showCancel: false, //隐藏取消按钮
+ confirmText: "确定更新", //只保留确定更新按钮
+ success: (res) => {
+ if (res.confirm) {
+ //下载新版本,并重新应用
+ downLoadAndUpdate(updateManager);
+ }
+ },
+ });
+ }
+ },
+ });
}
});
+ } else {
+ // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
+ uni.showModal({
+ title: "提示",
+ content: "当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。",
+ });
+ }
+}
+
+/**
+ * 下载小程序新版本并重启应用
+ */
+const downLoadAndUpdate = (updateManager) => {
+ uni.showLoading();
+ //静默下载更新小程序新版本,更新完成后回调
+ updateManager.onUpdateReady(() => {
+ uni.hideLoading();
+ //新的版本已经下载好,调用 applyUpdate 应用新版本并重启
+ updateManager.applyUpdate();
});
- // 下载失败处理
+ // 更新失败回调
updateManager.onUpdateFailed(() => {
- uni.hideLoading();
+ // 新的版本下载失败
uni.showModal({
- title: '提示',
- content: '更新失败,请删除小程序后重新搜索打开',
- showCancel: false
+ title: "已经有新版本了哟~",
+ content: "新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~",
});
});
-};
+}
+
+
onLaunch(() => {
- checkUpdate();
+ autoUpdate();
console.log('App Launch')
})
diff --git a/api/activity.js b/api/activity.js
new file mode 100644
index 0000000..10dc98e
--- /dev/null
+++ b/api/activity.js
@@ -0,0 +1,16 @@
+import api from './api'
+
+/**
+ * 获取某个优惠活动
+ */
+export function getpromotionactivity(id) {
+ return api.get(`/promotionactivity/get?id=${id}`, {}, { login: false })
+}
+
+/**
+* 获取所有优惠活动
+*/
+export function getPromotionactivityInfo(data) {
+ return api.get(`/promotionactivity/page`, data, { login: true })
+}
+
diff --git a/api/coupon.js b/api/coupon.js
index 3888787..797bfd9 100644
--- a/api/coupon.js
+++ b/api/coupon.js
@@ -14,6 +14,13 @@ export function couponMine(data) {
return api.get(`/coupon/my`, data, { login: false })
}
+/**
+ * couponMine
+ */
+export function couponCanUserMine(data) {
+ return api.get(`/coupon/use`, data, { login: false })
+}
+
/**
* couponIndex let couponCount = (params = {}) => vm.$u.get('/coupon/count', params);
*/
diff --git a/api/distributor.js b/api/distributor.js
index c26b643..b3bdb0b 100644
--- a/api/distributor.js
+++ b/api/distributor.js
@@ -21,3 +21,11 @@ export function getDistributorInfo(id) {
export function getCommissionList(data) {
return api.get(`/order/listByDistributor`, data, { login: true })
}
+
+/**
+ * 编辑分销商信息
+ * @param {Object} data - 包含 id, name, phone, workUnit, recipientName, bankCardNumber, bankName
+ */
+export function editDistributor(data) {
+ return api.put(`/distributor/update`, data, { login: true })
+}
diff --git a/api/goods.js b/api/goods.js
index 79863f2..6a00862 100644
--- a/api/goods.js
+++ b/api/goods.js
@@ -13,3 +13,10 @@ export function menuGoods(data) {
return api.get('/product/products', data, { login: false })
}
+/**
+ * 获取某个商品信息
+ */
+export function getGoods(id) {
+ return api.get('/product/detail/' + id, { login: false })
+}
+
diff --git a/pages.json b/pages.json
index 9c2a8c3..76b363d 100644
--- a/pages.json
+++ b/pages.json
@@ -124,11 +124,19 @@
"path": "pages/coupons/coupons",
"style": {
"enablePullDownRefresh": true,
- "navigationBarTitleText": "我的卡券",
+ "navigationBarTitleText": "领取卡券",
"navigationBarTextStyle": "black",
"navigationBarBackgroundColor": "#ffffff"
}
}, {
+ "path": "pages/coupons/mycoupons",
+ "style": {
+ "enablePullDownRefresh": true,
+ "navigationBarTitleText": "我的卡券",
+ "navigationBarTextStyle": "black",
+ "navigationBarBackgroundColor": "#ffffff"
+ }
+ },{
"path": "pages/mine/userinfo",
"style": {
"navigationBarTitleText": "用户信息",
diff --git a/pages/components/pages/coupons/coupons copy.vue b/pages/components/pages/coupons/coupons copy.vue
new file mode 100644
index 0000000..378d9bf
--- /dev/null
+++ b/pages/components/pages/coupons/coupons copy.vue
@@ -0,0 +1,563 @@
+
+
+
+
+
+
+
+
+
+
+
+ {{ item.title }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ¥
+ {{ item.value }}
+
+ 满{{ item.least }}减{{ item.value }}
+
+
+ {{ item.title }}
+ {{ formatDateTime(item.startTime,
+ 'yyyy-MM-dd')}}-{{ formatDateTime(item.endTime, 'yyyy-MM-dd') }}
+
+
+
+ 立即领取
+
+
+
+ 立即使用
+ 已使用
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ¥
+ {{ item.value }}
+
+ 满{{ item.least }}减{{ item.value }}
+
+
+ {{ item.title }}
+ {{ formatDateTime(item.startTime,
+ 'yyyy-MM-dd')}}-{{ formatDateTime(item.endTime, 'yyyy-MM-dd') }}
+
+
+
+ 立即领取
+
+
+
+ 立即使用
+ 已使用
+
+
+
+
+
+
+
+
+
+
+
+ 有效期:{{ formatDateTime(coupon.startTime, 'yyyy-MM-dd') }}-{{ formatDateTime(coupon.endTime,
+ 'yyyy-MM-dd')}}
+
+
+ 领取时间:{{ formatDateTime(coupon.createTime) }}
+
+
+ 券价值:满{{ coupon.least }}减{{ coupon.value }}
+
+
+ 每人限领:{{ coupon.limit }} 张
+
+
+ 适用范围:{{ typeInfo(coupon.type) }}
+
+
+ 适用店铺:{{ coupon.shopName }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/components/pages/coupons/coupons.vue b/pages/components/pages/coupons/coupons.vue
index 378d9bf..a527de0 100644
--- a/pages/components/pages/coupons/coupons.vue
+++ b/pages/components/pages/coupons/coupons.vue
@@ -1,6 +1,7 @@
+
兑换
-
+
-
+
@@ -34,14 +35,18 @@
{{ item.title }}
{{ formatDateTime(item.startTime,
- 'yyyy-MM-dd')}}-{{ formatDateTime(item.endTime, 'yyyy-MM-dd') }}
-
-
-
- 立即领取
+ 'yyyy-MM-dd') }}-{{ formatDateTime(item.endTime, 'yyyy-MM-dd') }}
+ 已领取
+
+ 立即领取{{ item.isReceive }}
+
+
+
立即使用
已使用
@@ -50,14 +55,17 @@
-
+
-
+
-
+
+
+ 满减券
+
¥
@@ -68,14 +76,51 @@
{{ item.title }}
{{ formatDateTime(item.startTime,
- 'yyyy-MM-dd')}}-{{ formatDateTime(item.endTime, 'yyyy-MM-dd') }}
-
-
-
- 立即领取
+ 'yyyy-MM-dd') }}-{{ formatDateTime(item.endTime, 'yyyy-MM-dd') }}
+
+ 已领取
+
+ 立即领取
+
+
+
+ 立即使用
+ 已使用
+
+
+
+
+
+
+
+ 商品券
+
+
+
+ 商品名称:{{ item.productName
+ }}
+
+ {{ item.title }}
+ {{ formatDateTime(item.startTime,
+ 'yyyy-MM-dd') }}-{{ formatDateTime(item.endTime, 'yyyy-MM-dd') }}
+
+
+
+
+ 已领取
+
+ 立即领取
+
+
+
立即使用
已使用
@@ -86,21 +131,26 @@
+
-
+
- 有效期:{{ formatDateTime(coupon.startTime, 'yyyy-MM-dd') }}-{{ formatDateTime(coupon.endTime,
- 'yyyy-MM-dd')}}
+ 领取期限:{{ formatDateTime(coupon.startTime, 'yyyy-MM-dd') }}-{{ formatDateTime(coupon.endTime,
+ 'yyyy-MM-dd') }}
-
- 领取时间:{{ formatDateTime(coupon.createTime) }}
+
+ 有效期:自领取后{{ coupon.expiryDays }}天内有效
+
+
+ 有效期:{{ formatDateTime(coupon.startTime, 'yyyy-MM-dd') }}-{{ formatDateTime(coupon.endTime,
+ 'yyyy-MM-dd') }}
券价值:满{{ coupon.least }}减{{ coupon.value }}
-
+
每人限领:{{ coupon.limit }} 张
@@ -109,11 +159,50 @@
适用店铺:{{ coupon.shopName }}
-
+
+
+
+
+
+
+
+
+
+ 领取期限:{{ formatDateTime(coupon.startTime, 'yyyy-MM-dd') }}-{{ formatDateTime(coupon.endTime,
+ 'yyyy-MM-dd') }}
+
+
+ 有效期:自领取后{{ coupon.expiryDays }}天内有效
+
+
+ 有效期:{{ formatDateTime(coupon.startTime, 'yyyy-MM-dd') }}-{{ formatDateTime(coupon.endTime,
+ 'yyyy-MM-dd') }}
+
+
+ 券价值:使用此券免费领取 {{ coupon.productName }} 一份
+
+
+ 每人限领:{{ coupon.limit }} 张
+
+
+ 适用范围:{{ typeInfo(coupon.type) }}
+
+
+ 适用店铺:{{ coupon.shopName }}
+
-
+
+
+
+
+
@@ -138,16 +227,16 @@ import {
couponIndexApi
} from '@/api/coupon'
const main = useMainStore()
-const { isLogin } = storeToRefs(main)
-const title = ref('优惠券')
+const { member, isLogin } = storeToRefs(main);
+const title = ref('领取优惠券')
const tabs = ref([
+ // {
+ // title: '我的优惠券', page: 1, pagesize: 10,
+ // coupons: []
+ // },
{
- title: '我的优惠券', page: 1, pagesize: 10,
- coupons: []
- },
- {
- title: '未领优惠券', page: 1, pagesize: 10,
+ title: '领优惠券', page: 1, pagesize: 10,
coupons: []
}
])
@@ -160,7 +249,50 @@ const uToast = ref()
const myCoupons = ref([])
const notCoupons = ref([])
+
+onLoad(async (options) => {
+
+
+ // 如果有优惠券id参数,自动领取优惠券
+ if (options.couponId) {
+ console.log('111111111111111options.couponId', options.couponId);
+
+ if (!main.isLogin) {
+ uni.navigateTo({ url: '/pages/components/pages/login/login?couponId=' + options.couponId })
+ return
+ }
+ // 初始化优惠券
+ getCoupons(0)
+ let data = await couponReceive({ id: options.couponId });
+ if (data) {
+ uToast.value.show({
+ message: '领取成功',
+ type: 'success'
+ });
+
+ setTimeout(() => {
+ uni.redirectTo({
+ url: '/pages/components/pages/coupons/mycoupons'
+ })
+ }, 1000)
+ }
+ } else {
+ if (!main.isLogin) {
+ uni.navigateTo({ url: '/pages/components/pages/login/login?' })
+ return
+ }
+ // 初始化优惠券
+ getCoupons(0)
+ }
+})
+
onShow(() => {
+ // console.log("444444444444", member);
+ // if (!main.isLogin) {
+ // uni.navigateTo({ url: '/pages/components/pages/login/login' })
+ // return
+ // }
+
getCoupons(0)
})
onPullDownRefresh(() => {
@@ -188,9 +320,14 @@ const exchange = async () => {
tabs.value[0].coupons = [];
tabs.value[0].page = 1;
getCoupons(0)
- tabs.value[1].coupons = [];
- tabs.value[1].page = 1;
- getCoupons(1)
+ setTimeout(() => {
+ uni.redirectTo({
+ url: '/pages/components/pages/coupons/mycoupons'
+ })
+ }, 1000)
+ // tabs.value[1].coupons = [];
+ // tabs.value[1].page = 1;
+ // getCoupons(1)
}
}
// 使用范围
@@ -214,14 +351,14 @@ const getCoupons = async (type) => {
let pagesize = tabs.value[type].pagesize;
// 我的优惠券
let data = [];
- if (type == 0) {
- myCoupons.value = await couponMine({ page: page, pagesize: pagesize });
- }
+ // if (type == 1) {
+ // myCoupons.value = await couponMine({ page: page, pagesize: pagesize });
+ // }
// 未领优惠券
// if (type == 1) {
// notCoupons.value = await couponIndexApi({page:page,pagesize:pagesize});
// }
- if (type == 1) {
+ if (type == 0) {
notCoupons.value = await couponIndexApi({ page: page, pagesize: pagesize });
// 过滤掉已领取的优惠券
notCoupons.value = notCoupons.value.filter(notCoupon =>
@@ -273,6 +410,12 @@ const receive = async (coupon, index) => {
type: 'success'
});
detailModalVisible.value = false
+
+ setTimeout(() => {
+ uni.redirectTo({
+ url: '/pages/components/pages/coupons/mycoupons'
+ })
+ }, 1000)
}
}
@@ -449,6 +592,7 @@ page {
align-items: center;
}
+
.store {
font-weight: 500;
}
@@ -486,6 +630,21 @@ page {
border-radius: 20rpx;
width: 190rpx;
height: 190rpx;
+ position: relative;
+ flex-shrink: 0;
+ /* 禁止图片收缩 */
+
+ .coupon-type {
+ font-size: 24rpx;
+ color: #ffffff;
+ background-color: #f9ae3d;
+ padding: 5rpx 10rpx;
+ border-radius: 10rpx;
+ margin-right: 10rpx;
+ position: absolute;
+ top: 10rpx;
+ right: 0rpx;
+ }
}
.introduce {
@@ -499,6 +658,7 @@ page {
font-size: 60rpx;
font-weight: bold;
margin-right: 10rpx;
+ max-width: 300rpx;
}
}
diff --git a/pages/components/pages/coupons/mycoupons.vue b/pages/components/pages/coupons/mycoupons.vue
new file mode 100644
index 0000000..49515f0
--- /dev/null
+++ b/pages/components/pages/coupons/mycoupons.vue
@@ -0,0 +1,738 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 满减券
+
+
+
+ ¥
+ {{ item.value }}
+
+ 满{{ item.least }}减{{ item.value }}
+
+
+ {{ item.title }}
+ {{ formatDateTime(item.startTime,
+ 'yyyy-MM-dd') }}-{{ formatDateTime(item.endTime, 'yyyy-MM-dd') }}
+
+
+
+ 立即使用
+ 未到使用期限
+ 已使用
+ 已过期
+
+
+
+
+
+
+
+
+
+ 商品券
+
+
+
+ 商品名称:{{ item.productName }}
+
+ {{ item.title }}
+ {{ formatDateTime(item.startTime,
+ 'yyyy-MM-dd') }}-{{ formatDateTime(item.endTime, 'yyyy-MM-dd') }}
+
+
+
+ 立即使用
+ 未到使用期限
+ 已使用
+ 已过期
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 有效期:{{ formatDateTime(coupon.startTime, 'yyyy-MM-dd') }}-{{ formatDateTime(coupon.endTime,
+ 'yyyy-MM-dd') }}
+
+
+ 领取时间:{{ formatDateTime(coupon.createTime) }}
+
+
+ 券价值:满{{ coupon.least }}减{{ coupon.value }}
+
+
+ 券价值:使用此券免费领取 {{ coupon.productName }} 一份
+
+
+ 适用范围:{{ typeInfo(coupon.type) }}
+
+
+ 适用店铺:{{ coupon.shopName }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/components/pages/fenxiao/fenxiao.vue b/pages/components/pages/fenxiao/fenxiao.vue
index 3dd7ec0..3e16610 100644
--- a/pages/components/pages/fenxiao/fenxiao.vue
+++ b/pages/components/pages/fenxiao/fenxiao.vue
@@ -11,7 +11,7 @@
-
+
Hi,{{ userName }}
@@ -238,6 +238,13 @@ const goToApplyForm = () => {
});
};
+// 跳转到编辑信息页面
+const goToEditInfo = () => {
+ uni.navigateTo({
+ url: `/pages/components/pages/fenxiao/fenxiaorequestform?id=${userId.value}&isEdit=true`,
+ });
+};
+
// 显示邀请码弹窗
const showInviteCodePopup = () => {
showInvitePopup.value = true;
diff --git a/pages/components/pages/fenxiao/fenxiaorequestform.vue b/pages/components/pages/fenxiao/fenxiaorequestform.vue
index bb9a218..0ff58b7 100644
--- a/pages/components/pages/fenxiao/fenxiaorequestform.vue
+++ b/pages/components/pages/fenxiao/fenxiaorequestform.vue
@@ -1,5 +1,5 @@
-
+
- 提交
-
+ {{ isEdit ? '保存修改' : '提交' }}
+
为什么要加入我们?
加入我们的分销团队,不仅能共享潜力巨大的健康市场红利,更是爱的传递。
@@ -81,11 +81,14 @@ import { ref, reactive } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import { useMainStore } from "@/store/store";
import { storeToRefs } from "pinia";
-import { createDistributor } from "@/api/distributor";
+import { createDistributor, getDistributorInfo, editDistributor } from "@/api/distributor";
const main = useMainStore();
const { isLogin, member } = storeToRefs(main);
+// 是否是编辑模式
+const isEdit = ref(false);
+
// 表单数据
const formData = reactive({
id: "", // ID
@@ -155,35 +158,82 @@ const validateForm = () => {
return true;
};
+// 加载分销商信息
+const loadDistributorInfo = async (id) => {
+ try {
+ const data = await getDistributorInfo({ id });
+ if (data) {
+ formData.id = data.id;
+ formData.name = data.name;
+ formData.phone = data.phone;
+ formData.workUnit = data.workUnit || "";
+ formData.recipientName = data.recipientName;
+ formData.bankCardNumber = data.bankCardNumber;
+ formData.bankName = data.bankName;
+ }
+ } catch (error) {
+ console.error("加载分销商信息失败:", error);
+ uni.showToast({
+ title: "加载信息失败",
+ icon: "none",
+ });
+ }
+};
+
// 提交表单
const submitForm = async () => {
if (!validateForm()) return;
uni.showLoading({
- title: "提交中...",
+ title: isEdit.value ? "保存中..." : "提交中...",
});
- // 调用分销商申请接口
+ // 调用分销商申请/更新接口
const requestData = {
- memberId: member.value.id, // ID 可选
+ memberId: member.value.id,
name: formData.name,
phone: formData.phone,
- workUnit: formData.workUnit || "", // 工作单位可选
- recipientName: formData.recipientName, // 收款人姓名可选
- bankCardNumber: formData.bankCardNumber, // 银行卡号可选
- bankName: formData.bankName, // 开户行可选
+ workUnit: formData.workUnit || "",
+ recipientName: formData.recipientName,
+ bankCardNumber: formData.bankCardNumber,
+ bankName: formData.bankName,
};
- let data = await createDistributor(requestData);
- if (data) {
- uni.showToast({
- title: "申请提交成功",
- icon: "success",
- });
+ try {
+ // let data = await createDistributor(requestData);
+ let data = null;
+ if (isEdit.value) {
+ data = await editDistributor({
+ id: formData.id,
+ memberId: member.value.id,
+ name: formData.name,
+ phone: formData.phone,
+ workUnit: formData.workUnit || "",
+ recipientName: formData.recipientName,
+ bankCardNumber: formData.bankCardNumber,
+ bankName: formData.bankName,
+ });
+ } else {
+ data = await createDistributor(requestData);
+ }
+ if (data) {
+ uni.showToast({
+ title: isEdit.value ? "保存成功" : "申请提交成功",
+ icon: "success",
+ });
- // 延迟返回上一页
- setTimeout(() => {
- uni.navigateBack();
- }, 1500);
+ // 延迟返回上一页
+ setTimeout(() => {
+ uni.navigateBack();
+ }, 1500);
+ }
+ } catch (error) {
+ console.error("提交失败:", error);
+ uni.showToast({
+ title: "提交失败",
+ icon: "none",
+ });
+ } finally {
+ uni.hideLoading();
}
};
@@ -196,11 +246,18 @@ const goBack = () => {
onLoad((options) => {
if (!isLogin.value) {
uni.navigateTo({ url: "/pages/components/pages/login/login" });
+ return;
}
- // 获取传入的id参数并赋值
- if (options && options.id) {
+ // 判断是否是编辑模式
+ if (options && options.isEdit === "true") {
+ isEdit.value = true;
+ }
+
+ // 获取传入的id参数并加载数据
+ if (options && options.id && options.isEdit === "true") {
formData.id = options.id;
+ loadDistributorInfo(options.id);
}
});
diff --git a/pages/components/pages/login/login.vue b/pages/components/pages/login/login.vue
index c952941..66ca450 100644
--- a/pages/components/pages/login/login.vue
+++ b/pages/components/pages/login/login.vue
@@ -77,6 +77,7 @@ const isChecked = ref(false)
const openid = ref(main.openid)
const uToast = ref()
const uCode = ref()
+const couponId = ref('');
const captchaStyle = computed(() => {
let style = {};
@@ -87,6 +88,12 @@ const captchaStyle = computed(() => {
return style;
});
+onLoad(async (options) => {
+ if (options.couponId) {
+ couponId.value = options.couponId;
+ }
+})
+
onShow(() => {
// #ifdef MP-WEIXIN
@@ -140,7 +147,13 @@ const loginForWechatMini = async (e) => {
type: 'success'
});
setTimeout(function() {
- uni.navigateBack();
+ if(couponId.value != ''){
+ uni.redirectTo({
+ url: '/pages/components/pages/coupons/coupons?couponId=' + couponId.value
+ })
+ }else{
+ uni.navigateBack();
+ }
}, 2000);
}
}else {
diff --git a/pages/components/pages/mine/helpcenter.vue b/pages/components/pages/mine/helpcenter.vue
index d0eb918..5e09304 100644
--- a/pages/components/pages/mine/helpcenter.vue
+++ b/pages/components/pages/mine/helpcenter.vue
@@ -78,9 +78,12 @@ const questionList = ref([
]);
+const phoneNumber = ref('');
+
onLoad((options) => {
- if (options && options.phone) {
- phoneNumber.value = options.phone;
+ if (options && options.phoneNumber) {
+ console.log("电话:==============",options.phoneNumber)
+ phoneNumber.value = options.phoneNumber;
}
});
@@ -121,7 +124,7 @@ const closePopup = () => {
// 添加打电话方法
const callService = () => {
uni.makePhoneCall({
- phoneNumber: '15251830311' // 替换为实际客服电话
+ phoneNumber: phoneNumber.value // 替换为实际客服电话
});
}
diff --git a/pages/components/pages/orders/detail.vue b/pages/components/pages/orders/detail.vue
index d1edd08..8ce343d 100644
--- a/pages/components/pages/orders/detail.vue
+++ b/pages/components/pages/orders/detail.vue
@@ -248,6 +248,14 @@
优惠金额
¥{{ order.couponPrice }}
+
+ 商品券
+ {{ order.title }}
+
+
+ 商品券规格
+ {{ order.couponProductSpec }}
+
实付金额
¥{{ order.payPrice }}
diff --git a/pages/components/pages/packages/index.vue b/pages/components/pages/packages/index.vue
index 6ab087a..598f492 100644
--- a/pages/components/pages/packages/index.vue
+++ b/pages/components/pages/packages/index.vue
@@ -1,20 +1,17 @@
-
+
-
+
-
-
+
+
-
+
+ 满减券
+
¥
@@ -22,25 +19,57 @@
满{{ item.least }}减{{ item.value }}
{{ item.title }}
- {{formatDateTime(item.startTime, 'yyyy-MM-dd')}}-{{formatDateTime(item.endTime, 'yyyy-MM-dd')}}
+ {{ formatDateTime(item.startTime,
+ 'yyyy-MM-dd') }}-{{ formatDateTime(item.endTime, 'yyyy-MM-dd') }}
- 立即使用
- 取消使用
+ 立即使用
+ 取消使用
+
+
+
+
+
+
+
+
+ 商品券
+
+
+
+ 商品名称:{{ item.productName }}
+
+ {{ item.title }}
+ {{ formatDateTime(item.startTime,
+ 'yyyy-MM-dd') }}-{{ formatDateTime(item.endTime, 'yyyy-MM-dd') }}
+
+
+
+ 立即使用
+ 取消使用
+
-
+
-
- 有效期:{{formatDateTime(coupon.startTime, 'yyyy-MM-dd')}}至{{formatDateTime(coupon.endTime, 'yyyy-MM-dd')}}
- 领取时间:{{formatDateTime(coupon.createTime, 'yyyy-MM-dd')}}
- 卷价值:满{{ coupon.least }}减{{ coupon.value }}
+
+ 有效期:{{ formatDateTime(coupon.startTime,
+ 'yyyy-MM-dd') }}至{{ formatDateTime(coupon.endTime, 'yyyy-MM-dd') }}
+ 领取时间:{{ formatDateTime(coupon.createTime,
+ 'yyyy-MM-dd') }}
+ 卷价值:满{{
+ coupon.least }}减{{ coupon.value }}
+ 券价值:使用此券免费领取 {{ coupon.productName }} 一份
+
适用范围:{{ typeInfo(coupon.type) }}
适用店铺:{{ coupon.shopName }}
@@ -56,16 +85,16 @@
diff --git a/pages/index/index.vue b/pages/index/index.vue
index efb7b99..c584bae 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -144,10 +144,6 @@ const takeout = () => {
const coupons = () => {
console.log("--> % orderType:\n", main.orderType)
console.log("--> % isLogin:\n", main.isLogin)
- if (!main.isLogin) {
- uni.navigateTo({ url: '/pages/components/pages/login/login' })
- return
- }
uni.navigateTo({
url: '/pages/components/pages/coupons/coupons'
})
diff --git a/pages/menu/coupon-float.vue b/pages/menu/coupon-float.vue
new file mode 100644
index 0000000..8be1c4a
--- /dev/null
+++ b/pages/menu/coupon-float.vue
@@ -0,0 +1,217 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/menu/menu.vue b/pages/menu/menu.vue
index 63b088f..254fc1d 100644
--- a/pages/menu/menu.vue
+++ b/pages/menu/menu.vue
@@ -35,8 +35,9 @@
- (配送距离: {{
- store.distance }}km)
+ (配送距离:
+ {{
+ store.distance }}km)
(本店不支持外卖)
@@ -62,102 +63,60 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
- {{ item.name }}
-
-
-
-
-
-
-
-
-
- {{ good.storeName }}
- {{ good.storeInfo }}
-
-
- ¥{{ good.price
- }}
-
-
-
-
- {{ goodCartNum(good.id) }}
-
-
-
- 已售罄
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+ {{ item.name }}
+
+
+
+
+
+
+
+ {{
+ promo.name }}
+
+
+
+
{{ good.storeName }}
- {{ good.storeInfo }}
-
- ¥{{ good.price }}
-
-
-
-
- {{ goodCartNum(good.id) }}
-
-
+ 已售罄
+
+
+
+
+
+
+
+ {{
+ promo.name }}
+
+
+
+ {{ good.storeName }}
+ {{ good.storeInfo }}
+
+ ¥{{ good.price }}
+
+
+
+
+
+
+ {{ goodCartNum(good.id) }}
- 已售罄
-
+
+
+
+
+ 已售罄
-
-
-
-
-
-
-
-
-
-
- 致敏物质提示:
-
-
- 本菜单中含有含麸质的谷物及其制品,甲壳类动物及甲壳类动物制品,蛋类及蛋类制品,鱼类及鱼类制品,花生、大豆及其制品,奶类及奶类制品,木本坚果及坚果制品。汤内含有当归,当归不适宜人群有脾胃虚弱、腹泻、孕妇、经期女性、热盛出血及当归过敏者。
-
-
-
-
-
-
-
-
+
-
-
-
-
- {{ getCartGoodsNumber }}
-
-
- ¥{{ getCartGoodsPrice }}
-
- 免配送费 ¥{{ store.deliveryPrice }}
-
-
- 预估配送费 ¥{{ store.deliveryPrice }}
+
+
+
+
+
+
+ 致敏物质提示:
+
+
+ 本菜单中含有含麸质的谷物及其制品,甲壳类动物及甲壳类动物制品,蛋类及蛋类制品,鱼类及鱼类制品,花生、大豆及其制品,奶类及奶类制品,木本坚果及坚果制品。汤内含有当归,当归不适宜人群有脾胃虚弱、腹泻、孕妇、经期女性、热盛出血及当归过敏者。
+
+
-
- {{ disabledPay ? `差${spread}元起送` : '去结算' }}
-
-
-
+
+
+
-
-
-
-
+
+
+
+
+
+ 刷新
+
+
-
-
+
+
-
-
-
- 刷新
-
-
+
+
+
+ 优惠券
+
-
-
+
+
@@ -423,6 +468,26 @@ import {
import {
menuAds
} from "@/api/market";
+import { getPromotionactivityInfo } from "@/api/activity"; // 确保路径正确
+import CouponFloat from './coupon-float.vue'
+import { couponMine } from '@/api/coupon'
+const promotionActivities = ref([]); //所有优惠活动
+const selectedPromotion = ref(null); // 用于存储用户选择的优惠活动
+const showPromotionModal = ref(false); // 控制优惠选择弹窗的显示
+const applicablePromotions = ref([]); // 存储当前购物车适用的优惠活动
+
+// 用户选择优惠活动后的处理
+const onPromotionChange = (e) => {
+ // 1. 获取选中项的ID
+ const selectedId = e.detail.value;
+
+ // 2. 通过ID查找完整对象
+ selectedPromotion.value = applicablePromotions.value.find(
+ p => p.id == parseInt(selectedId)
+ );
+ // console.log("ssssssssssssssss", selectedPromotion.value);
+};
+
const main = useMainStore();
const {
orderType,
@@ -461,6 +526,10 @@ const newkmUnit = computed(() => (param) => {
console.log("param:", param);
return "10km";
});
+
+const showCouponFloat = ref(false)
+const allCoupons = ref([])
+
const goodCartNum = computed(() => {
//计算单个饮品添加到购物车的数量
return (id) =>
@@ -491,11 +560,19 @@ const getCartGoodsNumber = computed(() => {
// });
const getCartGoodsPrice = computed(() => {
let total = cart.value.reduce((acc, cur) => {
- const itemPrice = cur.price * cur.number;
+ let itemPrice = cur.price * cur.number;
+
+ // 如果有优惠活动,将商品打折后,加入总价
+ if (selectedPromotion.value) {
+ // console.log("动态更新总价格11111111111",selectedPromotion.value)
+ itemPrice = selectedPromotion.value.discountRate * itemPrice;
+ }
const boxPrice = (cur.boxFee || 0) * cur.number;
return acc + itemPrice + boxPrice; // 注意:你原先漏掉了 boxPrice
}, 0);
+
+
// 返回数值类型(而非字符串)
return parseFloat(total.toFixed(2)); // 关键修改:parseFloat 转换回数值
});
@@ -522,8 +599,7 @@ uni.$on("refreshMenu", () => {
onPullDownRefresh(() => {
init();
});
-onLoad((options) => {
-
+onLoad(async (options) => {
// 处理扫描二维码进入的情况
if (options && options.q) {
try {
@@ -546,6 +622,7 @@ onLoad((options) => {
}
init();
refreshCart();
+
nextTick(() => {
if (goods.value.length > 0) {
currentCateId.value = goods.value[0].id;
@@ -561,10 +638,14 @@ onShow(() => {
//init();
refreshCart();
shopAd.value = uni.getStorageSync("shopAd");
+
// 初始化页面高度计算
nextTick(() => {
calcLayoutHeights();
});
+
+ // 获取所有优惠券
+ loadAllCoupons();
});
const openCartShow = () => {
@@ -681,6 +762,9 @@ const getShopList = async (res) => {
// uni.stopPullDownRefresh();
// 加载数据后显示弹窗
showPopup.value = true
+
+ // 获取活动信息
+ loadPromotionActivities();
}
}
uni.stopPullDownRefresh();
@@ -703,9 +787,28 @@ const refreshCart = () => {
}
cart.value = tmpCart;
cartPopupVisible.value = false;
+
+ // 初始化,获取购物车数据,开始计算优惠
+ isPromotionActivity();
}
}
};
+
+const loadPromotionActivities = async () => {
+ try {
+ const data = { pageNo: 1, pageSize: 100, shopId: store.value.id ? store.value.id : 0 }
+ const res = await getPromotionactivityInfo(data);
+ // console.log("res:", res);
+ if (res) {
+ promotionActivities.value = res.list; // 假设接口返回的数据在 data 字段
+ console.log("promotionActivities活动信息000000000:", promotionActivities.value);
+ } else {
+ console.error('获取优惠活动失败:', res.msg);
+ }
+ } catch (error) {
+ console.error('获取优惠活动异常:', error);
+ }
+};
const getAds = async (shop_id) => {
let data = await menuAds({
shop_id: shop_id ? shop_id : 0
@@ -850,9 +953,9 @@ const calcSize = () => {
}
h += data.height;
item.bottom = h;
- console.log(
- `Category ${item.id} calculated: top=${item.top}, height=${data.height}, bottom=${item.bottom}`
- );
+ // console.log(
+ // `Category ${item.id} calculated: top=${item.top}, height=${data.height}, bottom=${item.bottom}`
+ // );
}
}
)
@@ -955,7 +1058,12 @@ const handleAddToCart = (cate, newGood, num) => {
});
}
uni.setStorageSync("cart", JSON.parse(JSON.stringify(cart.value)));
+
+ //将商品添加到购物车后,开始计算优惠
+ isPromotionActivity()
};
+
+
const handleReduceFromCart = (item, good) => {
const index = cart.value.findIndex((item) => item.id === good.id);
cart.value[index].number -= 1;
@@ -996,6 +1104,22 @@ const handleGoodReduce = (currentGood) => {
cart.value.splice(cartIndex, 1);
}
}
+
+ // 重新计算优惠
+ isPromotionActivity();
+};
+
+const getGoodPromotions = (productId) => {
+ if (!promotionActivities.value || promotionActivities.value.length === 0) {
+ return [];
+ }
+ return promotionActivities.value.filter(promo => {
+ if (promo.productId) {
+ const productIds = promo.productId.split(',');
+ return productIds.includes(String(productId));
+ }
+ return false;
+ });
};
const showGoodDetailModal = (item, newGood) => {
@@ -1020,7 +1144,7 @@ const closeGoodDetailModal = () => {
const changePropertyDefault = (index, key, isDefault) => {
//改变默认属性值
let valueStr = "";
- console.log("good:", good.value);
+ // console.log("good:", good.value);
if (isDefault) {
newValue.value = [];
for (let i = 0; i < good.value.productAttr.length; i++) {
@@ -1033,16 +1157,26 @@ const changePropertyDefault = (index, key, isDefault) => {
// //valueStr = newValue.value.join(',')
// }
valueStr = newValue.value.join(",");
+
+ // 转换为数组并排序
+ const sortedArray = valueStr.split(",").sort((a, b) => {
+ return a.charCodeAt(0) - b.charCodeAt(0); // 比较Unicode码点
+ });
+
+ // 重新组合为字符串
+ valueStr = sortedArray.join(",");
+
// let productValue = good.value.productValue[valueStr]
// if(!productValue) {
// let skukey = JSON.parse(JSON.stringify(newValue.value))
- // skukey.sort((a, b) => a.localeCompare(b))
// //console.log('skukey:',skukey)
- // valueStr = skukey.join(',')
+ // valueStr = skukey.sort((a, b) => a.charCodeAt(0) - b.charCodeAt(0)).join(',')
// productValue = good.value.productValue[valueStr]
}
+ // console.log('valueStr--------:', valueStr)
let productValue = good.value.productValue[valueStr];
+ // console.log('productValue--------------:', productValue)
good.value.number = 1;
good.value.price = parseFloat(productValue.price).toFixed(2);
good.value.stock = productValue.stock;
@@ -1065,10 +1199,96 @@ const handleAddToCartInModal = () => {
return;
}
+ // // 暂存当前要添加的商品信息
+ // const currentGoodToAdd = JSON.parse(JSON.stringify(good.value));
+ // const currentCategory = JSON.parse(JSON.stringify(category.value));
+ // const currentNum = good.value.number;
+
+ // // 模拟将商品加入购物车后的状态,用于计算优惠
+ // let tempCart = JSON.parse(JSON.stringify(cart.value));
+ // const existingCartItemIndex = tempCart.findIndex(item => item.id === currentGoodToAdd.id && item.valueStr === currentGoodToAdd.valueStr);
+ // if (existingCartItemIndex > -1) {
+ // tempCart[existingCartItemIndex].number += currentNum;
+ // } else {
+ // tempCart.push({
+ // id: currentGoodToAdd.id,
+ // cate_id: currentCategory.id,
+ // name: currentGoodToAdd.storeName,
+ // price: currentGoodToAdd.price,
+ // number: currentNum,
+ // image: currentGoodToAdd.image,
+ // valueStr: currentGoodToAdd.valueStr,
+ // boxFee: currentGoodToAdd.boxFee || 0,
+ // aloneSell: currentGoodToAdd.aloneSell,
+ // });
+ // }
+
+ // let cartTotalAmount = tempCart.reduce((acc, cur) => acc + cur.number * cur.price, 0);
+
+
// console.log('good:',good.value,'category:',category.value)
handleAddToCart(category.value, good.value, good.value.number);
closeGoodDetailModal();
};
+
+// 判断是否满足优惠活动、
+const isPromotionActivity = () => {
+ // console.log("===============初始化时判断是否满足优惠活动", cart.value);
+ // applicablePromotions.value = [];
+ const applicablePromotionsCopy = [];
+
+ if (promotionActivities.value && promotionActivities.value.length > 0) {
+ promotionActivities.value.forEach(promo => {
+ let activityAmount = 0;
+ let activityCount = 0;
+ const productIds = promo.productId ? promo.productId.split(',') : [];
+ // 遍历购物车计算活动商品总额和数量
+ cart.value.forEach(item => {
+ if (productIds.includes(String(item.id))) {
+ activityAmount += item.price * item.number;
+ activityCount += item.number;
+ }
+ });
+
+ if (activityAmount >= promo.minAmount && activityCount >= promo.minQuantity) {
+ applicablePromotionsCopy.push(promo);
+ }
+
+ });
+ // console.log(applicablePromotionsCopy.length,"applicablePromotionssssssssssssssss:", applicablePromotionsCopy);
+ if (selectedPromotion.value == null) {
+ selectedPromotion.value = applicablePromotionsCopy[0];
+ }
+ if (applicablePromotionsCopy.length == 0) {
+ selectedPromotion.value = null;
+ }
+ if (applicablePromotionsCopy.length == 1) {
+ selectedPromotion.value = applicablePromotionsCopy[0];
+ }
+
+ applicablePromotions.value = applicablePromotionsCopy;
+
+ // console.log("选择的优惠活动:", selectedPromotion.value);
+ // console.log("真实的优惠活动", applicablePromotions.value);
+ }
+
+ // console.log('applicablePromotions:', applicablePromotions.value);
+ // if (applicablePromotions.value.length > 1) {
+ // // 多个活动满足条件,弹窗让用户选择
+ // showPromotionModal.value = true;
+ // // 此处不直接添加购物车,等待用户选择活动
+ // } else if (applicablePromotions.value.length === 1) {
+ // // 只有一个活动满足条件,自动应用
+ // selectedPromotion.value = applicablePromotions.value[0];
+ // // applyPromotionAndAddToCart(currentCategory, currentGoodToAdd, currentNum);
+ // closeGoodDetailModal();
+ // } else {
+ // // 没有活动满足条件,直接添加
+ // selectedPromotion.value = null; // 清空已选优惠
+ // // handleAddToCart(currentCategory, currentGoodToAdd, currentNum);
+ // closeGoodDetailModal();
+ // }
+};
const openCartPopup = () => {
//打开/关闭购物车列表popup
popup.value.open();
@@ -1092,6 +1312,9 @@ const handleCartClear = () => {
const handleCartItemAdd = (index) => {
cart.value[index].number += 1;
uni.setStorageSync("cart", JSON.parse(JSON.stringify(cart.value)));
+
+ // 重新计算优惠
+ isPromotionActivity();
};
const handleCartItemReduce = (index) => {
if (cart.value[index].number === 1) {
@@ -1103,6 +1326,9 @@ const handleCartItemReduce = (index) => {
cartPopupVisible.value = false;
}
uni.setStorageSync("cart", JSON.parse(JSON.stringify(cart.value)));
+
+ // 重新计算优惠
+ isPromotionActivity();
};
const toPay = () => {
if (!isLogin.value) {
@@ -1135,7 +1361,7 @@ const toPay = () => {
});
uni.setStorageSync("cart", JSON.parse(JSON.stringify(cart.value)));
uni.navigateTo({
- url: `/pages/components/pages/pay/pay?distributorId=${distributorId.value}`,
+ url: `/pages/components/pages/pay/pay?distributorId=${distributorId.value}&promotionId=${selectedPromotion.value?.id}`,
});
}
@@ -1165,6 +1391,26 @@ const isSpecialPackage = (name) => {
const closePopup = () => {
showPopup.value = false
}
+
+
+
+// 获取所有优惠券
+const loadAllCoupons = async () => {
+ const data = await couponMine({ page: 1, pagesize: 100 });
+ if (data) allCoupons.value = data;
+
+ console.log(data,"------------")
+ console.log(allCoupons.value,"------------")
+}
+
+const showCouponFlo = () => {
+ console.log("我点击了优惠券按钮")
+ showCouponFloat.value = true;
+}
+
+const closeCouponFloat = () => {
+ showCouponFloat.value = false;
+}
\ No newline at end of file
diff --git a/pages/mine/mine.vue b/pages/mine/mine.vue
index f270504..e486244 100644
--- a/pages/mine/mine.vue
+++ b/pages/mine/mine.vue
@@ -49,7 +49,7 @@
去使用
@@ -237,7 +237,7 @@ const serv = (item) => {
item.id +
"&name=" +
item.name +
- "&phone=" +
+ "&phoneNumber=" +
item.phone,
});
break;
diff --git a/static/images/coupon-icon.png b/static/images/coupon-icon.png
new file mode 100644
index 0000000..6b6ecd0
Binary files /dev/null and b/static/images/coupon-icon.png differ
diff --git a/uni.scss b/uni.scss
index 1bebb92..18e23e4 100644
--- a/uni.scss
+++ b/uni.scss
@@ -15,7 +15,8 @@
/* 颜色变量 */
/* 行为相关颜色 */
// $color-primary: #ADB838;
-$color-primary: #09b4f1;
+// $color-primary: #09b4f1;
+$color-primary: #52ac41;
$color-success: #4cd964;
$color-warning: #FAB714;
$color-error: #D12E32;