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", "path" : "addGood/addGood",
"style" : "style" :
{ {
"navigationBarTitleText" : "", "navigationBarTitleText" : "商品设置",
"enablePullDownRefresh" : false
}
},
{
"path" : "addGood/specGood",
"style" :
{
"navigationBarTitleText" : "规格设置",
"enablePullDownRefresh" : false "enablePullDownRefresh" : false
} }
}, },

View File

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

View File

@ -64,6 +64,7 @@
<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>
@ -72,11 +73,34 @@
<platfrom @close="closePlatfrom" :classifiedData="platformClassificationData" @getPlatData="getPlatData"> <platfrom @close="closePlatfrom" :classifiedData="platformClassificationData" @getPlatData="getPlatData">
</platfrom> </platfrom>
</uni-popup> </uni-popup>
<!-- 规格设置 --> <!-- 规格设置 -->
<priceComponent ref="priceRef" :product_id="product_id" :bar_code="code" @updateCode="updateCode" <picker mode="selector" :range="['单规格','多规格']" :value="setFormData.spec_type" @change="changeSpecType">
v-if="showCommodity"> <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> </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">
<!-- <view class="popup_group_item" @click="showMoreInfo=!showMoreInfo"> <!-- <view class="popup_group_item" @click="showMoreInfo=!showMoreInfo">
@ -196,8 +220,8 @@
spec_type: '0', // 0. 1 spec_type: '0', // 0. 1
attr: [], // attr: [], //
specifica: '', // specifica: '', //
setSpecificaValue: '', // // setSpecificaValue: '', //
setSpecificaValue2: '', // setSpecificaValue2: '',
delivery_way: [1, 2], // 1 2 delivery_way: [1, 2], // 1 2
delivery_free: '1', // 0 1 delivery_free: '1', // 0 1
temp_id: '', // ID temp_id: '', // ID
@ -225,56 +249,61 @@
temp_id: [] temp_id: []
}, },
productItem: {} || [], productItem: {} || [],
showSpecType: false, //
spec_type: 0, //,0,1
}; };
}, },
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.showCommodity = true;;
this.initData(); this.initData();
this.initClasiffy(); this.initClasiffy();
this.initDataEditData();
}, },
onBackPress() {}, onBackPress() {},
onShow() { onShow() {
this.setFormData = Object.assign(this.setFormData, { // this.setFormData = Object.assign(this.setFormData, {
"store_name": "方法", // "store_name": "",
"imageList": [ // "imageList": [
"https://lihai001.oss-cn-chengdu.aliyuncs.com/def/457c6202311181745387896.jpeg", // "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/457c6202311181745387896.jpeg",
"https://lihai001.oss-cn-chengdu.aliyuncs.com/def/185e2202311181745434402.jpeg" // "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/185e2202311181745434402.jpeg"
], // ],
"cate_name": "丧葬服务", // "cate_name": "",
"unit_name": "给", // "unit_name": "",
"cate_id": 445, // "cate_id": 445,
"keyword": "22" // "keyword": "22"
}) // })
this.$nextTick(() => { // this.$nextTick(async () => {
this.$refs.commodityRef.addGoodsSecoundData = { // await this.$u.sleep(200)
"is_good": 1, // this.$refs.commodityRef.addGoodsSecoundData = {
"is_gift_bag": 0, // "is_good": 1,
"sort": "20", // "is_gift_bag": 0,
"once_count": "", // "sort": "20",
"video_link": "https://lihai001.oss-cn-chengdu.aliyuncs.com/media/7ce3d202311181816166215.mp4" // "once_count": "",
} // "video_link": "https://lihai001.oss-cn-chengdu.aliyuncs.com/media/7ce3d202311181816166215.mp4"
this.$refs.commodityRef.goodsDis = { // }
"store_name": "", // this.$refs.commodityRef.goodsDis = {
"imageList": [ // "store_name": "",
"https://lihai001.oss-cn-chengdu.aliyuncs.com/def/fb73d202311181751262661.png" // "imageList": [
] // "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/fb73d202311181751262661.png"
} // ]
this.$refs.priceRef.singleSpecification = { // }
"price": "1", // this.$refs.priceRef.singleSpecification = {
"cost": "1", // "price": "1",
"stock": "11", // "cost": "1",
"ot_price": "", // "stock": "11",
"procure_price": "", // "ot_price": "",
"bar_code": "666", // "procure_price": "",
"weight": "10", // "bar_code": "666",
"volume": "5", // "weight": "10",
"image": "", // "volume": "5",
"extension_one": "", // "image": "",
"extension_two": "" // "extension_one": "",
} // "extension_two": ""
}) // }
// })
}, },
beforeDestroy() {}, beforeDestroy() {},
watch: { watch: {
@ -304,20 +333,16 @@
spec_type: '0', // 0. 1 spec_type: '0', // 0. 1
attr: [], // attr: [], //
specifica: '', // specifica: '', //
setSpecificaValue: '', // // setSpecificaValue: '', //
setSpecificaValue2: '', // // setSpecificaValue2: '', //
delivery_way: [], // 1 2 delivery_way: [], // 1 2
delivery_free: '0', // 0 1 delivery_free: '0', // 0 1
temp_id: '', // ID temp_id: '', // ID
tempName: '' // tempName: '' //
}; };
if (getStorage('editGoodsDetils')) { productDetail(this.merId, this.product_id).then(async (res) => {
removeStorage('editGoodsDetils'); this.showCommodity = true;
}
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; let editGoodsDetils = res.data;
Object.keys(this.setFormData).forEach(item => { Object.keys(this.setFormData).forEach(item => {
this.setFormData[item] = editGoodsDetils[item]; this.setFormData[item] = editGoodsDetils[item];
@ -332,27 +357,30 @@
item => item item => item
.category && item.category.cate_name).join(',') : ''; .category && item.category.cate_name).join(',') : '';
this.setFormData.brand_name = editGoodsDetils.brand ? editGoodsDetils.brand.brand_name : ''; 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 (this.setFormData.spec_type == 1) {
if (editGoodsDetils.attr.length) {
this.setFormData.specifica = '点击修改规格'
}
if (editGoodsDetils.attrValue.length) {
this.setFormData.setSpecificaValue2 = '点击修改价格'
}
} }
if (editGoodsDetils.spec_type == 0) { if (this.setFormData.spec_type == 0) {
setStorage('singleSpecification', editGoodsDetils.attrValue[0]); this.$refs.priceRef.setDatas(res.data.attrValue[0]);
if (editGoodsDetils.attrValue.length) {
this.setFormData.setSpecificaValue = '点击修改价格'
}
} }
setStorage('attrValue', editGoodsDetils.attrValue);
editGoodsDetils.temp && (this.setFormData.tempName = editGoodsDetils.temp.name); editGoodsDetils.temp && (this.setFormData.tempName = editGoodsDetils.temp.name);
setStorage('canChange', true);
hideLoading(); hideLoading();
this.showCommodity = true;
}); });
}, },
// //
@ -528,7 +556,7 @@
image: this.$refs.commodityRef.goodsDis?.imageList || [] image: this.$refs.commodityRef.goodsDis?.imageList || []
}, },
video_link: this.$refs.commodityRef.addGoodsSecoundData.video_link, 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; postData.stock = postData.attrValue[0]?.stock||0;
// return console.log('', postData); // return console.log('', postData);
@ -540,7 +568,6 @@
Modal('提交成功', '点击确定,返回商品管理', { Modal('提交成功', '点击确定,返回商品管理', {
showCancel: false showCancel: false
}).then(() => { }).then(() => {
uni.removeStorageSync('singleSpecification')
uni.redirectTo({ uni.redirectTo({
url: '/pages/product/goodsOnSale/index?mer_id=' + this.merId 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> </script>

View File

@ -164,13 +164,6 @@
}, },
mounted() { mounted() {
this.initData();
// this.$nextTick(()=>{
// this.initData();
// })
},
updated() {
// this.initData();
}, },
methods: { methods: {
videoshow() { videoshow() {
@ -179,52 +172,10 @@
this.$nextTick(() => { this.$nextTick(() => {
this.videoContext.play(); this.videoContext.play();
}) })
// this.video_link = this.formData.video_link;
// this.videoContext.requestFullScreen({ direction: 90 });
// this.videoContext.play(); this.videoplay = true;
}, },
initData() { setDatas(data){
let editGoodsDetils = {}; this.addGoodsSecoundData = data.addGoodsSecoundData;
if (getStorage('goodsDis')) { this.goodsDis = data.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');
}, },
// //
isGood(e) { isGood(e) {

View File

@ -164,6 +164,9 @@
this.formList.splice(4, this.formList.length); this.formList.splice(4, this.formList.length);
else this.formList.splice(3, this.formList.length); else this.formList.splice(3, this.formList.length);
}, },
setDatas(data){
this.singleSpecification = data;
},
input(val) { input(val) {
this.singleSpecification = 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 => { 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;
if(typeof res.data.content == 'string')res.data.content = JSON.parse(res.data.content);
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 => {

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 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 != 1 && type != 3" @click="handleDelete(item, index)">删除</view>
<view class="shop_button" v-if="type == 5" @click="reduction(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> </view>
</view> </view>
@ -209,7 +209,7 @@ export default {
removeStorage(item); 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) { 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 mer_id: this.mer_id
}); });
}, },
@ -580,23 +580,23 @@
); );
}, },
editGoods(item) { editGoods(item) {
let waitDeleteData = [ // let waitDeleteData = [
'addGoodsFormData', // 'addGoodsFormData',
'singleSpecification', // 'singleSpecification',
'attrValue', // 'attrValue',
'modifyPriceData', // 'modifyPriceData',
'addGoodsSecoundData', // 'addGoodsSecoundData',
'goodsDis', // 'goodsDis',
'editGoodsDetils', // 'editGoodsDetils',
'canChange', // 'canChange',
'canChangeSecound' // 'canChangeSecound'
]; // ];
waitDeleteData.forEach(item => { // waitDeleteData.forEach(item => {
if (getStorage(item)) { // if (getStorage(item)) {
removeStorage(item); // removeStorage(item);
} // }
}); // });
navigateTo(1, '/pages/product/addGoods/index', { navigateTo(1, '/pages/product/addGood/addGood', {
mer_id: item.mer_id, mer_id: item.mer_id,
product_id: item.product_id product_id: item.product_id
}); });