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 @@
+
+
+
+
+
+
+ {{switchType(couponData.stockType)}}
+
+
+
+
+
+
+
+
+ {{couponData.stockName}}
+ 可用于
+ 专业喂养
+ 专业遛狗
+
+
+ 有效期至: {{couponData.availableEndTime ? couponData.availableEndTime.slice(0, 16) : ''}}
+
+
+ {{ getCouponButtonText }}
+
+
+
+
+
+ 优惠券不可兑换现金
+
+
+ 查看详细规则>
+
+
+
+
+
+
+
+
+
\ 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 @@
-
-
-
-
-
-
-
- {{switchType(item.stockType)}}
-
-
-
-
-
-
-
-
- {{item.stockName}}
- 可用于
- 专业喂养
- 专业遛狗
-
-
- 有效期至: {{item.availableEndTime.slice(0, 16)}}
-
-
-
- 立即领取
-
-
-
-
-
- 优惠券不可兑换现金
-
-
- 查看详细规则>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ 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 @@
-
+
@@ -14,7 +14,8 @@
-
+
@@ -97,40 +98,14 @@
-
-
-
- {{switchType(item.stockType)}}
-
-
-
-
-
-
- {{item.stockName}}
- 可用于
- 专业喂养
- 专业遛狗
-
- 有效期至: {{item && item.availableEndTime ? item.availableEndTime.slice(0, 16) : ''}}
-
-
-
- 立即领取
-
-
-
-
-
-
- 优惠券不可兑换现金
-
-
- 查看详细规则>
-
-
-
-
+
@@ -212,11 +187,11 @@
历史记录
-
+
@@ -241,7 +216,7 @@
- *数据来源于布丁猫妈狗爸平台
+ *数据来源于猫妈狗爸平台
@@ -275,11 +250,12 @@
-
+
-
-
-
+
+
+
@@ -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 @@
@@ -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'>