商品发布

This commit is contained in:
zmj 2024-04-22 18:05:44 +08:00
parent 8c05ceb8fb
commit 12acca43be
9 changed files with 675 additions and 301 deletions

View File

@ -2,7 +2,7 @@
<view class='content'>
<u--form :model="formData" :rules="rules" ref="formData" :labelStyle="{fontSize:'32rpx'}" labelWidth='auto'>
<view class="card" style="height: 300rpx;"
@click="navgo(`/pages/product/addGoodDetail/goodsSearch?mer_id=${mer_id}`)">
@click="navgo(`/pages/product/addGoodDetail/goodsSearch?mer_id=${mer_id}&&type=simple&&formData=${JSON.stringify(formData)}`)">
<u-form-item label="想卖什么" prop="title">
<text slot='right' style="font-size:28rpx ; color:#989898 ;">{{value1.length}}/{{maxLength}}</text>
</u-form-item>
@ -10,31 +10,49 @@
<u--textarea v-model="formData.cate_name" placeholder="请输入内容" :autoHeight='true'
:maxlength='maxLength'></u--textarea>
</view>
<view class="card" style="min-height: 268rpx;">
<u-form-item label="商品图片" prop="userInfo.name" ref="item1" labelWidth='auto'>
<text style="font-size:24rpx ; color:#E18C34 ;">上传时应注重真实性清晰度</text>
</u-form-item>
<view class="" style="display: flex;flex-wrap: wrap;">
<view v-for="(item,index) in formData.imageList" style="margin-right: 20rpx;margin-bottom: 20rpx;">
<view class="video_list" v-if='vidioTypeList.includes(getSuffix(item))'>
<view class="video_list_item photo" style="position: relative;">
<view class="jiao" @click="formData.imageList.splice(index,1)">
<!-- video标签在app端层级过高 -->
<!--#ifndef APP-PLUS-->
<video :src="item"></video>
<!--#endif-->
<!--#ifdef APP-PLUS-->
<img src="https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/3/video_bg.png"
style=" width:150rpx"></img>
<!--#endif-->
<image src="@/static/images/gban.png" mode="widthFix"></image>
</view>
<view style="position: absolute;top: 20rpx;z-index: 99;width: 140rpx;height: 100%;"
@click="videoshow(index)">
<view class="videoHover">
</view>
</view>
</view>
</view>
<view class="" style="position: relative;" v-else>
<view class="jiao" @click="formData.imageList.splice(index,1)">
<image src="@/static/images/gban.png" mode="widthFix"></image>
</view>
<u--image :src="item" :fade="true" duration="450" width='140rpx' height='140rpx'></u--image>
</view>
</view>
<view class='uploadimg' @click="show=true">
<u-icon name="plus" color="#777777"></u-icon>
<view class="" style="color: #777777;font-size: 20rpx;">
上传图片/视频
</view>
</view>
<!-- <view class="" style="width: 100rpx;height: 100rpx;background-color: red;" @click="test">
</view>
</view>
</view> -->
<!-- <u-upload :fileList="formData.imageList" @afterRead="afterRead" @delete="deletePic" name="6"
multiple :maxCount="5" accept="video">
<view class='uploadimg'>
<u-icon name="plus" color="#777777"></u-icon>
<view class="" style="color: #777777;font-size: 24rpx;">
上传图片
</view>
</view>
</u-upload> -->
</view>
</view>
<view class="card">
<u-form-item label="规格与价格" prop="userInfo.name" ref="item1" border-bottom>
</u-form-item>
@ -56,7 +74,7 @@
</u-form-item>
<u-form-item label="商品库存" prop="userInfo.name" ref="item1">
<u--input inputAlign='right' placeholderStyle="color:#777777" style="width: 220rpx;"
placeholder="请输入零售价" v-model="formData.attrValue[0].stock" slot='right'></u--input>
placeholder="请输入库存" v-model="formData.attrValue[0].stock" slot='right'></u--input>
</u-form-item>
</view>
<view class="footer">
@ -110,6 +128,10 @@
<u-picker :show="show" :columns="columns" confirmColor='#33BB3C' @close='show=false' @confirm='choseMedia'
@cancel='show=false'></u-picker>
<view v-if="showVideo" class="video-count">
<video id="myVideo" class="videoLink" autoplay loop muted :src="formData.imageList[videoIndex]"></video>
</view>
<view class='mask' catchtouchmove="true" :hidden='showVideo==false' @tap="showVideo=false"></view>
</view>
@ -118,21 +140,17 @@
<script>
import {
productCreate,
productUpdate
productUpdate,
productDetail
} from '@/api/product.js';
import uploadImgVideo from "./components/uploadImgVideo.vue"
import {
TOKENNAME,
HTTP_REQUEST_URL
} from '@/config/app.js';
import store from 'store';
import {
formatDate
} from "../../../libs/uniApi";
import {
serialize,
Toast,
Loading,
hideLoading,
Modal
} from "@/libs/uniApi.js";
export default {
@ -141,6 +159,10 @@
},
data() {
return {
videoIndex: 0,
showVideo: false,
upload_max: 100,
uploadUrl: `${HTTP_REQUEST_URL}/api/upload/video`,
columns: [
['图片', '视频', ]
],
@ -148,6 +170,7 @@
show: false, //
showCustom: false, //
mer_id: "",
vidioTypeList: ['mp4', 'avi', 'mov', 'wmv', 'mkv', 'flv', 'mpeg', '3gp', 'webm'],
attrList: ['斤',
"公斤",
"吨",
@ -184,7 +207,7 @@
"extension_one": "",
"extension_two": "",
open: true,
spec_type: " "
spec_type: ""
}],
"cate_name": "",
"unit_name": "",
@ -214,9 +237,7 @@
"video_link": "",
"content": {
"title": "",
"image": [
]
"image": []
},
"stock": ""
},
@ -241,27 +262,37 @@
},
methods: {
deleteImage(index) {
// this.addGoodsSecoundData.video_link = '';
},
videoshow(index) {
this.videoIndex = index
console.log('show')
this.showVideo = true
this.videoContext = uni.createVideoContext('myVideo', this);
this.$nextTick(() => {
this.videoContext.play();
})
},
getSuffix(url) {
const str = url;
const lastIndex = str.lastIndexOf(".");
if (lastIndex !== -1) {
const extension = str.substring(lastIndex + 1);
return extension
} else {
console.log("字符串中没有找到点号。");
}
},
choseMedia(e) {
console.log(e.value)
this.show = false
if (e.value[0] == '图片') {
this.handleChooseImage()
// uni.chooseImage({
// count: 6, //9
// sizeType: ['original', 'compressed'], //
// sourceType: ['album', 'camera'], //
// success: function(res) {
// console.log(JSON.stringify(res.tempFilePaths));
// }
// });
} else {
this.uploadVideo()
// uni.chooseVideo({
// sourceType: ['camera', 'album'],
// success: function(res) {
// self.src = res.tempFilePath;
// }
// });
}
},
@ -269,25 +300,24 @@
handleChooseImage() {
let that = this;
that.$util.uploadImageOne('upload/image', function(res) {
// that.setFormData.imageList.push(res.data.path);
console.log(that.formData)
that.formData.imageList.push(res.data.path);
});
},
//
uploadVideo() {
let that = this
uni.chooseVideo({
sourceType: ['camera', 'album'],
success: res => {
console.log(res)
uni.showLoading({
title: '正在上传中。。。'
});
if (Math.ceil(res.size / 1024) < this.upload_max * 1024) {
uni.uploadFile({
url: this.uploadUrl, //
filePath: res.tempFilePath,
name: 'file',
//
// formData: {
// user: 'test'
// },
header: {
// #ifdef MP
'Content-Type': 'multipart/form-data',
@ -295,8 +325,9 @@
[TOKENNAME]: 'Bearer ' + store.state.app.token
},
success: uploadFileRes => {
// let data = JSON.parse(uploadFileRes.data);
// this.addGoodsSecoundData.video_link = (data.data.src);
uni.hideLoading();
let data = JSON.parse(uploadFileRes.data);
that.formData.imageList.push(data.data.src.replace(/\\/g, ""))
},
complete: a => {
// console.log(a);
@ -329,46 +360,6 @@
});
},
//
deletePic(event) {
this.formData[`imageList`].splice(event.index, 1)
},
//
async afterRead(event) {
// multiple true , file
let lists = [].concat(event.file)
let fileListLen = this.formData[`imageList`].length
lists.map((item) => {
this.formData[`imageList`].push({
...item,
status: 'uploading',
message: '上传中'
})
})
for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise(lists[i].url)
let item = this.formData[`imageList`][fileListLen]
this.formData[`imageList`].splice(fileListLen, 1, Object.assign(item, {
status: 'success',
message: '',
url: result
}))
fileListLen++
}
},
uploadFilePromise(url) {
return new Promise((resolve, reject) => {
let a = uni.uploadFile({
url: HTTP_REQUEST_URL + '/api/upload/image/field',
filePath: url,
name: 'field',
success: (res) => {
console.log(res.data)
resolve(JSON.parse(res.data).data.path)
}
});
})
},
choseAttr(name) {
this.formData.attrValue[0].unit_name = name;
@ -387,7 +378,7 @@
goDetail() {
uni.navigateTo({
url: `/pages/product/addGoodDetail/addGoodDetail?mer_id=${this.mer_id}&&formData=${JSON.stringify(this.formData)}`
url: `/pages/product/addGoodDetail/addGoodDetail?mer_id=${this.mer_id}&&formData=${JSON.stringify(this.formData)}&&showSet=${false}`
})
},
navgo(url) {
@ -397,9 +388,6 @@
},
async submit() {
let data = uni.$u.deepClone(this.formData)
data.imageList = data.imageList.map(item => item.url)
data.image = data.imageList[0]
data.slider_image = data.imageList.splice(0, 1)
data.store_name = data.cate_name
@ -415,7 +403,9 @@
url: `/pages/product/goodsOnSale/index?mer_id=${this.mer_id}&type=6`
})
}).catch(() => {
uni.navigateBack()
uni.redirectTo({
url: `/pages/nongKe/gather/select_warehouse?mer_id=${this.mer_id}&stype=2`
})
})
})
.catch(rej => {
@ -427,6 +417,10 @@
onLoad(option) {
this.mer_id = option.mer_id
this.isWholeSale = this.$store.state.app.userInfo?.mer_info?.wholesale == 2;
if (option.formData) {
this.formData = JSON.parse(option.formData)
}
if (option.data) {
this.formData.cate_name = JSON.parse(option.data).label.includes('--') ? JSON.parse(option.data).label
.split('--')[1] : JSON.parse(option.data).label;
@ -465,7 +459,8 @@
justify-content: space-around;
align-items: center;
box-sizing: border-box;
padding: 20rpx 0;
/* padding: 20rpx 0; */
/* margin-left: 20rpx; */
}
@ -529,4 +524,74 @@
border-radius: 40rpx;
overflow: hidden;
}
.jiao {
image {
position: absolute;
top: -14rpx;
right: -14rpx;
width: 50rpx;
height: 50rpx;
border-radius: 50%;
padding: 8rpx;
z-index: 2;
}
video {
width: 140rpx;
height: 140rpx;
}
}
.preview_video {
position: absolute;
background-color: red;
}
.content_list_video {
min-height: 154rpx;
padding: 23rpx 10rpx;
display: flex;
justify-content: space-between;
.content_list_video_title {
padding-top: 10rpx;
}
.video_list {
flex: 1;
display: flex;
justify-content: flex-end;
flex-wrap: wrap;
}
}
.video-count {
position: fixed;
width: 600rpx;
height: 500rpx;
top: 50%;
left: 50%;
margin-left: -300rpx;
margin-top: -250rpx;
z-index: 100;
display: flex;
align-items: center;
justify-content: center;
.videoLink {
width: 600rpx;
height: 500rpx;
}
}
.video-text {
color: red;
font-size: 24rpx;
text-align: center;
/* position: absolute; */
}
</style>

View File

@ -9,7 +9,9 @@
:prodectContent="goodsDis" :maxLength="200"></input-goods-detils>
<block v-if="!moreThanFlag">
<view class="content_list_video input-goods-detils">
<view class="content_list_video_title">商品视频</view>
<view class="video_list">
<view class="video_list_item photo" v-if="addGoodsSecoundData.video_link">
<view class="jiao" @click="deleteImage()">
@ -47,6 +49,8 @@
<view>添加视频</view>
</view>
</view>
</view>
<view class="container_input marginTop_none input-goods-detils">
<view class="container_input_item">

View File

@ -15,31 +15,94 @@
<u-form-item label="商品主图" prop="userInfo.name" ref="item1" required>
<text style="color: #E18C34;font-size: 24rpx">上传时应注重真实性清晰度</text>
</u-form-item>
<u-form-item prop="userInfo.name" ref="item1">
<u-upload :fileList="formData.imageList" @afterRead="afterRead1" @delete="deletePic1" name="6"
multiple :maxCount="5">
<view class='uploadimg'>
<view class="card" style="min-height: 150rpx;margin-bottom: 0;padding: 0;">
<view class="" style="display: flex;flex-wrap: wrap;">
<view v-for="(item,index) in formData.imageList"
style="margin-right: 20rpx;margin-bottom: 20rpx;">
<view class="video_list" v-if='vidioTypeList.includes(getSuffix(item))'>
<view class="video_list_item photo" style="position: relative;">
<view class="jiao" @click="formData.imageList.splice(index,1)">
<!-- video标签在app端层级过高 -->
<!--#ifndef APP-PLUS-->
<video :src="item"></video>
<!--#endif-->
<!--#ifdef APP-PLUS-->
<img src="https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/3/video_bg.png"
style=" width:150rpx"></img>
<!--#endif-->
<image src="@/static/images/gban.png" mode="widthFix"></image>
</view>
<view style="position: absolute;top: 20rpx;z-index: 99;width: 140rpx;height: 100%;"
@click="videoshow(index)">
<view class="videoHover">
</view>
</view>
</view>
</view>
<view class="" style="position: relative;" v-else>
<view class="jiao" @click="formData.imageList.splice(index,1)">
<image src="@/static/images/gban.png" mode="widthFix"></image>
</view>
<u--image :src="item" :fade="true" duration="450" width='140rpx'
height='140rpx'></u--image>
</view>
</view>
<view class='uploadimg' @click="show=true">
<u-icon name="plus" color="#777777"></u-icon>
<view class="" style="color: #777777;font-size: 24rpx;">
上传图片
<view class="" style="color: #777777;font-size: 20rpx;">
上传图片/视频
</view>
</view>
</u-upload>
</u-form-item>
</view>
</view>
<u-form-item label="商品详情" prop="userInfo.name" ref="item1" required>
<text style="color: #E18C34;font-size: 24rpx">上传时应注重真实性清晰度</text>
</u-form-item>
<u-form-item prop="userInfo.name" ref="item1">
<u-upload :fileList="formData.content.image" @afterRead="afterRead" @delete="deletePic" name="6"
multiple :maxCount="5">
<view class='uploadimg'>
<view class="card" style="min-height: 150rpx;margin-bottom: 0;padding: 0;">
<view class="" style="display: flex;flex-wrap: wrap;">
<view v-for="(item,index) in formData.content.image"
style="margin-right: 20rpx;margin-bottom: 20rpx;">
<view class="video_list" v-if='vidioTypeList.includes(getSuffix(item))'>
<view class="video_list_item photo" style="position: relative;">
<view class="jiao" @click="formData.imageList.splice(index,1)">
<!-- video标签在app端层级过高 -->
<!--#ifndef APP-PLUS-->
<video :src="item"></video>
<!--#endif-->
<!--#ifdef APP-PLUS-->
<img src="https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/3/video_bg.png"
style=" width:150rpx"></img>
<!--#endif-->
<image src="@/static/images/gban.png" mode="widthFix"></image>
</view>
<view style="position: absolute;top: 20rpx;z-index: 99;width: 140rpx;height: 100%;"
@click="videoshow(index)">
<view class="videoHover">
</view>
</view>
</view>
</view>
<view class="" style="position: relative;" v-else>
<view class="jiao" @click="formData.imageList.splice(index,1)">
<image src="@/static/images/gban.png" mode="widthFix"></image>
</view>
<u--image :src="item" :fade="true" duration="450" width='140rpx'
height='140rpx'></u--image>
</view>
</view>
<view class='uploadimg' @click="show=true,isDetail=true">
<u-icon name="plus" color="#777777"></u-icon>
<view class="" style="color: #777777;font-size: 24rpx;">
上传图片
<view class="" style="color: #777777;font-size: 20rpx;">
上传图片/视频
</view>
</view>
</u-upload>
</u-form-item>
</view>
</view>
</view>
<view class='tips'>
商品类目属性
@ -54,7 +117,7 @@
</u-form-item>
<u-form-item label="商品属性" prop="userInfo.name" ref="item1" labelPosition="left">
<view style="display: flex;align-items: center;font-size: 28rpx;color:#777777 ;" slot="right"
@click="navgo(`/pages/product/addGoodDetail/goodsAttr?formData=${JSON.stringify(formData)}&&mer_id=${mer_id}`)">
@click="navgo(`/pages/product/addGoodDetail/goodsAttr?mer_id=${mer_id}&&formData=${JSON.stringify(formData)}`)">
<view style="margin-right: 10rpx;line-height: 25rpx;">
{{isSet(formData.product_attribute)?'已设置':'未设置' }}
</view>
@ -69,14 +132,21 @@
<u-form-item label="规格与价格" prop="userInfo.name" ref="item1" labelPosition="left" required>
<view style="display: flex;align-items: center;font-size: 28rpx;color:#777777 ;" slot="right"
@click="navgo(`/pages/product/addGoodDetail/goodsPrice?formData=${JSON.stringify(formData)}&&mer_id=${mer_id}`)">
<view style="margin-right: 10rpx;line-height: 25rpx;">去设置</view>
<view style="margin-right: 10rpx;line-height: 25rpx;">{{sets?"已设置":""}}
</view>
<u-icon name="arrow-right"></u-icon>
</view>
</u-form-item>
<view class="" v-for="(item,index) in formData.attrValue.filter(item=> item.open)">
<view class="" v-if="showSet">
<view class="" v-for="(item,index) in formData.attrValue.filter(item=> !item.is_use)">
<u-form-item :label="item.spec_type" label-width="350rpx" prop="userInfo.name" ref="item1"
labelPosition="left" border-bottom>
<view class="" style="display: flex;justify-content: space-between;width: 100%">
<view style="width: 250rpx;" v-if='!item.spec_type'>
</view>
<view style="font-size: 28rpx;color:#777777 ;">
零售价
</view>
@ -85,8 +155,8 @@
</view>
</view>
</u-form-item>
<u-form-item label=" " label-width="350rpx" prop="userInfo.name" ref="item1" labelPosition="left"
border-bottom>
<u-form-item label=" " label-width="350rpx" prop="userInfo.name" ref="item1"
labelPosition="left" border-bottom v-if='isWholeSale'>
<view class="" style="display: flex;justify-content: space-between;width: 100%">
<view style="font-size: 28rpx;color:#777777 ;">
批发价
@ -98,6 +168,9 @@
</u-form-item>
</view>
</view>
</view>
<view class='tips'>
服务与承诺
</view>
@ -111,7 +184,7 @@
<u-line color="#F3F3F3" style="margin: 30rpx 0;"></u-line>
<u-form-item label="送货方式" labelPosition="left" required>
<u-checkbox-group v-model="formData.delivery_way" placement="row" slot="right">
<u-checkbox-group v-model="delivery_way" placement="row" slot="right">
<u-checkbox shape="circle" v-for="(item, index) in checkboxList1" :key="index"
:label="item.name" :name="item.value" activeColor="#20B128"
:customStyle="{marginRight: '8px'}"
@ -162,58 +235,98 @@
</view>
</u-overlay>
</view>
<u-picker :show="show" :columns="columns" confirmColor='#33BB3C' @close='show=false' @confirm='choseMedia'
@cancel='show=false'></u-picker>
<view v-if="showVideo" class="video-count">
<video id="myVideo" class="videoLink" autoplay loop muted
:src=" isDetail?formData.content.image[videoIndex]: formData.imageList[videoIndex]"></video>
</view>
<view class='mask' catchtouchmove="true" :hidden='showVideo==false' @tap="showVideo=false"></view>
</view>
</template>
<script>
import {
serialize,
Toast,
Loading,
hideLoading,
Modal
} from "@/libs/uniApi.js";
import {
HTTP_REQUEST_URL
HTTP_REQUEST_URL,
TOKENNAME
} from '@/config/app.js';
import store from 'store';
import {
productCreate,
productUpdate
productUpdate,
productDetail
} from '@/api/product.js';
import uploadImgVideo from "../addGood/components/uploadImgVideo.vue"
import form from "../../../uni_modules/uview-ui/libs/config/props/form";
export default {
components: {
uploadImgVideo,
},
data() {
return {
mode: 'add',
isDetail: false,
columns: [
['图片', '视频', ]
],
sets: false,
showVideo: false,
vidioTypeList: ['mp4', 'avi', 'mov', 'wmv', 'mkv', 'flv', 'mpeg', '3gp', 'webm'],
videoIndex: 0,
upload_max: 100,
uploadUrl: `${HTTP_REQUEST_URL}/api/upload/video`,
show: false, //
showSet: false,
vidioTypeList: ['mp4', 'avi', 'mov', 'wmv', 'mkv', 'flv', 'mpeg', '3gp', 'webm'],
delivery_way: [],
isWholeSale: false,
formData: {
"store_name": "测试商品",
store_info: "",
product_id: "",
"store_name": "",
"imageList": [
],
"attrValue": [
],
"attrValue": [{
"price": "",
"unit_name": "",
"wholesale_unit_name": "",
"wholesale_price": "",
"cost": "",
"stock": "",
"ot_price": "",
"procure_price": "",
"bar_code": "",
"weight": "",
"volume": "",
"extension_one": "",
"extension_two": "",
"open": true,
"spec_type": ""
}],
"cate_name": "",
"unit_name": "",
"cate_id": '',
"mer_cate_id": [
],
"mer_cate_name": "测试",
"cate_id": "",
"mer_cate_id": [],
"mer_cate_name": "",
"spec_type": "0",
"attr": [],
"specifica": "",
"delivery_way": [],
"delivery_free": "1",
"delivery_free": "",
"temp_id": "",
"tempName": "",
"once_min_count": "",
"image": "https://crmeb-test.shop.lihaink.cn/uploads/def/20240419/a09b7188e9ef408a3f96d82b2b178082.jpeg",
"image": "",
"slider_image": [
""
],
"is_good": 0,
"is_gift_bag": 0,
@ -224,9 +337,7 @@
"title": "",
"image": []
},
"stock": "20",
store_info: "",
attribute: {},
"stock": "",
product_attribute: {
address: "",
leval: "",
@ -236,6 +347,7 @@
value: ''
}]
}
},
mer_id: "",
maxLength: 30,
@ -268,11 +380,11 @@
checkboxValue1: [],
checkboxList1: [{
name: '到店核销',
value: 1,
value: '1',
},
{
name: '快递配送',
value: 2,
value: '2',
},
],
@ -284,97 +396,123 @@
};
},
methods: {
deleteImage(index) {
// this.addGoodsSecoundData.video_link = '';
},
videoshow(index) {
this.videoIndex = index
this.showVideo = true
this.videoContext = uni.createVideoContext('myVideo', this);
this.$nextTick(() => {
this.videoContext.play();
})
},
getSuffix(url) {
const str = url;
const lastIndex = str.lastIndexOf(".");
if (lastIndex !== -1) {
const extension = str.substring(lastIndex + 1);
return extension
} else {
console.log("字符串中没有找到点号。");
}
},
choseMedia(e) {
console.log(e.value)
this.show = false
if (e.value[0] == '图片') {
this.handleChooseImage()
} else {
this.uploadVideo()
}
},
//
handleChooseImage() {
let that = this;
that.$util.uploadImageOne('upload/image', function(res) {
if (that.isDetail) {
that.formData.content.image.push(res.data.path);
} else {
that.formData.imageList.push(res.data.path);
}
});
},
//
uploadVideo() {
let that = this
uni.chooseVideo({
sourceType: ['camera', 'album'],
success: res => {
uni.showLoading({
title: '正在上传中。。。'
});
if (Math.ceil(res.size / 1024) < this.upload_max * 1024) {
uni.uploadFile({
url: this.uploadUrl, //
filePath: res.tempFilePath,
name: 'file',
header: {
// #ifdef MP
'Content-Type': 'multipart/form-data',
// #endif
[TOKENNAME]: 'Bearer ' + store.state.app.token
},
success: uploadFileRes => {
uni.hideLoading();
let data = JSON.parse(uploadFileRes.data);
if (that.isDetail) {
that.formData.content.image.push(data.data.src.replace(
/\\/g, ""));
} else {
that.formData.imageList.push(data.data.src.replace(/\\/g,
""))
}
},
complete: a => {
// console.log(a);
}
});
} else {
uni.showModal({
title: '提示',
content: `视频超出限制${this.upload_max}MB,已过滤`
});
}
},
fail: err => {
console.log(err)
}
});
},
isSet(obj) {
for (let key in obj) {
if (typeof obj[key] == 'object') this.isSet(obj[key])
else {
if (Boolean(obj[key])) return true;
if (Boolean(obj[key])) return 'true12';
}
}
},
//
deletePic1(event) {
this.formData[`imageList`].splice(event.index, 1)
},
//
async afterRead1(event) {
// multiple true , file
let lists = [].concat(event.file)
let fileListLen = this.formData[`imageList`].length
lists.map((item) => {
this.formData[`imageList`].push({
...item,
status: 'uploading',
message: '上传中'
})
})
for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise1(lists[i].url)
let item = this.formData[`imageList`][fileListLen]
this.formData[`imageList`].splice(fileListLen, 1, Object.assign(item, {
status: 'success',
message: '',
url: result
}))
fileListLen++
isSet2(obj) {
let lists = ['unit_name', 'price', 'wholesale_price', 'stock']
lists.forEach(item => {
if (Boolean(this.formData.attrValue[0][item])) {
this.sets = true
}
},
uploadFilePromise1(url) {
return new Promise((resolve, reject) => {
let a = uni.uploadFile({
url: HTTP_REQUEST_URL + '/api/upload/image/field',
filePath: url,
name: 'field',
success: (res) => {
console.log(res.data)
resolve(JSON.parse(res.data).data.path)
}
});
})
},
//
deletePic(event) {
this.formData.content.image.splice(event.index, 1)
},
//
async afterRead(event) {
// multiple true , file
let lists = [].concat(event.file)
let fileListLen = this.formData.content.image.length
lists.map((item) => {
this.formData.content.image.push({
...item,
status: 'uploading',
message: '上传中'
})
})
for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise(lists[i].url)
let item = this.formData.content.image[fileListLen]
this.formData.content.image.splice(fileListLen, 1, Object.assign(item, {
status: 'success',
message: '',
url: result
}))
fileListLen++
}
},
uploadFilePromise(url) {
return new Promise((resolve, reject) => {
let a = uni.uploadFile({
url: HTTP_REQUEST_URL + '/api/upload/image/field',
filePath: url,
name: 'field',
success: (res) => {
setTimeout(() => {
resolve(res.data.data)
}, 1000)
}
});
})
},
sexSelect(e) {
this.model1.userInfo.sex = e.name
this.$refs.uForm.validateField('userInfo.sex')
@ -400,23 +538,23 @@
},
getAttrValue(object) {
this.formData.attrValue = object
console.log(this.formData.attrValue)
},
async submit() {
let that = this
let data = uni.$u.deepClone(this.formData)
data.imageList = data.imageList.map(item => item.url)
data.image = data.imageList[0]
data.slider_image = data.imageList.splice(0, 1)
data.store_name = data.cate_name
productCreate(this.mer_id, data)
that.formData.product_id ?
productUpdate(that.mer_id, that.formData.product_id, data)
.then(res => {
hideLoading();
Modal('提交成功', '点击确定,前往商品列表页面').then(() => {
if (this.import == 1) {
uni.$emit('importAttrValueOK', this.setFormData.import_id);
uni.navigateBack();
} else uni.redirectTo({
url: `/pages/product/goodsOnSale/index?mer_id=${this.mer_id}&type=6`
url: `/pages/product/goodsOnSale/index?mer_id=${that.mer_id}&type=6`
})
}).catch(() => {
uni.navigateBack()
@ -424,14 +562,34 @@
})
.catch(rej => {
// Toast(rej);
});
console.log(this.formData)
}) :
productCreate(that.mer_id, data)
.then(res => {
Modal('提交成功', '点击确定,前往商品列表页面').then(() => {
if (this.import == 1) {
uni.$emit('importAttrValueOK', this.setFormData.import_id);
uni.navigateBack();
} else uni.redirectTo({
url: `/pages/product/goodsOnSale/index?mer_id=${that.mer_id}&type=6`
})
}).catch(() => {
uni.navigateBack()
})
})
.catch(rej => {
// Toast(rej);
})
}
},
onLoad(option) {
this.delivery_way = this.$store.state.app.userInfo?.mer_info.delivery_way.split(',')
this.isWholeSale = this.$store.state.app.userInfo?.mer_info?.wholesale == 2;
this.mer_id = option.mer_id
this.showSet = option.showSet ? JSON.parse(option.showSet) : this.showSet
if (option.typeData) {
this.formData.cate_name = JSON.parse(option.typeData).label
this.formData.cate_id = JSON.parse(option.typeData).value
@ -441,9 +599,22 @@
for (let key in data) {
this.formData[key] = data[key]
}
console.log(this.formData)
}
let that = this
this.isSet2()
if (option.product_id) {
that.formData.product_id = option.product_id
this.mode = 'edit'
productDetail(option.mer_id, option.product_id).then(res => {
this.formData = res.data
this.formData.product_attribute = JSON.parse(this.formData.product_attribute)
this.formData.cate_name = this.formData.storeCategory.cate_name
this.formData.cate_id = this.formData.storeCategory.store_category_id
this.formData.imageList = this.formData.image_list
})
}
// console.log(this.isSet(this.formData.attrValue))
},
onBackPress: function(e) {
this.showlay = true
@ -481,6 +652,8 @@
align-items: center;
box-sizing: border-box;
padding: 20rpx 0;
/* margin-left: 20rpx; */
overflow: hidden;
}
@ -521,4 +694,68 @@
align-items: center;
padding: 70rpx 0 40rpx 0;
}
.jiao {
image {
position: absolute;
top: -14rpx;
right: -14rpx;
width: 50rpx;
height: 50rpx;
border-radius: 50%;
padding: 8rpx;
z-index: 2;
}
video {
width: 140rpx;
height: 140rpx;
}
}
.preview_video {
position: absolute;
background-color: red;
}
.content_list_video {
min-height: 154rpx;
padding: 23rpx 10rpx;
display: flex;
justify-content: space-between;
.content_list_video_title {
/* padding-top: 10rpx; */
}
}
.video-count {
position: fixed;
width: 600rpx;
height: 500rpx;
top: 50%;
left: 50%;
margin-left: -300rpx;
margin-top: -250rpx;
z-index: 100;
display: flex;
align-items: center;
justify-content: center;
.videoLink {
width: 600rpx;
height: 500rpx;
}
}
.video-text {
color: red;
font-size: 24rpx;
text-align: center;
/* position: absolute; */
}
</style>

View File

@ -299,7 +299,7 @@
choseCity() {
this.positionType = 1;
getCity({
province_code: this.address.province_code
code: this.address.province_code
}).then(res => {
this.cityList = res.data
this.positionList = this.cityList
@ -343,8 +343,9 @@
},
submit() {
let that = this
console.log(this.mer_id)
uni.navigateTo({
url: `/pages/product/addGoodDetail/addGoodDetail?formData=${JSON.stringify(that.formData) }&&mer_id=${that.mer_id}`
url: `/pages/product/addGoodDetail/addGoodDetail?mer_id=${that.mer_id}&&formData=${JSON.stringify(that.formData) }`
})
}
@ -355,10 +356,10 @@
this.provinceList = res.data
})
this.formData = JSON.parse(option.formData)
console.log(this.formData)
// if (Object.values(JSON.parse(option.attr)).length) {
// this.formData = JSON.parse(option.attr)
// }
if (option.mer_id) {
this.mer_id = option.mer_id
}
}
};

View File

@ -1,14 +1,14 @@
<template>
<view class="content">
<view class="">
<u-button icon="plus" text="新增规格" @click="attrValue.push({})" class="custom-style"
iconColor='#38BE41'></u-button>
<u-button icon="plus" text="新增规格" @click="attrValue.push({is_use:true}),attr.push({value:'',detail: [],})"
class="custom-style" iconColor='#38BE41'></u-button>
</view>
<view class="card" v-for="(item,index) in attrValue">
<view class="card-head card-li">
<text style="font-size: 32rpx;font-family: PingFangFamily;">规格{{index+1}}</text>
<view class="" style="width: 300rpx;">
<u--input placeholder="请输入规格名称" inputAlign='right' v-model="item.spec_type"></u--input>
<u--input placeholder="请输入规格名称" inputAlign='right' v-model="attr[index].value"></u--input>
</view>
</view>
<u-line direction="row" style="margin: 30rpx 0;" color="#ECECEC"></u-line>
@ -38,14 +38,15 @@
<view class=" card-li">
<text style="font-size: 32rpx;">商品库存</text>
<view class="" style="width: 300rpx;">
<u--input placeholder="请填写库存数量" inputAlign='right' v-model="item.stock"></u--input>
<u--input type='number' placeholder="请填写库存数量" inputAlign='right' v-model="item.stock"></u--input>
</view>
</view>
<u-line direction="row" style="margin: 25rpx 0;" color="#ECECEC"></u-line>
<view class=" card-li">
<text style="font-size: 32rpx;">条形码</text>
<view class="" style="width: 300rpx;">
<u--input placeholder="请填写商品条形码" inputAlign='right' v-model="item.bar_code"></u--input>
<u--input placeholder="请填写商品条形码" inputAlign='right' v-model="item.bar_code"
type='number'></u--input>
</view>
</view>
<u-line direction="row" style="margin: 25rpx 0;" color="#ECECEC"></u-line>
@ -54,7 +55,7 @@
<u-icon name="trash" style='margin-right: 8rpx;'></u-icon>
</view>
<view class="" style="display: flex;align-items: center;">
<u-switch v-model="item.open" type='primaryy' activeColor="#38BE41" size="19"></u-switch>
<u-switch v-model="item.is_use" type='primaryy' activeColor="#38BE41" size="19"></u-switch>
<text style="margin-left: 8rpx;color: #777777;">启用</text>
</view>
</view>
@ -74,22 +75,27 @@
text: "",
value: "",
formData: {},
attr: [{
detail: [],
value: ""
}, ],
attrValue: [{
spec_type: "",
"price": "100",
"unit_name": "箱",
"wholesale_unit_name": "件",
"wholesale_price": 88,
"price": "",
"unit_name": "",
"wholesale_unit_name": "",
"wholesale_price": '',
"cost": "",
"stock": "20",
"stock": "",
"ot_price": "",
"procure_price": "",
"bar_code": "5656",
"bar_code": "",
"weight": "",
"volume": "",
"extension_one": "",
"extension_two": "",
open: true
is_use: true
},
],
@ -97,10 +103,15 @@
},
methods: {
submit() {
this.attrValue.forEach(item => {
item.is_use ? item.is_use = 0 : item.is_use = 1
})
this.formData.attrValue = this.attrValue
this.formData.attr = this.attr
let that = this
uni.navigateTo({
url: `/pages/product/addGoodDetail/addGoodDetail?formData=${JSON.stringify(that.formData) }&&mer_id=${that.mer_id}`
url: `/pages/product/addGoodDetail/addGoodDetail?mer_id=${that.mer_id}&&formData=${JSON.stringify(that.formData) }&&showSet=${true}`
})
}
},
@ -109,7 +120,17 @@
if (option.formData) {
this.formData = JSON.parse(option.formData)
this.attrValue = this.formData.attrValue
this.attr = this.formData.attr
this.attrValue.forEach(item => {
item.is_use = !Boolean(item.is_use)
})
}
if (option.mer_id) {
this.mer_id = option.mer_id
}
console.log(this.mer_id, 'meridd')
}
}
@ -129,6 +150,7 @@
position: relative;
font-size: 28rpx;
font-family: PingFangRegular;
padding-bottom: 200rpx;
/* font-family: PingFangFamily; */

View File

@ -49,6 +49,8 @@
export default {
data() {
return {
formData: {},
type: 'detail',
keyword: "",
mer_id: "",
searchList: [],
@ -67,20 +69,25 @@
},
navgo() {
uni.navigateTo({
url: `/pages/product/addGoodDetail/goodsType?mer_id=${this.mer_id}&&type=simple`
url: `/pages/product/addGoodDetail/goodsType?mer_id=${this.mer_id}&&type=${this.type}`
})
},
hdChose(item) {
categorySearchHistory(this.mer_id, this.$store.state.app.userInfo.uid, {
cate_id: item.value
})
uni.navigateTo({
url: `/pages/product/addGood/addGood?mer_id=${this.mer_id}&&data=${JSON.stringify(item)}`
uni.redirectTo({
url: `/pages/product/addGood/addGood?mer_id=${this.mer_id}&&data=${JSON.stringify(item)}&&formData=${JSON.stringify(this.formData)}`
})
}
},
onLoad(option) {
this.mer_id = option.mer_id
if (option.type) {
this.type = 'simple'
}
this.formData = JSON.parse(option.formData)
if (option.formData) {}
categoryHotcate(
option.mer_id,
this.$store.state.app.userInfo.uid

View File

@ -1,9 +1,9 @@
<template>
<view class="">
<view class="" style="padding: 30rpx;font-size: 28rpx;color: #989898;font-family: PingFangRegular;">
<!-- <view class="" style="padding: 30rpx;font-size: 28rpx;color: #989898;font-family: PingFangRegular;">
<text>当前已选</text>
<text style="margin-left: 48rpx;color: #20B128;">生鲜--水果阿萨</text>
</view>
</view> -->
<view class="content">
<view class="lines" :style="{top:(actIndex*82)+30+'rpx'}" />
<view class="left">
@ -46,11 +46,13 @@
data() {
return {
type: 'detail',
mer_id: "",
keyword: "",
actIndex: 0,
leftList: [],
rightList: []
rightList: [],
formData: {}
};
},
methods: {
@ -60,9 +62,17 @@
this.rightList = this.leftList[index].children
},
choseType(item) {
if (this.type == 'detail') {
uni.navigateTo({
url: `/pages/product/addGoodDetail/addGoodDetail?mer_id=${this.mer_id}&&typeData=${JSON.stringify(item)} `
url: `/pages/product/addGoodDetail/addGoodDetail?mer_id=${this.mer_id}&&typeData=${JSON.stringify(item)}&&formData=${JSON.stringify(this.formData)} `
})
} else {
uni.navigateTo({
url: `/pages/product/addGood/addGood?mer_id=${this.mer_id}&&data=${JSON.stringify(item)}&&formData=${JSON.stringify(this.formData)}`
})
}
},
hdSearch() {
categorySearch(this.mer_id, {
@ -80,6 +90,12 @@
},
onLoad(option) {
this.mer_id = option.mer_id
if (option.type) {
this.type = 'simple'
}
if (option.formData) {
this.formData = JSON.parse(option.formData)
}
categoryList(option.mer_id).then((res) => {
this.leftList = res.data
this.rightList = res.data[0].children

File diff suppressed because one or more lines are too long

BIN
static/images/gban.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB