重写添加商品页面(进行中)
This commit is contained in:
parent
fe899f95f1
commit
3d93e06173
|
@ -42,8 +42,8 @@
|
|||
</view>
|
||||
|
||||
<!-- 商品详情 -->
|
||||
<commodityComponent v-if="showCommodity" :key="showCommodity" :showCommodity="showCommodity" :product_id="product_id" :merId="merId"
|
||||
:code="code" @lastStep="lastStep">
|
||||
<commodityComponent ref="commodityRef" v-if="showCommodity" :key="showCommodity" :showCommodity="showCommodity"
|
||||
:product_id="product_id" :merId="merId" :code="code" @lastStep="lastStep">
|
||||
</commodityComponent>
|
||||
|
||||
<view class="popup_group">
|
||||
|
@ -74,7 +74,9 @@
|
|||
</uni-popup>
|
||||
|
||||
<!-- 规格设置 -->
|
||||
<priceComponent :product_id="product_id" :bar_code="code" @updateCode = "updateCode" v-if="showCommodity"></priceComponent>
|
||||
<priceComponent ref="priceRef" :product_id="product_id" :bar_code="code" @updateCode="updateCode"
|
||||
v-if="showCommodity">
|
||||
</priceComponent>
|
||||
|
||||
<view class="popup_group">
|
||||
<!-- <view class="popup_group_item" @click="showMoreInfo=!showMoreInfo">
|
||||
|
@ -83,7 +85,7 @@
|
|||
<view><span class="iconfont"></span></view>
|
||||
</view>
|
||||
</view> -->
|
||||
<block >
|
||||
<block>
|
||||
<view class="input_content">
|
||||
<!-- <view class="input_content_describe" style="border-top: none">
|
||||
<view class="input_content_describe_title">
|
||||
|
@ -153,14 +155,23 @@
|
|||
attrList,
|
||||
templateList,
|
||||
productDetail,
|
||||
getDeliveryType
|
||||
getDeliveryType,
|
||||
productCreate,
|
||||
productUpdate
|
||||
} from '@/api/product.js';
|
||||
import {
|
||||
serialize,
|
||||
Toast,
|
||||
Loading,
|
||||
hideLoading,
|
||||
Modal
|
||||
} from "@/libs/uniApi.js";
|
||||
import avatar from "@/components/yq-avatar/yq-avatar.vue";
|
||||
import platfrom from "./components/platform.vue";
|
||||
import commodityComponent from "./components/commodity.vue";
|
||||
import priceComponent from "./components/price.vue";
|
||||
export default {
|
||||
components:{
|
||||
components: {
|
||||
avatar,
|
||||
platfrom,
|
||||
commodityComponent,
|
||||
|
@ -174,11 +185,23 @@
|
|||
code: '', //商品条码
|
||||
show: false, //是否预览图片
|
||||
image: false, //预览的图
|
||||
setFormData:{
|
||||
setFormData: {
|
||||
store_name: '',
|
||||
imageList: [],
|
||||
cate_name: '', //平台分类
|
||||
cate_name: '', //平台名称
|
||||
unit_name: '', //商品单位
|
||||
cate_id: '', // 平台分类id
|
||||
mer_cate_id: '', // 店铺分类
|
||||
mer_cate_name: '', // 店铺分类名称
|
||||
spec_type: '0', // 0.单规格 1:多规格
|
||||
attr: [], // 商品规格
|
||||
specifica: '', // 商品规格名称
|
||||
setSpecificaValue: '', // 价格设置提示
|
||||
setSpecificaValue2: '',
|
||||
delivery_way: [1, 2], // 配送方式 1 到店核销 2 快递配送
|
||||
delivery_free: '1', // 是否包邮 0不包邮 1包邮
|
||||
temp_id: '', // 运费模板ID
|
||||
tempName: '' // 运费模板名称
|
||||
},
|
||||
platformClassificationData: [], // 平台分类数据
|
||||
merchantClassification: [], // 店铺分类
|
||||
|
@ -207,18 +230,58 @@
|
|||
onLoad(opt) {
|
||||
this.merId = Number(opt.mer_id);
|
||||
this.product_id = opt.product_id;
|
||||
if(!opt.product_id)this.showCommodity=true;
|
||||
if (!opt.product_id) this.showCommodity = true;
|
||||
this.initData();
|
||||
this.initClasiffy();
|
||||
},
|
||||
onBackPress() {
|
||||
|
||||
},
|
||||
onBackPress() {},
|
||||
onShow() {
|
||||
|
||||
this.setFormData = Object.assign(this.setFormData, {
|
||||
"store_name": "方法",
|
||||
"imageList": [
|
||||
"https://lihai001.oss-cn-chengdu.aliyuncs.com/def/457c6202311181745387896.jpeg",
|
||||
"https://lihai001.oss-cn-chengdu.aliyuncs.com/def/185e2202311181745434402.jpeg"
|
||||
],
|
||||
"cate_name": "丧葬服务",
|
||||
"unit_name": "给",
|
||||
"cate_id": 445,
|
||||
"keyword": "22"
|
||||
})
|
||||
this.$nextTick(() => {
|
||||
this.$refs.commodityRef.addGoodsSecoundData = {
|
||||
"is_good": 1,
|
||||
"is_gift_bag": 0,
|
||||
"sort": "20",
|
||||
"once_count": "",
|
||||
"video_link": "https://lihai001.oss-cn-chengdu.aliyuncs.com/media/7ce3d202311181816166215.mp4"
|
||||
}
|
||||
this.$refs.commodityRef.goodsDis = {
|
||||
"store_name": "",
|
||||
"imageList": [
|
||||
"https://lihai001.oss-cn-chengdu.aliyuncs.com/def/fb73d202311181751262661.png"
|
||||
]
|
||||
}
|
||||
this.$refs.priceRef.singleSpecification = {
|
||||
"price": "1",
|
||||
"cost": "1",
|
||||
"stock": "11",
|
||||
"ot_price": "",
|
||||
"procure_price": "",
|
||||
"bar_code": "666",
|
||||
"weight": "10",
|
||||
"volume": "5",
|
||||
"image": "",
|
||||
"extension_one": "",
|
||||
"extension_two": ""
|
||||
}
|
||||
})
|
||||
},
|
||||
beforeDestroy() {
|
||||
|
||||
beforeDestroy() {},
|
||||
watch: {
|
||||
'setFormData.imageList'(val) {
|
||||
this.setFormData.image = val.length ? val[0] : '';
|
||||
this.setFormData.slider_image = val.length ? serialize(val).splice(1) : [];
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 查询详情数据
|
||||
|
@ -253,7 +316,7 @@
|
|||
}
|
||||
productDetail(this.merId, this.product_id).then(res => {
|
||||
setStorage('editGoodsDetils', res.data);
|
||||
if(res.data.content_arr.length>0) res.data.content = res.data.content_arr;
|
||||
if (res.data.content_arr.length > 0) res.data.content = res.data.content_arr;
|
||||
this.$store.commit('setStorage', res.data);
|
||||
let editGoodsDetils = res.data;
|
||||
Object.keys(this.setFormData).forEach(item => {
|
||||
|
@ -301,15 +364,15 @@
|
|||
this.brand = (await categoryBrandlist(this.merId)).data;
|
||||
// 获取平台分类
|
||||
let { data } = await categoryList(this.merId);
|
||||
data.forEach((item1)=>{
|
||||
item1.children.forEach((item2)=>{
|
||||
data.forEach((item1) => {
|
||||
item1.children.forEach((item2) => {
|
||||
item2.children = null;
|
||||
})
|
||||
})
|
||||
this.platformClassificationData = data;
|
||||
},
|
||||
// 更新商品条码
|
||||
updateCode(e){
|
||||
updateCode(e) {
|
||||
this.code = e + '';
|
||||
},
|
||||
// 选择图片
|
||||
|
@ -454,7 +517,55 @@
|
|||
// 创建商品
|
||||
submitCreatedGoods() {
|
||||
console.log('创建商品');
|
||||
console.log('商品数据', this.setFormData);
|
||||
console.log('是否推荐', this.$refs.commodityRef.addGoodsSecoundData);
|
||||
console.log('商品详情', this.$refs.commodityRef.goodsDis, this.$refs.commodityRef.store_name);
|
||||
console.log('价格库存', this.$refs.priceRef.singleSpecification);
|
||||
let postData = {
|
||||
...this.setFormData,
|
||||
...this.$refs.commodityRef.addGoodsSecoundData,
|
||||
content: {
|
||||
title: this.$refs.commodityRef.goodsDis?.store_name || '',
|
||||
image: this.$refs.commodityRef.goodsDis?.imageList || []
|
||||
},
|
||||
video_link: this.$refs.commodityRef.addGoodsSecoundData.video_link,
|
||||
attrValue: this.$refs.priceRef.singleSpecification
|
||||
};
|
||||
postData.stock = postData.attrValue[0]?.stock||0;
|
||||
// return console.log('商品数据', postData);
|
||||
Loading();
|
||||
if (this.product_id) {
|
||||
productUpdate(this.merId, this.product_id, postData)
|
||||
.then(res => {
|
||||
hideLoading()
|
||||
Modal('提交成功', '点击确定,返回商品管理', {
|
||||
showCancel: false
|
||||
}).then(() => {
|
||||
uni.removeStorageSync('singleSpecification')
|
||||
uni.redirectTo({
|
||||
url: '/pages/product/goodsOnSale/index?mer_id=' + this.merId
|
||||
})
|
||||
})
|
||||
})
|
||||
.catch(rej => {
|
||||
Toast(rej);
|
||||
});
|
||||
|
||||
} else {
|
||||
productCreate(this.merId, postData)
|
||||
.then(res => {
|
||||
hideLoading();
|
||||
Modal('提交成功', '点击确定,返回商品管理', {
|
||||
showCancel: false,
|
||||
}).then(() => {
|
||||
uni.redirectTo({
|
||||
url: '/pages/product/goodsOnSale/index?mer_id=' + this.merId
|
||||
})
|
||||
})
|
||||
})
|
||||
.catch(rej => {
|
||||
Toast(rej);
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue