diff --git a/api/local_store.js b/api/local_store.js index e47015b..a149d0b 100644 --- a/api/local_store.js +++ b/api/local_store.js @@ -108,3 +108,6 @@ export function wxPay(data) { return request.post("gt/wxPay", data) } +export function getSubsidy(data) { + return request.post("LocalStoreGoods/getSubsidy", data) +} diff --git a/bundle_b/pages/local_shop/components/spec-popup.vue b/bundle_b/pages/local_shop/components/spec-popup.vue index ff83f25..40a2fa5 100644 --- a/bundle_b/pages/local_shop/components/spec-popup.vue +++ b/bundle_b/pages/local_shop/components/spec-popup.vue @@ -274,11 +274,18 @@ setSpecData(data) { this.isEdit = true - this.specList = data.spec - data.item.forEach((item) => { - item.attributes = item.spec_value_str.split(',') - }) + this.specList = [] + if (data.spec) { + this.specList = data.spec + } + + if (data.item) { + data.item.forEach((item) => { + item.attributes = item.spec_value_str.split(',') + }) + } + this.skuList = data.item } }, diff --git a/bundle_b/pages/local_shop/local_shop_add.vue b/bundle_b/pages/local_shop/local_shop_add.vue index 0b8a8d6..cfb7143 100644 --- a/bundle_b/pages/local_shop/local_shop_add.vue +++ b/bundle_b/pages/local_shop/local_shop_add.vue @@ -6,22 +6,44 @@ + + + + + + + + + + + + 商家折扣比例 + 商品最高返补比例 + + + {{currentSubsidy.profit}} + {{currentSubsidy.subsidy}} + + + 选择此条件是商家折扣比例 + + + + @on-success="onSuccessShopPic" @on-remove="onRemoveShopPic" :multiple="true"> @@ -33,6 +55,7 @@ 第一张图片默认为商品封面图 + + 添加规格(默认为单规格) @@ -50,8 +73,34 @@ - - + + + + + + + + + 商家折扣比例 + + + 商品最高返补比例 + + + 操作 + + + + {{item.profit}} + {{item.subsidy}} + + 选择 + + + + + @@ -60,6 +109,9 @@ import { saveLocalShopGoods } from '@/api/store' + import { + getSubsidy + } from '@/api/local_store' import { trottle } from "@/utils/tools"; @@ -92,20 +144,36 @@ shop_pic: [], editorIns: null, toolbar_keys: ['bold', 'italic', 'underline', 'align', 'alignLeft', 'alignCenter', 'alignRight', - 'fontSize', 'color', 'backgroundColor', 'image'], + 'fontSize', 'color', 'backgroundColor', 'image' + ], action: baseURL + '/api/file/aliOSS', aliOSSpath: 'local_life_shop_goods/', lstore_id: 0, - showPopup: false + showPopup: false, + subsidy: [], + currentSubsidy: [], + show: false }; }, onLoad(options) { // 这里要设置商家的ID做为目录区分 this.aliOSSpath += options?.lstore_id + '/' this.lstore_id = options?.lstore_id + + this.getSubsidyFun() }, // 函数 methods: { + async getSubsidyFun() { + const { + code, + data + } = await getSubsidy() + if (code == 1) { + this.subsidy = data + } + }, + onSuccessShopPic(e) { this.shop_pic.push(e.data.file) }, @@ -132,7 +200,6 @@ success, data } = await ossUpload(item.tempFilePath, item.tempFilePath, this.aliOSSpath) - // console.log('success=', success) if (success) { editorCtx.insertImage({ src: data, @@ -150,18 +217,24 @@ } }) }, - + // 获取sku getSpec(sku, spec) { this.formData.sku = sku this.formData.spec = spec }, - + // 关闭sku closeSpec(state) { this.showPopup = state }, + // 选择比例 + selSubsidy(index) { + this.show = false + this.currentSubsidy = this.subsidy[index] + }, + async formSubmit() { let { title, @@ -171,22 +244,26 @@ sku, spec } = this.formData; - if (!title)return this.$toast({ + if (!title) return this.$toast({ title: "商品标题不能为空" }) - + if (!this.$u.test.amount(price)) return this.$toast({ title: "商品价格格式错误" }) + + if (this.currentSubsidy == '') return this.$toast({ + title: "请选择商品全返比例" + }) if (this.shop_pic.length == 0) return this.$toast({ title: "商品图片不能为空" }) - + if (this.specValue == 2 && this.spec.length == 0) return this.$toast({ title: "缺少商品规格" }) - + const { data, code @@ -194,6 +271,7 @@ lstore_id: this.lstore_id, title, price, + subsidy_id: this.currentSubsidy.id, desc, sku, spec, @@ -211,7 +289,7 @@ title: '添加成功', content: '商品添加成功' }); - + setTimeout(() => { this.$refs.specPopup.clearSpec() Object.keys(this.formData).forEach(key => this.formData[key] = '') @@ -225,7 +303,7 @@ content: '商品添加失败' }); } - + uni.hideLoading() } } @@ -347,4 +425,11 @@ .text-danger { color: #fb2d2d; } + + .block { + height: 90rpx; + display: flex; + align-items: center; + justify-content: center; + } \ No newline at end of file diff --git a/bundle_b/pages/local_shop/local_shop_buy.vue b/bundle_b/pages/local_shop/local_shop_buy.vue index e23c93c..d38bd4d 100644 --- a/bundle_b/pages/local_shop/local_shop_buy.vue +++ b/bundle_b/pages/local_shop/local_shop_buy.vue @@ -4,8 +4,16 @@ - + + + + 返 + + + 返补{{data.subsidy.profit}} + + @@ -117,7 +125,9 @@ shop_num: 1, shop_stock: 0, shop_max: 999, - shop_original_price: 0 + shop_original_price: 0, + isActive: true, + subsidy: '' } }, onLoad() { @@ -221,6 +231,10 @@ current: i, urls: f }); + }, + + expand() { + this.isActive = !this.isActive; } } } @@ -290,4 +304,43 @@ color: #FF2C3C; border-color: currentColor; } + + .swiper { + position: relative; + .txt { + background-color: #FF2C3C; + width: 80rpx; + height: 80rpx; + text-align: center; + line-height: 80rpx; + border-radius: 50%; + position: absolute; + top: 180rpx; + left: 20rpx; + color: #fff; + box-shadow: 0 0 24rpx 0 #d59797; + z-index: 2; + font-size: 32rpx; + font-weight: bold; + } + + .con { + background-color: rgb(255, 44, 60); + box-shadow: 0 0 12px 0 #ea6f6f; + transition: all 0.5s ease; + transform: translateX(26rpx); + position: absolute; + top: 192rpx; + color: #fff; + z-index: 1; + opacity: 0; + padding: 10rpx 20rpx; + border-radius: 10rpx; + } + + .active { + opacity: 1; + transform: translateX(84rpx); + } + } \ No newline at end of file diff --git a/bundle_b/pages/local_shop/local_shop_edit.vue b/bundle_b/pages/local_shop/local_shop_edit.vue index 998b03e..e3e2bb6 100644 --- a/bundle_b/pages/local_shop/local_shop_edit.vue +++ b/bundle_b/pages/local_shop/local_shop_edit.vue @@ -4,22 +4,46 @@ 审核失败,点击查看原因 + + + + + + + + + + + + + 商家折扣比例 + 商品最高返补比例 + + + {{currentSubsidy.profit}} + {{currentSubsidy.subsidy}} + + + 选择此条件是商家折扣比例 + + + - @@ -27,7 +51,7 @@ 上传商品图片 - + --> 第一张图片默认为商品封面图 @@ -63,6 +87,31 @@ + + + + + + + 商家折扣比例 + + + 商品最高返补比例 + + + 操作 + + + + {{item.profit}} + {{item.subsidy}} + + 选择 + + + + + @@ -74,6 +123,9 @@ setLocalShopState, editLocalShopPrice } from '@/api/store' + import { + getSubsidy + } from '@/api/local_store' import { trottle } from "@/utils/tools"; @@ -111,7 +163,10 @@ auditRemark: '', showSpecPopup: false, showSpecComponent: false, - is_multiple_spec: 0 + is_multiple_spec: 0, + subsidy:[], + currentSubsidy:[], + show: false }; }, onLoad(options) { @@ -121,7 +176,8 @@ this.order_type = options.order_type this.aliOSSpath += options.lstore_id + '/' - this.getData(); + this.getData() + this.getSubsidyFun() }, methods: { async getData() { @@ -148,10 +204,22 @@ this.state = data.state this.auditRemark = data.audit_remark this.is_multiple_spec = data.is_multiple_spec - + this.currentSubsidy = data.subsidy + console.log('currentSubsidy=', this.currentSubsidy) this.$refs.specPopup.setSpecData(data) } }, + + async getSubsidyFun() { + const { + code, + data + } = await getSubsidy() + if (code == 1) { + this.subsidy = data + } + }, + onSuccessShopPic(e) { this.shop_pic.push(e.data.file) }, @@ -253,6 +321,12 @@ this.showSpecPopup = state }, + // 选择比例 + selSubsidy(index) { + this.show = false + this.currentSubsidy = this.subsidy[index] + }, + async formSubmit() { const url = this.shop_pic.map((item) => { if (item.lsg_id && item.url) { @@ -282,6 +356,10 @@ }); return false; } + + if (this.currentSubsidy == '') return this.$toast({ + title: "请选择商品全返比例" + }) if (this.shop_pic.length == 0) { this.$toast({ @@ -298,6 +376,7 @@ lstore_id: this.lstore_id, title, price, + subsidy_id: this.currentSubsidy.id, desc, details: details.html, url, diff --git a/components/product-swiper/product-swiper.vue b/components/product-swiper/product-swiper.vue index 965bcbe..9363ad7 100644 --- a/components/product-swiper/product-swiper.vue +++ b/components/product-swiper/product-swiper.vue @@ -21,7 +21,7 @@ 返 - 返补50% + 返补{{subsidy}} @@ -71,6 +71,10 @@ tip: { type: String, default: '' + }, + subsidy: { + type: String, + default: '', } }, watch: { @@ -187,7 +191,7 @@ } .con { - background-color: rgb(255 44 60); + background-color: rgb(255, 44, 60); box-shadow: 0 0 12px 0 #ea6f6f; transition: all 0.5s ease; transform: translateX(26rpx);