From badf7be50037e7e2f467cabb819060b6bf9d50bb Mon Sep 17 00:00:00 2001 From: lynn Date: Tue, 8 Jul 2025 13:27:28 +0800 Subject: [PATCH] add order count --- package.json | 2 +- package_sub/pages/AddOrder/AddOrder.vue | 155 +++++++++++++++++- .../pages/ServiceDetail/ServiceDetail.vue | 50 +++--- package_sub/pages/ServiceList/ServiceList.vue | 3 +- project.config.json | 28 ++++ project.private.config.json | 7 + vue.config.js | 12 +- 7 files changed, 224 insertions(+), 33 deletions(-) create mode 100644 project.config.json create mode 100644 project.private.config.json diff --git a/package.json b/package.json index 9a349bc..77772f4 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "copy-webpack-plugin": "^5.0.0" + "copy-webpack-plugin": "^6.4.1" } } diff --git a/package_sub/pages/AddOrder/AddOrder.vue b/package_sub/pages/AddOrder/AddOrder.vue index 92d4d2e..aeb3611 100644 --- a/package_sub/pages/AddOrder/AddOrder.vue +++ b/package_sub/pages/AddOrder/AddOrder.vue @@ -62,6 +62,49 @@ + + + + 产品数量 + + + + + + {{ form.quantity }} + + + + + + + + + + + + 产品数量 + + + {{ form.quantity }} 份 + + + + + 护工信息 @@ -326,6 +369,12 @@
+ 数量 + + {{ form.quantity || 1 }} 份 + +
+ @@ -352,7 +401,7 @@ 实付: - ¥ {{ orderId?paidPrice:accompanyProduct.price }} + ¥ {{ orderId ? paidPrice : ((accompanyProduct.price || 0) * (form.quantity || 1)) }} 1) { + this.$set(this.form, 'quantity', this.form.quantity - 1); + } else { + uni.showToast({ + title: '最小数量为1', + icon: 'none' + }); + } + }, // 获取产品列表 async getList(type) { const res = await this.$u.api.accompanyProduct({ @@ -775,6 +848,11 @@ export default { this.form[key] = res[key]; } } + + // 确保数量字段有默认值 + if (!this.form.quantity) { + this.form.quantity = 1; + } this.form['created_at'] = res['created_at'] this.form['status'] = res['status'] this.form['nurse_id'] = res['nurse_id'] @@ -885,6 +963,8 @@ export default { } } // return + this.form.price = this.orderId ? this.paidPrice : (this.accompanyProduct.price * this.form.quantity) + this.form.total = this.form.quantity.toString() const res = await this.$u.api.accompanyProductOrder(this.form); if (res) { this.orderId = res.id; @@ -1160,6 +1240,79 @@ export default { background: #f4efee; } +// 数量选择Card样式 +.quantity-card { + background: #fff; + border-radius: 20rpx; + margin: 30rpx; + box-shadow: 0 4rpx 16rpx #e6eaf1; + padding: 30rpx; + + &__header { + display: flex; + justify-content: space-between; + align-items: center; + } + + &__title { + font-size: 28rpx; + color: #000000; + font-weight: bold; + position: relative; + padding-left: 24rpx; + + &::before { + content: ""; + background: linear-gradient( + 0deg, + #c10d12 0%, + #c10d12 6%, + #e26165 100% + ); + border-radius: 4rpx; + width: 6rpx; + position: absolute; + top: 0; + left: 0; + bottom: 0; + } + } + + &__content { + display: flex; + align-items: center; + + .quantity-control { + display: flex; + align-items: center; + justify-content: center; + + .quantity-display { + width: 120rpx; + height: 60rpx; + line-height: 60rpx; + text-align: center; + background: #f8f8f8; + border-radius: 8rpx; + margin: 0 20rpx; + font-size: 28rpx; + color: #333; + font-weight: 500; + } + + .quantity-display-static { + font-size: 28rpx; + color: #333; + font-weight: 500; + padding: 10rpx 20rpx; + background: #f8f8f8; + border-radius: 8rpx; + text-align: center; + } + } + } +} + .pay-popup { &-container { padding-bottom: 20rpx; diff --git a/package_sub/pages/ServiceDetail/ServiceDetail.vue b/package_sub/pages/ServiceDetail/ServiceDetail.vue index a2257ff..c775dfb 100644 --- a/package_sub/pages/ServiceDetail/ServiceDetail.vue +++ b/package_sub/pages/ServiceDetail/ServiceDetail.vue @@ -120,11 +120,11 @@ }, mounted() { - }, - computed: { - token() { - return this.vuex_token || uni.getStorageSync('lifeData')?.vuex_token - } + }, + computed: { + token() { + return this.vuex_token || uni.getStorageSync('lifeData')?.vuex_token + } }, methods: { async getDetail(id) { @@ -136,28 +136,28 @@ }) }, - toOrder(info) { - if (!this.token) { - uni.showModal({ - title: "提示", - content: "请先登录再下单", - confirmText: "登录", - success: (status) => { - if (status.confirm) { - this.$u.route({ - url: '/pages/login/login', - type: 'redirect' - }) - } else { - - } - }, - fail: () => {}, - }); - return + toOrder(info) { + if (!this.token) { + uni.showModal({ + title: "提示", + content: "请先登录再下单", + confirmText: "登录", + success: (status) => { + if (status.confirm) { + this.$u.route({ + url: '/pages/login/login', + type: 'redirect' + }) + } else { + + } + }, + fail: () => {}, + }); + return } this.$u.route({ - url: '/package_sub/pages/AddOrder/AddOrder?id='+info.id+'&site_id='+info.site_id+'&type='+info.type + url: '/package_sub/pages/AddOrder/AddOrder?id='+info.id+'&site_id='+info.site_id+'&type='+info.type+'&can_multi_num='+info.can_multi_num }) }, } diff --git a/package_sub/pages/ServiceList/ServiceList.vue b/package_sub/pages/ServiceList/ServiceList.vue index 34841a5..0016e15 100644 --- a/package_sub/pages/ServiceList/ServiceList.vue +++ b/package_sub/pages/ServiceList/ServiceList.vue @@ -124,7 +124,8 @@ this.getList() }, confirmSite(e) { - // this.$u.vuex("vuex_site", e[0]) + // this.$u.vuex("vuex_site", e[0]) + console.log(e[0]) this.select.site_id = e[0].id?e[0].id:'' this.site_name = e[0].name?e[0].name:'全部' this.list = [] diff --git a/project.config.json b/project.config.json new file mode 100644 index 0000000..256c162 --- /dev/null +++ b/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx2129de75c4937c40", + "compileType": "miniprogram", + "libVersion": "3.8.8", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 2 + } +} \ No newline at end of file diff --git a/project.private.config.json b/project.private.config.json new file mode 100644 index 0000000..21e4046 --- /dev/null +++ b/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "yikangyang-wx", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/vue.config.js b/vue.config.js index 45cea18..bc9cbb6 100644 --- a/vue.config.js +++ b/vue.config.js @@ -7,11 +7,13 @@ const CopyWebpackPlugin = require('copy-webpack-plugin') module.exports = { configureWebpack:{ plugins: [ - new CopyWebpackPlugin([{ - from: path.join(__dirname, 'agent_sub/wxcomponents'), - to: path.join(__dirname, 'unpackage/dist', process.env.NODE_ENV === 'production' ? 'build' : 'dev', - 'mp-weixin', 'agent_sub/wxcomponents') - }]) + new CopyWebpackPlugin({ + patterns: [{ + from: path.join(__dirname, 'package_sub'), + to: path.join(__dirname, 'unpackage/dist', process.env.NODE_ENV === 'production' ? 'build' : 'dev', + 'mp-weixin', 'package_sub') + }] + }) ] } }