添加和显示返比
This commit is contained in:
parent
31ffe6e196
commit
f2d25e770a
@ -108,3 +108,6 @@ export function wxPay(data) {
|
||||
return request.post("gt/wxPay", data)
|
||||
}
|
||||
|
||||
export function getSubsidy(data) {
|
||||
return request.post("LocalStoreGoods/getSubsidy", data)
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
},
|
||||
|
||||
@ -6,22 +6,44 @@
|
||||
<u-field v-model="formData.title" :focus="true" label="商品标题" label-width="160" placeholder="请输入商品标题"
|
||||
required />
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<u-field v-model="formData.price" label="商品价格" label-width="160" placeholder="请输入商品价格" required>
|
||||
<u-icon slot="right" name="rmb" size="28"></u-icon>
|
||||
</u-field>
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<u-field v-model="formData.desc" label="商品概述" label-width="160" placeholder="请输入商品概述" />
|
||||
</view>
|
||||
|
||||
<view @click="show = true">
|
||||
<u-field label="请选择商品全返补比例" label-width="300" :border-bottom="false" required disabled>
|
||||
<u-icon slot="right" name="arrow-right" size="28"></u-icon>
|
||||
</u-field>
|
||||
|
||||
<view v-if="currentSubsidy != ''">
|
||||
<u-table>
|
||||
<u-tr>
|
||||
<u-th>商家折扣比例</u-th>
|
||||
<u-th>商品最高返补比例</u-th>
|
||||
</u-tr>
|
||||
<u-tr>
|
||||
<u-td>{{currentSubsidy.profit}}</u-td>
|
||||
<u-td>{{currentSubsidy.subsidy}}</u-td>
|
||||
</u-tr>
|
||||
</u-table>
|
||||
<view class="bold">选择此条件是商家折扣比例</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="m-b-20">
|
||||
<u-field label="商品图片" label-width="200" :border-bottom="false" required disabled />
|
||||
<view>
|
||||
<u-upload :file-list="shop_pic" :header="{token: $store.getters.token}"
|
||||
:form-data="{type: 'local_shop_add', lstore_id }" ref="uUpload" :show-progress="true"
|
||||
:max-count="6" width="250" height="150" :action="action" custom-btn
|
||||
@on-success="onSuccessShopPic" @on-remove="onRemoveShopPic"
|
||||
:multiple="true">
|
||||
@on-success="onSuccessShopPic" @on-remove="onRemoveShopPic" :multiple="true">
|
||||
<view slot="addBtn" class="uplader-upload" hover-class="slot-btn__hover" hover-stay-time="150">
|
||||
<u-icon size="48" color="#dcdee0" name="camera" />
|
||||
<view class="xs m-t-10">
|
||||
@ -33,6 +55,7 @@
|
||||
<view class="sm bold thumb-info">第一张图片默认为商品封面图</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view @click="showPopup = true">
|
||||
<u-field label="商品规格" label-width="200" :border-bottom="false" disabled />
|
||||
<view class="m-l-30 bold">+ 添加规格(默认为单规格)</view>
|
||||
@ -50,8 +73,34 @@
|
||||
<button class="primary-btn white flex row-center" @click="formSubmit">提交</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<spec-popup :showPopup.sync="showPopup" :lstoreId="lstore_id" @specDataHandle="getSpec" @closeSpec="closeSpec" ref="specPopup"></spec-popup>
|
||||
|
||||
<spec-popup :showPopup.sync="showPopup" :lstoreId="lstore_id" @specDataHandle="getSpec" @closeSpec="closeSpec"
|
||||
ref="specPopup"></spec-popup>
|
||||
|
||||
<u-popup v-model="show" mode="bottom">
|
||||
<view>
|
||||
<u-table>
|
||||
<u-tr>
|
||||
<u-th>
|
||||
<view class="block">商家折扣比例</view>
|
||||
</u-th>
|
||||
<u-th>
|
||||
<view class="block">商品最高返补比例</view>
|
||||
</u-th>
|
||||
<u-th>
|
||||
<view class="block">操作</view>
|
||||
</u-th>
|
||||
</u-tr>
|
||||
<u-tr v-for="(item, index) in subsidy" :key="index">
|
||||
<u-td>{{item.profit}}</u-td>
|
||||
<u-td>{{item.subsidy}}</u-td>
|
||||
<u-td>
|
||||
<u-button type="error" size="mini" @click="selSubsidy(index)">选择</u-button>
|
||||
</u-td>
|
||||
</u-tr>
|
||||
</u-table>
|
||||
</view>
|
||||
</u-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -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;
|
||||
}
|
||||
</style>
|
||||
@ -4,8 +4,16 @@
|
||||
<u-notice-bar mode="horizontal" :list="[data.close.text]"></u-notice-bar>
|
||||
</view>
|
||||
|
||||
<view class="m-b-20">
|
||||
<view class="m-b-20 swiper">
|
||||
<u-swiper :list="file" height="750" border-radius="0" mode="number" @click="preview"></u-swiper>
|
||||
<view>
|
||||
<view class="txt" @click="expand">
|
||||
返
|
||||
</view>
|
||||
<view :class="'con ' + (isActive ? 'active' : '')">
|
||||
返补{{data.subsidy.profit}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="info">
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -4,22 +4,46 @@
|
||||
<view class="bold text-center no-pass" v-if="order_type == 4" @click="this.showPopup = true">
|
||||
审核失败,点击查看原因
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<u-field v-model="formData.title" :focus="true" label="商品标题" label-width="160" placeholder="请输入商品标题"
|
||||
required />
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<u-field v-model="formData.price" label="商品价格" label-width="160" placeholder="请输入商品价格" required>
|
||||
<u-icon slot="right" name="rmb" size="28"></u-icon>
|
||||
</u-field>
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<u-field v-model="formData.desc" label="商品概述" label-width="160" placeholder="请输入商品概述"/>
|
||||
</view>
|
||||
|
||||
<view @click="show = true">
|
||||
<u-field label="请选择商品全返补比例" label-width="300" :border-bottom="false" required disabled>
|
||||
<u-icon slot="right" name="arrow-right" size="28"></u-icon>
|
||||
</u-field>
|
||||
|
||||
<view v-if="currentSubsidy != ''">
|
||||
<u-table>
|
||||
<u-tr>
|
||||
<u-th>商家折扣比例</u-th>
|
||||
<u-th>商品最高返补比例</u-th>
|
||||
</u-tr>
|
||||
<u-tr>
|
||||
<u-td>{{currentSubsidy.profit}}</u-td>
|
||||
<u-td>{{currentSubsidy.subsidy}}</u-td>
|
||||
</u-tr>
|
||||
</u-table>
|
||||
<view class="bold">选择此条件是商家折扣比例</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="m-b-20">
|
||||
<u-field label="商品图片" label-width="200" :border-bottom="false" required disabled />
|
||||
<view>
|
||||
<u-upload :file-list="shop_pic" :max-size="4 * 1024 * 1024" :header="{token: $store.getters.token}" size-type="compressed" :form-data="{type: 'local_shop_add', lstore_id }" ref="uUpload" :show-progress="true" :max-count="6" width="250" height="150" :action="action"
|
||||
<!-- <u-upload :file-list="shop_pic" :max-size="4 * 1024 * 1024" :header="{token: $store.getters.token}" size-type="compressed" :form-data="{type: 'local_shop_add', lstore_id }" ref="uUpload" :show-progress="true" :max-count="6" width="250" height="150" :action="action"
|
||||
custom-btn @on-success="onSuccessShopPic" @on-remove="onRemoveShopPic" :multiple="true">
|
||||
<view slot="addBtn" class="uplader-upload" hover-class="slot-btn__hover" hover-stay-time="150">
|
||||
<u-icon size="48" color="#dcdee0" name="camera" />
|
||||
@ -27,7 +51,7 @@
|
||||
上传商品图片
|
||||
</view>
|
||||
</view>
|
||||
</u-upload>
|
||||
</u-upload> -->
|
||||
</view>
|
||||
<view class="sm bold thumb-info">第一张图片默认为商品封面图</view>
|
||||
</view>
|
||||
@ -63,6 +87,31 @@
|
||||
</u-popup>
|
||||
|
||||
<spec-popup :showPopup="showSpecPopup" :lstoreId="lstore_id" :orderType="order_type" @specDataHandle="getSpec" @closeSpec="closeSpec" ref="specPopup"></spec-popup>
|
||||
|
||||
<u-popup v-model="show" mode="bottom">
|
||||
<view>
|
||||
<u-table>
|
||||
<u-tr>
|
||||
<u-th>
|
||||
<view class="block">商家折扣比例</view>
|
||||
</u-th>
|
||||
<u-th>
|
||||
<view class="block">商品最高返补比例</view>
|
||||
</u-th>
|
||||
<u-th>
|
||||
<view class="block">操作</view>
|
||||
</u-th>
|
||||
</u-tr>
|
||||
<u-tr v-for="(item, index) in subsidy" :key="index">
|
||||
<u-td>{{item.profit}}</u-td>
|
||||
<u-td>{{item.subsidy}}</u-td>
|
||||
<u-td>
|
||||
<u-button type="error" size="mini" @click="selSubsidy(index)">选择</u-button>
|
||||
</u-td>
|
||||
</u-tr>
|
||||
</u-table>
|
||||
</view>
|
||||
</u-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
返
|
||||
</view>
|
||||
<view :class="'con ' + (isActive ? 'active' : '')">
|
||||
返补50%
|
||||
返补{{subsidy}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user