shop-applet/pages/product/addGoodDetail/addGoodDetail.vue

477 lines
13 KiB
Vue
Raw Normal View History

2024-04-17 18:02:49 +08:00
<template>
<view class='content'>
2024-04-19 18:08:04 +08:00
<u--form :model="model1" :rules="rules" ref="uForm" :labelStyle="{fontSize:'32rpx',color:'#444444'}"
labelWidth='auto'>
<view class="good-baseInfo card">
<u-form-item label="商品标题" prop="userInfo.name" ref="item1" required>
<text slot='right' style="font-size:28rpx ; color:#989898 ;">{{value1.length}}/{{maxLength}}</text>
</u-form-item>
<u-form-item label="" prop="userInfo.name" ref="item1">
2024-04-20 14:51:26 +08:00
<u--textarea v-model="formData.store_name" placeholder="建议描述产品品牌、名称、规格、口味"
2024-04-19 18:08:04 +08:00
style="background-color: #F9F9F9;height: 166rpx;" :autoHeight='true'
:maxlength='maxLength'></u--textarea>
</u-form-item>
2024-04-17 18:02:49 +08:00
2024-04-19 18:08:04 +08:00
<u-form-item label="商品主图" prop="userInfo.name" ref="item1" required>
<text style="color: #E18C34;font-size: 24rpx">上传时应注重真实性清晰度</text>
2024-04-17 18:02:49 +08:00
</u-form-item>
2024-04-19 18:08:04 +08:00
<u-form-item prop="userInfo.name" ref="item1">
2024-04-20 08:40:27 +08:00
<u-upload :fileList="formData.imageList" @afterRead="afterRead1" @delete="deletePic1" name="6"
multiple :maxCount="5">
2024-04-19 18:08:04 +08:00
<view class='uploadimg'>
<u-icon name="plus" color="#777777"></u-icon>
<view class="" style="color: #777777;font-size: 24rpx;">
上传图片
</view>
2024-04-18 18:02:57 +08:00
</view>
2024-04-19 18:08:04 +08:00
</u-upload>
2024-04-17 18:02:49 +08:00
</u-form-item>
2024-04-19 18:08:04 +08:00
<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">
2024-04-20 08:40:27 +08:00
<u-upload :fileList="formData.content.image" @afterRead="afterRead" @delete="deletePic" name="6"
multiple :maxCount="5">
2024-04-19 18:08:04 +08:00
<view class='uploadimg'>
<u-icon name="plus" color="#777777"></u-icon>
<view class="" style="color: #777777;font-size: 24rpx;">
上传图片
</view>
2024-04-18 18:02:57 +08:00
</view>
2024-04-19 18:08:04 +08:00
</u-upload>
2024-04-18 18:02:57 +08:00
</u-form-item>
</view>
<view class='tips'>
2024-04-19 18:08:04 +08:00
商品类目属性
2024-04-18 18:02:57 +08:00
</view>
2024-04-19 18:08:04 +08:00
<view class="card" style="padding: 14rpx 30rpx;">
<u-form-item label="商品分类" prop="userInfo.name" ref="item1" labelPosition="left" required>
2024-04-18 18:02:57 +08:00
<view style="display: flex;align-items: center;font-size: 28rpx;color:#777777 ;" slot="right"
2024-04-19 18:08:04 +08:00
@click="navgo(`/pages/product/addGoodDetail/goodsType?mer_id=${mer_id}`)">
2024-04-20 08:40:27 +08:00
<view style="margin-right: 10rpx;line-height: 25rpx;">{{ formData.cate_name|| '请选择'}}</view>
2024-04-18 18:02:57 +08:00
<u-icon name="arrow-right"></u-icon>
</view>
</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"
2024-04-20 14:51:26 +08:00
@click="navgo(`/pages/product/addGoodDetail/goodsAttr?attr=${JSON.stringify(formData.attribute) }`)">
<view style="margin-right: 10rpx;line-height: 25rpx;">
{{Object.values(formData.attribute).length ?"已设置":"未设置"}}
</view>
2024-04-18 18:02:57 +08:00
<u-icon name="arrow-right"></u-icon>
</view>
</u-form-item>
</view>
2024-04-19 18:08:04 +08:00
<view class='tips'>
2024-04-18 18:02:57 +08:00
规格与价格
</view>
2024-04-20 14:51:26 +08:00
<view class="card" style="min-height: 100rpx;padding: 14rpx 30rpx;">
<u-form-item label="规格与价格" prop="userInfo.name" ref="item1" labelPosition="left" required border-bottom>
2024-04-18 18:02:57 +08:00
<view style="display: flex;align-items: center;font-size: 28rpx;color:#777777 ;" slot="right"
2024-04-20 14:51:26 +08:00
@click="navgo(`/pages/product/addGoodDetail/goodsPrice?attrValue=${JSON.stringify(formData.attrValue)}`)">
2024-04-19 18:08:04 +08:00
<view style="margin-right: 10rpx;line-height: 25rpx;">去设置</view>
2024-04-18 18:02:57 +08:00
<u-icon name="arrow-right"></u-icon>
</view>
</u-form-item>
2024-04-20 14:51:26 +08:00
<view class="" v-for="(item,index) in formData.attrValue.filter(item=> item.open)">
<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="font-size: 28rpx;color:#777777 ;">
零售价
</view>
<view style="font-size: 28rpx;color:#777777 ;">
{{item.price}}/{{item.unit_name}}
</view>
</view>
</u-form-item>
<u-form-item label=" " 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="font-size: 28rpx;color:#777777 ;">
批发价
</view>
<view style="font-size: 28rpx;color:#777777 ;">
<!-- 8/ -->
{{item.wholesale_price}}/{{item.wholesale_unit_name}}
</view>
</view>
</u-form-item>
</view>
2024-04-18 18:02:57 +08:00
</view>
2024-04-19 18:08:04 +08:00
<view class='tips'>
2024-04-18 18:02:57 +08:00
服务与承诺
</view>
2024-04-19 18:08:04 +08:00
<view class="card" style="padding: 14rpx 30rpx;">
<u-form-item label="商品详细描述" prop="userInfo.name" ref="item1" labelPosition="left">
<text slot='right' style="font-size:28rpx ; color:#989898 ;">{{value1.length}}/{{maxLength}}</text>
2024-04-18 18:02:57 +08:00
</u-form-item>
2024-04-19 18:08:04 +08:00
<u--textarea v-model="value1" placeholder="货品描述请严格遵循《广告法》规定,避免出现虚假宣传和误导消费者的词语"
style="background-color: #F9F9F9;height: 166rpx;" :autoHeight='true'
:maxlength='maxLength'></u--textarea>
<u-line color="#F3F3F3" style="margin: 30rpx 0;"></u-line>
<u-form-item label="送货方式" labelPosition="left" required>
2024-04-20 14:51:26 +08:00
<u-checkbox-group v-model="formData.delivery_way" placement="row" slot="right">
2024-04-18 18:02:57 +08:00
<u-checkbox shape="circle" v-for="(item, index) in checkboxList1" :key="index"
2024-04-20 14:51:26 +08:00
:label="item.name" :name="item.value" activeColor="#20B128"
2024-04-18 18:02:57 +08:00
:customStyle="{marginRight: '8px'}"
:labelColor="checkboxValue1.includes(item.name)?'#20B128':'#777777'">
</u-checkbox>
</u-checkbox-group>
2024-04-17 18:02:49 +08:00
</u-form-item>
</view>
</u--form>
2024-04-18 18:02:57 +08:00
<view class="submit-btn">
2024-04-20 08:40:27 +08:00
<u-button text="确认发布" @click="submit" color="#33BB3C" class="custom-style"></u-button>
2024-04-19 18:08:04 +08:00
</view>
<view class="overlay">
<u-overlay :show="showlay">
<view class="overlay-content">
<view class="">
温馨提示
</view>
<view class="" style="font-family: PingFangFamily;font-size: 36rpx;">
发布中断可能导致商机流失
</view>
<view class="" style="font-size: 26rpx;color: #777777;">
<view class="">
您的商品信息已经填写了大半
</view>
<view class="">
只差最后几步就能上架销售了
</view>
</view>
<view class=""
style="font-size: 28rpx;color: #444444;background-color: #EDF8ED;padding: 20rpx 44rpx;border-radius: 12rpx;">
<view class="">
越早发布产品<text style='color: #21B129;'>曝光量越高</text>
</view>
<view class="">
越早发布产品可提前 <text style='color: #21B129;'>抢占商机</text>
</view>
</view>
<view style="display: flex;">
<view style="width: 236rpx;height: 84rpx;margin-right: 30rpx;">
<u-button text="确定返回" @click='back'></u-button>
</view>
<view style="width: 236rpx;height: 84rpx;">
<u-button type='primary' text="继续编辑" @click='showlay=false'></u-button>
</view>
</view>
</view>
</u-overlay>
2024-04-18 18:02:57 +08:00
</view>
2024-04-17 18:02:49 +08:00
</view>
</template>
<script>
2024-04-19 18:08:04 +08:00
import {
HTTP_REQUEST_URL
} from '@/config/app.js';
2024-04-20 08:40:27 +08:00
import {
formatDate
} from '../../../libs/uniApi';
2024-04-17 18:02:49 +08:00
import uploadImgVideo from "../addGood/components/uploadImgVideo.vue"
export default {
components: {
uploadImgVideo,
},
data() {
return {
2024-04-19 18:08:04 +08:00
formData: {
"store_name": "测试商品",
"imageList": [
2024-04-20 08:40:27 +08:00
2024-04-19 18:08:04 +08:00
],
2024-04-20 14:51:26 +08:00
"attrValue": [
],
2024-04-19 18:08:04 +08:00
"cate_name": "兽药",
"unit_name": "件",
"cate_id": 1826,
"mer_cate_id": [
2331
],
"mer_cate_name": "测试",
"spec_type": "0",
"attr": [],
"specifica": "",
2024-04-20 14:51:26 +08:00
"delivery_way": [],
2024-04-19 18:08:04 +08:00
"delivery_free": "1",
"temp_id": "",
"tempName": "",
"once_min_count": "",
"image": "https://crmeb-test.shop.lihaink.cn/uploads/def/20240419/a09b7188e9ef408a3f96d82b2b178082.jpeg",
"slider_image": [
2024-04-20 08:40:27 +08:00
2024-04-19 18:08:04 +08:00
],
"is_good": 0,
"is_gift_bag": 0,
"sort": "",
"once_count": "",
"video_link": "",
"content": {
"title": "",
2024-04-20 08:40:27 +08:00
"image": []
2024-04-19 18:08:04 +08:00
},
2024-04-20 14:51:26 +08:00
"stock": "20",
attribute: {},
2024-04-19 18:08:04 +08:00
},
mer_id: "",
maxLength: 30,
fileList6: [],
2024-04-17 18:02:49 +08:00
showSex: false,
2024-04-19 18:08:04 +08:00
showlay: false,
go: true,
2024-04-17 18:02:49 +08:00
model1: {
userInfo: {
name: '',
sex: '',
},
},
range: [{
value: 0,
text: "篮球"
},
{
value: 1,
text: "足球"
},
{
value: 2,
text: "游泳"
},
],
text: "",
2024-04-18 18:02:57 +08:00
text1: "",
value1: "",
checkboxValue1: [],
checkboxList1: [{
name: '到店核销',
2024-04-20 14:51:26 +08:00
value: 1,
2024-04-18 18:02:57 +08:00
},
{
name: '快递配送',
2024-04-20 14:51:26 +08:00
value: 2,
2024-04-18 18:02:57 +08:00
},
2024-04-17 18:02:49 +08:00
2024-04-18 18:02:57 +08:00
],
2024-04-17 18:02:49 +08:00
rules: {
2024-04-19 18:08:04 +08:00
2024-04-17 18:02:49 +08:00
},
radio: '',
switchVal: false
};
},
methods: {
2024-04-19 18:08:04 +08:00
2024-04-20 08:40:27 +08:00
// 删除图片
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++
}
},
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)
}
});
})
},
2024-04-19 18:08:04 +08:00
// 删除图片
deletePic(event) {
2024-04-20 08:40:27 +08:00
this.formData.content.image.splice(event.index, 1)
2024-04-19 18:08:04 +08:00
},
// 新增图片
async afterRead(event) {
// 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
let lists = [].concat(event.file)
2024-04-20 08:40:27 +08:00
let fileListLen = this.formData.content.image.length
2024-04-19 18:08:04 +08:00
lists.map((item) => {
2024-04-20 08:40:27 +08:00
this.formData.content.image.push({
2024-04-19 18:08:04 +08:00
...item,
status: 'uploading',
message: '上传中'
})
})
for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise(lists[i].url)
2024-04-20 08:40:27 +08:00
let item = this.formData.content.image[fileListLen]
this.formData.content.image.splice(fileListLen, 1, Object.assign(item, {
2024-04-19 18:08:04 +08:00
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)
}
});
})
},
2024-04-17 18:02:49 +08:00
sexSelect(e) {
this.model1.userInfo.sex = e.name
this.$refs.uForm.validateField('userInfo.sex')
},
2024-04-18 18:02:57 +08:00
navgo(url) {
uni.navigateTo({
url
})
2024-04-19 18:08:04 +08:00
},
back() {
// console.log('show')
this.go = false
uni.navigateBack()
},
showlayFn() {
uni.navigateBack()
2024-04-20 08:40:27 +08:00
},
submit() {
console.log(this.formData)
2024-04-20 14:51:26 +08:00
},
getAttr(object) {
this.formData.attribute = object
},
getAttrValue(object) {
this.formData.attrValue = object
console.log(this.formData.attrValue)
},
2024-04-17 18:02:49 +08:00
},
2024-04-20 14:51:26 +08:00
2024-04-19 18:08:04 +08:00
onLoad(option) {
this.mer_id = option.mer_id
if (option.typeData) {
2024-04-20 08:40:27 +08:00
this.formData.cate_name = JSON.parse(option.typeData).label
this.formData.cate_id = JSON.parse(option.typeData).value
}
if (option.formData) {
2024-04-20 14:51:26 +08:00
let data = JSON.parse(option.formData)
for (let key in data) {
this.formData[key] = data[key]
}
console.log(this.formData)
2024-04-19 18:08:04 +08:00
}
2024-04-17 18:02:49 +08:00
2024-04-19 18:08:04 +08:00
},
onBackPress: function(e) {
this.showlay = true
return this.go;
}
2024-04-17 18:02:49 +08:00
};
</script>
<style lang='scss'>
.content {
width: 100vw;
min-height: 100vh;
background-color: #F1F1F1;
box-sizing: border-box;
2024-04-18 18:02:57 +08:00
padding-bottom: 280rpx;
2024-04-19 18:08:04 +08:00
font-family: PingFangRegular;
padding: 20rpx 20rpx 200rpx 20rpx;
2024-04-17 18:02:49 +08:00
2024-04-19 18:08:04 +08:00
.card {
2024-04-17 18:02:49 +08:00
background-color: white;
2024-04-19 18:08:04 +08:00
padding: 28rpx 30rpx;
border-radius: 12rpx;
2024-04-18 18:02:57 +08:00
margin-bottom: 30rpx;
}
2024-04-19 18:08:04 +08:00
.uploadimg {
width: 140rpx;
height: 140rpx;
border-radius: 16rpx;
border: 2rpx solid #F1F1F1;
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
box-sizing: border-box;
padding: 20rpx 0;
2024-04-17 18:02:49 +08:00
}
2024-04-19 18:08:04 +08:00
.tips {
2024-04-18 18:02:57 +08:00
color: #777777;
2024-04-19 18:08:04 +08:00
font-size: 28rpx;
margin: 30rpx 0;
2024-04-18 18:02:57 +08:00
}
.submit-btn {
position: fixed;
2024-04-19 18:08:04 +08:00
bottom: 50rpx;
left: 50%;
transform: translate(-50%, 0);
width: 670rpx;
border-radius: 40rpx;
overflow: hidden;
2024-04-18 18:02:57 +08:00
}
2024-04-19 18:08:04 +08:00
}
2024-04-17 18:02:49 +08:00
2024-04-19 18:08:04 +08:00
.overlay-content {
width: 570rpx;
height: 640rpx;
box-sizing: border-box;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border-radius: 16rpx;
background-image: url('/static/images/addGodd/addGoodBg.png');
background-size: 100% 100%;
background-repeat: no-repeat;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
padding: 70rpx 0 40rpx 0;
2024-04-17 18:02:49 +08:00
}
</style>