重写添加商品页面(进行中)
This commit is contained in:
parent
fe899f95f1
commit
3d93e06173
|
@ -35,15 +35,15 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<u-popup ref="select_popup" class="pop" :show="show" mode="center" closeOnClickOverlay bgColor='transparent'>
|
<u-popup ref="select_popup" class="pop" :show="show" mode="center" closeOnClickOverlay bgColor='transparent'>
|
||||||
<image :src="image"></image>
|
<image :src="image"></image>
|
||||||
<image src="@/static/images/guanbi.png" class="guanbi" @click="close"></image>
|
<image src="@/static/images/guanbi.png" class="guanbi" @click="close"></image>
|
||||||
</u-popup>
|
</u-popup>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 商品详情 -->
|
<!-- 商品详情 -->
|
||||||
<commodityComponent v-if="showCommodity" :key="showCommodity" :showCommodity="showCommodity" :product_id="product_id" :merId="merId"
|
<commodityComponent ref="commodityRef" v-if="showCommodity" :key="showCommodity" :showCommodity="showCommodity"
|
||||||
:code="code" @lastStep="lastStep">
|
:product_id="product_id" :merId="merId" :code="code" @lastStep="lastStep">
|
||||||
</commodityComponent>
|
</commodityComponent>
|
||||||
|
|
||||||
<view class="popup_group">
|
<view class="popup_group">
|
||||||
|
@ -58,32 +58,34 @@
|
||||||
<view><span class="iconfont"></span></view>
|
<view><span class="iconfont"></span></view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="popup_group_item">
|
<view class="popup_group_item">
|
||||||
<view class="popup_group_item_label">商品单位</view>
|
<view class="popup_group_item_label">商品单位</view>
|
||||||
<view class="popup_group_item_value"><input v-model="setFormData.unit_name" type="text"
|
<view class="popup_group_item_value"><input v-model="setFormData.unit_name" type="text"
|
||||||
placeholder="请填写商品单位" /></view>
|
placeholder="请填写商品单位" /></view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 选择平台分类弹框 -->
|
<!-- 选择平台分类弹框 -->
|
||||||
<uni-popup ref="select_platform" type="bottom">
|
<uni-popup ref="select_platform" type="bottom">
|
||||||
<platfrom @close="closePlatfrom" :classifiedData="platformClassificationData" @getPlatData="getPlatData">
|
<platfrom @close="closePlatfrom" :classifiedData="platformClassificationData" @getPlatData="getPlatData">
|
||||||
</platfrom>
|
</platfrom>
|
||||||
</uni-popup>
|
</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">
|
||||||
<!-- <view class="popup_group_item" @click="showMoreInfo=!showMoreInfo">
|
<!-- <view class="popup_group_item" @click="showMoreInfo=!showMoreInfo">
|
||||||
<view class="popup_group_item_label">更多信息</view>
|
<view class="popup_group_item_label">更多信息</view>
|
||||||
<view class="popup_group_item_value" :class="showMoreInfo?'icon_bottom':'icon_top'">
|
<view class="popup_group_item_value" :class="showMoreInfo?'icon_bottom':'icon_top'">
|
||||||
<view><span class="iconfont"></span></view>
|
<view><span class="iconfont"></span></view>
|
||||||
</view>
|
</view>
|
||||||
</view> -->
|
</view> -->
|
||||||
<block >
|
<block>
|
||||||
<view class="input_content">
|
<view class="input_content">
|
||||||
<!-- <view class="input_content_describe" style="border-top: none">
|
<!-- <view class="input_content_describe" style="border-top: none">
|
||||||
<view class="input_content_describe_title">
|
<view class="input_content_describe_title">
|
||||||
|
@ -99,7 +101,7 @@
|
||||||
placeholderClass="placeholderClass" maxlength="200" />
|
placeholderClass="placeholderClass" maxlength="200" />
|
||||||
</view>
|
</view>
|
||||||
</view> -->
|
</view> -->
|
||||||
|
|
||||||
<view class="input_content_keyword">
|
<view class="input_content_keyword">
|
||||||
<view class="input_content_keyword_label">关键字</view>
|
<view class="input_content_keyword_label">关键字</view>
|
||||||
<view class="input_content_keyword_value"><input v-model="setFormData.keyword" type="text" value=""
|
<view class="input_content_keyword_value"><input v-model="setFormData.keyword" type="text" value=""
|
||||||
|
@ -118,25 +120,25 @@
|
||||||
</checkbox-group>
|
</checkbox-group>
|
||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="handle">
|
<view class="handle">
|
||||||
<view class="handle_button" @click="submitCreatedGoods">提交</view>
|
<view class="handle_button" @click="submitCreatedGoods">提交</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<uni-popup ref="tempId" type="bottom">
|
<uni-popup ref="tempId" type="bottom">
|
||||||
<linkage-assembly selectProductTitle="选择运费模板" :form="setFormData" :classifiedData="classified['temp_id']"
|
<linkage-assembly selectProductTitle="选择运费模板" :form="setFormData" :classifiedData="classified['temp_id']"
|
||||||
:selectProductItem="productItem" :mer_id="merId" @getLinkageData="getTempIdData" @multipleList="multipleList"
|
:selectProductItem="productItem" :mer_id="merId" @getLinkageData="getTempIdData" @multipleList="multipleList"
|
||||||
@close="$refs.tempId.close()" @scrolltolower="scrolltolower"></linkage-assembly>
|
@close="$refs.tempId.close()" @scrolltolower="scrolltolower"></linkage-assembly>
|
||||||
</uni-popup>
|
</uni-popup>
|
||||||
|
|
||||||
<!-- 图片选择器 -->
|
<!-- 图片选择器 -->
|
||||||
<avatar @upload="doUpload" @getName="getImgName" quality="1" ref="avatar" selWidth="250upx" selHeight="250upx">
|
<avatar @upload="doUpload" @getName="getImgName" quality="1" ref="avatar" selWidth="250upx" selHeight="250upx">
|
||||||
</avatar>
|
</avatar>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -153,14 +155,23 @@
|
||||||
attrList,
|
attrList,
|
||||||
templateList,
|
templateList,
|
||||||
productDetail,
|
productDetail,
|
||||||
getDeliveryType
|
getDeliveryType,
|
||||||
|
productCreate,
|
||||||
|
productUpdate
|
||||||
} from '@/api/product.js';
|
} from '@/api/product.js';
|
||||||
|
import {
|
||||||
|
serialize,
|
||||||
|
Toast,
|
||||||
|
Loading,
|
||||||
|
hideLoading,
|
||||||
|
Modal
|
||||||
|
} from "@/libs/uniApi.js";
|
||||||
import avatar from "@/components/yq-avatar/yq-avatar.vue";
|
import avatar from "@/components/yq-avatar/yq-avatar.vue";
|
||||||
import platfrom from "./components/platform.vue";
|
import platfrom from "./components/platform.vue";
|
||||||
import commodityComponent from "./components/commodity.vue";
|
import commodityComponent from "./components/commodity.vue";
|
||||||
import priceComponent from "./components/price.vue";
|
import priceComponent from "./components/price.vue";
|
||||||
export default {
|
export default {
|
||||||
components:{
|
components: {
|
||||||
avatar,
|
avatar,
|
||||||
platfrom,
|
platfrom,
|
||||||
commodityComponent,
|
commodityComponent,
|
||||||
|
@ -174,11 +185,23 @@
|
||||||
code: '', //商品条码
|
code: '', //商品条码
|
||||||
show: false, //是否预览图片
|
show: false, //是否预览图片
|
||||||
image: false, //预览的图
|
image: false, //预览的图
|
||||||
setFormData:{
|
setFormData: {
|
||||||
store_name: '',
|
store_name: '',
|
||||||
imageList: [],
|
imageList: [],
|
||||||
cate_name: '', //平台分类
|
cate_name: '', //平台名称
|
||||||
unit_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: [], // 平台分类数据
|
platformClassificationData: [], // 平台分类数据
|
||||||
merchantClassification: [], // 店铺分类
|
merchantClassification: [], // 店铺分类
|
||||||
|
@ -207,18 +230,58 @@
|
||||||
onLoad(opt) {
|
onLoad(opt) {
|
||||||
this.merId = Number(opt.mer_id);
|
this.merId = Number(opt.mer_id);
|
||||||
this.product_id = opt.product_id;
|
this.product_id = opt.product_id;
|
||||||
if(!opt.product_id)this.showCommodity=true;
|
if (!opt.product_id) this.showCommodity = true;
|
||||||
this.initData();
|
this.initData();
|
||||||
this.initClasiffy();
|
this.initClasiffy();
|
||||||
},
|
},
|
||||||
onBackPress() {
|
onBackPress() {},
|
||||||
|
|
||||||
},
|
|
||||||
onShow() {
|
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: {
|
methods: {
|
||||||
// 查询详情数据
|
// 查询详情数据
|
||||||
|
@ -253,7 +316,7 @@
|
||||||
}
|
}
|
||||||
productDetail(this.merId, this.product_id).then(res => {
|
productDetail(this.merId, this.product_id).then(res => {
|
||||||
setStorage('editGoodsDetils', res.data);
|
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);
|
this.$store.commit('setStorage', res.data);
|
||||||
let editGoodsDetils = res.data;
|
let editGoodsDetils = res.data;
|
||||||
Object.keys(this.setFormData).forEach(item => {
|
Object.keys(this.setFormData).forEach(item => {
|
||||||
|
@ -288,8 +351,8 @@
|
||||||
editGoodsDetils.temp && (this.setFormData.tempName = editGoodsDetils.temp.name);
|
editGoodsDetils.temp && (this.setFormData.tempName = editGoodsDetils.temp.name);
|
||||||
setStorage('canChange', true);
|
setStorage('canChange', true);
|
||||||
hideLoading();
|
hideLoading();
|
||||||
this.showCommodity = true;
|
this.showCommodity = true;
|
||||||
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
//获取商户分类
|
//获取商户分类
|
||||||
|
@ -301,15 +364,15 @@
|
||||||
this.brand = (await categoryBrandlist(this.merId)).data;
|
this.brand = (await categoryBrandlist(this.merId)).data;
|
||||||
// 获取平台分类
|
// 获取平台分类
|
||||||
let { data } = await categoryList(this.merId);
|
let { data } = await categoryList(this.merId);
|
||||||
data.forEach((item1)=>{
|
data.forEach((item1) => {
|
||||||
item1.children.forEach((item2)=>{
|
item1.children.forEach((item2) => {
|
||||||
item2.children = null;
|
item2.children = null;
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
this.platformClassificationData = data;
|
this.platformClassificationData = data;
|
||||||
},
|
},
|
||||||
// 更新商品条码
|
// 更新商品条码
|
||||||
updateCode(e){
|
updateCode(e) {
|
||||||
this.code = e + '';
|
this.code = e + '';
|
||||||
},
|
},
|
||||||
// 选择图片
|
// 选择图片
|
||||||
|
@ -450,11 +513,59 @@
|
||||||
this.$refs.tempId.open();
|
this.$refs.tempId.open();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// 创建商品
|
// 创建商品
|
||||||
submitCreatedGoods() {
|
submitCreatedGoods() {
|
||||||
console.log('创建商品');
|
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