This commit is contained in:
weipengfei 2023-11-20 14:53:54 +08:00
parent 3d93e06173
commit d8c0bbe9cf
9 changed files with 191 additions and 146 deletions

View File

@ -1332,7 +1332,15 @@
"path" : "addGood/addGood",
"style" :
{
"navigationBarTitleText" : "",
"navigationBarTitleText" : "商品设置",
"enablePullDownRefresh" : false
}
},
{
"path" : "addGood/specGood",
"style" :
{
"navigationBarTitleText" : "规格设置",
"enablePullDownRefresh" : false
}
},

View File

@ -528,7 +528,7 @@
Toast("暂无搜索商品,请添加!")
setTimeout(() => {
uni.navigateTo({
url: `/pages/product/addGoods/index?mer_id=${rq.mer_id}`
url: `/pages/product/addGood/addGood?mer_id=${rq.mer_id}`
})
}, 2000)
return
@ -646,8 +646,8 @@
},
navToAdd(){
let url;
if(this.showModelCode) url = `/pages/product/addGoods/index?mer_id=${this.mer_id}&code=${this.showModelCode}`;
else url = `/pages/product/addGoods/index?mer_id=${this.mer_id}`;
if(this.showModelCode) url = `/pages/product/addGood/addGood?mer_id=${this.mer_id}&code=${this.showModelCode}`;
else url = `/pages/product/addGood/addGood?mer_id=${this.mer_id}`;
uni.navigateTo({
url:url,
success:()=> {
@ -667,7 +667,7 @@
}
})
}
navigateTo(1, '/pages/product/addGoods/index', {
navigateTo(1, '/pages/product/addGood/addGood', {
mer_id: this.mer_id
});
},

View File

@ -65,6 +65,7 @@
placeholder="请填写商品单位" /></view>
</view>
</view>
<!-- 选择平台分类弹框 -->
@ -73,10 +74,33 @@
</platfrom>
</uni-popup>
<!-- 规格设置 -->
<priceComponent ref="priceRef" :product_id="product_id" :bar_code="code" @updateCode="updateCode"
v-if="showCommodity">
<picker mode="selector" :range="['单规格','多规格']" :value="setFormData.spec_type" @change="changeSpecType">
<view class="popup_group" style="margin-bottom: 0;">
<view class="popup_group_item">
<view class="popup_group_item_label">商品规格</view>
<view class="popup_group_item_value">
<view class="popup_group_item_message">
<span class="popup_group_item_message_value">{{ setFormData.spec_type==0?'单规格':'多规格' }}</span>
</view>
<view><span class="iconfont">&#xe6bd;</span></view>
</view>
</view>
</view>
<u-modal :show="showSpecType" title="温馨提示" content="切换后商品原有规格将失效,是否继续?"
show-cancel-button confirm-text="继续" @confirm="changeSpecType2" @cancel="showSpecType=false"
></u-modal>
</picker>
<priceComponent v-if="setFormData.spec_type==0" ref="priceRef" :product_id="product_id" :bar_code="code" @updateCode="updateCode">
</priceComponent>
<view v-else class="popup_group" style="margin-top: 0;border-top: 1rpx solid #eeeeee;">
<view class="popup_group_item" @click="navToSpecGood()">
<view class="popup_group_item_label" style="flex: 1; text-align: center;">设置多规格</view>
</view>
</view>
<view class="popup_group">
<!-- <view class="popup_group_item" @click="showMoreInfo=!showMoreInfo">
@ -196,8 +220,8 @@
spec_type: '0', // 0. 1
attr: [], //
specifica: '', //
setSpecificaValue: '', //
setSpecificaValue2: '',
// setSpecificaValue: '', //
// setSpecificaValue2: '',
delivery_way: [1, 2], // 1 2
delivery_free: '1', // 0 1
temp_id: '', // ID
@ -225,56 +249,61 @@
temp_id: []
},
productItem: {} || [],
showSpecType: false, //
spec_type: 0, //,0,1
};
},
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.showCommodity = true;;
this.initData();
this.initClasiffy();
this.initDataEditData();
},
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": ""
}
})
// 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(async () => {
// await this.$u.sleep(200)
// 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() {},
watch: {
@ -304,20 +333,16 @@
spec_type: '0', // 0. 1
attr: [], //
specifica: '', //
setSpecificaValue: '', //
setSpecificaValue2: '', //
// setSpecificaValue: '', //
// setSpecificaValue2: '', //
delivery_way: [], // 1 2
delivery_free: '0', // 0 1
temp_id: '', // ID
tempName: '' //
};
if (getStorage('editGoodsDetils')) {
removeStorage('editGoodsDetils');
}
productDetail(this.merId, this.product_id).then(res => {
setStorage('editGoodsDetils', res.data);
productDetail(this.merId, this.product_id).then(async (res) => {
this.showCommodity = true;
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 => {
this.setFormData[item] = editGoodsDetils[item];
@ -332,26 +357,29 @@
item => item
.category && item.category.cate_name).join(',') : '';
this.setFormData.brand_name = editGoodsDetils.brand ? editGoodsDetils.brand.brand_name : '';
if(typeof res.data.content == 'string')res.data.content = JSON.parse(res.data.content);
//
this.$refs.commodityRef.setDatas({
addGoodsSecoundData: {
is_good: res.data.is_good, //
is_gift_bag: res.data.is_gift_bag,
sort: res.data.sort,
once_count: res.data.once_count, //
video_link: res.data.video_link,
},
goodsDis: {
store_name: res.data.content?.title,
imageList: res.data.content?.image
}
})
//
if (this.setFormData.spec_type == 1) {
if (editGoodsDetils.attr.length) {
this.setFormData.specifica = '点击修改规格'
}
if (editGoodsDetils.attrValue.length) {
this.setFormData.setSpecificaValue2 = '点击修改价格'
if (this.setFormData.spec_type == 0) {
this.$refs.priceRef.setDatas(res.data.attrValue[0]);
}
}
if (editGoodsDetils.spec_type == 0) {
setStorage('singleSpecification', editGoodsDetils.attrValue[0]);
if (editGoodsDetils.attrValue.length) {
this.setFormData.setSpecificaValue = '点击修改价格'
}
}
setStorage('attrValue', editGoodsDetils.attrValue);
editGoodsDetils.temp && (this.setFormData.tempName = editGoodsDetils.temp.name);
setStorage('canChange', true);
hideLoading();
this.showCommodity = true;
});
},
@ -528,7 +556,7 @@
image: this.$refs.commodityRef.goodsDis?.imageList || []
},
video_link: this.$refs.commodityRef.addGoodsSecoundData.video_link,
attrValue: this.$refs.priceRef.singleSpecification
attrValue: [this.$refs.priceRef.singleSpecification]
};
postData.stock = postData.attrValue[0]?.stock||0;
// return console.log('', postData);
@ -540,7 +568,6 @@
Modal('提交成功', '点击确定,返回商品管理', {
showCancel: false
}).then(() => {
uni.removeStorageSync('singleSpecification')
uni.redirectTo({
url: '/pages/product/goodsOnSale/index?mer_id=' + this.merId
})
@ -567,6 +594,27 @@
});
}
},
//
changeSpecType(e){
if(this.setFormData.spec_type!=e.detail.value){
this.showSpecType = true;
}
this.spec_type = e.detail.value;
},
//
changeSpecType2(){
this.showSpecType = false;
this.setFormData.spec_type = this.spec_type + '';
},
//
navToSpecGood(){
uni.navigateTo({
url:'/pages/product/addGood/specGood?product_id=' + this.product_id,
success: (e) => {
uni.$emit()
}
})
}
}
};
</script>

View File

@ -164,13 +164,6 @@
},
mounted() {
this.initData();
// this.$nextTick(()=>{
// this.initData();
// })
},
updated() {
// this.initData();
},
methods: {
videoshow() {
@ -179,52 +172,10 @@
this.$nextTick(() => {
this.videoContext.play();
})
// this.video_link = this.formData.video_link;
// this.videoContext.requestFullScreen({ direction: 90 });
// this.videoContext.play(); this.videoplay = true;
},
initData() {
let editGoodsDetils = {};
if (getStorage('goodsDis')) {
this.disModel = true;
}
if (this.product_id) {
editGoodsDetils = this.$store.state.storage.storage;
Object.keys(this.addGoodsSecoundData).forEach(item => {
// console.log(item, editGoodsDetils[item]);
this.addGoodsSecoundData[item] = editGoodsDetils[item];
});
if (editGoodsDetils.content) {
this.goodsDis.imageList = editGoodsDetils.content.image;
this.goodsDis.store_name = editGoodsDetils.content.title;
this.store_name = editGoodsDetils.content.title;
// console.log(this.goodsDis, editGoodsDetils.content);
setStorage('goodsDis', {
store_name: editGoodsDetils.content.title,
imageList: editGoodsDetils.content.image
});
this.disModel = true;
}
setStorage('canChangeSecound', true);
return;
}else {
setStorage('goodsDis', {
store_name: '',
imageList: []
});
}
if (getStorage('addGoodsSecoundData')) {
Object.keys(this.addGoodsSecoundData).forEach(item => {
if (getStorage('addGoodsSecoundData')[item] || getStorage('addGoodsSecoundData')[item] == 0) {
this.addGoodsSecoundData[item] = getStorage('addGoodsSecoundData')[item];
}
});
}
},
lastStep() {
this.$emit('lastStep');
setDatas(data){
this.addGoodsSecoundData = data.addGoodsSecoundData;
this.goodsDis = data.goodsDis;
},
//
isGood(e) {

View File

@ -164,6 +164,9 @@
this.formList.splice(4, this.formList.length);
else this.formList.splice(3, this.formList.length);
},
setDatas(data){
this.singleSpecification = data;
},
input(val) {
this.singleSpecification = val
},

View File

@ -0,0 +1,34 @@
<template>
<view>
<block v-for="item in attrValue">
<priceComponent ref="priceRef" :product_id="item.product_id" :bar_code="item.code" @updateCode="updateCode">
</priceComponent>
</block>
</view>
</template>
<script>
import priceComponent from "./components/price.vue";
export default {
components:{
priceComponent
},
data(){
return{
attrValue: [],
product_id: ''
}
},
onLoad(options) {
this.product_id = options.product_id
},
methods:{
updateCode(e){
console.log(e);
}
}
}
</script>
<style>
</style>

View File

@ -597,6 +597,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(typeof res.data.content == 'string')res.data.content = JSON.parse(res.data.content);
this.$store.commit('setStorage', res.data);
let editGoodsDetils = res.data;
Object.keys(this.setFormData).forEach(item => {

View File

@ -55,7 +55,7 @@
<view v-if="item.is_show == 0 && item.status == 1 && type != 5" class="shop_button" @click="upperShelfAndLowerShelf(item, index)">上架</view>
<view class="shop_button" v-if="type != 1 && type != 3" @click="handleDelete(item, index)">删除</view>
<view class="shop_button" v-if="type == 5" @click="reduction(item, index)">恢复</view>
<navigator :url="`/pages/product/addGoods/index?mer_id=${merId}&product_id=${item.product_id}`" v-if="type != 5" class="shop_button" hover-class="none">编辑</navigator>
<navigator :url="`/pages/product/addGood/addGood?mer_id=${merId}&product_id=${item.product_id}`" v-if="type != 5" class="shop_button" hover-class="none">编辑</navigator>
</view>
</view>
</view>
@ -209,7 +209,7 @@ export default {
removeStorage(item);
}
});
navigateTo(1, '/pages/product/addGoods/index', { mer_id: this.merId, type: 'edit', product_id: item.product_id, type: 'edit' });
navigateTo(1, '/pages/product/addGood/addGood', { mer_id: this.merId, type: 'edit', product_id: item.product_id, type: 'edit' });
},
//
handleDelete(item, index) {

View File

@ -541,7 +541,7 @@
}
})
}
navigateTo(1, '/pages/product/addGoods/index', {
navigateTo(1, '/pages/product/addGood/addGood', {
mer_id: this.mer_id
});
},
@ -580,23 +580,23 @@
);
},
editGoods(item) {
let waitDeleteData = [
'addGoodsFormData',
'singleSpecification',
'attrValue',
'modifyPriceData',
'addGoodsSecoundData',
'goodsDis',
'editGoodsDetils',
'canChange',
'canChangeSecound'
];
waitDeleteData.forEach(item => {
if (getStorage(item)) {
removeStorage(item);
}
});
navigateTo(1, '/pages/product/addGoods/index', {
// let waitDeleteData = [
// 'addGoodsFormData',
// 'singleSpecification',
// 'attrValue',
// 'modifyPriceData',
// 'addGoodsSecoundData',
// 'goodsDis',
// 'editGoodsDetils',
// 'canChange',
// 'canChangeSecound'
// ];
// waitDeleteData.forEach(item => {
// if (getStorage(item)) {
// removeStorage(item);
// }
// });
navigateTo(1, '/pages/product/addGood/addGood', {
mer_id: item.mer_id,
product_id: item.product_id
});