修复bug

This commit is contained in:
weipengfei 2023-09-28 11:18:19 +08:00
parent 124fbeefca
commit 61049a01dc
5 changed files with 1146 additions and 1073 deletions

View File

@ -2,7 +2,7 @@
<view class=" writeBg "> <view class=" writeBg ">
<view class="content_list"> <view class="content_list">
<view class="content_list_item" @click="inputGoodsDetils"> <view class="content_list_item">
<view>商品详情</view> <view>商品详情</view>
<!-- <view class="content_list_item_han"> <!-- <view class="content_list_item_han">
<span v-if="disModel" style="color: #000000">去修改</span> <span v-if="disModel" style="color: #000000">去修改</span>
@ -73,13 +73,13 @@
<span>开启后此商品只能在分销礼包中展示并销售</span> <span>开启后此商品只能在分销礼包中展示并销售</span>
</view> --> </view> -->
<view class="container_input marginTop_none input-goods-detils"> <view class="container_input marginTop_none input-goods-detils">
<view class="container_input_item"> <!-- <view class="container_input_item">
<view class="container_input_item_label"><span>限购数量</span></view> <view class="container_input_item_label"><span>限购数量</span></view>
<view class="container_input_item_value"> <view class="container_input_item_value">
<input v-model="addGoodsSecoundData.once_count" type="number" value="" placeholder="请输入限购数量" <input v-model="addGoodsSecoundData.once_count" type="number" value="" placeholder="请输入限购数量"
placeholder-class="inputPlaceHolder" /> placeholder-class="inputPlaceHolder" />
</view> </view>
</view> </view> -->
<view class="container_input_item"> <view class="container_input_item">
<view class="container_input_item_label"><span>商品排序</span></view> <view class="container_input_item_label"><span>商品排序</span></view>
<view class="container_input_item_value"> <view class="container_input_item_value">
@ -140,6 +140,10 @@
type: [String, Number], type: [String, Number],
default: '' default: ''
}, },
showCommodity: {
type: Boolean,
default: false
},
resetKey: { resetKey: {
type: Boolean, type: Boolean,
default: false default: false
@ -162,22 +166,26 @@
once_count: '', // once_count: '', //
video_link: '' video_link: ''
}, },
goodsDis: {imageList: []}, goodsDis: {imageList: [],store_name:""},
store_name:'', store_name:'',
moreThanFlag: true, moreThanFlag: true,
}; };
}, },
created() { mounted() {
// console.log('123');
this.initData(); this.initData();
// this.$nextTick(()=>{
// this.initData();
// })
},
updated() {
// this.initData();
}, },
watch: { watch: {
addGoodsSecoundData: { addGoodsSecoundData: {
handler(val) { handler(val) {
setTimeout(() => { setTimeout(() => {
setStorage(this.product_id ? 'editGoodsDetils' : 'addGoodsSecoundData', val) setStorage('editCommodity', val)
}); });
}, },
deep: true deep: true
@ -214,12 +222,21 @@
this.disModel = true; this.disModel = true;
} }
if (this.product_id) { if (this.product_id) {
editGoodsDetils = getStorage('editGoodsDetils'); // editGoodsDetils = getStorage('editGoodsDetils');
editGoodsDetils = this.$store.state.storage.storage;
console.log(editGoodsDetils);
// editGoodsDetils = getStorage('editGoodsDetils');
// console.log('',editGoodsDetils);
Object.keys(this.addGoodsSecoundData).forEach(item => { Object.keys(this.addGoodsSecoundData).forEach(item => {
console.log(item, editGoodsDetils[item]);
this.addGoodsSecoundData[item] = editGoodsDetils[item]; this.addGoodsSecoundData[item] = editGoodsDetils[item];
}); });
if (editGoodsDetils.content) { 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', { setStorage('goodsDis', {
store_name: editGoodsDetils.content.title, store_name: editGoodsDetils.content.title,
imageList: editGoodsDetils.content.image imageList: editGoodsDetils.content.image
@ -228,6 +245,11 @@
} }
setStorage('canChangeSecound', true); setStorage('canChangeSecound', true);
return; return;
}else {
setStorage('goodsDis', {
store_name: '',
imageList: []
});
} }
if (getStorage('addGoodsSecoundData')) { if (getStorage('addGoodsSecoundData')) {
@ -236,10 +258,6 @@
this.addGoodsSecoundData[item] = getStorage('addGoodsSecoundData')[item]; this.addGoodsSecoundData[item] = getStorage('addGoodsSecoundData')[item];
} }
}); });
} }
}, },
lastStep() { lastStep() {
@ -514,7 +532,7 @@
border-radius: 50%; border-radius: 50%;
padding: 8rpx; padding: 8rpx;
background: #e93323; background: #e93323;
z-index: 999; z-index: 2;
} }
video { video {

File diff suppressed because it is too large Load Diff

View File

@ -1,202 +1,222 @@
<template> <template>
<view class="container"> <view class="container">
<select-form style="border-radius: 10rpx 10rpx 0 0;" :platformClassification="formList" :form="singleSpecification" @input="input"></select-form> <select-form style="border-radius: 10rpx 10rpx 0 0;" :platformClassification="formList" :form="singleSpecification"
<view class="more_than" @click="moreThanFlag?selectMoreThan():spliceMoreThan()" > @input="input"></select-form>
<view v-if="moreThanFlag">更多</view> <view class="more_than" @click="moreThanFlag?selectMoreThan():spliceMoreThan()">
<view v-if="moreThanFlag">更多</view>
<view v-else>收起</view> <view v-else>收起</view>
</view> </view>
<!-- <view class="handle"> <!-- <view class="handle">
<view class="button" @click="saveSingleSpecification"> <view class="button" @click="saveSingleSpecification">
保存 保存
</view> </view>
</view> --> </view> -->
</view> </view>
</template> </template>
<script> <script>
import selectForm from '../components/selectForm.vue'; import selectForm from '../components/selectForm.vue';
import { navigateTo, navigateBack, serialize, setStorage, getStorage } from '../../../libs/uniApi.js'; import { navigateTo, navigateBack, serialize, setStorage, getStorage } from '../../../libs/uniApi.js';
// attrValue // attrValue
export default { export default {
components:{ components: {
selectForm selectForm
}, },
data() { props: ['product_id'],
return { data() {
singleSpecification: { return {
price: '', // singleSpecification: {
cost: '', // price: '', //
ot_price: '', // cost: '', //
bar_code: '', // stock: '', //
weight: '', // ot_price: '', //
volume: '', // bar_code: '', //
image: '', weight: '', //
extension_one: '', volume: '', //
extension_two: '' image: '',
}, extension_one: '',
moreThanFlag: true, extension_two: ''
formList: [ },
{ moreThanFlag: true,
id: 1, formList: [{
label: '售价', id: 1,
type: 'digit', label: '售价',
model: 'price', type: 'digit',
holder: '请填写售价' model: 'price',
}, holder: '请填写售价'
{ }],
id: 0, moreThanList: [{
label: '库存', id: 2,
type: 'digit', label: '成本价',
model: 'stock_num', type: 'digit',
holder: '请填写库存' holder: '请填写成本价',
}, model: 'cost'
],
moreThanList: [
{
id: 2,
label: '成本价',
type: 'digit',
holder: '请填写成本价',
model: 'cost'
}, },
{ {
id: 3, id: 3,
label: '原价', label: '原价',
type: 'digit', type: 'digit',
holder: '请填写原价', holder: '请填写原价',
model: 'ot_price' model: 'ot_price'
}, },
{ {
id: 5, id: 5,
label: '商品编号', label: '商品编号',
type: 'input', type: 'input',
holder: '请填写商品编号', holder: '请填写商品编号',
model: 'bar_code' model: 'bar_code'
}, },
{ {
id: 6, id: 6,
label: '重量', label: '重量',
type: 'digit', type: 'digit',
holder: '请输入重量', holder: '请输入重量',
model: 'weight' model: 'weight'
}, },
{ {
id: 7, id: 7,
label: '体积', label: '体积',
type: 'digit', type: 'digit',
holder: '请输入体积', holder: '请输入体积',
model: 'volume' model: 'volume'
}, },
// { // {
// id: 8, // id: 8,
// label: '', // label: '',
// type: 'digit', // type: 'digit',
// holder: '', // holder: '',
// model: 'extension_one' // model: 'extension_one'
// }, // },
// { // {
// id: 9, // id: 9,
// label: '', // label: '',
// type: 'digit', // type: 'digit',
// holder: '', // holder: '',
// model: 'extension_two' // model: 'extension_two'
// } // }
], ],
} }
}, },
watch: { watch: {
singleSpecification: { singleSpecification: {
handler(val) { handler(val) {
this.singleSpecification = val; this.singleSpecification = val;
this.saveSingleSpecification(); this.saveSingleSpecification();
}, },
deep: true deep: true
} }
}, },
// onLoad(option) { // onLoad(option) {
// console.log(option); // console.log(option);
// this.singleSpecification.bar_code=option.code // this.singleSpecification.bar_code=option.code
// }, // },
// onShow() { // onShow() {
// if(getStorage('addGoodsFormData').image) { // if(getStorage('addGoodsFormData').image) {
// this.singleSpecification.image = getStorage('addGoodsFormData').image; // this.singleSpecification.image = getStorage('addGoodsFormData').image;
// } // }
// if(getStorage('singleSpecification')) { // if(getStorage('singleSpecification')) {
// Object.keys(this.singleSpecification).forEach(item => { // Object.keys(this.singleSpecification).forEach(item => {
// if(getStorage('singleSpecification')[item]) { // if(getStorage('singleSpecification')[item]) {
// this.singleSpecification[item] = getStorage('singleSpecification')[item] // this.singleSpecification[item] = getStorage('singleSpecification')[item]
// } // }
// }) // })
// } // }
// }, // },
// beforeDestroy() { // beforeDestroy() {
// console.log('123'); // console.log('123');
// uni.removeStorage({ // uni.removeStorage({
// key: 'singleSpecification' // key: 'singleSpecification'
// }); // });
// }, // },
methods: { mounted() {
selectMoreThan() { if (getStorage('addGoodsFormData').image) {
this.formList = this.formList.concat(this.moreThanList); this.singleSpecification.image = getStorage('addGoodsFormData').image;
this.moreThanFlag = false; }
}, if (getStorage('singleSpecification')) {
spliceMoreThan() { Object.keys(this.singleSpecification).forEach(item => {
this.moreThanFlag = true; if (getStorage('singleSpecification')[item]) {
this.formList.splice(2, this.formList.length); this.singleSpecification[item] = getStorage('singleSpecification')[item]
}, }
input(val) { })
this.singleSpecification = val }
}, if (!this.$props.product_id) {
// this.formList.push({
saveSingleSpecification() { id: 10,
setStorage('singleSpecification', this.singleSpecification); label: '库存',
// navigateBack(1); type: 'digit',
} model: 'stock',
} holder: '请填写库存',
} disable: true
})
}
},
destroyed() {
setStorage('singleSpecification', {});
},
methods: {
selectMoreThan() {
this.formList = this.formList.concat(this.moreThanList);
this.moreThanFlag = false;
},
spliceMoreThan() {
this.moreThanFlag = true;
this.formList.splice(!this.$props.product_id?2:1, this.formList.length);
},
input(val) {
this.singleSpecification = val
},
//
saveSingleSpecification() {
setStorage('singleSpecification', this.singleSpecification);
// navigateBack(1);
}
}
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.container { .container {
padding: 0 !important; padding: 0 !important;
} }
.more_than {
background: #FFFFFF; .more_than {
border-radius: 0 0 10rpx 10rpx; background: #FFFFFF;
margin: auto; border-radius: 0 0 10rpx 10rpx;
// margin-top: 30rpx; margin: auto;
margin-top: 1px; // margin-top: 30rpx;
display: flex; margin-top: 1px;
align-items: center; display: flex;
justify-content: center; align-items: center;
width: 710rpx; justify-content: center;
height: 84rpx; width: 710rpx;
color: #333333; height: 84rpx;
font-size: 30rpx; color: #333333;
} font-size: 30rpx;
}
.handle {
position: fixed; .handle {
left: 0; position: fixed;
bottom: 0; left: 0;
width: 100%; bottom: 0;
height: 126rpx; width: 100%;
background: #FFFFFF; height: 126rpx;
display: flex; background: #FFFFFF;
align-items: center; display: flex;
justify-content: center; align-items: center;
.button { justify-content: center;
display: flex;
align-items: center; .button {
justify-content: center; display: flex;
color: #FFFFFF; align-items: center;
font-size: 32rpx; justify-content: center;
width: 690rpx; color: #FFFFFF;
height: 86rpx; font-size: 32rpx;
background: #E93323; width: 690rpx;
border-radius: 43rpx; height: 86rpx;
} background: #E93323;
} border-radius: 43rpx;
</style> }
}
</style>

View File

@ -50,41 +50,42 @@
<view class="content_list_video"> <view class="content_list_video">
<view class="content_list_video_title">商品视频</view> <view class="content_list_video_title">商品视频</view>
<view class="video_list"> <view class="video_list">
<view class="video_list_item photo" v-if="addGoodsSecoundData.video_link"> <view class="video_list_item photo" v-if="addGoodsSecoundData.video_link">
<view class="jiao" @click="deleteImage()"> <view class="jiao" @click="deleteImage()">
<!-- video标签在app端层级过高 --> <!-- video标签在app端层级过高 -->
<!--#ifndef APP-PLUS--> <!--#ifndef APP-PLUS-->
<video :src="addGoodsSecoundData.video_link"></video> <video :src="addGoodsSecoundData.video_link"></video>
<!--#endif--> <!--#endif-->
<!--#ifdef APP-PLUS--> <!--#ifdef APP-PLUS-->
<img src="https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/3/video_bg.png" style=" width:150rpx" ></img> <img src="https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/3/video_bg.png"
<!--#endif--> style=" width:150rpx"></img>
<!--#endif-->
<image src="../static/images/close.png" mode="widthFix"></image> <image src="../static/images/close.png" mode="widthFix"></image>
</view> </view>
<!--#ifndef APP-PLUS--> <!--#ifndef APP-PLUS-->
<view style="position: absolute;"> <view style="position: absolute;">
<view class="videoHover" @click="videoshow"> <view class="videoHover" @click="videoshow">
</view> </view>
<text class="video-text">点击可预览视频</text> <text class="video-text">点击可预览视频</text>
</view> </view>
<!--#endif--> <!--#endif-->
<!--#ifdef APP-PLUS--> <!--#ifdef APP-PLUS-->
<view class='preview_video'> <view class='preview_video'>
<view class="videoHover" @click="videoshow"> <view class="videoHover" @click="videoshow">
</view> </view>
<text class="video-text">点击可预览视频</text> <text class="video-text">点击可预览视频</text>
</view> </view>
<!--#endif--> <!--#endif-->
</view> </view>
<view class="photo" @click="uploadVideo" v-else> <view class="photo" @click="uploadVideo" v-else>
<view> <view>
<image src="../static/images/creamer.png" mode="widthFix"></image> <image src="../static/images/creamer.png" mode="widthFix"></image>
@ -93,18 +94,18 @@
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<view v-if="showVideo" class="video-count"> <view v-if="showVideo" class="video-count">
<!--#ifndef APP-PLUS--> <!--#ifndef APP-PLUS-->
<video id="myVideo" class="videoLink" autoplay loop muted :src="addGoodsSecoundData.video_link"></video> <video id="myVideo" class="videoLink" autoplay loop muted :src="addGoodsSecoundData.video_link"></video>
<!--#endif--> <!--#endif-->
<!--#ifdef APP-PLUS--> <!--#ifdef APP-PLUS-->
<video id="myVideo" class="videoLink" autoplay loop <video id="myVideo" class="videoLink" autoplay loop
:src='addGoodsSecoundData.video_link && (addGoodsSecoundData.video_link.substring(0,4) == "http" || addGoodsSecoundData.video_link.substring(0,5) == "https") ?addGoodsSecoundData.video_link : "http:" + addGoodsSecoundData.video_link'></video> :src='addGoodsSecoundData.video_link && (addGoodsSecoundData.video_link.substring(0,4) == "http" || addGoodsSecoundData.video_link.substring(0,5) == "https") ?addGoodsSecoundData.video_link : "http:" + addGoodsSecoundData.video_link'></video>
<!--#endif--> <!--#endif-->
</view> </view>
<view class='mask' catchtouchmove="true" :hidden='showVideo==false' @tap="showVideo=false"></view> <view class='mask' catchtouchmove="true" :hidden='showVideo==false' @tap="showVideo=false"></view>
<view class="handle dobuButton"> <view class="handle dobuButton">
<view class="handle_button margin_right" @click="lastStep">上一步</view> <view class="handle_button margin_right" @click="lastStep">上一步</view>
<view class="handle_button" @click="submitCreatedGoods">提交</view> <view class="handle_button" @click="submitCreatedGoods">提交</view>
@ -154,7 +155,7 @@
data() { data() {
return { return {
showComponent: false, showComponent: false,
showVideo:false, showVideo: false,
disModel: false, disModel: false,
upload_max: 10, upload_max: 10,
uploadUrl: `${HTTP_REQUEST_URL}/api/upload/video`, uploadUrl: `${HTTP_REQUEST_URL}/api/upload/video`,
@ -172,7 +173,7 @@
// console.log('123'); // console.log('123');
this.initData(); this.initData();
}, },
watch: { watch: {
addGoodsSecoundData: { addGoodsSecoundData: {
handler(val) { handler(val) {
@ -190,16 +191,16 @@
} }
}, },
methods: { methods: {
videoshow() { videoshow() {
this.showVideo = true this.showVideo = true
this.videoContext = uni.createVideoContext('myVideo', this); this.videoContext = uni.createVideoContext('myVideo', this);
this.$nextTick(() => { this.$nextTick(() => {
this.videoContext.play(); this.videoContext.play();
}) })
// this.video_link = this.formData.video_link; // this.video_link = this.formData.video_link;
// this.videoContext.requestFullScreen({ direction: 90 }); // this.videoContext.requestFullScreen({ direction: 90 });
// this.videoContext.play(); this.videoplay = true; // this.videoContext.play(); this.videoplay = true;
}, },
initData() { initData() {
let editGoodsDetils = {}; let editGoodsDetils = {};
if (getStorage('goodsDis')) { if (getStorage('goodsDis')) {
@ -241,7 +242,7 @@
submitCreatedGoods() { submitCreatedGoods() {
Loading(); Loading();
let waitDeleteData = ['addGoodsFormData', 'singleSpecification', 'attrValue', 'modifyPriceData', let waitDeleteData = ['addGoodsFormData', 'singleSpecification', 'attrValue', 'modifyPriceData',
'addGoodsSecoundData', 'goodsDis', 'editGoodsDetils', 'canChange', 'canChangeSecound' 'addGoodsSecoundData', 'goodsDis', 'editGoodsDetils', 'canChange', 'canChangeSecound', 'editCommodity'
]; ];
let attrValue = getStorage('addGoodsFormData').spec_type == 0 ? [getStorage('singleSpecification')] : let attrValue = getStorage('addGoodsFormData').spec_type == 0 ? [getStorage('singleSpecification')] :
getStorage('attrValue'); getStorage('attrValue');
@ -254,12 +255,25 @@
}, },
video_link: this.addGoodsSecoundData.video_link video_link: this.addGoodsSecoundData.video_link
}; };
if (attrValue) {
if(attrValue){ postData.attrValue = attrValue.filter(item => item != '');
postData.attrValue = attrValue.filter(item => item != ''); postData.attrValue[0].bar_code
postData.attrValue[0].bar_code }
} let info = getStorage('editCommodity');
// console.log(postData); Object.keys(info).forEach(key=>{
postData[key]=info[key];
})
postData.stock = postData.attrValue[0].stock;
console.log(postData);
if(postData.store_name.trim().length<=0)return Toast('请输入商品名称');
if(postData.imageList.length<=0)return Toast('请上传商品图片');
if(postData.cate_name.trim().length<=0)return Toast('请选择平台分类');
if(postData.unit_name.trim().length<=0)return Toast('请输入商品单位');
if(!postData.attrValue[0].price||postData.attrValue[0].price<0)return Toast('价格不能小于0');
if(!postData.stock||postData.stock<0)return Toast('库存不能小于0');
if(postData.content.title.trim().length<=0)return Toast('请输入商品详情');
if(postData.content.image.length<=0)return Toast('请上传商品图片');
// return Toast('');
if (getStorage('addGoodsFormData').spec_type == 0) { if (getStorage('addGoodsFormData').spec_type == 0) {
// postData.attr = [getStorage('singleSpecification')]; // postData.attr = [getStorage('singleSpecification')];
} }
@ -275,7 +289,7 @@
Modal('提交成功', '点击确定,返回商品管理', { Modal('提交成功', '点击确定,返回商品管理', {
showCancel: false showCancel: false
}).then(() => { }).then(() => {
uni.removeStorageSync('singleSpecification') 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
}) })
@ -328,8 +342,8 @@
uni.chooseVideo({ uni.chooseVideo({
sourceType: ['camera', 'album'], sourceType: ['camera', 'album'],
success: res => { success: res => {
console.log(res) console.log(res)
if (Math.ceil(res.size / 1024) < this.upload_max * 1024) { if (Math.ceil(res.size / 1024) < this.upload_max * 1024) {
uni.uploadFile({ uni.uploadFile({
url: this.uploadUrl, // url: this.uploadUrl, //
@ -361,11 +375,11 @@
} }
}, },
fail: err => { fail: err => {
// //
// uni.showModal({ // uni.showModal({
// content: JSON.stringify(err) // content: JSON.stringify(err)
// }); // });
console.log(err) console.log(err)
} }
}); });
}, },
@ -419,32 +433,34 @@
} }
} }
} }
.videoHover {
width: 180rpx; .videoHover {
height: 180rpx; width: 180rpx;
height: 180rpx;
display: flex;
align-items: center;
justify-content: center;
position: absolute;
top: 0;
left: 0;
z-index: 10;
view {
width: 50rpx;
height: 50rpx;
background: #000000;
border-radius: 50rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
position: absolute;
top: 0;
left: 0;
z-index: 10;
view { .iconfont {
width: 50rpx; color: #ffffff;
height: 50rpx; font-size: 21rpx;
background: #000000;
border-radius: 50rpx;
display: flex;
align-items: center;
justify-content: center;
.iconfont {
color: #ffffff;
font-size: 21rpx;
}
} }
} }
}
.photo { .photo {
border: 1px solid #dddddd; border: 1px solid #dddddd;
opacity: 1; opacity: 1;
@ -487,10 +503,12 @@
height: 150rpx; height: 150rpx;
} }
} }
.preview_video{
position: absolute; .preview_video {
position: absolute;
}
}
.container_input { .container_input {
background: #fff; background: #fff;
padding: 0 20rpx; padding: 0 20rpx;
@ -609,6 +627,7 @@
.marginTop_none { .marginTop_none {
margin-top: 0; margin-top: 0;
} }
.video-count { .video-count {
position: fixed; position: fixed;
width: 600rpx; width: 600rpx;
@ -627,6 +646,7 @@
height: 500rpx; height: 500rpx;
} }
} }
// .writeBg { // .writeBg {
// background: #fff; // background: #fff;
// } // }

View File

@ -31,7 +31,8 @@
<text v-else>0</text>/200 <text v-else>0</text>/200
</view> </view>
</view> </view>
<view class="input_content_describe_textarea"><textarea v-model="prodectContent.store_info" value="" <view class="input_content_describe_textarea">
<textarea v-model="prodectContent.store_info" value=""
placeholder="请填写商品简介" placeholderClass="placeholderClass" maxlength="200" /></view> placeholder="请填写商品简介" placeholderClass="placeholderClass" maxlength="200" /></view>
</view> </view>
@ -110,7 +111,7 @@
} }
}, },
mounted() { mounted() {
console.log(this.$props.prodectContent);
}, },
methods: { methods: {
handleChooseImage() { handleChooseImage() {