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

892 lines
25 KiB
Vue
Raw Normal View History

2024-04-17 18:02:49 +08:00
<template>
<view class='content'>
2024-04-23 18:01:32 +08:00
<u--form :model="formData" :rules="rules" ref="formData" :labelStyle="{fontSize:'32rpx',color:'#444444'}"
2024-04-19 18:08:04 +08:00
labelWidth='auto'>
<view class="good-baseInfo card">
2024-04-23 18:01:32 +08:00
<u-form-item label="商品标题" prop="store_name" ref="item1" required>
2024-04-19 18:08:04 +08:00
<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-23 18:01:32 +08:00
style="background-color: #F9F9F9;height: 166rpx;" :maxlength='maxLength'></u--textarea>
<!-- <u--textarea v-model="formData.store_name" placeholder="请输入内容"></u--textarea> -->
2024-04-19 18:08:04 +08:00
</u-form-item>
2024-04-17 18:02:49 +08:00
2024-04-23 18:01:32 +08:00
<u-form-item label="商品主图" prop="formData.imageList" ref="item1" required>
2024-04-19 18:08:04 +08:00
<text style="color: #E18C34;font-size: 24rpx">上传时应注重真实性清晰度</text>
2024-04-23 18:01:32 +08:00
<!-- {{formData.imageList}}
{{formData.content.image}} -->
2024-04-17 18:02:49 +08:00
</u-form-item>
2024-04-22 18:05:44 +08:00
<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>
2024-04-23 18:01:32 +08:00
<u--image @click="preViewImg(item)" :src="item" :fade="true" duration="450"
width='140rpx' height='140rpx'></u--image>
2024-04-22 18:05:44 +08:00
</view>
</view>
2024-04-23 18:01:32 +08:00
<view class='uploadimg' @click="show=true,isDetail=false">
2024-04-19 18:08:04 +08:00
<u-icon name="plus" color="#777777"></u-icon>
2024-04-22 18:05:44 +08:00
<view class="" style="color: #777777;font-size: 20rpx;">
上传图片/视频
2024-04-19 18:08:04 +08:00
</view>
2024-04-18 18:02:57 +08:00
</view>
2024-04-22 18:05:44 +08:00
</view>
</view>
2024-04-23 18:01:32 +08:00
<u-form-item label="商品详情" prop="formData.content.image" required>
2024-04-19 18:08:04 +08:00
<text style="color: #E18C34;font-size: 24rpx">上传时应注重真实性清晰度</text>
</u-form-item>
2024-04-22 18:05:44 +08:00
<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;">
2024-04-23 18:01:32 +08:00
<view class="jiao" @click="formData.content.image.splice(index,1)">
2024-04-22 18:05:44 +08:00
<!-- 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>
2024-04-23 18:01:32 +08:00
<view class="jiao" @click="formData.content.image.splice(index,1)">
2024-04-22 18:05:44 +08:00
<image src="@/static/images/gban.png" mode="widthFix"></image>
</view>
2024-04-23 18:01:32 +08:00
<u--image @click="preViewImg(item)" :src="item" :fade="true" duration="450"
width='140rpx' height='140rpx'></u--image>
2024-04-22 18:05:44 +08:00
</view>
</view>
<view class='uploadimg' @click="show=true,isDetail=true">
2024-04-19 18:08:04 +08:00
<u-icon name="plus" color="#777777"></u-icon>
2024-04-22 18:05:44 +08:00
<view class="" style="color: #777777;font-size: 20rpx;">
上传图片/视频
2024-04-19 18:08:04 +08:00
</view>
2024-04-18 18:02:57 +08:00
</view>
2024-04-22 18:05:44 +08:00
</view>
</view>
2024-04-18 18:02:57 +08:00
</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;">
2024-04-23 18:01:32 +08:00
<u-form-item label="商品分类" prop="cate_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-20 18:02:16 +08:00
@click="navgo(`/pages/product/addGoodDetail/goodsType?mer_id=${mer_id}&&formData=${JSON.stringify(formData)}`)">
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-22 18:05:44 +08:00
@click="navgo(`/pages/product/addGoodDetail/goodsAttr?mer_id=${mer_id}&&formData=${JSON.stringify(formData)}`)">
2024-04-20 14:51:26 +08:00
<view style="margin-right: 10rpx;line-height: 25rpx;">
2024-04-22 08:38:39 +08:00
{{isSet(formData.product_attribute)?'已设置':'未设置' }}
2024-04-20 14:51:26 +08:00
</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;">
2024-04-23 18:01:32 +08:00
<u-form-item label="规格与价格" prop="formData.attrValue" 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-20 18:02:16 +08:00
@click="navgo(`/pages/product/addGoodDetail/goodsPrice?formData=${JSON.stringify(formData)}&&mer_id=${mer_id}`)">
2024-04-22 18:05:44 +08:00
<view style="margin-right: 10rpx;line-height: 25rpx;">{{sets?"已设置":""}}
</view>
2024-04-18 18:02:57 +08:00
<u-icon name="arrow-right"></u-icon>
</view>
</u-form-item>
2024-04-22 18:05:44 +08:00
<view class="" v-if="showSet">
2024-04-23 08:45:17 +08:00
<view class="" v-for="(item,index) in formData.attrValue.filter(item=> item.is_use==0)">
<view class="" v-if='formData.attrValue.filter(item=> item.is_use==0).length==1'>
2024-04-23 18:01:32 +08:00
<u-line color="#CECECE" style="margin: 30rpx 0;"></u-line>
2024-04-23 08:45:17 +08:00
<view class="" style="display: flex;justify-content: space-around;">
<view class=""
style="display: flex;justify-content: space-around;flex: 1;border-right: 1px solid #CECECE;">
<text>零售价格</text>
2024-04-23 18:01:32 +08:00
<text>{{item.price}}/{{item.unit_name}}</text>
2024-04-22 18:05:44 +08:00
</view>
2024-04-23 08:45:17 +08:00
<view class="" style="display: flex;justify-content: space-around;flex: 1;">
<text>商品库存</text>
2024-04-23 18:01:32 +08:00
<text>{{item.stock}}</text>
</view>
</view>
<u-line color="#CECECE" style="margin: 30rpx 0;" v-if='isWholeSale'></u-line>
<view class="" style="display: flex;justify-content: space-around;" v-if='isWholeSale'>
<view class=""
style="display: flex;justify-content: space-around;flex: 1;border-right: 1px solid #CECECE;">
<text>批发价格</text>
<text>{{item.wholesale_price}}/{{item.wholesale_unit_name}}</text>
</view>
<view class="" style="display: flex;justify-content: space-around;flex: 1;">
<text>批发单位</text>
<text>{{item.stock}}</text>
2024-04-22 18:05:44 +08:00
</view>
2024-04-20 14:51:26 +08:00
</view>
2024-04-23 08:45:17 +08:00
</view>
<view class="" v-else>
<u-form-item :label="formData.attr[index].value" 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='!formData.attr[index].value'>
</view>
<view style="font-size: 28rpx;color:#777777 ;">
零售价
</view>
<view style="font-size: 28rpx;color:#777777 ;">
{{item.price}}/{{item.unit_name}}
</view>
2024-04-22 18:05:44 +08:00
</view>
2024-04-23 08:45:17 +08:00
</u-form-item>
<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 ;">
批发价
</view>
<view style="font-size: 28rpx;color:#777777 ;">
{{item.wholesale_price}}/{{item.wholesale_unit_name}}
</view>
2024-04-22 18:05:44 +08:00
</view>
2024-04-23 08:45:17 +08:00
</u-form-item>
</view>
2024-04-22 18:05:44 +08:00
</view>
2024-04-20 14:51:26 +08:00
</view>
2024-04-22 18:05:44 +08:00
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">
2024-04-23 18:01:32 +08:00
<text slot='right' style="font-size:28rpx ; color:#989898 ;">{{value1.length}}/{{300}}</text>
2024-04-18 18:02:57 +08:00
</u-form-item>
2024-04-20 14:59:16 +08:00
<u--textarea v-model="formData.store_info" placeholder="货品描述请严格遵循《广告法》规定,避免出现虚假宣传和误导消费者的词语"
2024-04-23 18:01:32 +08:00
style="background-color: #F9F9F9;height: 166rpx;" :maxlength='300'></u--textarea>
2024-04-19 18:08:04 +08:00
<u-line color="#F3F3F3" style="margin: 30rpx 0;"></u-line>
2024-04-23 18:01:32 +08:00
<u-form-item label="送货方式" labelPosition="left" prop='delivery_way' required>
<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-22 18:05:44 +08:00
<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>
2024-04-17 18:02:49 +08:00
</view>
2024-04-22 18:05:44 +08:00
2024-04-17 18:02:49 +08:00
</template>
<script>
2024-04-20 18:02:16 +08:00
import {
Toast,
Modal
} from "@/libs/uniApi.js";
2024-04-19 18:08:04 +08:00
import {
2024-04-22 18:05:44 +08:00
HTTP_REQUEST_URL,
TOKENNAME
2024-04-19 18:08:04 +08:00
} from '@/config/app.js';
2024-04-22 18:05:44 +08:00
import store from 'store';
2024-04-20 08:40:27 +08:00
import {
2024-04-20 18:02:16 +08:00
productCreate,
2024-04-22 18:05:44 +08:00
productUpdate,
productDetail
2024-04-20 18:02:16 +08:00
} from '@/api/product.js';
2024-04-17 18:02:49 +08:00
import uploadImgVideo from "../addGood/components/uploadImgVideo.vue"
2024-04-22 18:05:44 +08:00
import form from "../../../uni_modules/uview-ui/libs/config/props/form";
2024-04-17 18:02:49 +08:00
export default {
components: {
uploadImgVideo,
},
data() {
return {
2024-04-22 18:05:44 +08:00
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,
2024-04-19 18:08:04 +08:00
formData: {
2024-04-22 18:05:44 +08:00
product_id: "",
"store_name": "",
2024-04-19 18:08:04 +08:00
"imageList": [
2024-04-20 08:40:27 +08:00
2024-04-19 18:08:04 +08:00
],
2024-04-23 18:01:32 +08:00
attr: [{
detail: [],
value: ""
}, ],
2024-04-22 18:05:44 +08:00
"attrValue": [{
2024-04-23 18:01:32 +08:00
detail: {
规格名: 'attr[index]value',
},
2024-04-22 18:05:44 +08:00
"price": "",
"unit_name": "",
"wholesale_unit_name": "",
2024-04-23 18:01:32 +08:00
"wholesale_price": '',
2024-04-22 18:05:44 +08:00
"cost": "",
"stock": "",
2024-04-23 18:01:32 +08:00
sku: 'attr[index]value',
2024-04-22 18:05:44 +08:00
"ot_price": "",
"procure_price": "",
"bar_code": "",
"weight": "",
"extension_one": "",
"extension_two": "",
2024-04-23 18:01:32 +08:00
uuid: "",
volume: "",
2024-04-23 08:45:17 +08:00
"is_use": 0,
2024-04-22 18:05:44 +08:00
}],
2024-04-20 14:59:16 +08:00
"cate_name": "",
"unit_name": "",
2024-04-23 18:01:32 +08:00
"cate_id": '',
"mer_cate_id": [
],
2024-04-22 18:05:44 +08:00
"mer_cate_name": "",
2024-04-23 18:01:32 +08:00
"spec_type": "",
2024-04-19 18:08:04 +08:00
"specifica": "",
2024-04-23 18:01:32 +08:00
"delivery_way": [
],
"delivery_free": "1",
2024-04-19 18:08:04 +08:00
"temp_id": "",
"tempName": "",
"once_min_count": "",
2024-04-22 18:05:44 +08:00
"image": "",
2024-04-19 18:08:04 +08:00
"slider_image": [
2024-04-22 18:05:44 +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-22 18:05:44 +08:00
"stock": "",
2024-04-20 18:02:16 +08:00
product_attribute: {
address: "",
leval: "",
pack: "",
attr: [{
label: "",
value: ''
}]
}
2024-04-22 18:05:44 +08:00
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-22 18:05:44 +08:00
value: '1',
2024-04-18 18:02:57 +08:00
},
{
name: '快递配送',
2024-04-22 18:05:44 +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-23 18:01:32 +08:00
attrRules: {
price: '单价不能为空',
unit_name: '计量单位不能为空',
wholesale_price: '批发价格不能为空',
wholesale_unit_name: '批发单位不能为空',
stock: '库存不能为空'
},
2024-04-17 18:02:49 +08:00
rules: {
2024-04-23 18:01:32 +08:00
"formData.imageList": [{
validator: (rule, value, callback) => {
return this.formData.imageList.length >= 2
},
message: '请至少上传2张图片',
trigger: ['change', 'blur'],
}],
"formData.attrValue": [{
validator: (rule, value, callback) => {
if (!this.isWholeSale) {
delete this.attrRules.wholesale_unit_name
delete this.attrRules.wholesale_price
}
let errList = []
this.formData.attrValue.forEach(item => {
for (let key in this.attrRules) {
if (!item[key]) {
errList.push(this.rules[key])
}
}
})
console.log(errList, 'err')
return errList.length == 0
},
message: '请填写完整商品规格',
trigger: ['change', 'blur'],
}],
'store_name': {
type: 'string',
required: true,
message: '请填写商品标题',
trigger: ['blur', 'change']
},
'cate_name': {
type: 'string',
required: true,
message: '请填写商品分类',
trigger: ['blur', 'change']
},
'delivery_way': {
validator: (rule, value, callback) => {
return this.formData.delivery_way.length > 0
},
required: true,
message: '请选择送货方式',
trigger: ['blur', 'change']
},
'formData.content.image': {
validator: (rule, value, callback) => {
return this.formData.content.image.length > 0
},
required: true,
message: '请上传商品详情图',
trigger: ['blur', 'change']
},
2024-04-19 18:08:04 +08:00
2024-04-17 18:02:49 +08:00
},
radio: '',
switchVal: false
};
},
methods: {
2024-04-23 18:01:32 +08:00
preViewImg(url) {
let that = this
uni.previewImage({
urls: [url],
});
},
2024-04-22 18:05:44 +08:00
deleteImage(index) {
// this.addGoodsSecoundData.video_link = '';
2024-04-20 08:40:27 +08:00
},
2024-04-22 18:05:44 +08:00
videoshow(index) {
this.videoIndex = index
this.showVideo = true
this.videoContext = uni.createVideoContext('myVideo', this);
this.$nextTick(() => {
this.videoContext.play();
2024-04-20 08:40:27 +08:00
})
2024-04-22 18:05:44 +08:00
},
getSuffix(url) {
const str = url;
const lastIndex = str.lastIndexOf(".");
if (lastIndex !== -1) {
const extension = str.substring(lastIndex + 1);
return extension
} else {
console.log("字符串中没有找到点号。");
2024-04-20 08:40:27 +08:00
}
},
2024-04-22 18:05:44 +08:00
choseMedia(e) {
console.log(e.value)
this.show = false
if (e.value[0] == '图片') {
this.handleChooseImage()
} else {
this.uploadVideo()
}
2024-04-20 08:40:27 +08:00
},
2024-04-23 08:45:17 +08:00
2024-04-22 18:05:44 +08:00
// 选择图片
handleChooseImage() {
let that = this;
2024-04-23 08:45:17 +08:00
that.$util.uploadImages({
count: 6,
url: 'upload/image'
}, function(res) {
2024-04-23 18:01:32 +08:00
if (that.isDetail) {
that.formData.content.image.push(res.data.path.replace(
/\\/g, ""));
} else {
that.$set(that.formData.imageList, that.formData.imageList.length, res.data.path.replace(
/\\/g,
""));
}
// that.formData.imageList.push(res.data.path);
2024-04-22 18:05:44 +08:00
});
2024-04-19 18:08:04 +08:00
},
2024-04-22 18:05:44 +08:00
// 上传视频
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 'true12';
}
2024-04-19 18:08:04 +08:00
}
2024-04-22 18:05:44 +08:00
2024-04-19 18:08:04 +08:00
},
2024-04-22 18:05:44 +08:00
isSet2(obj) {
let lists = ['unit_name', 'price', 'wholesale_price', 'stock']
lists.forEach(item => {
if (Boolean(this.formData.attrValue[0][item])) {
this.sets = true
}
2024-04-19 18:08:04 +08:00
})
2024-04-22 18:05:44 +08:00
2024-04-19 18:08:04 +08:00
},
2024-04-22 18:05:44 +08:00
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
},
2024-04-20 18:02:16 +08:00
// submit() {
// console.log(this.formData)
// },
2024-04-20 14:51:26 +08:00
getAttr(object) {
2024-04-20 18:02:16 +08:00
this.formData.product_attribute = object
2024-04-20 14:51:26 +08:00
},
getAttrValue(object) {
this.formData.attrValue = object
},
2024-04-23 18:01:32 +08:00
async handAdd() {
2024-04-22 18:05:44 +08:00
let that = this
2024-04-20 18:02:16 +08:00
let data = uni.$u.deepClone(this.formData)
data.image = data.imageList[0]
data.slider_image = data.imageList.splice(0, 1)
data.store_name = data.cate_name
2024-04-22 18:05:44 +08:00
that.formData.product_id ?
productUpdate(that.mer_id, that.formData.product_id, data)
2024-04-20 18:02:16 +08:00
.then(res => {
Modal('提交成功', '点击确定,前往商品列表页面').then(() => {
if (this.import == 1) {
uni.$emit('importAttrValueOK', this.setFormData.import_id);
uni.navigateBack();
} else uni.redirectTo({
2024-04-22 18:05:44 +08:00
url: `/pages/product/goodsOnSale/index?mer_id=${that.mer_id}&type=6`
2024-04-20 18:02:16 +08:00
})
}).catch(() => {
uni.navigateBack()
})
})
.catch(rej => {
// Toast(rej);
2024-04-22 18:05:44 +08:00
}) :
productCreate(that.mer_id, data)
.then(res => {
Modal('提交成功', '点击确定,前往商品列表页面').then(() => {
if (this.import == 1) {
uni.$emit('importAttrValueOK', this.setFormData.import_id);
2024-04-23 18:01:32 +08:00
uni.redirectTo({
url: `/pages/product/list/index?mer_id=${this.mer_id}&type=6`
})
2024-04-22 18:05:44 +08:00
} else uni.redirectTo({
2024-04-23 18:01:32 +08:00
url: `/pages/product/list/index?mer_id=${this.mer_id}&type=6`
2024-04-22 18:05:44 +08:00
})
}).catch(() => {
uni.navigateBack()
})
})
.catch(rej => {
// Toast(rej);
})
2024-04-23 08:45:17 +08:00
},
2024-04-23 18:01:32 +08:00
submit() {
this.$refs.formData.validate().then(res => {
this.handAdd()
}).catch(errors => {
uni.$u.toast(errors[0].message)
})
},
2024-04-23 08:45:17 +08:00
initFormData(option) {
this.isWholeSale = this.$store.state.app.userInfo?.mer_info?.wholesale == 2;
this.mer_id = option.mer_id
if (option.formData) {
this.formData = JSON.parse(option.formData)
}
2024-04-20 18:02:16 +08:00
}
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) {
2024-04-23 08:45:17 +08:00
this.initFormData(option)
2024-04-22 18:05:44 +08:00
this.showSet = option.showSet ? JSON.parse(option.showSet) : this.showSet
let that = this
this.isSet2()
2024-04-23 18:01:32 +08:00
that.formData.delivery_way = that.$store.state.app.userInfo?.mer_info.delivery_way.split(',')
2024-04-24 08:47:26 +08:00
if (option.product_id) {
that.formData.product_id = option.product_id
this.mode = 'edit'
this.showSet = true
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
if (!that.formData.imageList) that.formData.imageList = []
})
}
2024-04-23 18:01:32 +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-22 18:05:44 +08:00
/* margin-left: 20rpx; */
overflow: hidden;
2024-04-19 18:08:04 +08:00
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
}
2024-04-22 18:05:44 +08:00
.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; */
}
2024-04-17 18:02:49 +08:00
</style>