diff --git a/api/order/order.js b/api/order/order.js index db8926b..3d39683 100644 --- a/api/order/order.js +++ b/api/order/order.js @@ -178,4 +178,16 @@ export const orderPay = (data) => { method: "POST", data }) +} + +// 再次支付订单 +export const updateBaseOrder = (params) => { + return request({ + url: '/applet/mall/order/updateBaseOrder', + headers: { + isToken: true + }, + method: "POST", + params + }) } \ No newline at end of file diff --git a/api/system/user.js b/api/system/user.js index b8040ac..04536ad 100644 --- a/api/system/user.js +++ b/api/system/user.js @@ -153,4 +153,16 @@ export function getPhoneNumber(data) { method: 'post', data }) +} + +//获取手机号 +export function updateInfo(params) { + return request({ + url: `/h5/member/updateInfoH5`, + headers: { + "isToken": true + }, + method: 'post', + params + }) } \ No newline at end of file diff --git a/components/CouponItem/index.vue b/components/CouponItem/index.vue new file mode 100644 index 0000000..653ea58 --- /dev/null +++ b/components/CouponItem/index.vue @@ -0,0 +1,299 @@ + + + + + \ No newline at end of file diff --git a/components/CouponRulePopup/index.vue b/components/CouponRulePopup/index.vue new file mode 100644 index 0000000..cc85bb7 --- /dev/null +++ b/components/CouponRulePopup/index.vue @@ -0,0 +1,198 @@ + + + + + \ No newline at end of file diff --git a/doc/Group 1000001818.png b/doc/Group 1000001818.png new file mode 100644 index 0000000..571005b Binary files /dev/null and b/doc/Group 1000001818.png differ diff --git a/doc/Group 1000001818@2x.png b/doc/Group 1000001818@2x.png new file mode 100644 index 0000000..e299706 Binary files /dev/null and b/doc/Group 1000001818@2x.png differ diff --git a/doc/Group 1000001818@3x.png b/doc/Group 1000001818@3x.png new file mode 100644 index 0000000..a6a9e27 Binary files /dev/null and b/doc/Group 1000001818@3x.png differ diff --git a/doc/Rectangle 9031.png b/doc/Rectangle 9031.png new file mode 100644 index 0000000..0ee3412 Binary files /dev/null and b/doc/Rectangle 9031.png differ diff --git a/doc/Rectangle 9031@2x.png b/doc/Rectangle 9031@2x.png new file mode 100644 index 0000000..94fb8fb Binary files /dev/null and b/doc/Rectangle 9031@2x.png differ diff --git a/doc/Rectangle 9031@3x.png b/doc/Rectangle 9031@3x.png new file mode 100644 index 0000000..b854c96 Binary files /dev/null and b/doc/Rectangle 9031@3x.png differ diff --git a/static/logo.png b/doc/logo.png similarity index 100% rename from static/logo.png rename to doc/logo.png diff --git a/static/logo200.png b/doc/logo200.png similarity index 100% rename from static/logo200.png rename to doc/logo200.png diff --git a/docs/品种选择功能说明.md b/docs/品种选择功能说明.md new file mode 100644 index 0000000..102f784 --- /dev/null +++ b/docs/品种选择功能说明.md @@ -0,0 +1,112 @@ +# 品种选择功能说明 + +## 功能概述 + +根据设计图要求,新建了一个专门的品种选择页面,替换了原有的弹窗式品种选择功能。 + +## 主要特性 + +### 1. 页面布局 +- **系统导航栏**:橙色背景,显示"选择品种"标题 +- **搜索栏**:支持实时搜索品种名称 +- **品种列表**:按字母分组显示,支持滚动 +- **字母索引**:右侧固定位置,支持快速跳转到指定字母 + +### 2. 功能实现 + +#### 品种数据获取 +- 根据宠物类型(猫/狗)获取对应的品种数据 +- 支持从API动态获取品种列表 + +#### 搜索功能 +- 实时搜索,支持中文和英文搜索 +- 搜索结果实时更新显示 + +#### 字母分组 +- 自动按品种名称首字母分组 +- 支持中文字符的拼音首字母映射 +- 按字母顺序排列显示 +- 每个字母组内的品种按中文拼音排序 + +#### 快速导航 +- 右侧字母索引支持点击跳转 +- 滚动动画效果 +- 当前字母高亮显示 +- 滚动时自动更新激活的字母索引 + +### 3. 页面路由 + +**新增页面路径**:`/pages/personalCenter/breedSelect` + +**页面配置**: +```json +{ + "path": "pages/personalCenter/breedSelect", + "style": { + "navigationBarTitleText": "选择品种", + "navigationBarBackgroundColor": "#FF6B35", + "enablePullDownRefresh": false, + "navigationBarTextStyle": "white" + } +} +``` + +### 4. 使用方式 + +在需要选择品种的地方,调用以下代码跳转到品种选择页面: + +```javascript +uni.navigateTo({ + url: `/pages/personalCenter/breedSelect?petType=${petType}&selectedBreed=${encodeURIComponent(selectedBreed || '')}` +}); +``` + +### 5. 数据传递 + +- **输入参数**: + - `petType`:宠物类型('cat' 或 'dog') + - `selectedBreed`:当前已选择的品种(可选) + +- **输出结果**: + - 选择品种后自动返回上一页 + - 自动更新上一页的品种数据 + +### 6. 样式特点 + +- 使用系统导航栏,符合设计图要求 +- 简洁的白色背景设计 +- 流畅的动画效果 +- 响应式布局 +- 字母索引激活状态有橙色背景高亮 + +## 技术实现 + +### 核心组件 +- `breedSelect.vue`:品种选择页面主组件 +- 修改了 `petBaseInfo.vue`:移除原有弹窗,改为页面跳转 + +### 主要方法 +- `getPetBreeds()`:获取品种数据 +- `groupBreedsByLetter()`:按字母分组 +- `onSearchChange()`:搜索处理 +- `selectBreed()`:选择品种 +- `scrollToLetter()`:字母跳转 +- `onScroll()`:滚动事件处理 +- `updateCurrentLetter()`:更新当前激活字母 + +### 数据映射 +- 中文字符到拼音首字母的映射表 +- 支持常见的中文品种名称 + +## 兼容性 + +- 完全兼容原有的品种选择逻辑 +- 保持数据格式不变 +- 支持现有API接口 + +## 注意事项 + +1. 确保API接口 `getDictList` 正常工作 +2. 品种数据需要包含 `dictLabel` 字段 +3. 页面需要正确配置在 `pages.json` 中 +4. 建议在真机上测试滚动和点击效果 \ No newline at end of file diff --git a/docs/性格选择功能说明.md b/docs/性格选择功能说明.md new file mode 100644 index 0000000..372eebc --- /dev/null +++ b/docs/性格选择功能说明.md @@ -0,0 +1,71 @@ +# 性格选择功能说明 + +## 功能概述 + +新增了独立的性格选择页面,用户可以在该页面中: +1. 输入宠物的性格描述 +2. 选择预设的性格标签 +3. 保存后回显到宠物信息页面 + +## 文件结构 + +### 新增文件 +- `pages/personalCenter/personalitySelect.vue` - 性格选择页面 + +### 修改文件 +- `pages/personalCenter/components/petBaseInfo.vue` - 修改性格选择逻辑,跳转到新页面 +- `pages.json` - 添加新页面路由配置 + +## 功能特点 + +### 1. 性格描述输入 +- 提供文本输入框,用户可以自由描述宠物性格 +- 支持最多200字符输入 +- 灰色背景,符合设计规范 + +### 2. 快捷选择 +- 提供8个预设性格标签 +- 支持多选功能 +- 选中状态为橙色背景,白色文字 +- 2行4列网格布局 + +### 3. 数据回显 +- 从API获取性格选项列表 +- 支持解析已有的性格数据 +- 保存后自动更新父页面数据 + +### 4. 页面导航 +- 从宠物信息页面点击"性格"字段跳转 +- 保存后自动返回上一页 +- 显示保存成功提示 + +## 使用流程 + +1. 在宠物信息页面点击"性格"字段 +2. 跳转到性格选择页面 +3. 输入性格描述(可选) +4. 选择性格标签(可多选) +5. 点击"保存"按钮 +6. 自动返回宠物信息页面,数据已更新 + +## 技术实现 + +### 数据传递 +- 使用URL参数传递现有性格数据 +- 使用页面栈更新父页面数据 + +### 样式设计 +- 响应式网格布局 +- 符合设计图的颜色方案 +- 流畅的交互动画 + +### API集成 +- 从`pet_personality`字典获取性格选项 +- 支持动态加载和解析 + +## 注意事项 + +1. 确保至少选择一项性格特征才能保存 +2. 性格描述和快捷选择可以组合使用 +3. 数据格式为:描述 + "," + 快捷选择标签 +4. 支持编辑现有性格数据 \ No newline at end of file diff --git a/main.js b/main.js index 0cb51bc..6cb6945 100644 --- a/main.js +++ b/main.js @@ -23,47 +23,87 @@ Vue.mixin(share) // 创建一个空的Vue实例作为事件中心 Vue.prototype.$eventHub = new Vue() -// 创建全局变量 -Vue.prototype.$globalData = { - isAgree:false, - submitData: { - "phone": "", - "wechatId": "", - "note": "", - "totalPrice": "", - "address": { - "province": "", - "city": "", - "district": "", - "detailAddress": "" - }, - "skuList": [], - "service": { - "serviceFrequency": "once_a_day", - "serviceDate": [], - "serviceTimeFirst": "", - "serviceTimeSecond": "", - "pet": [] - } - }, - mainSku:[], - augmentedSku:[], - itemPrices:[], - servicePrices:[], - openIdStr:'', - confirmData: { - phone: "", - wechatId: "", - note: "", - }, - newOrderData:{ - currentAddress:{}, - currentPets:[], - totalPrice:0, - needPreFamiliarize:[] - } + +Vue.prototype.initGlobalData = function() { + Vue.prototype.$globalData = { + isAgree:false, + submitData: { + "phone": "", + "wechatId": "", + "note": "", + "totalPrice": "", + "address": { + "province": "", + "city": "", + "district": "", + "detailAddress": "" + } + }, + mainSku:[], + augmentedSku:[], + itemPrices:[], + servicePrices:[], + openIdStr:'', + confirmData: { + phone: "", + wechatId: "", + note: "", + }, + newOrderData:{ + orderId : '',//需要取消的订单id + currentAddress:{}, + currentPets:[], + totalPrice:0, + needPreFamiliarize:[], + distancePrice : 0, // 距离加价 + } + } } +Vue.prototype.initGlobalData() + +// 创建全局变量 +// Vue.prototype.$globalData = { +// isAgree:false, +// submitData: { +// "phone": "", +// "wechatId": "", +// "note": "", +// "totalPrice": "", +// "address": { +// "province": "", +// "city": "", +// "district": "", +// "detailAddress": "" +// }, +// "skuList": [], +// "service": { +// "serviceFrequency": "once_a_day", +// "serviceDate": [], +// "serviceTimeFirst": "", +// "serviceTimeSecond": "", +// "pet": [] +// } +// }, +// mainSku:[], +// augmentedSku:[], +// itemPrices:[], +// servicePrices:[], +// openIdStr:'', +// confirmData: { +// phone: "", +// wechatId: "", +// note: "", +// }, +// newOrderData:{ +// orderId : '',//需要取消的订单id +// currentAddress:{}, +// currentPets:[], +// totalPrice:0, +// needPreFamiliarize:[] +// } +// } + const app = new Vue({ ...App }) diff --git a/mixins/configList.js b/mixins/configList.js index e0316b8..edc8205 100644 --- a/mixins/configList.js +++ b/mixins/configList.js @@ -13,7 +13,7 @@ export default { } }, computed: { - ...mapState(['configList', 'userInfo', 'buyInfo']), + ...mapState(['configList', 'userInfo', 'buyInfo', 'price_config']), // currentPagePath() { // const pages = getCurrentPages(); // const currentPage = pages[pages.length - 1]; diff --git a/mixins/position.js b/mixins/position.js index 964cfb1..dbebcfd 100644 --- a/mixins/position.js +++ b/mixins/position.js @@ -38,16 +38,22 @@ export default { return minDistance }, - calculateDistanceAddressList(teacherAddress){ + calculateDistanceAddressList(teacherAddress, position){ + + if(!position){ + position = this.position + } + if (!teacherAddress || teacherAddress.length == 0 || !this.position || !this.position.latitude || !this.position.longitude) { - return 0 + return [{ + distance : 0 + }] } - teacherAddress.forEach((item, index) => { item.distance = calculateDistance( this.position.latitude, diff --git a/pages.json b/pages.json index fae1ccc..5fe2fe7 100644 --- a/pages.json +++ b/pages.json @@ -183,6 +183,24 @@ "navigationBarTextStyle": "white" } }, + { + "path": "pages/personalCenter/personalitySelect", + "style": { + "navigationBarTitleText": "性格选择", + "navigationBarBackgroundColor": "#FFBF60", + "enablePullDownRefresh": false, + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/personalCenter/breedSelect", + "style": { + "navigationBarTitleText": "选择品种", + "navigationBarBackgroundColor": "#FFBF60", + "enablePullDownRefresh": false, + "navigationBarTextStyle": "white" + } + }, { "path": "pages/personalCenter/address", "style": { @@ -282,33 +300,6 @@ "navigationBarTextStyle": "white" } }, - { - "path": "pages/companionPetList/companionPetList", - "style": { - "navigationBarTitleText": "周边伴宠师", - "navigationBarBackgroundColor": "#FFBF60", - "enablePullDownRefresh": false, - "navigationBarTextStyle": "white" - } - }, - { - "path": "pages/companionPetList/companionPetInfo", - "style": { - "navigationBarTitleText": "伴宠师主页", - "navigationBarBackgroundColor": "#FFBF60", - "enablePullDownRefresh": false, - "navigationBarTextStyle": "white" - } - }, - { - "path": "pages/companionPetList/couponList", - "style": { - "navigationBarTitleText": "领券中心", - "navigationBarBackgroundColor": "#FFBF60", - "enablePullDownRefresh": false, - "navigationBarTextStyle": "white" - } - }, { "path": "pages/personalCenter/userInfo", "style": { @@ -326,9 +317,36 @@ } }, "subPackages": [ - { - "root": "pages_order", - "pages": [ + { + "root": "pages_order", + "pages": [ + { + "path": "companionPetList/companionPetList", + "style": { + "navigationBarTitleText": "周边伴宠师", + "navigationBarBackgroundColor": "#FFBF60", + "enablePullDownRefresh": false, + "navigationBarTextStyle": "white" + } + }, + { + "path": "companionPetList/companionPetInfo", + "style": { + "navigationBarTitleText": "伴宠师主页", + "navigationBarBackgroundColor": "#FFBF60", + "enablePullDownRefresh": false, + "navigationBarTextStyle": "white" + } + }, + { + "path": "companionPetList/couponList", + "style": { + "navigationBarTitleText": "领券中心", + "navigationBarBackgroundColor": "#FFBF60", + "enablePullDownRefresh": false, + "navigationBarTextStyle": "white" + } + }, { "path": "task/taskList", "style": { @@ -427,6 +445,15 @@ "enablePullDownRefresh": true, "navigationBarTextStyle": "white" } + }, + { + "path": "auth/login", + "style": { + "navigationBarTitleText": "授权登录", + "navigationBarBackgroundColor": "#FFBF60", + "enablePullDownRefresh": false, + "navigationBarTextStyle": "white" + } } ] } diff --git a/pages/companionPetList/couponList.vue b/pages/companionPetList/couponList.vue deleted file mode 100644 index f2dd0f2..0000000 --- a/pages/companionPetList/couponList.vue +++ /dev/null @@ -1,323 +0,0 @@ - - - - \ No newline at end of file diff --git a/pages/components/NewUserCoupon.vue b/pages/components/NewUserCoupon.vue index 0174c3a..f2fdc1a 100644 --- a/pages/components/NewUserCoupon.vue +++ b/pages/components/NewUserCoupon.vue @@ -33,7 +33,7 @@ export default { if (!getToken()) { // 未登录,跳转到登录页面 uni.navigateTo({ - url: '/pages/login/index' + url: '/pages_order/auth/login' }) } else { // 已登录,触发领券事件 diff --git a/pages/index.vue b/pages/index.vue index 2d8ac2a..c7207c0 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1,7 +1,7 @@ @@ -347,7 +298,6 @@ getCouponList, getCouponListNoAuth, getOpenId, - receiveCoupon, } from "@/api/system/user" import { setToken, @@ -362,8 +312,10 @@ import Kefu from './common/kefu.vue' import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue'; import NewUserCoupon from './components/NewUserCoupon.vue'; + import CouponItem from '@/components/CouponItem/index.vue'; + import CouponRulePopup from '@/components/CouponRulePopup/index.vue'; import positionMixin from '@/mixins/position.js'; - + import {getPhoneNumber} from "@/api/system/user.js" export default { mixins: [positionMixin], data() { @@ -425,12 +377,15 @@ }, currentCoupon: null, companionList: [], + isMember: false, } }, components: { Kefu, uniPopup, - NewUserCoupon + NewUserCoupon, + CouponItem, + CouponRulePopup }, mounted() { this.getCalendarDate(); @@ -449,7 +404,7 @@ }, handleGetCoupon() { if (getToken()) { - this.getCoupon(); + } else { uni.navigateTo({ url: '/pages/personalCenter/index' @@ -458,7 +413,7 @@ }, getAllCoupon() { uni.navigateTo({ - url: '/pages/companionPetList/couponList' + url: '/pages_order/companionPetList/couponList' }); }, getAllCompanion() { @@ -470,11 +425,16 @@ }) } else { uni.navigateTo({ - url: `/pages/companionPetList/companionPetList?info=` + encodeURIComponent(JSON + url: `/pages_order/companionPetList/companionPetList?info=` + encodeURIComponent(JSON .stringify(this.allInfo)) }); } }, + toProductDetail(){ + uni.switchTab({ + url: 'details/feed' + }) + }, getAllRecord () { }, @@ -651,6 +611,21 @@ console.log(response); }) }, + // 跳转伴宠师 + toPetFront(){ + uni.navigateToMiniProgram({ + appId: 'wx01f0f43759922fda', + // path: '', + envVersion: "release", + success: res => { + // 打开成功 + console.log("打开成功", res); + }, + fail: err => { + console.log(err); + } + }) + }, calculateTeacherListDistance(){ this.companionList.forEach(item => { item.distanceText = this.calculateDistanceAddress(item.appletAddresseList) @@ -676,12 +651,13 @@ }) uni.navigateTo({ - url: `/pages/companionPetList/companionPetList?info=` + url: `/pages_order/companionPetList/companionPetList?info=` + encodeURIComponent(JSON .stringify(this.allInfo)) }); } } else { + this.initGlobalData() this.$store.commit('setPosition', {}) this.buyInfo.teacher = null uni.navigateTo({ @@ -689,18 +665,6 @@ }); } }, - getCoupon() { - // getCouponList().then(res => { - // if (res.code == 200) { - // this.couponList = res.rows - // this.showMask = true - // } else { - // this.$modal.showToast('获取优惠券失败') - // } - - // }) - - }, getCouponListAuth() { getCouponList().then(res => { if (res.code == 200) { @@ -711,31 +675,6 @@ } }) }, - switchType(type) { - if (type == 'PNORMAL') { - return '满减券' - } - if (type == 'PDISCOUNT') { - return '折扣券' - } - if (type == 'PTRAIL') { - return '体验券' - } - return '优惠券' - }, - receiveCoupon(id) { - let data = { - stockId: id - } - receiveCoupon(data).then(res => { - console.log("this.receiveCoupon", res) - if (res.code == 200) { - this.$modal.showToast('优惠券领取成功') - } else { - this.$modal.showToast('领取优惠券失败') - } - }) - }, getCouponListNoAuth() { // console.log('进入 getCouponListNoAuth:'); // getCouponListNoAuth().then(res => { @@ -888,23 +827,25 @@ return; } this.currentCoupon = coupon; - this.$refs.rulePopup.open(); + this.$refs.rulePopup.show(); }, - closeRulePopup() { - this.$refs.rulePopup.close(); + + // 处理优惠券领取成功事件 + handleCouponReceived(couponData) { + console.log('首页优惠券领取成功:', couponData); + // 可以在这里处理一些额外的逻辑,比如刷新优惠券列表等 }, - getDiscountText(coupon) { - if (!coupon || !coupon.stockType) return ''; - - if (coupon.stockType === 'PNORMAL') { - return '满100可减10元'; - } else if (coupon.stockType === 'PDISCOUNT') { - return '打8折'; - } else if (coupon.stockType === 'PTRAIL') { - return '免费体验一次'; + + // 更新优惠券数据 + updateCouponData(updatedCoupon) { + // 找到对应的优惠券并更新数据 + const couponIndex = this.couponData.findIndex(item => item.id === updatedCoupon.id); + if (couponIndex !== -1) { + // 使用Vue.set或者$set来确保响应式更新 + this.$set(this.couponData, couponIndex, updatedCoupon); } - return ''; - }, + } + }, @@ -1048,82 +989,7 @@ } .coupon-content { - .card { - display: flex; - align-items: center; - width: 100%; - padding: 10px 0; - border-radius: 8px 8px 0 0; - } - - .card-bottom { - display: flex; - background-color: #FFF1E0; - height: 50rpx; - align-items: center; - justify-content: space-between; - padding: 0 20rpx 0 20rpx; - border-radius: 0 0 8px 8px; - - .card-bottom-text { - color: #AAAAAA; - font-size: 24rpx; - font-weight: 400; - } - } - - .card-left { - width: 88px; - text-align: center; - color: #FF530A; - font-size: 28rpx; - font-weight: 900; - } - - .card-center { - display: flex; - flex-direction: column; - - .card-center-top { - width: 40rpx; - height: 20rpx; - border-radius: 0 0 20rpx 20rpx; - background-color: #fff; - line-height: 20rpx; - border-bottom: 1px solid #FDA714; - border-left: 1px solid #FDA714; - border-right: 1px solid #FDA714; - margin-top: -22rpx; - margin-bottom: 20rpx; - margin-left: -19rpx; - } - - .card-center-bottom { - border-right: 1px dashed #AAAAAA; - width: 1px; - height: 120rpx; - } - } - - .card-right { - padding: 0 16rpx 0 0; - display: flex; - flex: 1; - justify-content: space-between; - align-items: center; - height: 60px; - font-size: 24rpx; - - .card-content { - width: 77%; - } - - .card-icon { - position: relative; - right: -10px; - top: -10px; - } - } + // 优惠券内容样式已移至CouponItem组件 } } @@ -1692,53 +1558,5 @@ } } - /* 优惠券规则弹窗样式 */ - .rule-popup { - width: 600rpx; - background-color: #FFFFFF; - border-radius: 16rpx; - overflow: hidden; - } - .rule-popup-title { - height: 100rpx; - line-height: 100rpx; - text-align: center; - font-size: 32rpx; - font-weight: 600; - color: #FFFFFF; - background-color: #FFAA48; - } - - .rule-popup-content { - padding: 30rpx; - } - - .rule-item { - display: flex; - margin-bottom: 20rpx; - } - - .rule-label { - width: 140rpx; - font-size: 28rpx; - color: #666666; - flex-shrink: 0; - } - - .rule-value { - flex: 1; - font-size: 28rpx; - color: #333333; - line-height: 40rpx; - } - - .rule-popup-close { - height: 90rpx; - line-height: 90rpx; - text-align: center; - font-size: 30rpx; - color: #FFAA48; - border-top: 1px solid #EEEEEE; - } \ No newline at end of file diff --git a/pages/newOrder/confirmOrder.vue b/pages/newOrder/confirmOrder.vue index 2f3657f..2e12308 100644 --- a/pages/newOrder/confirmOrder.vue +++ b/pages/newOrder/confirmOrder.vue @@ -106,7 +106,7 @@ - ¥{{ item.totalCost }}.00 + ¥{{ item.totalCost }} - {{ item2.itemName }} - ¥{{ item2.price }} × + ¥{{ parseFloat(item2.price) }} × {{ item2.quantity }} {{ item2.unit }} @@ -145,9 +145,9 @@ - - {{ customItem.name }} - ¥{{ customItem.price }} × {{ customItem.quantity }} 次 - + - {{ customItem.name }} + ¥{{ parseFloat(customItem.price).toFixed(2) }} × {{ customItem.quantity }} 次 + @@ -156,12 +156,16 @@ 提前熟悉 - ¥40 + ¥{{ price_config.preFamiliarize.price }} - - 费用总计 - ¥{{ originalTotalPrice }} + + {{ buyInfo.teacher ? buyInfo.teacher.userName : companionLevelTitle }} + ¥{{ companionLevelPrice() }} + + 费用总计 + ¥{{ parseFloat(originalTotalPrice).toFixed(2) }} + 平台优惠 @@ -169,18 +173,18 @@ - + 会员折扣 - {{ currentMember.itemType }} - - -¥{{ memberDiscount }} - + {{ currentMember.itemType }}{{ discountMemberText }}折优惠 + + -¥{{ parseFloat(memberDiscount).toFixed(2) }} - - 应付费用 - ¥{{ finalPrice }} + + 应付费用 + ¥{{ parseFloat(finalPrice).toFixed(2) }} + @@ -211,7 +215,7 @@ * - 价格40元/次 + 价格{{ price_config.preFamiliarize.price }}元/次 * @@ -238,7 +242,7 @@ 订单总价: - ¥{{ finalPrice }} ¥{{ parseFloat(finalPrice).toFixed(2) }} @@ -255,7 +259,7 @@ 优惠券 (已自动选择最优惠) + style="text-align: center; width: 100%; font-size: 32rpx; font-weight: 500; color: #333333;">优惠券 @@ -327,20 +331,16 @@ defaultPhoto: 'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/pet/catdog.png', currentMember: {}, memberDiscountList: [{ - itemType: "新晋家长9.5折优惠", - discount: 0.05 + itemType: "新晋家长", }, { - itemType: "普卡会员9折优惠", - discount: 0.1 + itemType: "普卡会员", }, { - itemType: "银卡会员8.8折优惠", - discount: 0.12 + itemType: "银卡会员", }, { - itemType: "金卡会员8.5折优惠", - discount: 0.15 + itemType: "金卡会员", } ], couponList: [], @@ -350,7 +350,13 @@ couponId: null, basePrice: 0, baseProduct: '', - + // 节假日价格配置 + holidayPrice: 75, + normalPrice: 75, + holidayDate: [], + //折扣 + discountMemberText : '', + companionLevelTitle : '', } }, onLoad() { @@ -371,13 +377,46 @@ url: '/pages/index' }); } + this.initPriceConfig() this.getShowPets() this.groupPetsByDate() this.getCouponList() // this.totalPrice = this.$globalData.newOrderData.totalPrice + this.companionLevelTitle = this.$globalData.newOrderData.companionLevel.paramValue }, methods: { + companionLevelPrice(){ + let companionLevel = this.$globalData.newOrderData.companionLevel + let price = Number(companionLevel.paramValueText) * this.isAddPrice() + + return price * this.$store.state.memberRate + }, + //判断当前选中的地址是否加价 + isAddPrice(){ + let currentAddress = this.$globalData.newOrderData.currentAddress || {} + + let defaultPrice = 1 + + try{ + defaultPrice = this.price_config.cityConfig.priceRates.default + }catch(e){ + defaultPrice = 1 + } + + if(!this.price_config.cityConfig || !currentAddress.province || !currentAddress.city){ + return defaultPrice + } + + let addressList = this.price_config.cityConfig.priceRates || [] + + for(let key in addressList){ + if((currentAddress.province + currentAddress.city).includes(key)){ + return addressList[key] + } + } + return defaultPrice + }, getDateText(date){ return dayjs(date).format('MM-DD') }, @@ -427,8 +466,8 @@ for (const date in dailyPets) { const pets = dailyPets[date]; const priceDetails = [] - // 基础服务 - const baseServiceCost = this.basePrice + // 基础服务 - 根据是否为节假日设置价格 + const baseServiceCost = Number(this.isHoliday(date) ? this.holidayPrice : this.normalPrice) const largeDogCount = pets.filter(pet => pet.petType === 'dog' && pet.bodyType.includes('大型')).length; let mediumDogCount = pets.filter(pet => pet.petType === 'dog' && pet.bodyType.includes('中型')).length; @@ -442,29 +481,35 @@ let totalPetCost = pets.reduce((acc, pet) => { return acc + this.calculatePetCost(pet); }, 0); - // 如果总宠物费用>30 - if (totalPetCost > 30) { - // 如果猫数量>=3,则免3只猫 - if (catCount >= 3) { - additionalCost = totalPetCost - 30 - catCount = catCount - 3 - } else if (smallDogCount >= 2) { // 如果小型犬数量>=2,则免2只小型犬 - additionalCost = totalPetCost - 30 - smallDogCount = smallDogCount - 2 - } else if (mediumDogCount >= 1) { // 如果中型犬数量>=1,则免1只中型犬 - additionalCost = totalPetCost - 30 - mediumDogCount = mediumDogCount - 1 - } else { - additionalCost = totalPetCost - 25 - catCount = catCount - 1 - smallDogCount = smallDogCount - 1 - } + + + //免费规则 + // 如果总宠物费用>30 + const freeQuota = this.price_config.freeQuota + if (totalPetCost > Number(freeQuota.threshold)) { + freeQuota.rules.forEach(rule => { + if (rule.type === 'cat' && catCount >= rule.count) { + additionalCost = totalPetCost - Number(rule.freeAmount) + catCount = catCount - rule.count + }else if(rule.type === 'smallDog' && smallDogCount >= rule.count){ + additionalCost = totalPetCost - Number(rule.freeAmount) + smallDogCount = smallDogCount - rule.count + }else if(rule.type === 'mediumDog' && mediumDogCount >= rule.count){ + additionalCost = totalPetCost - Number(rule.freeAmount) + mediumDogCount = mediumDogCount - rule.count + }else{ + additionalCost = totalPetCost - Number(rule.freeAmount) + } + }) if (mediumDogCount > 0) { additionalCostItem.push({ itemName: '中型犬', - price: 30, + price: this.calculatePetCost({ + petType: 'dog', + bodyType: '中型', + }), quantity: mediumDogCount, unit: '只' }) @@ -472,7 +517,10 @@ if (smallDogCount > 0) { additionalCostItem.push({ itemName: '小型犬', - price: 15, + price: this.calculatePetCost({ + petType: 'dog', + bodyType: '小型', + }), quantity: smallDogCount, unit: '只' }) @@ -480,7 +528,9 @@ if (catCount > 0) { additionalCostItem.push({ itemName: '猫猫', - price: 10, + price: this.calculatePetCost({ + petType: 'cat', + }), quantity: catCount, unit: '只' }) @@ -489,10 +539,16 @@ } // 如果有大型犬,额外费用为40元/只 if (largeDogCount > 0) { - additionalCost += (40 * largeDogCount) + additionalCost += (this.calculatePetCost({ + petType: 'dog', + bodyType: '大型', + }) * largeDogCount) additionalCostItem.push({ itemName: '大型犬', - price: 40, + price: this.calculatePetCost({ + petType: 'dog', + bodyType: '大型', + }), quantity: largeDogCount, unit: '只' }) @@ -501,14 +557,14 @@ let multServicesTotalCost = 0 const maxFeedCount = Math.max(...pets.map(pet => pet.feedCount)); if (maxFeedCount === 2) { - multServicesTotalCost += 45; // 1天2次 + multServicesTotalCost += this.price_config.multiService.two.price; // 1天2次 } else if (maxFeedCount === 3) { - multServicesTotalCost += 130; // 1天3次 + multServicesTotalCost += this.price_config.multiService.three.price; // 1天3次 } priceDetails.push({ name: '专业喂养', item: [{ - itemName: '专业喂养', + itemName: this.isHoliday(date) ? '节假日' : '非节假日', price: baseServiceCost, quantity: 1, unit: '天' @@ -518,13 +574,13 @@ name: '上门次数', item: [{ itemName: '1天2次', - price: 45, + price: this.price_config.multiService.two.price, quantity: maxFeedCount === 2 ? 1 : 0, unit: '天' }, { itemName: '1天3次', - price: 130, + price: this.price_config.multiService.three.price, quantity: maxFeedCount === 3 ? 1 : 0, unit: '天' }, @@ -540,7 +596,10 @@ // 所有宠物定制服务费用 const customServiceCost = pets.reduce((acc, pet) => acc + this.calculatePetCustomServiceCost(pet), 0) - const totalCost = baseServiceCost + additionalCost + multServicesTotalCost + customServiceCost + console.log(baseServiceCost + additionalCost + multServicesTotalCost + customServiceCost); + console.log(baseServiceCost , additionalCost , multServicesTotalCost , customServiceCost); + + const totalCost = parseFloat((baseServiceCost + additionalCost + multServicesTotalCost + Number(customServiceCost))).toFixed(2) // 所有宠物定制服务总项数,每个类型的服务只算一次 const acc = [] pets.map(pet => { @@ -565,21 +624,24 @@ this.getShowTotalPrice() }, calculatePetCost(pet) { - // 宠物额外费用 不计算大型犬 - let petCost = 0; - if (pet.petType === 'cat') { - petCost += 10; // 猫额外费用 - } else if (pet.petType === 'dog' && pet.bodyType.includes('小型')) { - petCost += 15; // 小型犬额外费用 - } else if (pet.petType === 'dog' && pet.bodyType.includes('中型')) { - petCost += 30; // 中型犬额外费用 - } - return petCost; - }, + // 宠物额外费用 不计算大型犬 + let petExtra = this.price_config.petExtra + let petCost = 0; + if (pet.petType === 'cat') { + petCost += Number(petExtra.cat); // 猫额外费用 + } else if (pet.petType === 'dog' && pet.bodyType.includes('小型')) { + petCost += Number(petExtra.smallDog); // 小型犬额外费用 + } else if (pet.petType === 'dog' && pet.bodyType.includes('中型')) { + petCost += Number(petExtra.mediumDog); // 中型犬额外费用 + } + return petCost; + }, // 计算宠物定制服务费用 calculatePetCustomServiceCost(pet) { - const customServiceCost = pet.customServices.reduce((acc, item) => acc + item.price * item.quantity, 0) - return customServiceCost + console.log('pet.customServices',pet.customServices) + const customServiceCost = pet.customServices.reduce((acc, item) => acc + Number(item.price) * item.quantity, 0) + console.log('customServiceCost',customServiceCost) + return parseFloat(customServiceCost).toFixed(2) }, // 展开或收起服务详情 toggleExpand(index) { @@ -607,6 +669,27 @@ url: '/pages/details/agreement' }); }, + // 初始化价格配置 + initPriceConfig() { + let priceConfig = this.$store.state.price_config + console.log('价格配置:', priceConfig) + if(priceConfig.basePrice && priceConfig.basePrice.holiday){ + this.holidayPrice = Number(priceConfig.basePrice.holiday * this.$store.state.memberRate).toFixed(2) + } + if(priceConfig.basePrice && priceConfig.basePrice.normal){ + this.normalPrice = Number(priceConfig.basePrice.normal * this.$store.state.memberRate).toFixed(2) + } + if(priceConfig.holidays && priceConfig.holidays.length > 0){ + this.holidayDate = priceConfig.holidays + }else{ + this.holidayDate = [] + } + this.discountMemberText = (this.$store.state.memberRate * 10) + }, + // 判断是否为节假日 + isHoliday(date) { + return this.holidayDate.includes(date) + }, // 节流 throttle(func, delay) { let lastCall = 0; @@ -719,46 +802,81 @@ const order = { openId: getOpenIdKey(), addressId: this.currentAddress.id, - totalPrice: this.finalPrice, + totalPrice: this.finalPrice,//应付费用 needPreFamiliarize: this.needPreFamiliarize.length > 0, couponId: this.couponId, petOrderServices: this.getPetOrderServices(this.currentPetsByDay), + //费用明细 + //dailyShowData : JSON.stringify(this.dailyShowData), + //优惠券优惠 + couponDiscount: this.discount, + //会员折扣 + memberDiscount: this.memberDiscount, + //费用总计 + oldPrice : this.originalTotalPrice, + //提前熟悉的费用 + preFamiliarizePrice: this.price_config.preFamiliarize.price, + + //伴宠师等级名称 + companionLevelTitle : this.companionLevelTitle, + //伴宠师等级加价 + companionLevelPrice: this.companionLevelPrice(), } if(this.buyInfo.teacher){ order.teacherId = this.buyInfo.teacher.userId - }else{ + } + if(this.$globalData.newOrderData.companionLevel){ //打印 console.log(this.$globalData.newOrderData.companionLevel); - order.companionLevel = ['', 'junior', 'senior'].indexOf(this.$globalData.newOrderData.companionLevel) + order.companionLevel = this.$globalData.newOrderData.companionLevel.paramValueNum + // order.companionLevel = ['', 'junior', 'senior'].indexOf(this.$globalData.newOrderData.companionLevel) + } + + if(this.$globalData.newOrderData.orderId){ + order.orderId = this.$globalData.newOrderData.orderId } console.log(order) return order }, - getSkuList(customServices, feedCount) { + getSkuList(customServices, feedCount, price) { + console.log('customServices', JSON.parse(JSON.stringify(customServices))); const skuList = customServices.filter(service => service.quantity > 0).map(service2 => { return { skuId: service2.skuId, quantity: service2.quantity, - isMainProduct: service2.isMainProduct + isMainProduct: service2.isMainProduct, + price: service2.price } }) skuList.push({ skuId: this.$globalData.mainSku[0].skuId, quantity: feedCount, - isMainProduct: true + isMainProduct: true, + price }) return skuList }, getPetOrderServices(currentPetsByDay) { + console.log('currentPetsByDay', JSON.parse(JSON.stringify(currentPetsByDay))); const petOrderServices = currentPetsByDay.map(pet => { + let price = this.isHoliday(pet.serviceDate) ? this.holidayPrice : this.normalPrice + + // 当日多次服务次数 + let feedCountPrice = 0; + if (pet.feedCount == 2) { + feedCountPrice += this.price_config.multiService.two.price; // 1天2次 + } else if (pet.feedCount == 3) { + feedCountPrice += this.price_config.multiService.three.price; // 1天3次 + } return { petId: pet.petId, serviceDate: pet.serviceDate, feedCount: pet.feedCount, selectedTimeSlots: pet.selectedTimeSlots.join(','), - skuList: this.getSkuList(pet.customServices, pet.feedCount) + skuList: this.getSkuList(pet.customServices, pet.feedCount, price), + feedCountPrice,//当日多次服务加价 } }) return petOrderServices @@ -802,19 +920,27 @@ changePreFamiliarize(name) { if (name && name.length > 0) { this.needPreFamiliarize = name - this.originalTotalPrice = this.originalTotalPrice + 40 + this.originalTotalPrice = this.originalTotalPrice + this.price_config.preFamiliarize.price } else { this.needPreFamiliarize = [] - this.originalTotalPrice = this.originalTotalPrice - 40 + this.originalTotalPrice = this.originalTotalPrice - this.price_config.preFamiliarize.price } // 重新计算最优惠的优惠券 this.autoSelectBestCoupon() this.getShowTotalPrice() }, getShowTotalPrice() { - //保留两位小数 - this.memberDiscount = ((this.originalTotalPrice - this.discount) * this.currentMember.discount).toFixed(2) - this.finalPrice = (this.originalTotalPrice - this.memberDiscount - this.discount).toFixed(2) + // 会员折扣已经在上一个页面减去了,这里需要根据originalTotalPrice反推会员减去了多少 + // originalTotalPrice: 已经应用会员折扣后的价格 + // memberRate: 会员折扣率(如0.9表示9折) + // 反推原价:originalTotalPrice / memberRate + // 会员折扣金额:原价 - originalTotalPrice + const originalPriceBeforeMemberDiscount = this.originalTotalPrice / this.$store.state.memberRate + this.memberDiscount = (originalPriceBeforeMemberDiscount - this.originalTotalPrice).toFixed(2) + + // 计算最终支付价格 + // finalPrice: 最终支付价格 = 已应用会员折扣的价格 - 优惠券优惠 + this.finalPrice = (this.originalTotalPrice - this.discount).toFixed(2) }, getCouponAmountOrDiscount(item) { if (item.stockType == "PDISCOUNT") { diff --git a/pages/newOrder/petList.vue b/pages/newOrder/petList.vue index 19b8f7e..ca9081d 100644 --- a/pages/newOrder/petList.vue +++ b/pages/newOrder/petList.vue @@ -97,6 +97,7 @@ + @@ -105,10 +106,16 @@ :asyncClose="true" :content='delContent'> + + + 确定 @@ -145,11 +152,28 @@ export default { currentPets: [], //当前技师不接单日期 outDateList : ['2025-6-20'], + holidayDate: [], + holidayPrice: 75, + normalPrice : 75, } }, onShow() { this.getPetList(); this.getOutDateList() + let priceConfig = this.$store.state.price_config + console.log(priceConfig) + if(priceConfig.basePrice && priceConfig.basePrice.holiday){ + this.holidayPrice = (priceConfig.basePrice.holiday * this.$store.state.memberRate).toFixed(2) + } + if(priceConfig.basePrice && priceConfig.basePrice.normal){ + this.normalPrice = (priceConfig.basePrice.normal * this.$store.state.memberRate).toFixed(2) + } + if(priceConfig.holidays && priceConfig.holidays.length > 0){ + this.holidayDate = priceConfig.holidays + }else{ + this.holidayDate = [] + } + this.$store.commit('getUserInfo') }, onPullDownRefresh() { this.getPetList(); diff --git a/pages/newOrder/price_config.json b/pages/newOrder/price_config.json new file mode 100644 index 0000000..f4db69f --- /dev/null +++ b/pages/newOrder/price_config.json @@ -0,0 +1,109 @@ +{ + "basePrice": { + "normal": 75, + "holiday": 85, + "weekend": 80, + "perKm": 3 + }, + "memberDiscount": { + "new": 0.95, + "regular": 0.9, + "silver": 0.88, + "gold": 0.85 + }, + "preFamiliarize": { + "price": 38, + "holidayRate": 1.2 + }, + "multiService": { + "two": { + "price": 46, + "holidayRate": 1.1 + }, + "three": { + "price": 131, + "holidayRate": 1.1 + } + }, + "petExtra": { + "largeDog": { + "price": 40, + "holidayRate": 1.1 + }, + "mediumDog": { + "price": 30, + "holidayRate": 1.1 + }, + "smallDog": { + "price": 15, + "holidayRate": 1.1 + }, + "cat": { + "price": 10, + "holidayRate": 1.1 + } + }, + "freeQuota": { + "threshold": 30, + "rules": [ + { + "type": "cat", + "count": 3, + "freeAmount": 30, + "description": "3只及以上猫免费30元" + }, + { + "type": "smallDog", + "count": 2, + "freeAmount": 30, + "description": "2只及以上小型犬免费30元" + }, + { + "type": "mediumDog", + "count": 1, + "freeAmount": 30, + "description": "1只及以上中型犬免费30元" + }, + { + "type": "mixed", + "count": 0, + "freeAmount": 29, + "description": "以上都不满足则免费25元" + } + ] + }, + "holidays": [ + "2025-10-01", + "2025-10-02", + "2025-10-03", + "2025-10-04", + "2025-10-05", + "2025-10-06", + "2025-10-07", + "2025-07-15", + "2025-07-22", + "2025-07-16", + "2025-07-23", + "2025-07-17", + "2025-07-11", + "2025-07-18", + "2025-07-25", + "2025-07-24", + "2025-09-11" + ], + "weekends": [ + 6, + 0 + ], + "customServices": { + "priceConfig": {}, + "holidayRate": 1.1 + }, + "cityConfig": { + "currentCity": "shenzhen", + "priceRates": { + "default": 1, + "长沙": 1.1 + } + } +} \ No newline at end of file diff --git a/pages/newOrder/serviceNew.vue b/pages/newOrder/serviceNew.vue index 861c76b..e0d4f0b 100644 --- a/pages/newOrder/serviceNew.vue +++ b/pages/newOrder/serviceNew.vue @@ -4,7 +4,8 @@ - + @@ -12,17 +13,15 @@ - - - 初级伴宠师 - - - - - - - 高级伴宠师 - + + + {{ item.paramValue }} + @@ -50,20 +49,23 @@ - {{ popupTitle }} + {{ showLevelInfo.paramValue }} 等级: - {{ popupLevel }} + {{ showLevelInfo.paramValue }} 价格: - 要根据规城市不同展示不同的价格 + {{ companionLevelPrice() }} 分类标准: - 文字描述初级是什么类型的,高级是什么类型的 :) + + @@ -197,7 +199,7 @@ * - 价格40元/次 + 价格{{ price_config.preFamiliarize.price }}元/次 * @@ -224,6 +226,7 @@ getOpenId } from "@/api/system/user" import { setToken,getToken,getOpenIdKey,setOpenIdKey } from '@/utils/auth' + import { mapState } from 'vuex' export default { data() { @@ -234,12 +237,13 @@ currentPets:[], needPreFamiliarize:[], defaultPhoto:'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/pet/catdog.png', - companionLevel: 'junior', // 默认选择初级伴宠师 - companionLevelList: ['', 'junior', 'senior'], // 默认选择初级伴宠师 - popupTitle: '', - popupLevel: '', + companionLevel: {}, // 默认选择初级伴宠师 + showLevelInfo : {}, } }, + computed: { + ...mapState(['teacherLevelList']) + }, onLoad: function(option) { }, onShow() { @@ -259,14 +263,51 @@ this.isPetSelected=true } this.needPreFamiliarize = this.$globalData.newOrderData.needPreFamiliarize + + + // 初始化伴宠师等级 if(this.$globalData.newOrderData.companionLevel) { this.companionLevel = this.$globalData.newOrderData.companionLevel }else{ + this.companionLevel = this.teacherLevelList[0] this.$globalData.newOrderData.companionLevel = this.companionLevel } + + + this.$store.commit('getUserInfo') }, methods:{ + companionLevelPrice(){ + let price = Number(this.showLevelInfo.paramValueText) * this.isAddPrice() + + return price * this.$store.state.memberRate + }, + //判断当前选中的地址是否加价 + isAddPrice(){ + let currentAddress = this.$globalData.newOrderData.currentAddress || {} + + let defaultPrice = 1 + + try{ + defaultPrice = this.price_config.cityConfig.priceRates.default + }catch(e){ + defaultPrice = 1 + } + + if(!this.price_config.cityConfig || !currentAddress.province || !currentAddress.city){ + return defaultPrice + } + + let addressList = this.price_config.cityConfig.priceRates || [] + + for(let key in addressList){ + if((currentAddress.province + currentAddress.city).includes(key)){ + return addressList[key] + } + } + return defaultPrice + }, selectAddress(){ uni.navigateTo({ url: "/pages/newOrder/addressList" @@ -283,13 +324,7 @@ this.$globalData.newOrderData.companionLevel = level; }, showCompanionInfo(level) { - if(level === 'junior') { - this.popupTitle = '初级伴宠师'; - this.popupLevel = '初级伴宠师'; - } else { - this.popupTitle = '高级伴宠师'; - this.popupLevel = '高级伴宠师'; - } + this.showLevelInfo = level this.$refs.companionInfoPopup.open(); }, closeCompanionInfo() { @@ -304,9 +339,11 @@ if (response && response.content && response.content.length > 0) { const skus = response && response.content[0].skus if(skus && skus.length>0){ + let price = this.price_config.basePrice.normal || skus[0].price let productSku = { "skuId": skus[0].id, - "price":skus[0].price, + // "price":(price * this.$store.state.memberRate).toFixed(2), + "price":(skus[0].price).toFixed(2), "name":response.content[0].name, "quantity": 1, "isMainProduct":true @@ -345,7 +382,7 @@ }) }, goNext(){ - console.log('this.needPreFamiliarize', this.needPreFamiliarize) + console.log('this.$globalData', this.$globalData) if(!this.isAddressSelected) { this.$modal.showToast('请选择服务地址'); return; @@ -398,6 +435,8 @@ display: flex; justify-content: space-between; margin-top: 20rpx; + flex-wrap: wrap; + gap: 20rpx; .order-type-option { display: flex; diff --git a/pages/newOrder/serviceNew2.vue b/pages/newOrder/serviceNew2.vue index b0a915a..a734542 100644 --- a/pages/newOrder/serviceNew2.vue +++ b/pages/newOrder/serviceNew2.vue @@ -153,7 +153,7 @@ 额外服务费 - ¥{{ feedCount > 2 ? 130 : 45 }} + ¥{{ feedCount > 2 ? price_config.multiService.three.price : price_config.multiService.two.price }} @@ -200,12 +200,12 @@ 订单总价: - ¥{{ totalPrice }} .00 + ¥{{ Number(totalPrice).toFixed(2) }} - 当日价格:¥{{ currentDayPrice - }}.00 | + 当日价格:¥{{ Number(currentDayPrice).toFixed(2) + }}| 明细 @@ -256,7 +256,7 @@ 合计 - ¥{{ totalPrice }} + ¥{{ Number(totalPrice).toFixed(2) }} @@ -267,12 +267,12 @@ 订单总价: - ¥{{ totalPrice }} .00 + ¥{{ Number(totalPrice).toFixed(2) }} 当日价格:¥{{ - currentDayPrice }}.00 | + Number(currentDayPrice).toFixed(2) }}| 明细 @@ -295,11 +295,18 @@ import { getOpenId } from "@/api/system/user" import { setToken, setOpenIdKey } from '@/utils/auth' +import positionMixin from '../../mixins/position'; export default { + mixins: [positionMixin], data() { return { basePrice: 75, baseProduct: '专业喂养', + // 节假日价格配置 + holidayPrice: 75, + normalPrice: 75, + distancePrice: 1, + holidayDate: [], currentPets: [], currentPetId: '', currentMonthDay: {}, @@ -335,14 +342,14 @@ export default { // customServices原始值 customServicesStr: '', customServices: [ - { name: '陪玩(20分钟)', price: 20, quantity: 0 }, - { name: '活动区吸毛', price: 20, quantity: 0 }, - { name: '毛发梳理', price: 15, quantity: 0 }, - { name: '身体清洁(如眼、耳、鼻等)', price: 5, quantity: 0 }, - { name: '指甲修剪', price: 10, quantity: 0 }, - { name: '会员深度清洁', price: 20, quantity: 0 }, - { name: '喂药', price: 15, quantity: 0 }, - { name: '上药', price: 25, quantity: 0 } + // { name: '陪玩(20分钟)', price: 20, quantity: 0 }, + // { name: '活动区吸毛', price: 20, quantity: 0 }, + // { name: '毛发梳理', price: 15, quantity: 0 }, + // { name: '身体清洁(如眼、耳、鼻等)', price: 5, quantity: 0 }, + // { name: '指甲修剪', price: 10, quantity: 0 }, + // { name: '会员深度清洁', price: 20, quantity: 0 }, + // { name: '喂药', price: 15, quantity: 0 }, + // { name: '上药', price: 25, quantity: 0 } ], showPriceDetails: false, // 控制价格明细的显示 priceDetails: [], @@ -374,8 +381,10 @@ export default { }, onLoad: function (option) { + this.$globalData.newOrderData.distancePrice = this.calculateDistancePrice() }, mounted() { + console.log('this.$globalData', this.$globalData) this.currentPets = this.$globalData.newOrderData.currentPets; if (this.currentPets.length < 1) { uni.reLaunch({ @@ -388,6 +397,8 @@ export default { this.baseProduct = this.$globalData.mainSku[0].name } + // 初始化价格配置 + this.initPriceConfig() this.getProductList() }, watch: { @@ -401,6 +412,51 @@ export default { } }, methods: { + companionLevelPrice(){ + let companionLevel = this.$globalData.newOrderData.companionLevel + let price = Number(companionLevel.paramValueText) * this.isAddPrice() + + return price * this.$store.state.memberRate + }, + //判断当前选中的地址是否加价 + isAddPrice(){ + let currentAddress = this.$globalData.newOrderData.currentAddress || {} + + let defaultPrice = 1 + + try{ + defaultPrice = this.price_config.cityConfig.priceRates.default + }catch(e){ + defaultPrice = 1 + } + + if(!this.price_config.cityConfig || !currentAddress.province || !currentAddress.city){ + return defaultPrice + } + + let addressList = this.price_config.cityConfig.priceRates || [] + + for(let key in addressList){ + if((currentAddress.province + currentAddress.city).includes(key)){ + return addressList[key] + } + } + return defaultPrice + }, + //计算距离价格 + calculateDistancePrice() { + if(!this.buyInfo.teacher || !this.buyInfo.teacher.appletAddresseList){ + return + } + let addressList = this.buyInfo.teacher.appletAddresseList + + let d = this.calculateDistanceAddressList(addressList, { + latitude: this.$globalData.newOrderData.latitude, + longitude: this.$globalData.newOrderData.longitude, + })[0]?.distance || 0 + + return d * this.distancePrice + }, initNewOrderData() { const needPreFamiliarize = this.$globalData.newOrderData.needPreFamiliarize.length > 0 const pets = [] @@ -434,7 +490,7 @@ export default { needPreFamiliarize: needPreFamiliarize, // 是否需要提前熟悉 40元/次 参与计算 pets: pets } - // 默认选择第一个宠物 + // 默认选择第一个宠物 this.selectPet(this.currentPets[0] || {}) this.calculateTotalPrice() }, @@ -613,31 +669,39 @@ export default { calculateTotalPrice() { // 1. 订单维度:是否需要提前熟悉 if (this.$globalData.newOrderData.needPreFamiliarize && this.$globalData.newOrderData.needPreFamiliarize.length > 0) { - this.needPreFamiliarizeCost = 40 + this.needPreFamiliarizeCost = this.price_config.preFamiliarize.price } else { this.needPreFamiliarizeCost = 0 } // 2. 日期维度 - // 2.1 基础服务费用 + // 2.1 基础服务费用 - 根据节假日和非节假日分别计算 const uniqueDates = new Set(this.newOrderData.pets.map(item => item.serviceDate)); // 去重日期 - this.baseServiceTotalCost = uniqueDates.size * this.basePrice; // 每个唯一日期75元 + let baseServiceTotalCost = 0; + uniqueDates.forEach(date => { + const isHolidayDate = this.isHoliday(date); + const dayPrice = isHolidayDate ? parseFloat(this.holidayPrice) : parseFloat(this.normalPrice); + baseServiceTotalCost += dayPrice; + }); + this.baseServiceTotalCost = baseServiceTotalCost; // 2.2 额外宠物费用 // petType为dog 且bodyType包含 '大型' 则为大型犬,40元/次 // petType为dog 且bodyType包含 '中型' 则为中型犬,30元/次 // petType为dog 且bodyType包含 '小型' 则为小型犬,15元/次 // petType为cat 则为猫,10元/次 + this.newOrderData.pets.forEach(pet => { - if (pet.petType === 'dog' && pet.bodyType.includes('大型')) { - pet.additionalCost = 40 - } else if (pet.petType === 'dog' && pet.bodyType.includes('中型')) { - pet.additionalCost = 30 - } else if (pet.petType === 'dog' && pet.bodyType.includes('小型')) { - pet.additionalCost = 15 - } else if (pet.petType === 'cat') { - pet.additionalCost = 10 - } + pet.additionalCost = this.calculatePetCost(pet) + // if (pet.petType === 'dog' && pet.bodyType.includes('大型')) { + // pet.additionalCost = 40 + // } else if (pet.petType === 'dog' && pet.bodyType.includes('中型')) { + // pet.additionalCost = 30 + // } else if (pet.petType === 'dog' && pet.bodyType.includes('小型')) { + // pet.additionalCost = 15 + // } else if (pet.petType === 'cat') { + // pet.additionalCost = 10 + // } }) // const largeDogArray = this.newOrderData.pets.filter(pet => pet.petType === 'dog' && pet.bodyType.includes('大型')); @@ -670,23 +734,39 @@ export default { let totalPetCost = pets.reduce((acc, pet) => { return acc + this.calculatePetCost(pet); }, 0); - // 如果总宠物费用>30 - if (totalPetCost > 30) { - // 如果猫数量>=3 - if (catCount >= 3) { - additionalCost = totalPetCost - 30 - catCount = catCount - 3 - } else if (smallDogCount >= 2) { - additionalCost = totalPetCost - 30 - smallDogCount = smallDogCount - 2 - } else if (mediumDogCount >= 1) { - additionalCost = totalPetCost - 30 - mediumDogCount = mediumDogCount - 1 - } else { - additionalCost = totalPetCost - 25 - catCount = catCount - 1 - smallDogCount = smallDogCount - 1 - } + // 如果总宠物费用>30 + const freeQuota = this.price_config.freeQuota + if (totalPetCost > Number(freeQuota.threshold)) { + freeQuota.rules.forEach(rule => { + if (rule.type === 'cat' && catCount >= rule.count) { + additionalCost = totalPetCost - Number(rule.freeAmount) + catCount = catCount - rule.count + }else if(rule.type === 'smallDog' && smallDogCount >= rule.count){ + additionalCost = totalPetCost - Number(rule.freeAmount) + smallDogCount = smallDogCount - rule.count + }else if(rule.type === 'mediumDog' && mediumDogCount >= rule.count){ + additionalCost = totalPetCost - Number(rule.freeAmount) + mediumDogCount = mediumDogCount - rule.count + }else{ + additionalCost = totalPetCost - Number(rule.freeAmount) + } + }) + // if (totalPetCost > 30) { + // // 如果猫数量>=3 + // if (catCount >= 3) { + // additionalCost = totalPetCost - 30 + // catCount = catCount - 3 + // } else if (smallDogCount >= 2) { + // additionalCost = totalPetCost - 30 + // smallDogCount = smallDogCount - 2 + // } else if (mediumDogCount >= 1) { + // additionalCost = totalPetCost - 30 + // mediumDogCount = mediumDogCount - 1 + // } else { + // additionalCost = totalPetCost - 25 + // catCount = catCount - 1 + // smallDogCount = smallDogCount - 1 + // } petTypeCounts.push({ date, largeDogCount, @@ -717,10 +797,10 @@ export default { for (const date in dailyPets) { const maxFeedCount = Math.max(...dailyPets[date].map(pet => pet.feedCount)); if (maxFeedCount === 2) { - multServicesTotalCost += 45; // 1天2次 + multServicesTotalCost += this.price_config.multiService.two.price; // 1天2次 oneDayTwoTimesDates.push(date) } else if (maxFeedCount === 3) { - multServicesTotalCost += 130; // 1天3次 + multServicesTotalCost += this.price_config.multiService.three.price; // 1天3次 oneDayThreeTimesDates.push(date) } } @@ -745,24 +825,26 @@ export default { this.customServiceItemCount = customServiceItemCount this.customServicesTotalCost = customServicesTotalCost - this.totalPrice = this.needPreFamiliarizeCost - + this.baseServiceTotalCost - + this.additionalTotalCost - + this.multServicesTotalCost - + this.customServicesTotalCost; // 更新总价 + this.totalPrice = Number(this.needPreFamiliarizeCost) + + Number(this.baseServiceTotalCost) + + Number(this.additionalTotalCost) + + Number(this.multServicesTotalCost) + + Number(this.companionLevelPrice()) + + Number(this.customServicesTotalCost); // 更新总价 this.getCurrentDayPrice(this.currentMonthDay.fullDate) }, calculatePetCost(pet) { // 宠物额外费用 不计算大型犬 + let petExtra = this.price_config.petExtra let petCost = 0; if (pet.petType === 'cat') { - petCost += 10; // 猫额外费用 + petCost += Number(petExtra.cat); // 猫额外费用 } else if (pet.petType === 'dog' && pet.bodyType.includes('小型')) { - petCost += 15; // 小型犬额外费用 + petCost += Number(petExtra.smallDog); // 小型犬额外费用 } else if (pet.petType === 'dog' && pet.bodyType.includes('中型')) { - petCost += 30; // 中型犬额外费用 + petCost += Number(petExtra.mediumDog); // 中型犬额外费用 } return petCost; }, @@ -797,32 +879,73 @@ export default { name: '提前熟悉', item: [{ itemName: '提前熟悉', - price: 40, + price: this.price_config.preFamiliarize.price, quantity: this.newOrderData.needPreFamiliarize ? 1 : 0, unit: '次' },] }) } - const uniqueDateCount = new Set(this.newOrderData.pets.map(item => item.serviceDate)).size; // 去重日期 - if (uniqueDateCount > 1) { + + let companionLevel = this.$globalData.newOrderData.companionLevel + if (companionLevel) { priceDetails.push({ - name: this.baseProduct, item: [ - { itemName: this.baseProduct, price: this.basePrice, quantity: uniqueDateCount, unit: '天' }, - ] + name: '伴宠师等级', + item: [{ + itemName: companionLevel.paramValue, + price: this.companionLevelPrice(), + quantity: 1, + unit: '位' + },] }) } + // 分别统计节假日和非节假日的天数 + const uniqueDates = new Set(this.newOrderData.pets.map(item => item.serviceDate)); + let holidayCount = 0; + let normalCount = 0; + uniqueDates.forEach(date => { + if (this.isHoliday(date)) { + holidayCount++; + } else { + normalCount++; + } + }); + + const baseServiceItems = []; + if (normalCount > 0) { + baseServiceItems.push({ + itemName: '非节假日 | ', + price: parseFloat(this.normalPrice), + quantity: normalCount, + unit: '天' + }); + } + if (holidayCount > 0) { + baseServiceItems.push({ + itemName: '节假日 | ', + price: parseFloat(this.holidayPrice), + quantity: holidayCount, + unit: '天' + }); + } + + if (baseServiceItems.length > 0) { + priceDetails.push({ + name: this.baseProduct, + item: baseServiceItems + }); + } if (this.oneDayTwoTimesDates.length > 0 || this.oneDayThreeTimesDates.length > 0) { priceDetails.push({ name: '上门次数', item: [{ itemName: '1天2次', - price: 45, + price: this.price_config.multiService.two.price, quantity: this.oneDayTwoTimesDates.length, unit: '天' }, { itemName: '1天3次', - price: 130, + price: this.price_config.multiService.three.price, quantity: this.oneDayThreeTimesDates.length, unit: '天' }, @@ -838,7 +961,10 @@ export default { if (item.largeDogCount > 0) { additionalCostItem.push({ itemName: '大型犬', - price: 40, + price: this.calculatePetCost({ + petType: 'dog', + bodyType: '大型', + }), quantity: item.largeDogCount, unit: '只', date: item.date @@ -847,7 +973,10 @@ export default { if (item.mediumDogCount > 0) { additionalCostItem.push({ itemName: '中型犬', - price: 30, + price: this.calculatePetCost({ + petType: 'dog', + bodyType: '中型', + }), quantity: item.mediumDogCount, unit: '只', date: item.date @@ -856,7 +985,10 @@ export default { if (item.smallDogCount > 0) { additionalCostItem.push({ itemName: '小型犬', - price: 15, + price: this.calculatePetCost({ + petType: 'dog', + bodyType: '小型', + }), quantity: item.smallDogCount, unit: '只', date: item.date @@ -865,7 +997,9 @@ export default { if (item.catCount > 0) { additionalCostItem.push({ itemName: '猫猫', - price: 10, + price: this.calculatePetCost({ + petType: 'cat', + }), quantity: item.catCount, unit: '只', date: item.date @@ -914,6 +1048,26 @@ export default { } }, + // 初始化价格配置 + initPriceConfig() { + let priceConfig = this.$store.state.price_config + console.log('价格配置:', priceConfig) + if(priceConfig.basePrice && priceConfig.basePrice.holiday){ + this.holidayPrice = (priceConfig.basePrice.holiday * this.$store.state.memberRate).toFixed(2) + } + if(priceConfig.basePrice && priceConfig.basePrice.normal){ + this.normalPrice = (priceConfig.basePrice.normal * this.$store.state.memberRate).toFixed(2) + } + if(priceConfig.holidays && priceConfig.holidays.length > 0){ + this.holidayDate = priceConfig.holidays + }else{ + this.holidayDate = [] + } + }, + // 判断是否为节假日 + isHoliday(date) { + return this.holidayDate.some(holiday => holiday === date) + }, getProductList() { getProductList({ "publishStatus": 1, @@ -926,7 +1080,7 @@ export default { if (skus && skus.length > 0) { let productSku = { "skuId": skus[0].id, - "price": skus[0].price, + "price": (skus[0].price * this.$store.state.memberRate).toFixed(2), "name": item.name, "quantity": 0, "isMainProduct": false @@ -972,8 +1126,9 @@ export default { }, getCurrentDayPrice(currentDay) { const currentDayPets = this.newOrderData.pets.filter(pet => pet.serviceDate === currentDay) - // 基础服务 - const baseServiceCost = this.basePrice + // 根据是否为节假日确定基础服务价格 + const isHolidayDate = this.isHoliday(currentDay) + const baseServiceCost = isHolidayDate ? parseFloat(this.holidayPrice) : parseFloat(this.normalPrice) const largeDogCount = currentDayPets.filter(pet => pet.petType === 'dog' && pet.bodyType.includes('大型')).length; let mediumDogCount = currentDayPets.filter(pet => pet.petType === 'dog' && pet.bodyType.includes('中型')).length; @@ -988,48 +1143,62 @@ export default { return acc + this.calculatePetCost(pet); }, 0); // 如果总宠物费用>30 - if (totalPetCost > 30) { - // 如果猫数量>=3,则免3只猫 - if (catCount >= 3) { - additionalCost = totalPetCost - 30 - catCount = catCount - 3 - } else if (smallDogCount >= 2) { // 如果小型犬数量>=2,则免2只小型犬 - additionalCost = totalPetCost - 30 - smallDogCount = smallDogCount - 2 - } else if (mediumDogCount >= 1) { // 如果中型犬数量>=1,则免1只中型犬 - additionalCost = totalPetCost - 30 - mediumDogCount = mediumDogCount - 1 - } else { - additionalCost = totalPetCost - 25 - catCount = catCount - 1 - smallDogCount = smallDogCount - 1 - } + const freeQuota = this.price_config.freeQuota + if (totalPetCost > Number(freeQuota.threshold)) { + freeQuota.rules.forEach(rule => { + if (rule.type === 'cat' && catCount >= rule.count) { + additionalCost = totalPetCost - Number(rule.freeAmount) + catCount = catCount - rule.count + }else if(rule.type === 'smallDog' && smallDogCount >= rule.count){ + additionalCost = totalPetCost - Number(rule.freeAmount) + smallDogCount = smallDogCount - rule.count + }else if(rule.type === 'mediumDog' && mediumDogCount >= rule.count){ + additionalCost = totalPetCost - Number(rule.freeAmount) + mediumDogCount = mediumDogCount - rule.count + }else{ + additionalCost = totalPetCost - Number(rule.freeAmount) + } + }) if (largeDogCount > 0) { - additionalCostItem.push({ itemName: '大型犬', price: 40, quantity: largeDogCount, unit: '只' }) + additionalCostItem.push({ itemName: '大型犬', price: this.calculatePetCost({ + petType: 'dog', + bodyType: '大型', + }), quantity: largeDogCount, unit: '只' }) } if (mediumDogCount > 0) { - additionalCostItem.push({ itemName: '中型犬', price: 30, quantity: mediumDogCount, unit: '只' }) + additionalCostItem.push({ itemName: '中型犬', price: this.calculatePetCost({ + petType: 'dog', + bodyType: '中型', + }), quantity: mediumDogCount, unit: '只' }) } if (smallDogCount > 0) { - additionalCostItem.push({ itemName: '小型犬', price: 15, quantity: smallDogCount, unit: '只' }) + additionalCostItem.push({ itemName: '小型犬', price: this.calculatePetCost({ + petType: 'dog', + bodyType: '小型', + }), quantity: smallDogCount, unit: '只' }) } if (catCount > 0) { - additionalCostItem.push({ itemName: '猫猫', price: 10, quantity: catCount, unit: '只' }) + additionalCostItem.push({ itemName: '猫猫', price: this.calculatePetCost({ + petType: 'cat', + }), quantity: catCount, unit: '只' }) } } // 如果有大型犬,额外费用为40元/只 if (largeDogCount > 0) { - additionalCost += (40 * largeDogCount) + additionalCost += (this.calculatePetCost({ + petType: 'dog', + bodyType: '大型', + }) * largeDogCount) } // 当日多次服务次数 let multServicesTotalCost = 0 const maxFeedCount = Math.max(...currentDayPets.map(pet => pet.feedCount)); if (maxFeedCount === 2) { - multServicesTotalCost += 45; // 1天2次 + multServicesTotalCost += this.price_config.multiService.two.price; // 1天2次 } else if (maxFeedCount === 3) { - multServicesTotalCost += 130; // 1天3次 + multServicesTotalCost += this.price_config.multiService.three.price; // 1天3次 } // 所有宠物定制服务费用 const customServiceCost = currentDayPets.reduce((acc, pet) => acc + this.calculatePetCustomServiceCost(pet), 0) diff --git a/pages/newOrder备份/confirmOrder.vue b/pages/newOrder备份/confirmOrder.vue index c38fda8..4c4cb4b 100644 --- a/pages/newOrder备份/confirmOrder.vue +++ b/pages/newOrder备份/confirmOrder.vue @@ -237,7 +237,7 @@ 订单总价: - ¥{{ finalPrice }} ¥{{ Number(finalPrice).toFixed(2) }} diff --git a/pages/newOrder备份/petList.vue b/pages/newOrder备份/petList.vue index 19b8f7e..221e559 100644 --- a/pages/newOrder备份/petList.vue +++ b/pages/newOrder备份/petList.vue @@ -32,7 +32,7 @@ - + @@ -144,7 +144,7 @@ export default { selectedDate: [], currentPets: [], //当前技师不接单日期 - outDateList : ['2025-6-20'], + outDateList : [], } }, onShow() { diff --git a/pages/newOrder备份/serviceNew2.vue b/pages/newOrder备份/serviceNew2.vue index 30787ea..8d7fcb7 100644 --- a/pages/newOrder备份/serviceNew2.vue +++ b/pages/newOrder备份/serviceNew2.vue @@ -214,10 +214,10 @@ 订单总价: - ¥{{ totalPrice }} .00 - + ¥{{ Number(totalPrice).toFixed(2) }} .00 + Number(finalPrice).toFixed(2) - 当日价格:¥{{ currentDayPrice }}.00 | + 当日价格:¥{{ Number(currentDayPrice).toFixed(2) }} | 明细 @@ -835,8 +835,9 @@ } // 过滤宠物类型数量>0的数组 const additionalCostItem = [] - const petTypeArr = this.petTypeCounts.filter(item => item.largeDogCount > 0 || item.mediumDogCount > 0 || - item.smallDogCount > 0 || item.catCount > 0) + const petTypeArr = this.petTypeCounts.filter(item => item.largeDogCount > 0 || + item.mediumDogCount > 0 || + item.smallDogCount > 0 || item.catCount > 0) // 假设largeDogCount=1 mediumDogCount=2 smallDogCount=3 catCount=4 则生成4条数据 petTypeArr.forEach(item => { if (item.largeDogCount > 0) { diff --git a/pages/personalCenter/breedSelect.vue b/pages/personalCenter/breedSelect.vue new file mode 100644 index 0000000..b4ede99 --- /dev/null +++ b/pages/personalCenter/breedSelect.vue @@ -0,0 +1,405 @@ + + + + + \ No newline at end of file diff --git a/pages/personalCenter/components/petBaseInfo.vue b/pages/personalCenter/components/petBaseInfo.vue index c8a141e..055051e 100644 --- a/pages/personalCenter/components/petBaseInfo.vue +++ b/pages/personalCenter/components/petBaseInfo.vue @@ -38,56 +38,13 @@ - - - - - - - - + - - - - - - - - - - - - - 取消 - - - - - - - 确定 - - - - - - - - @@ -102,20 +59,21 @@ data() { return { showSex: false, - showBreed: false, showWeight: false, showBirthday: false, - showDisposition: false, sexActions: [['男生','女生']], weightActions: [['小型(<10 KG)','中型(10~20KG)', '大型(20KG以上)']], - dispositionActions: [], - - breedData: [], - searchBreedData:[], - tempBreed: '', - searchValue: '', - tempBirthday: '', - tempDisposition: '' + tempBirthday: '' + } + }, + + watch: { + 'petBaseInfo.breed': { + handler(newVal) { + console.log('品种数据更新:', newVal); + this.updatePetBaseInfo(); + }, + immediate: true } }, props:{ @@ -135,10 +93,7 @@ }) } }, - mounted() { - this.getPersonalityDataList() - this.getPetBreed() - }, + methods: { nameChange(){ this.updatePetBaseInfo() @@ -154,28 +109,12 @@ this.updatePetBaseInfo() }, breedSelectOpen() { - this.searchBreedData=this.breedData; - this.searchValue=''; - this.tempBreed = this.petBaseInfo.breed; - this.showBreed = true; - }, - searchBreed(){ - if(this.searchValue&&this.searchValue!=''){ - this.searchBreedData=this.breedData.filter(e=>e.includes(this.searchValue)); - }else{ - this.searchBreedData=this.breedData - } - - }, - breedSelectClose() { - this.tempBreed = ''; - this.showBreed = false; - }, - breedSelectConfirm() { - this.petBaseInfo.breed = this.tempBreed; - this.showBreed = false; - this.updatePetBaseInfo() + // 跳转到品种选择页面 + uni.navigateTo({ + url: `/pages/personalCenter/breedSelect?petType=${this.petType}&selectedBreed=${encodeURIComponent(this.petBaseInfo.breed || '')}` + }); }, + yearMonthOpen() { if (this.petBaseInfo.birthDate) { this.tempBirthday = Number(new Date(this.petBaseInfo.birthDate)) @@ -194,45 +133,18 @@ this.updatePetBaseInfo() }, dispositionSelectOpen() { - this.tempDisposition = this.petBaseInfo.personality; - this.showDisposition = true; - }, - dispositionSelectClose() { - this.tempDisposition = ''; - this.showDisposition = false; - }, - dispositionSelectConfirm() { - this.petBaseInfo.personality = this.tempDisposition; - this.showDisposition = false; - this.updatePetBaseInfo() - }, - checkboxChange(n) { - console.log('change', n); - this.updatePetBaseInfo(); + // 跳转到性格选择页面 + uni.navigateTo({ + url: `/pages/personalCenter/personalitySelect?personality=${encodeURIComponent(this.petBaseInfo.personality || '')}` + }); }, + updatePetBaseInfo() { // 触发 update 事件,将修改后的 petBaseInfo 对象发送给父组件 this.$emit('update:petBaseInfo', this.petBaseInfo); }, - getPersonalityDataList(){ - getDictList('pet_personality').then(res=>{ - if (res.code == 200) { - this.dispositionActions = Array.from(new Set(res.data.map(e=>e.dictLabel))) - } else { - this.$modal.showToast('获取性格失败') - } - }) - }, - getPetBreed(){ - let petBreedType = this.petType=='cat'?'pet_brand_cat':'pet_brand_dog' - getDictList(petBreedType).then(res=>{ - if (res.code == 200) { - this.breedData =Array.from(new Set(res.data.map(e=>e.dictLabel))) - } else { - this.$modal.showToast('获取种类失败') - } - }) - }, + + getMaxDate(){ return Date.now() }, @@ -251,14 +163,5 @@ margin-top: 10px; padding: 10px 20px; } - .personal-pet-breed-btns{ - display: flex; - justify-content: space-around; - align-items: center; - flex-wrap: nowrap; - flex-direction: row; - } - .personal-pet-breed-btn{ - width: 40%; - } + \ No newline at end of file diff --git a/pages/personalCenter/index.vue b/pages/personalCenter/index.vue index 376cdcd..662ff94 100644 --- a/pages/personalCenter/index.vue +++ b/pages/personalCenter/index.vue @@ -3,8 +3,8 @@ - + + + 性格描述 + + + + + + + + 快捷选择 + + + {{ item }} + + + + + + + + 保存 + + + + + + + + \ No newline at end of file diff --git a/pages/personalCenter/pet.vue b/pages/personalCenter/pet.vue index 54f1710..93e90f7 100644 --- a/pages/personalCenter/pet.vue +++ b/pages/personalCenter/pet.vue @@ -14,7 +14,7 @@ - + diff --git a/pages/personalCenter/petInfo.vue b/pages/personalCenter/petInfo.vue index 4acfff0..9861cfc 100644 --- a/pages/personalCenter/petInfo.vue +++ b/pages/personalCenter/petInfo.vue @@ -1,382 +1,515 @@ \ No newline at end of file diff --git a/pages/personalCenter/userInfo.vue b/pages/personalCenter/userInfo.vue index 6d89380..16a9b18 100644 --- a/pages/personalCenter/userInfo.vue +++ b/pages/personalCenter/userInfo.vue @@ -4,21 +4,16 @@ - - - - + + @@ -55,7 +50,7 @@ + + \ No newline at end of file diff --git a/pages/companionPetList/companionPetInfo.vue b/pages_order/companionPetList/companionPetInfo.vue similarity index 98% rename from pages/companionPetList/companionPetInfo.vue rename to pages_order/companionPetList/companionPetInfo.vue index 548be8f..ab5ace3 100644 --- a/pages/companionPetList/companionPetInfo.vue +++ b/pages_order/companionPetList/companionPetInfo.vue @@ -363,6 +363,7 @@ import uniRate from '@/uni_modules/uni-rate/components/uni-rate/uni-rate.vue'; import positionMixin from '../../mixins/position'; import addressMap from '@/components/addressMap.vue' + import { mapState } from 'vuex' export default { mixins: [positionMixin], components : { @@ -476,6 +477,9 @@ ] } }, + computed: { + ...mapState(['teacherLevelList']) + }, components: { uniRate, }, @@ -494,6 +498,12 @@ }, toBuy(){ this.buyInfo.teacher = this.companionInfo + + let companionLevel = this.teacherLevelList.find(n => n.paramValueNum == this.companionInfo.userBcsRole) + if(companionLevel){ + this.$globalData.newOrderData.companionLevel = companionLevel + } + uni.navigateTo({ url: '/pages/newOrder/serviceNew?type=teacher' }) diff --git a/pages/companionPetList/companionPetList.vue b/pages_order/companionPetList/companionPetList.vue similarity index 99% rename from pages/companionPetList/companionPetList.vue rename to pages_order/companionPetList/companionPetList.vue index 5693a80..40607d7 100644 --- a/pages/companionPetList/companionPetList.vue +++ b/pages_order/companionPetList/companionPetList.vue @@ -272,8 +272,8 @@ .stringify(this.allInfo)) uni.navigateTo({ - // url: '/pages/companionPetList/companionPetInfo', - url: `/pages/companionPetList/companionPetInfo?id=${id}` + // url: '/pages_order/companionPetList/companionPetInfo', + url: `/pages_order/companionPetList/companionPetInfo?id=${id}` }); } }, diff --git a/pages_order/companionPetList/couponList.vue b/pages_order/companionPetList/couponList.vue new file mode 100644 index 0000000..9517c68 --- /dev/null +++ b/pages_order/companionPetList/couponList.vue @@ -0,0 +1,76 @@ + + + + \ No newline at end of file diff --git a/pages_order/components/order/CompanionSelectPopup.vue b/pages_order/components/order/CompanionSelectPopup.vue index 5b9faec..2a3681b 100644 --- a/pages_order/components/order/CompanionSelectPopup.vue +++ b/pages_order/components/order/CompanionSelectPopup.vue @@ -83,7 +83,7 @@ export default { this.close(); setTimeout(() => { uni.navigateTo({ - url: '/pages/companionPetList/companionPetList' + url: '/pages_order/companionPetList/companionPetList' }); }, 300); } diff --git a/pages_order/components/order/ServiceItems.vue b/pages_order/components/order/ServiceItems.vue index 373bf32..050ad6f 100644 --- a/pages_order/components/order/ServiceItems.vue +++ b/pages_order/components/order/ServiceItems.vue @@ -54,9 +54,17 @@ - 费用合计 + 原价 ¥{{totalAmount.toFixed(2)}} + + 提前熟悉的费用 + ¥{{orderDetail.preFamiliarizePrice.toFixed(2)}} + + + 伴宠师 + ¥{{orderDetail.companionLevelPrice.toFixed(2)}} + 平台优惠 - ¥{{discount.toFixed(2)}} @@ -95,7 +103,11 @@ finalAmount: { type: Number, default: 0 - } + }, + orderDetail : { + type : Object, + default : () => {} + } }, data() { return { diff --git a/pages_order/components/order/ServiceRemarks.vue b/pages_order/components/order/ServiceRemarks.vue index 609d4be..abe8f52 100644 --- a/pages_order/components/order/ServiceRemarks.vue +++ b/pages_order/components/order/ServiceRemarks.vue @@ -14,9 +14,9 @@ 是否提前熟悉 - + diff --git a/pages_order/order/companionSelect.vue b/pages_order/order/companionSelect.vue index 8fc07a9..809b2c1 100644 --- a/pages_order/order/companionSelect.vue +++ b/pages_order/order/companionSelect.vue @@ -186,7 +186,7 @@ viewCompanionDetail(companionId) { // 跳转到伴宠师详情页面 uni.navigateTo({ - url: `/pages/companionPetList/companionPetInfo?id=${companionId}` + url: `/pages_order/companionPetList/companionPetInfo?id=${companionId}` }); } } diff --git a/pages_order/order/orderDetail.vue b/pages_order/order/orderDetail.vue index a9e001b..42ab434 100644 --- a/pages_order/order/orderDetail.vue +++ b/pages_order/order/orderDetail.vue @@ -11,7 +11,10 @@ + :discount="orderDetail.discount" :finalAmount="orderDetail.finalAmount" + :memberDiscount="orderDetail.memberDiscount" + :orderDetail="orderDetail" + > @@ -22,22 +25,22 @@ - + 取消订单 去付款 - - + + 去评价 再来一单 - + 查看服务记录 @@ -216,8 +219,11 @@ // 费用信息 totalAmount: data.totalAmount, - discount: data.totalAmount - data.payAmount, + discount: data.couponDiscount, + memberDiscount: data.memberDiscount, finalAmount: data.payAmount, + needPreFamiliarize : data.needPreFamiliarize, + companionLevelPrice : data.companionLevelPrice, // 订单状态 status: data.status.toString(), @@ -225,8 +231,8 @@ // 备注信息 remarks: { keyHandoverMethod: '存于快递柜', - isAdvanceFamiliar: true, - priceInfo: `价格${data.payAmount}元`, + isAdvanceFamiliar: data.needPreFamiliarize, + priceInfo: `价格${data.preFamiliarizePrice}元`, serviceContent: '服务内容: 伴宠师将按照约定时间上门照顾宠物', serviceCondition: '服务保障: 购买此服务后,平台将安排伴宠师与您确认服务细节', notes: data.note || '' diff --git a/pages_order/order/orderList.vue b/pages_order/order/orderList.vue index 794b4e4..42e8efa 100644 --- a/pages_order/order/orderList.vue +++ b/pages_order/order/orderList.vue @@ -60,7 +60,7 @@ - 取消订单 @@ -70,16 +70,18 @@ 去付款 - + 修改订单 - + 去评价 再来一单 - + 查看服务记录 @@ -206,6 +208,9 @@ onPullDownRefresh() { this.refreshing() }, + onShow() { + this.refreshing() + }, onReachBottom() { this.loadMore() }, @@ -630,12 +635,18 @@ display: flex; justify-content: flex-end; align-items: center; + flex-wrap: wrap; + gap: 20rpx; .action-btn { - padding: 16rpx 30rpx; + padding: 16rpx 24rpx; border-radius: 30rpx; - font-size: 26rpx; - margin-left: 20rpx; + font-size: 24rpx; + margin-left: 0; + white-space: nowrap; + flex-shrink: 0; + min-width: 120rpx; + text-align: center; } .details-btn { diff --git a/pages_order/order/orderModify.vue b/pages_order/order/orderModify.vue index dcdd963..ce77c44 100644 --- a/pages_order/order/orderModify.vue +++ b/pages_order/order/orderModify.vue @@ -71,9 +71,19 @@ + + + + diff --git a/uni_modules/ksp-cropper/package.json b/uni_modules/ksp-cropper/package.json new file mode 100644 index 0000000..8198256 --- /dev/null +++ b/uni_modules/ksp-cropper/package.json @@ -0,0 +1,81 @@ +{ + "id": "ksp-cropper", + "displayName": "ksp-cropper", + "version": "1.1.13", + "description": "高性能图片裁剪工具", + "keywords": [ + "头像", + "图片", + "裁剪" +], + "repository": "", + "engines": { + "HBuilderX": "^3.1.0" + }, +"dcloudext": { + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "无", + "data": "插件不采集任何数据", + "permissions": "无" + }, + "npmurl": "", + "type": "component-vue" + }, + "uni_modules": { + "dependencies": [], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "y", + "aliyun": "y" + }, + "client": { + "Vue": { + "vue2": "y", + "vue3": "y" + }, + "App": { + "app-vue": "y", + "app-nvue": "u" + }, + "H5-mobile": { + "Safari": "y", + "Android Browser": "y", + "微信浏览器(Android)": "y", + "QQ浏览器(Android)": "y" + }, + "H5-pc": { + "Chrome": "u", + "IE": "u", + "Edge": "u", + "Firefox": "u", + "Safari": "u" + }, + "小程序": { + "微信": { + "minVersion": "2.9.0" + }, + "阿里": "n", + "百度": "n", + "字节跳动": "n", + "QQ": "u" + }, + "快应用": { + "华为": "u", + "联盟": "u" + } + } + } + } +} \ No newline at end of file diff --git a/uni_modules/ksp-cropper/readme.md b/uni_modules/ksp-cropper/readme.md new file mode 100644 index 0000000..2a4a4ba --- /dev/null +++ b/uni_modules/ksp-cropper/readme.md @@ -0,0 +1,78 @@ +# ksp-cropper + +## 高性能图片裁剪工具 + +### 属性说明 +|属性 |类型 |默认 |备注 | +| :--------: | :-----: | :----: | :----: | +| url |String | "" | 需要裁剪的图片路径,为空时控件隐藏,不为空时控件显示| +| mode |String | "free" | 裁剪模式| +| width |Number | 200 | 图片裁剪后的宽度,固定大小时有效| +| height |Number | 200 | 图片裁剪后的高度,固定大小时有效| +| maxWidth |Number | 1024 | 图片裁剪后的最大宽度 | +| maxHeight |Number | 1024 | 图片裁剪后的最大高度 | + +### mode有效值 + +| 模式 |值 |说明 | +| :-----: | :-----: | :----: | +| 固定模式 |fixed | 裁剪出指定大小的图片,一般用于头像上传 | +| 等比缩放 |ratio | 限定宽高比,裁剪大小不固定 | +| 自由模式 |free | 不限定宽高比,裁剪大小不固定 | + +### 事件说明 +|事件名称 |说明 |返回 | +| :--------: | :-----: | :----: | +| ok |点击确定按钮 | e:{path} | +| cancel |点击取消按钮 | - | + + +### 示例 + +```html + + + + +``` + +### 注意 +1.微信小程序从基础库 2.21.0 开始, wx.chooseImage 停止维护,请使用 uni.chooseMedia 代替。
+2.微信小程序真机调试会报错,但正常运行是不会有问题的。
+3.uni-app版本不断更新,插件有时无法适应新版本,感谢大家及时提交bug,但希望大家手下留情,不要轻易给差评。 \ No newline at end of file diff --git a/uni_modules/uni-calendar/components/uni-calendar/uni-calendar-item.vue b/uni_modules/uni-calendar/components/uni-calendar/uni-calendar-item.vue index f124284..c8ee9f7 100644 --- a/uni_modules/uni-calendar/components/uni-calendar/uni-calendar-item.vue +++ b/uni_modules/uni-calendar/components/uni-calendar/uni-calendar-item.vue @@ -47,6 +47,8 @@ 不接单 + ¥{{holidayPrice}} + ¥{{normalPrice}}
@@ -86,6 +88,20 @@ lunar: { type: Boolean, default: false + }, + holidayDate: { + type: Array, + default () { + return [] + } + }, + holidayPrice: { + type: [Number, String], + default: 0 + }, + normalPrice: { + type: [Number, String], + default: 0 } }, computed: { @@ -95,6 +111,9 @@ isNotOrder(){ return this.disabledDay.includes(this.weeks.fullDate) }, + isHoliday(){ + return this.holidayDate.includes(this.weeks.fullDate) + }, }, methods: { choiceDate(weeks) { @@ -202,4 +221,18 @@ background-color: #ff5a5f; color: #fff; } + + .uni-calendar-item__holiday-price { + font-size: 20rpx; + color: #ff6b6b; + font-weight: bold; + margin-top: 4rpx; + } + + .uni-calendar-item__normal-price { + font-size: 20rpx; + color: #666; + font-weight: bold; + margin-top: 4rpx; + } diff --git a/uni_modules/uni-calendar/components/uni-calendar/uni-calendar.vue b/uni_modules/uni-calendar/components/uni-calendar/uni-calendar.vue index b219d0c..ba97a3e 100644 --- a/uni_modules/uni-calendar/components/uni-calendar/uni-calendar.vue +++ b/uni_modules/uni-calendar/components/uni-calendar/uni-calendar.vue @@ -53,7 +53,7 @@ + :disabledDay="disabledDay" :holidayDate="holidayDate" :holidayPrice="holidayPrice" :normalPrice="normalPrice">
@@ -138,6 +138,20 @@ clearDate: { type: Boolean, default: true + }, + holidayDate: { + type: Array, + default () { + return [] + } + }, + holidayPrice: { + type: [Number, String], + default: 0 + }, + normalPrice: { + type: [Number, String], + default: 0 } }, data() { diff --git a/utils/getUrl.js b/utils/getUrl.js index 1118bf6..4efb1bd 100644 --- a/utils/getUrl.js +++ b/utils/getUrl.js @@ -5,7 +5,7 @@ const accountInfo = wx.getAccountInfoSync(); const api={ - develop:"http://127.0.0.1:8080", + develop:"http://127.0.0.1:8002", // develop:"http://h5.xzaiyp.top", // develop:"https://api.catmdogd.com/prod-api", // develop:"https://api-test.catmdogd.com/test-api",