This commit is contained in:
zmj 2024-04-17 18:02:49 +08:00
parent b8e1824d21
commit 006041fca6
9 changed files with 1583 additions and 1223 deletions

View File

@ -308,12 +308,11 @@
}
},
{
"path" : "pages/cashier/cashier",
"style" :
{
"navigationBarTitleText" : "收银",
"enablePullDownRefresh" : true
}
"path": "pages/cashier/cashier",
"style": {
"navigationBarTitleText": "收银",
"enablePullDownRefresh": true
}
}
],
"subPackages": [{
@ -1509,6 +1508,13 @@
"enablePullDownRefresh": false
}
},
{
"path": "addGood/addGoodOld",
"style": {
"navigationBarTitleText": "发布商品",
"enablePullDownRefresh": false
}
},
{
"path": "addGood/addGood_one",
"style": {
@ -1536,6 +1542,13 @@
"navigationBarTitleText": "更新库存",
"enablePullDownRefresh": false
}
},
{
"path": "addGoodDetail/addGoodDetail",
"style": {
"navigationBarTitleText": "发布商品",
"enablePullDownRefresh": false
}
}
]
},

View File

@ -1,762 +1,157 @@
<template>
<view class="container">
<view class="step_one">
<view class="input_content">
<view class="bar-code" v-if="bar_code_dis">
<view>商品条码</view>
<input type="number" placeholder="请手动添加条码" v-model="code" :disabled="bar_code_dis"
placeholder-class="inputPlaceHolder" />
<view class='content'>
<u--form :model="model1" :rules="rules" ref="uForm" labelPosition="top"
:labelStyle="{fontWeight:'bold',fontSize:'32rpx'}" labelWidth='100'>
<u-form-item label="想卖什么" prop="userInfo.name" ref="item1">
<view class="borders">
<u--textarea v-model="model1.userInfo.name" placeholder="请描述您想卖的货品名称,如:红富士苹果、宁夏西瓜、梨。"></u--textarea>
</view>
<view class="input_content_textarea">
<textarea v-model="setFormData.store_name" placeholder="请输入45商品名称"
placeholder-class="placeholderStyle" maxlength="60" />
<view class="flex" style="justify-content: space-between;color: #999999;">
<view>(品牌,名称,规格,口味)</view>
<view>
<text v-if="setFormData.store_name">{{ setFormData.store_name.length }}</text>
<text v-else>0</text>/60
</view>
</view>
</u-form-item>
<u-form-item label="上传商品图" prop="userInfo.name" ref="item1">
<uploadImgVideo></uploadImgVideo>
</u-form-item>
<u-form-item label="商品售价" prop="userInfo.name" ref="item1">
<view class="borders" style="width:250rpx;height: 100rpx;">
<u--input placeholder="" v-model="text"></u--input>
</view>
<view class="photo_count">
<text class="photo_size" style="color: #e93323;">建议图片尺寸为750*750px, 上传2张以上</text>
<view class="input_content_photo">
<view class="input_content_photo_adPh" v-for="(item, index) in setFormData.imageList"
:key="index">
<image :src="item" class="myimg2 photos" @click="pop(item)"></image>
<view class="input_content_photo_adPh_jiao" @click="deleteImage(index)">
<image src="../static/images/close.png" mode=""></image>
</view>
</view>
<view v-if="setFormData.imageList.length < 9" class="input_content_photo_adPh addBtn"
@click="clk">
<view>
<image src="../static/images/creamer.png" mode="widthFix"></image>
</view>
<view>添加图片</view>
</view>
</view>
<text style="margin: 0 20rpx;"></text>
<uni-section type="line" style="width:250rpx;">
<uni-data-select v-model="text" :localdata="range" placeholder=""></uni-data-select>
</uni-section>
</u-form-item>
<view class="footer">
<view class="footer-top">
<text style="margin: 0 auto; ">
显示全部<u-icon style="display: inline-block;font-weight: bold;" color="$uni-newTheme-color"
name="arrow-right"></u-icon>
</text>
</view>
<u-popup ref="select_popup" class="pop" :show="show" mode="center" closeOnClickOverlay
bgColor='transparent'>
<image :src="image"></image>
<image src="@/static/images/guanbi.png" class="guanbi" @click="close"></image>
</u-popup>
</view>
<!-- 商品详情 -->
<commodityComponent ref="commodityRef" v-if="showCommodity" :key="showCommodity"
:showCommodity="showCommodity" :product_id="product_id" :merId="merId" :code="code">
</commodityComponent>
<view class="popup_group">
<view class="popup_group_item popup_group_item_b" @click="selectPlatform">
<view class="popup_group_item_label">平台分类</view>
<view class="popup_group_item_value">
<view class="popup_group_item_message">
<span v-if="setFormData.cate_name"
class="popup_group_item_message_value">{{ setFormData.cate_name }}</span>
<span v-else>请选择平台分类</span>
</view>
<view><span class="iconfont">&#xe6bd;</span></view>
</view>
</view>
<view class="popup_group_item" @click="selectStoreClass">
<view class="popup_group_item_label ">店铺分类</view>
<view class="popup_group_item_value">
<view class="popup_group_item_message">
<span v-if="setFormData.mer_cate_name"
class="popup_group_item_message_value">{{ setFormData.mer_cate_name }}</span>
<span v-else>请选择店铺分类</span>
</view>
<view><span class="iconfont">&#xe6bd;</span></view>
</view>
</view>
<view class="popup_group_item popup_group_item_b">
<view class="popup_group_item_label">商品单位</view>
<view class="popup_group_item_value"><input v-model="setFormData.unit_name" type="text"
placeholder="请填写商品单位" /></view>
</view>
</view>
<!-- 选择平台分类弹框 -->
<uni-popup ref="select_platform" type="bottom">
<platfrom @close="closePlatfrom" :classifiedData="platformClassificationData"
@getPlatData="getPlatData">
</platfrom>
</uni-popup>
<!-- 选择店铺分类弹框 -->
<uni-popup ref="select_store" type="bottom">
<store-classification :classifiedData="merchantClassification" :mer_id="merId"
@handleGetSelectArea="handleGetSelectStore" @close="merchantClose"></store-classification>
</uni-popup>
<!-- 规格设置 -->
<picker mode="selector" :range="['单规格','多规格']" :value="setFormData.spec_type" @change="changeSpecType">
<view class="popup_group" style="margin-bottom: 0;">
<view class="popup_group_item">
<view class="popup_group_item_label">商品规格</view>
<view class="popup_group_item_value">
<view class="popup_group_item_message">
<span
class="popup_group_item_message_value">{{ setFormData.spec_type==0?'单规格':'多规格' }}</span>
</view>
<view><span class="iconfont">&#xe6bd;</span></view>
</view>
</view>
</view>
<u-modal :show="showSpecType" title="温馨提示" content="切换后商品原有规格将失效,是否继续?" show-cancel-button
confirm-text="继续" @confirm="changeSpecType2" @cancel="showSpecType=false"></u-modal>
</picker>
<priceComponent v-if="setFormData.spec_type==0" :datas="setFormData.attrValue[0]" ref="priceRef"
:product_id="product_id" :bar_code="code" @updateCode="updateCode">
</priceComponent>
<view v-else class="popup_group" style="margin-top: 0;border-top: 1rpx solid #eeeeee;">
<view class="popup_group_item" @click="navToSpecGood()">
<view class="popup_group_item_label" style="flex: 1; text-align: center;">
设置多规格
<text v-if="setFormData.attrValue.length>0">({{setFormData.attrValue.length}})</text>
</view>
<view class="footer-bottom">
发布内容越详尽成单力越高
</view>
</view>
<view class="popup_group">
<!-- <view class="popup_group_item" @click="showMoreInfo=!showMoreInfo">
<view class="popup_group_item_label">更多信息</view>
<view class="popup_group_item_value" :class="showMoreInfo?'icon_bottom':'icon_top'">
<view><span class="iconfont">&#xe6bd;</span></view>
</view>
</view> -->
<block>
<view class="input_content">
<view class="input_content_describe" style="border: none;padding-bottom: 0;">
<view class="input_content_describe_title">
<view class="input_content_describe_title_msg">商品简介</view>
<view class="input_content_describe_title_num">
<text v-if="setFormData.store_info">{{ setFormData.store_info.length }}</text>
<text v-else>0</text>
/200
</view>
</view>
<view class="input_content_describe_textarea">
<textarea v-model="setFormData.store_info" style="width: 100%;" value=""
placeholder="请填写商品简介" placeholderClass="placeholderClass" maxlength="200" />
</view>
</view>
<!-- <view class="input_content_keyword">
<view class="input_content_keyword_label">关键字</view>
<view class="input_content_keyword_value"><input v-model="setFormData.keyword" type="text" value=""
placeholder="填写关键字" /></view>
</view> -->
</view>
<!-- <view class="input_content">
<view class="input_content_keyword">
<view class="input_content_keyword_label">最少购买件数</view>
<view class="input_content_keyword_value"><input v-model="setFormData.once_min_count" type="number" value=""
placeholder="不限量" /></view>
</view>
</view> -->
<view class="radio">
<view class="radio_label ">送货方式</view>
<checkbox-group class="select_group flex_start" @change="changeDelivery">
<label class="radio_select" v-for="(val, i) in deliveryFreeList" :key="val.value">
<view>
<checkbox :value="val.value"
:checked="setFormData.delivery_way.includes(val.value+'')" />
</view>
<view>{{ val.name }}</view>
</label>
</checkbox-group>
</view>
</block>
<view class="submit-btn">
<u-button text="立即发布获取订单" @click='goDetail' :class="{height:'200px'}" color="#33BB3C"></u-button>
</view>
</view>
<view class="handle">
<view class="handle_button" @click="submitCreatedGoods">提交</view>
</view>
<!-- 图片选择器 -->
<avatar @upload="doUpload" @getName="getImgName" quality="1" ref="avatar" selWidth="250upx" selHeight="250upx">
</avatar>
</u--form>
</view>
</template>
<script>
import {
TOKENNAME,
HTTP_REQUEST_URL
} from '@/config/app.js';
import {
categoryBrandlist,
categorySelect,
storeClassifyLst,
categoryList,
attrList,
templateList,
productDetail,
getDeliveryType,
productCreate,
productUpdate
} from '@/api/product.js';
import {
serialize,
Toast,
Loading,
hideLoading,
Modal
} from "@/libs/uniApi.js";
import avatar from "@/components/yq-avatar/yq-avatar.vue";
import platfrom from "./components/platform.vue";
import storeClassification from '../components/store_classification.vue';
import commodityComponent from "./components/commodity.vue";
import priceComponent from "./components/price.vue";
import uploadImgVideo from "./components/uploadImgVideo.vue"
export default {
components: {
avatar,
platfrom,
commodityComponent,
priceComponent,
storeClassification
uploadImgVideo,
},
data() {
return {
bar_code_dis: false,
merId: '', //id
product_id: '', //id
import: 0, //
code: '', //
show: false, //
image: false, //
setFormData: {
store_name: '',
imageList: [],
attrValue: [],
cate_name: '', //
unit_name: '', //
cate_id: '', // id
mer_cate_id: '', //
mer_cate_name: '', //
spec_type: '0', // 0. 1
attr: [], //
specifica: '', //
// setSpecificaValue: '', //
// setSpecificaValue2: '',
delivery_way: ['1', '2'], // 1 2
delivery_free: '1', // 0 1
temp_id: '', // ID
tempName: '', //
once_min_count: '', //
showSex: false,
model1: {
userInfo: {
name: '',
sex: '',
},
},
platformClassificationData: [], //
merchantClassification: [], //
brand: [], //
showCommodity: false, // ,
deliveryFreeList: [{
value: '1',
name: '到店核销'
range: [{
value: 0,
text: "篮球"
},
{
value: '2',
name: '快递配送'
}
value: 1,
text: "足球"
},
{
value: 2,
text: "游泳"
},
],
//
classified: {
cate_id: [],
mer_cate_id: [],
brand_id: [],
attr: [],
temp_id: []
text: "",
rules: {
// 'userInfo.name': {
// type: 'string',
// required: true,
// message: '',
// trigger: ['blur', 'change']
// },
// 'userInfo.sex': {
// type: 'string',
// max: 1,
// required: true,
// message: '',
// trigger: ['blur', 'change']
// },
},
productItem: {} || [],
showSpecType: false, //
spec_type: 0, //,0,1
radio: '',
switchVal: false
};
},
onLoad(opt) {
this.merId = Number(opt.mer_id);
this.product_id = opt.product_id;
this.import = opt.import;
// if (!opt.product_id) this.showCommodity = true;
this.showCommodity = true;
this.initData();
if (this.import == 1) {
this.getOpenerEventChannel().once('importAttrValue', (e) => {
this.attrValue = e.attrValue;
uni.setStorageSync('attrValue', JSON.stringify(e.attrValue));
this.attr = e.attr;
uni.setStorageSync('attr', JSON.stringify(e.attr));
this.setFormData = Object.assign({}, this.setFormData, e);
this.$nextTick(() => {
this.$refs.commodityRef?.setDatas({
addGoodsSecoundData: {
is_good: this.setFormData.is_good, //
is_gift_bag: this.setFormData.is_gift_bag,
sort: this.setFormData.sort,
once_count: this.setFormData.once_count, //
video_link: this.setFormData.video_link,
},
goodsDis: {
store_name: this.setFormData.content?.title,
imageList: this.setFormData.content?.image
}
})
})
})
} else if (this.product_id) {
this.initDataEditData();
}
},
onBackPress() {},
onShow() {
this.initClasiffy();
// this.setFormData = Object.assign(this.setFormData, {
// "store_name": "",
// "imageList": [
// "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/457c6202311181745387896.jpeg",
// "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/185e2202311181745434402.jpeg"
// ],
// "cate_name": "",
// "unit_name": "",
// "cate_id": 445,
// "keyword": "22"
// })
// this.$nextTick(async () => {
// await this.$u.sleep(200)
// this.$refs.commodityRef.addGoodsSecoundData = {
// "is_good": 1,
// "is_gift_bag": 0,
// "sort": "20",
// "once_count": "",
// "video_link": "https://lihai001.oss-cn-chengdu.aliyuncs.com/media/7ce3d202311181816166215.mp4"
// }
// this.$refs.commodityRef.goodsDis = {
// "store_name": "",
// "imageList": [
// "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/fb73d202311181751262661.png"
// ]
// }
// this.$refs.priceRef.singleSpecification = {
// "price": "1",
// "cost": "1",
// "stock": "11",
// "ot_price": "",
// "wholesale_price": "",
// "bar_code": "666",
// "weight": "10",
// "volume": "5",
// "image": "",
// "extension_one": "",
// "extension_two": ""
// }
// })
},
beforeDestroy() {},
watch: {
'setFormData.imageList'(val) {
this.setFormData.image = val.length ? val[0] : '';
this.setFormData.slider_image = val.length ? serialize(val).splice(1) : [];
}
},
methods: {
changeDelivery(e) {
this.setFormData.delivery_way = e.detail.value;
sexSelect(e) {
this.model1.userInfo.sex = e.name
this.$refs.uForm.validateField('userInfo.sex')
},
//
initDataEditData() {
this.setFormData = {
imageList: [],
attrValue: [],
specification: '',
image: '', //
slider_image: '', //
store_name: '', //
store_info: '', //
keyword: '', //
brand_id: '', // id
brand_name: '', //
cate_id: '', //
cate_name: '', //
mer_cate_id: '', //
mer_cate_name: '', //
unit_name: '', //
spec_type: '0', // 0. 1
attr: [], //
specifica: '', //
// setSpecificaValue: '', //
// setSpecificaValue2: '', //
delivery_way: [], // 1 2
delivery_free: '0', // 0 1
temp_id: '', // ID
tempName: '', //
once_min_count: '', //
};
productDetail(this.merId, this.product_id).then(async (res) => {
this.showCommodity = true;
if (res.data.content_arr && res.data.content_arr.length > 0) res.data.content = res.data
.content_arr;
let editGoodsDetils = res.data;
Object.keys(this.setFormData).forEach(item => {
this.setFormData[item] = editGoodsDetils[item];
});
this.setFormData.product_id = this.product_id;
this.setFormData.imageList = [...(this.setFormData.image ? [this.setFormData.image] : []),
...
this
.setFormData.slider_image
];
this.setFormData.cate_name = editGoodsDetils?.storeCategory?.cate_name; //
this.setFormData.mer_cate_name = editGoodsDetils.merCateId ? editGoodsDetils.merCateId.map(
item => item
.category && item.category.cate_name).join(',') : '';
this.setFormData.brand_name = editGoodsDetils.brand ? editGoodsDetils.brand.brand_name :
'';
if (res.data.content && typeof res.data.content == 'string') res.data.content = JSON.parse(
res.data
.content);
this.setFormData.once_min_count <= 0 ? this.setFormData.once_min_count = '' : null;
this.setFormData.delivery_way = res.data.delivery_way;
//
this.$nextTick(() => {
this.$refs.commodityRef.setDatas({
addGoodsSecoundData: {
is_good: res.data.is_good, //
is_gift_bag: res.data.is_gift_bag,
sort: res.data.sort,
once_count: res.data.once_count, //
video_link: res.data.video_link,
},
goodsDis: {
store_name: res.data.content?.title,
imageList: res.data.content?.image
}
})
//
if (this.setFormData.spec_type == 0) {
this.$refs.priceRef.setDatas(res.data.attrValue[0]);
}
})
editGoodsDetils.temp && (this.setFormData.tempName = editGoodsDetils.temp.name);
hideLoading();
});
},
//
async initClasiffy() {
this.merchantClassification = (await storeClassifyLst(this.merId)).data;
},
initData() {
//
categoryBrandlist(this.merId).then((res) => {
this.brand = res.data;
}).catch(e => {
console.log(e);
});
//
categoryList(this.merId).then((res) => {
res.data.forEach((item1) => {
item1.children.forEach((item2) => {
item2.children = null;
})
})
this.platformClassificationData = res.data;
}).catch(e => {
console.log(e);
})
},
//
updateCode(e) {
this.code = e + '';
},
//
handleChooseImage() {
let that = this;
that.$util.uploadImageOne('upload/image', function(res) {
that.setFormData.imageList.push(res.data.path);
});
},
clk() {
// let avatar = this.$refs.avatar;
// avatar.fChooseImg(1, {
// selWidth: '350upx',
// selHeight: '350upx',
// inner: true
// });
this.$util.uploadImageOne({
url: 'upload/image',
crop: {
width: 2000,
height: 2000,
}
},(res)=> {
this.setFormData.imageList.push(res.data.path);
});
},
doUpload(rsp) {
let that = this
// console.log(rsp);
uni.uploadFile({
url: HTTP_REQUEST_URL + '/api/upload/image/field',
filePath: rsp.path,
name: 'field',
formData: {
'filename': rsp.path,
'name': that.imgName
},
header: {
// #ifdef MP
"Content-Type": "multipart/form-data",
// #endif
[TOKENNAME]: 'Bearer ' + this.$store.state.app.token
},
success: (uploadFileRes) => {
// console.log(uploadFileRes.data);
let imgData = JSON.parse(uploadFileRes.data)
that.setFormData.imageList.push(imgData.data.path)
},
complete(res) {
// console.log(res)
}
});
},
getImgName(name) {
this.imgName = name
},
//
pop(e) {
this.show = true
this.image = e
},
//
close() {
this.$refs.select_popup.close();
this.show = false
},
//
deleteImage(index) {
this.setFormData.imageList.splice(index, 1);
},
//
selectPlatform() {
this.$refs.select_platform.open();
},
//
closePlatfrom() {
this.$refs.select_platform.close();
},
//
getPlatData(item, taplist) {
this.setFormData.cate_id = item.value;
this.setFormData.cate_name = item.label;
this.$refs.select_platform.close();
},
//
selectStoreClass() {
this.$refs.select_store.open();
},
//
merchantClose() {
this.$refs.select_store.close();
},
//
handleGetSelectStore(item) {
console.log(item);
this.setFormData.mer_cate_id = item.map(val => val.store_category_id);
this.setFormData.mer_cate_name = item.map(val => val.cate_name).join(',');
this.$refs.select_store.close();
},
//
selectBrand() {
this.$refs.select_popup.open();
},
//
getLinkageData(item) {
this.setFormData.brand_id = item[0].value;
this.setFormData.brand_name = item[0].cate_name;
this.$refs.select_popup.close();
},
//
multipleList(data, model) {
if (model == 'mer_cate_id') {
this.platformClassification[1].value = data.map(item => item.label).join('');
this.platformClassification[1].allreadySelect = data;
this.setFormData.mer_cate_id = data.map(item => item.value);
}
},
// popup
//
close() {
this.$refs.select_popup.close();
this.show = false
},
//
getLinkDataOfRecursion(arr, child = 'children', key = 'value') {
let str = '';
let id = '';
arr.forEach(item => {
str = item.label;
id = item.value;
});
// str = str.slice(0, str.length - 1);
return {
str,
id
};
},
//
getTemplateList() {
templateList(this.merId, this.templateListPage).then(res => {
res.data.list.forEach(item => {
this.$set(item, 'value', item.shipping_template_id);
this.$set(item, 'label', item.name);
});
this.classified['temp_id'] = res.data.list;
this.$refs.tempId.open();
});
},
//
submitCreatedGoods() {
console.log('创建商品');
// return console.log('', this.setFormData.attr);
console.log('是否推荐', this.$refs.commodityRef.addGoodsSecoundData);
console.log('商品详情', this.$refs.commodityRef.goodsDis, this.$refs.commodityRef.store_name);
if (this.setFormData.spec_type == 0) {
console.log('价格库存', this.$refs.priceRef.singleSpecification);
}
if (this.setFormData.delivery_way.length == 0) return Toast('请至少选择一种送货方式');
let postData = {
...this.setFormData,
...this.$refs.commodityRef.addGoodsSecoundData,
content: {
title: this.$refs.commodityRef.goodsDis?.store_name || '',
image: this.$refs.commodityRef.goodsDis?.imageList || []
},
video_link: this.$refs.commodityRef.addGoodsSecoundData.video_link,
};
if (this.setFormData.spec_type == 0) {
postData.attrValue = [this.$refs.priceRef.singleSpecification];
} else postData.attrValue = this.setFormData.attrValue;
postData.stock = postData.attrValue[0]?.stock || 0;
if (!postData.store_name || postData.store_name?.trim().length <= 0) return Toast('请输入商品名称');
if (!postData.imageList || postData.imageList?.length < 2) return Toast('请上传2张以上商品图片');
if (!postData.cate_name || postData.cate_name?.trim().length <= 0) return Toast('请选择平台分类');
if (!postData.unit_name || postData.unit_name?.trim().length <= 0) return Toast('请输入商品单位');
let userInfo = this.$store.state.app.userInfo;
if (typeof userInfo == 'string') userInfo = JSON.parse(userInfo);
let showFlag = '';
console.log(postData);
postData.attrValue.forEach(t => {
if (userInfo.mer_info.wholesale && (!t.wholesale_price || +t.wholesale_price <= 0)) {
showFlag = '批发价不能小于0'
}
if (!t.price || +t.price <= 0) showFlag = '零售价不能小于0';
if (!t.stock || +t.stock <= 0) showFlag = '库存不能小于0';
// if (!t.cost || +t.cost <= 0) showFlag = '0';
})
if (showFlag) {
if (this.setFormData.spec_type == 1) showFlag += ', 请点击设置多规格设置';
return Toast(showFlag);
}
Loading();
if (this.product_id) {
productUpdate(this.merId, this.product_id, postData)
.then(res => {
hideLoading()
Modal('提交成功', '点击确定, 前往商品列表页面').then(() => {
uni.redirectTo({
url: `/pages/product/goodsOnSale/index?mer_id=${this.merId}&type=6`
})
}).catch(() => {
uni.navigateBack()
})
})
.catch(rej => {
Toast(rej);
});
} else {
productCreate(this.merId, postData)
.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.merId}&type=6`
})
}).catch(() => {
uni.navigateBack()
})
})
.catch(rej => {
Toast(rej);
});
}
},
//
changeSpecType(e) {
if (this.setFormData.spec_type != e.detail.value) {
this.showSpecType = true;
}
this.spec_type = e.detail.value;
},
//
changeSpecType2() {
this.showSpecType = false;
this.setFormData.spec_type = this.spec_type + '';
this.setFormData.attrValue = [];
this.setFormData.attr = [];
},
//
navToSpecGood() {
goDetail() {
uni.navigateTo({
url: '/pages/product/addGood/specGood?product_id=' + this.product_id,
success: (e) => {
// console.log(this.setFormData.attrValue, e);
e.eventChannel.emit('updateAttrValue', {
attrValue: JSON.parse(JSON.stringify(this.setFormData.attrValue)),
attr: JSON.parse(JSON.stringify(this.setFormData.attr))
});
uni.$once('updateSpecType', (e) => {
this.setFormData.attrValue = JSON.parse(JSON.stringify(e.attrValue));
this.setFormData.attr = JSON.parse(JSON.stringify(e.attr));
})
}
url: '/pages/product/addGoodDetail/addGoodDetail'
})
}
}
},
};
</script>
<style lang="scss" scoped>
@import './scss/index.scss';
<style lang='scss'>
.content {
width: 100vw;
min-height: 100vh;
background-color: white;
box-sizing: border-box;
padding: 30rpx;
.pop {
z-index: 1;
.borders {
width: 690rpx;
border: 1px solid #CECECE;
border-radius: 10rpx;
}
}
.guanbi {
width: 20px;
height: 20px;
margin: 30px auto;
.footer {
position: absolute;
bottom: 270rpx;
left: 50%;
transform: translate(-50%, 0);
font-size: 28rpx;
.footer-top {
color: $uni-newTheme-color;
display: flex;
font-weight: bold;
align-items: center;
}
.footer-bottom {
font-size: 28rpx;
color: #989898;
}
}
.submit-btn {
position: absolute;
bottom: 86rpx;
left: 50%;
transform: translate(-50%, 0);
width: 670rpx;
border-radius: 40rpx;
overflow: hidden;
}
/deep/ .uni-select {
height: 100rpx;
border: 2rpx #CECECE solid;
}
</style>

View File

@ -0,0 +1,762 @@
<template>
<view class="container">
<view class="step_one">
<view class="input_content">
<view class="bar-code" v-if="bar_code_dis">
<view>商品条码</view>
<input type="number" placeholder="请手动添加条码" v-model="code" :disabled="bar_code_dis"
placeholder-class="inputPlaceHolder" />
</view>
<view class="input_content_textarea">
<textarea v-model="setFormData.store_name" placeholder="请输入45商品名称"
placeholder-class="placeholderStyle" maxlength="60" />
<view class="flex" style="justify-content: space-between;color: #999999;">
<view>(品牌,名称,规格,口味)</view>
<view>
<text v-if="setFormData.store_name">{{ setFormData.store_name.length }}</text>
<text v-else>0</text>/60
</view>
</view>
</view>
<view class="photo_count">
<text class="photo_size" style="color: #e93323;">建议图片尺寸为750*750px, 上传2张以上</text>
<view class="input_content_photo">
<view class="input_content_photo_adPh" v-for="(item, index) in setFormData.imageList"
:key="index">
<image :src="item" class="myimg2 photos" @click="pop(item)"></image>
<view class="input_content_photo_adPh_jiao" @click="deleteImage(index)">
<image src="../static/images/close.png" mode=""></image>
</view>
</view>
<view v-if="setFormData.imageList.length < 9" class="input_content_photo_adPh addBtn"
@click="clk">
<view>
<image src="../static/images/creamer.png" mode="widthFix"></image>
</view>
<view>添加图片</view>
</view>
</view>
</view>
<u-popup ref="select_popup" class="pop" :show="show" mode="center" closeOnClickOverlay
bgColor='transparent'>
<image :src="image"></image>
<image src="@/static/images/guanbi.png" class="guanbi" @click="close"></image>
</u-popup>
</view>
<!-- 商品详情 -->
<commodityComponent ref="commodityRef" v-if="showCommodity" :key="showCommodity"
:showCommodity="showCommodity" :product_id="product_id" :merId="merId" :code="code">
</commodityComponent>
<view class="popup_group">
<view class="popup_group_item popup_group_item_b" @click="selectPlatform">
<view class="popup_group_item_label">平台分类</view>
<view class="popup_group_item_value">
<view class="popup_group_item_message">
<span v-if="setFormData.cate_name"
class="popup_group_item_message_value">{{ setFormData.cate_name }}</span>
<span v-else>请选择平台分类</span>
</view>
<view><span class="iconfont">&#xe6bd;</span></view>
</view>
</view>
<view class="popup_group_item" @click="selectStoreClass">
<view class="popup_group_item_label ">店铺分类</view>
<view class="popup_group_item_value">
<view class="popup_group_item_message">
<span v-if="setFormData.mer_cate_name"
class="popup_group_item_message_value">{{ setFormData.mer_cate_name }}</span>
<span v-else>请选择店铺分类</span>
</view>
<view><span class="iconfont">&#xe6bd;</span></view>
</view>
</view>
<view class="popup_group_item popup_group_item_b">
<view class="popup_group_item_label">商品单位</view>
<view class="popup_group_item_value"><input v-model="setFormData.unit_name" type="text"
placeholder="请填写商品单位" /></view>
</view>
</view>
<!-- 选择平台分类弹框 -->
<uni-popup ref="select_platform" type="bottom">
<platfrom @close="closePlatfrom" :classifiedData="platformClassificationData"
@getPlatData="getPlatData">
</platfrom>
</uni-popup>
<!-- 选择店铺分类弹框 -->
<uni-popup ref="select_store" type="bottom">
<store-classification :classifiedData="merchantClassification" :mer_id="merId"
@handleGetSelectArea="handleGetSelectStore" @close="merchantClose"></store-classification>
</uni-popup>
<!-- 规格设置 -->
<picker mode="selector" :range="['单规格','多规格']" :value="setFormData.spec_type" @change="changeSpecType">
<view class="popup_group" style="margin-bottom: 0;">
<view class="popup_group_item">
<view class="popup_group_item_label">商品规格</view>
<view class="popup_group_item_value">
<view class="popup_group_item_message">
<span
class="popup_group_item_message_value">{{ setFormData.spec_type==0?'单规格':'多规格' }}</span>
</view>
<view><span class="iconfont">&#xe6bd;</span></view>
</view>
</view>
</view>
<u-modal :show="showSpecType" title="温馨提示" content="切换后商品原有规格将失效,是否继续?" show-cancel-button
confirm-text="继续" @confirm="changeSpecType2" @cancel="showSpecType=false"></u-modal>
</picker>
<priceComponent v-if="setFormData.spec_type==0" :datas="setFormData.attrValue[0]" ref="priceRef"
:product_id="product_id" :bar_code="code" @updateCode="updateCode">
</priceComponent>
<view v-else class="popup_group" style="margin-top: 0;border-top: 1rpx solid #eeeeee;">
<view class="popup_group_item" @click="navToSpecGood()">
<view class="popup_group_item_label" style="flex: 1; text-align: center;">
设置多规格
<text v-if="setFormData.attrValue.length>0">({{setFormData.attrValue.length}})</text>
</view>
</view>
</view>
<view class="popup_group">
<!-- <view class="popup_group_item" @click="showMoreInfo=!showMoreInfo">
<view class="popup_group_item_label">更多信息</view>
<view class="popup_group_item_value" :class="showMoreInfo?'icon_bottom':'icon_top'">
<view><span class="iconfont">&#xe6bd;</span></view>
</view>
</view> -->
<block>
<view class="input_content">
<view class="input_content_describe" style="border: none;padding-bottom: 0;">
<view class="input_content_describe_title">
<view class="input_content_describe_title_msg">商品简介</view>
<view class="input_content_describe_title_num">
<text v-if="setFormData.store_info">{{ setFormData.store_info.length }}</text>
<text v-else>0</text>
/200
</view>
</view>
<view class="input_content_describe_textarea">
<textarea v-model="setFormData.store_info" style="width: 100%;" value=""
placeholder="请填写商品简介" placeholderClass="placeholderClass" maxlength="200" />
</view>
</view>
<!-- <view class="input_content_keyword">
<view class="input_content_keyword_label">关键字</view>
<view class="input_content_keyword_value"><input v-model="setFormData.keyword" type="text" value=""
placeholder="填写关键字" /></view>
</view> -->
</view>
<!-- <view class="input_content">
<view class="input_content_keyword">
<view class="input_content_keyword_label">最少购买件数</view>
<view class="input_content_keyword_value"><input v-model="setFormData.once_min_count" type="number" value=""
placeholder="不限量" /></view>
</view>
</view> -->
<view class="radio">
<view class="radio_label ">送货方式</view>
<checkbox-group class="select_group flex_start" @change="changeDelivery">
<label class="radio_select" v-for="(val, i) in deliveryFreeList" :key="val.value">
<view>
<checkbox :value="val.value"
:checked="setFormData.delivery_way.includes(val.value+'')" />
</view>
<view>{{ val.name }}</view>
</label>
</checkbox-group>
</view>
</block>
</view>
</view>
<view class="handle">
<view class="handle_button" @click="submitCreatedGoods">提交</view>
</view>
<!-- 图片选择器 -->
<avatar @upload="doUpload" @getName="getImgName" quality="1" ref="avatar" selWidth="250upx" selHeight="250upx">
</avatar>
</view>
</template>
<script>
import {
TOKENNAME,
HTTP_REQUEST_URL
} from '@/config/app.js';
import {
categoryBrandlist,
categorySelect,
storeClassifyLst,
categoryList,
attrList,
templateList,
productDetail,
getDeliveryType,
productCreate,
productUpdate
} from '@/api/product.js';
import {
serialize,
Toast,
Loading,
hideLoading,
Modal
} from "@/libs/uniApi.js";
import avatar from "@/components/yq-avatar/yq-avatar.vue";
import platfrom from "./components/platform.vue";
import storeClassification from '../components/store_classification.vue';
import commodityComponent from "./components/commodity.vue";
import priceComponent from "./components/price.vue";
export default {
components: {
avatar,
platfrom,
commodityComponent,
priceComponent,
storeClassification
},
data() {
return {
bar_code_dis: false,
merId: '', //id
product_id: '', //id
import: 0, //
code: '', //
show: false, //
image: false, //
setFormData: {
store_name: '',
imageList: [],
attrValue: [],
cate_name: '', //
unit_name: '', //
cate_id: '', // id
mer_cate_id: '', //
mer_cate_name: '', //
spec_type: '0', // 0. 1
attr: [], //
specifica: '', //
// setSpecificaValue: '', //
// setSpecificaValue2: '',
delivery_way: ['1', '2'], // 1 2
delivery_free: '1', // 0 1
temp_id: '', // ID
tempName: '', //
once_min_count: '', //
},
platformClassificationData: [], //
merchantClassification: [], //
brand: [], //
showCommodity: false, // ,
deliveryFreeList: [{
value: '1',
name: '到店核销'
},
{
value: '2',
name: '快递配送'
}
],
//
classified: {
cate_id: [],
mer_cate_id: [],
brand_id: [],
attr: [],
temp_id: []
},
productItem: {} || [],
showSpecType: false, //
spec_type: 0, //,0,1
};
},
onLoad(opt) {
this.merId = Number(opt.mer_id);
this.product_id = opt.product_id;
this.import = opt.import;
// if (!opt.product_id) this.showCommodity = true;
this.showCommodity = true;
this.initData();
if (this.import == 1) {
this.getOpenerEventChannel().once('importAttrValue', (e) => {
this.attrValue = e.attrValue;
uni.setStorageSync('attrValue', JSON.stringify(e.attrValue));
this.attr = e.attr;
uni.setStorageSync('attr', JSON.stringify(e.attr));
this.setFormData = Object.assign({}, this.setFormData, e);
this.$nextTick(() => {
this.$refs.commodityRef?.setDatas({
addGoodsSecoundData: {
is_good: this.setFormData.is_good, //
is_gift_bag: this.setFormData.is_gift_bag,
sort: this.setFormData.sort,
once_count: this.setFormData.once_count, //
video_link: this.setFormData.video_link,
},
goodsDis: {
store_name: this.setFormData.content?.title,
imageList: this.setFormData.content?.image
}
})
})
})
} else if (this.product_id) {
this.initDataEditData();
}
},
onBackPress() {},
onShow() {
this.initClasiffy();
// this.setFormData = Object.assign(this.setFormData, {
// "store_name": "",
// "imageList": [
// "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/457c6202311181745387896.jpeg",
// "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/185e2202311181745434402.jpeg"
// ],
// "cate_name": "",
// "unit_name": "",
// "cate_id": 445,
// "keyword": "22"
// })
// this.$nextTick(async () => {
// await this.$u.sleep(200)
// this.$refs.commodityRef.addGoodsSecoundData = {
// "is_good": 1,
// "is_gift_bag": 0,
// "sort": "20",
// "once_count": "",
// "video_link": "https://lihai001.oss-cn-chengdu.aliyuncs.com/media/7ce3d202311181816166215.mp4"
// }
// this.$refs.commodityRef.goodsDis = {
// "store_name": "",
// "imageList": [
// "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/fb73d202311181751262661.png"
// ]
// }
// this.$refs.priceRef.singleSpecification = {
// "price": "1",
// "cost": "1",
// "stock": "11",
// "ot_price": "",
// "wholesale_price": "",
// "bar_code": "666",
// "weight": "10",
// "volume": "5",
// "image": "",
// "extension_one": "",
// "extension_two": ""
// }
// })
},
beforeDestroy() {},
watch: {
'setFormData.imageList'(val) {
this.setFormData.image = val.length ? val[0] : '';
this.setFormData.slider_image = val.length ? serialize(val).splice(1) : [];
}
},
methods: {
changeDelivery(e) {
this.setFormData.delivery_way = e.detail.value;
},
//
initDataEditData() {
this.setFormData = {
imageList: [],
attrValue: [],
specification: '',
image: '', //
slider_image: '', //
store_name: '', //
store_info: '', //
keyword: '', //
brand_id: '', // id
brand_name: '', //
cate_id: '', //
cate_name: '', //
mer_cate_id: '', //
mer_cate_name: '', //
unit_name: '', //
spec_type: '0', // 0. 1
attr: [], //
specifica: '', //
// setSpecificaValue: '', //
// setSpecificaValue2: '', //
delivery_way: [], // 1 2
delivery_free: '0', // 0 1
temp_id: '', // ID
tempName: '', //
once_min_count: '', //
};
productDetail(this.merId, this.product_id).then(async (res) => {
this.showCommodity = true;
if (res.data.content_arr && res.data.content_arr.length > 0) res.data.content = res.data
.content_arr;
let editGoodsDetils = res.data;
Object.keys(this.setFormData).forEach(item => {
this.setFormData[item] = editGoodsDetils[item];
});
this.setFormData.product_id = this.product_id;
this.setFormData.imageList = [...(this.setFormData.image ? [this.setFormData.image] : []),
...
this
.setFormData.slider_image
];
this.setFormData.cate_name = editGoodsDetils?.storeCategory?.cate_name; //
this.setFormData.mer_cate_name = editGoodsDetils.merCateId ? editGoodsDetils.merCateId.map(
item => item
.category && item.category.cate_name).join(',') : '';
this.setFormData.brand_name = editGoodsDetils.brand ? editGoodsDetils.brand.brand_name :
'';
if (res.data.content && typeof res.data.content == 'string') res.data.content = JSON.parse(
res.data
.content);
this.setFormData.once_min_count <= 0 ? this.setFormData.once_min_count = '' : null;
this.setFormData.delivery_way = res.data.delivery_way;
//
this.$nextTick(() => {
this.$refs.commodityRef.setDatas({
addGoodsSecoundData: {
is_good: res.data.is_good, //
is_gift_bag: res.data.is_gift_bag,
sort: res.data.sort,
once_count: res.data.once_count, //
video_link: res.data.video_link,
},
goodsDis: {
store_name: res.data.content?.title,
imageList: res.data.content?.image
}
})
//
if (this.setFormData.spec_type == 0) {
this.$refs.priceRef.setDatas(res.data.attrValue[0]);
}
})
editGoodsDetils.temp && (this.setFormData.tempName = editGoodsDetils.temp.name);
hideLoading();
});
},
//
async initClasiffy() {
this.merchantClassification = (await storeClassifyLst(this.merId)).data;
},
initData() {
//
categoryBrandlist(this.merId).then((res) => {
this.brand = res.data;
}).catch(e => {
console.log(e);
});
//
categoryList(this.merId).then((res) => {
res.data.forEach((item1) => {
item1.children.forEach((item2) => {
item2.children = null;
})
})
this.platformClassificationData = res.data;
}).catch(e => {
console.log(e);
})
},
//
updateCode(e) {
this.code = e + '';
},
//
handleChooseImage() {
let that = this;
that.$util.uploadImageOne('upload/image', function(res) {
that.setFormData.imageList.push(res.data.path);
});
},
clk() {
// let avatar = this.$refs.avatar;
// avatar.fChooseImg(1, {
// selWidth: '350upx',
// selHeight: '350upx',
// inner: true
// });
this.$util.uploadImageOne({
url: 'upload/image',
crop: {
width: 2000,
height: 2000,
}
},(res)=> {
this.setFormData.imageList.push(res.data.path);
});
},
doUpload(rsp) {
let that = this
// console.log(rsp);
uni.uploadFile({
url: HTTP_REQUEST_URL + '/api/upload/image/field',
filePath: rsp.path,
name: 'field',
formData: {
'filename': rsp.path,
'name': that.imgName
},
header: {
// #ifdef MP
"Content-Type": "multipart/form-data",
// #endif
[TOKENNAME]: 'Bearer ' + this.$store.state.app.token
},
success: (uploadFileRes) => {
// console.log(uploadFileRes.data);
let imgData = JSON.parse(uploadFileRes.data)
that.setFormData.imageList.push(imgData.data.path)
},
complete(res) {
// console.log(res)
}
});
},
getImgName(name) {
this.imgName = name
},
//
pop(e) {
this.show = true
this.image = e
},
//
close() {
this.$refs.select_popup.close();
this.show = false
},
//
deleteImage(index) {
this.setFormData.imageList.splice(index, 1);
},
//
selectPlatform() {
this.$refs.select_platform.open();
},
//
closePlatfrom() {
this.$refs.select_platform.close();
},
//
getPlatData(item, taplist) {
this.setFormData.cate_id = item.value;
this.setFormData.cate_name = item.label;
this.$refs.select_platform.close();
},
//
selectStoreClass() {
this.$refs.select_store.open();
},
//
merchantClose() {
this.$refs.select_store.close();
},
//
handleGetSelectStore(item) {
console.log(item);
this.setFormData.mer_cate_id = item.map(val => val.store_category_id);
this.setFormData.mer_cate_name = item.map(val => val.cate_name).join(',');
this.$refs.select_store.close();
},
//
selectBrand() {
this.$refs.select_popup.open();
},
//
getLinkageData(item) {
this.setFormData.brand_id = item[0].value;
this.setFormData.brand_name = item[0].cate_name;
this.$refs.select_popup.close();
},
//
multipleList(data, model) {
if (model == 'mer_cate_id') {
this.platformClassification[1].value = data.map(item => item.label).join('');
this.platformClassification[1].allreadySelect = data;
this.setFormData.mer_cate_id = data.map(item => item.value);
}
},
// popup
//
close() {
this.$refs.select_popup.close();
this.show = false
},
//
getLinkDataOfRecursion(arr, child = 'children', key = 'value') {
let str = '';
let id = '';
arr.forEach(item => {
str = item.label;
id = item.value;
});
// str = str.slice(0, str.length - 1);
return {
str,
id
};
},
//
getTemplateList() {
templateList(this.merId, this.templateListPage).then(res => {
res.data.list.forEach(item => {
this.$set(item, 'value', item.shipping_template_id);
this.$set(item, 'label', item.name);
});
this.classified['temp_id'] = res.data.list;
this.$refs.tempId.open();
});
},
//
submitCreatedGoods() {
console.log('创建商品');
// return console.log('', this.setFormData.attr);
console.log('是否推荐', this.$refs.commodityRef.addGoodsSecoundData);
console.log('商品详情', this.$refs.commodityRef.goodsDis, this.$refs.commodityRef.store_name);
if (this.setFormData.spec_type == 0) {
console.log('价格库存', this.$refs.priceRef.singleSpecification);
}
if (this.setFormData.delivery_way.length == 0) return Toast('请至少选择一种送货方式');
let postData = {
...this.setFormData,
...this.$refs.commodityRef.addGoodsSecoundData,
content: {
title: this.$refs.commodityRef.goodsDis?.store_name || '',
image: this.$refs.commodityRef.goodsDis?.imageList || []
},
video_link: this.$refs.commodityRef.addGoodsSecoundData.video_link,
};
if (this.setFormData.spec_type == 0) {
postData.attrValue = [this.$refs.priceRef.singleSpecification];
} else postData.attrValue = this.setFormData.attrValue;
postData.stock = postData.attrValue[0]?.stock || 0;
if (!postData.store_name || postData.store_name?.trim().length <= 0) return Toast('请输入商品名称');
if (!postData.imageList || postData.imageList?.length < 2) return Toast('请上传2张以上商品图片');
if (!postData.cate_name || postData.cate_name?.trim().length <= 0) return Toast('请选择平台分类');
if (!postData.unit_name || postData.unit_name?.trim().length <= 0) return Toast('请输入商品单位');
let userInfo = this.$store.state.app.userInfo;
if (typeof userInfo == 'string') userInfo = JSON.parse(userInfo);
let showFlag = '';
console.log(postData);
postData.attrValue.forEach(t => {
if (userInfo.mer_info.wholesale && (!t.wholesale_price || +t.wholesale_price <= 0)) {
showFlag = '批发价不能小于0'
}
if (!t.price || +t.price <= 0) showFlag = '零售价不能小于0';
if (!t.stock || +t.stock <= 0) showFlag = '库存不能小于0';
// if (!t.cost || +t.cost <= 0) showFlag = '0';
})
if (showFlag) {
if (this.setFormData.spec_type == 1) showFlag += ', 请点击设置多规格设置';
return Toast(showFlag);
}
Loading();
if (this.product_id) {
productUpdate(this.merId, this.product_id, postData)
.then(res => {
hideLoading()
Modal('提交成功', '点击确定, 前往商品列表页面').then(() => {
uni.redirectTo({
url: `/pages/product/goodsOnSale/index?mer_id=${this.merId}&type=6`
})
}).catch(() => {
uni.navigateBack()
})
})
.catch(rej => {
Toast(rej);
});
} else {
productCreate(this.merId, postData)
.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.merId}&type=6`
})
}).catch(() => {
uni.navigateBack()
})
})
.catch(rej => {
Toast(rej);
});
}
},
//
changeSpecType(e) {
if (this.setFormData.spec_type != e.detail.value) {
this.showSpecType = true;
}
this.spec_type = e.detail.value;
},
//
changeSpecType2() {
this.showSpecType = false;
this.setFormData.spec_type = this.spec_type + '';
this.setFormData.attrValue = [];
this.setFormData.attr = [];
},
//
navToSpecGood() {
uni.navigateTo({
url: '/pages/product/addGood/specGood?product_id=' + this.product_id,
success: (e) => {
// console.log(this.setFormData.attrValue, e);
e.eventChannel.emit('updateAttrValue', {
attrValue: JSON.parse(JSON.stringify(this.setFormData.attrValue)),
attr: JSON.parse(JSON.stringify(this.setFormData.attr))
});
uni.$once('updateSpecType', (e) => {
this.setFormData.attrValue = JSON.parse(JSON.stringify(e.attrValue));
this.setFormData.attr = JSON.parse(JSON.stringify(e.attr));
})
}
})
}
}
};
</script>
<style lang="scss" scoped>
@import './scss/index.scss';
.pop {
z-index: 1;
}
.guanbi {
width: 20px;
height: 20px;
margin: 30px auto;
}
</style>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,77 @@
<template>
<view class="">
<u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
:maxCount="10"></u-upload>
</view>
</template>
<script>
import {
TOKENNAME,
HTTP_REQUEST_URL
} from '@/config/app.js';
export default {
data() {
return {
fileList1: [],
}
},
methods: {
//
deletePic(event) {
this[`fileList${event.name}`].splice(event.index, 1)
},
//
async afterRead(event) {
// multiple true , file
let lists = [].concat(event.file)
let fileListLen = this[`fileList${event.name}`].length
lists.map((item) => {
this[`fileList${event.name}`].push({
...item,
status: 'uploading',
message: '上传中'
})
})
for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise(lists[i].url)
let item = this[`fileList${event.name}`][fileListLen]
this[`fileList${event.name}`].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,
// formData: {
// 'filename': rsp.path,
// 'name': that.imgName
// },
header: {
// #ifdef MP
"Content-Type": "multipart/form-data",
// #endif
[TOKENNAME]: 'Bearer ' + this.$store.state.app.token
},
success: (res) => {
setTimeout(() => {
resolve(res.data.data)
}, 1000)
}
});
})
},
}
}
</script>
<style>
</style>

View File

@ -0,0 +1,99 @@
<template>
<view class='content'>
<u--form :model="model1" :rules="rules" ref="uForm" labelPosition="top"
:labelStyle="{fontSize:'32rpx',color:'#444444'}" labelWidth='100'>
<view class="good-baseInfo">
<u-form-item label="商品标题" prop="userInfo.name" ref="item1">
<u--input placeholder="建议描述产品品牌、名称" v-model="text"></u--input>
</u-form-item>
<u-form-item class='formItem' label="商品主图" prop="userInfo.name" ref="item1">
<uploadImgVideo />
</u-form-item>
<u-form-item label="商品细节图" prop="userInfo.name" ref="item1">
<uploadImgVideo />
</u-form-item>
</view>
</u--form>
</view>
</template>
<script>
import uploadImgVideo from "../addGood/components/uploadImgVideo.vue"
export default {
components: {
uploadImgVideo,
},
data() {
return {
showSex: false,
model1: {
userInfo: {
name: '',
sex: '',
},
},
range: [{
value: 0,
text: "篮球"
},
{
value: 1,
text: "足球"
},
{
value: 2,
text: "游泳"
},
],
text: "",
rules: {
// 'userInfo.name': {
// type: 'string',
// required: true,
// message: '',
// trigger: ['blur', 'change']
// },
// 'userInfo.sex': {
// type: 'string',
// max: 1,
// required: true,
// message: '',
// trigger: ['blur', 'change']
// },
},
radio: '',
switchVal: false
};
},
methods: {
sexSelect(e) {
this.model1.userInfo.sex = e.name
this.$refs.uForm.validateField('userInfo.sex')
},
},
};
</script>
<style lang='scss'>
.content {
width: 100vw;
min-height: 100vh;
background-color: #F1F1F1;
box-sizing: border-box;
.good-baseInfo {
background-color: white;
padding: 30rpx;
}
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

@ -14,6 +14,7 @@
@import '@/uni_modules/uview-ui/theme.scss';
/* 颜色变量 */
$uni-theme-color: #f45846;
$uni-newTheme-color: #38BE41;
$uni-theme-bg-color: linear-gradient(180deg, #f98649 0%, #f34e45 100%);
/* 行为相关颜色 */

View File

@ -6,8 +6,8 @@
<view class="uni-select__input-box" @click="toggleSelector">
<view v-if="current" class="uni-select__input-text">{{current}}</view>
<view v-else class="uni-select__input-text uni-select__input-placeholder">{{typePlaceholder}}</view>
<view v-if="current && clear && !disabled" @click.stop="clearVal" >
<uni-icons type="clear" color="#c0c4cc" size="24"/>
<view v-if="current && clear && !disabled" @click.stop="clearVal">
<uni-icons type="clear" color="#c0c4cc" size="24" />
</view>
<view v-else>
<uni-icons :type="showSelector? 'top' : 'bottom'" size="14" color="#999" />
@ -20,9 +20,10 @@
<view class="uni-select__selector-empty" v-if="mixinDatacomResData.length === 0">
<text>{{emptyTips}}</text>
</view>
<view v-else class="uni-select__selector-item" v-for="(item,index) in mixinDatacomResData" :key="index"
@click="change(item)">
<text :class="{'uni-select__selector__disabled': item.disable}">{{formatItemName(item)}}</text>
<view v-else class="uni-select__selector-item" v-for="(item,index) in mixinDatacomResData"
:key="index" @click="change(item)">
<text
:class="{'uni-select__selector__disabled': item.disable}">{{formatItemName(item)}}</text>
</view>
</scroll-view>
</view>
@ -125,7 +126,7 @@
common + placeholder :
common
},
valueCom(){
valueCom() {
// #ifdef VUE3
return this.modelValue;
// #endif
@ -156,7 +157,7 @@
}
},
methods: {
debounce(fn, time = 100){
debounce(fn, time = 100) {
let timer = null
return function(...args) {
if (timer) clearTimeout(timer)
@ -166,11 +167,11 @@
}
},
//
query(){
query() {
this.mixinDatacomEasyGet();
},
//
onMixinDatacomPropsChange(){
onMixinDatacomPropsChange() {
if (this.collection) {
this.debounceGet();
}
@ -193,9 +194,9 @@
}
defValue = defItem
}
if (defValue || defValue === 0) {
this.emit(defValue)
}
if (defValue || defValue === 0) {
this.emit(defValue)
}
}
const def = this.mixinDatacomResData.find(item => item.value === defValue)
this.current = def ? this.formatItemName(def) : ''
@ -258,7 +259,7 @@
let str = "";
str = this.format;
for (let key in item) {
str = str.replace(new RegExp(`{${key}}`,"g"),item[key]);
str = str.replace(new RegExp(`{${key}}`, "g"), item[key]);
}
return str;
} else {
@ -272,26 +273,26 @@
}
},
//
getLoadData(){
getLoadData() {
return this.mixinDatacomResData;
},
// key
getCurrentCacheKey(){
getCurrentCacheKey() {
return this.collection;
},
//
getCache(name=this.getCurrentCacheKey()){
getCache(name = this.getCurrentCacheKey()) {
let cacheData = uni.getStorageSync(this.cacheKey) || {};
return cacheData[name];
},
//
setCache(value, name=this.getCurrentCacheKey()){
setCache(value, name = this.getCurrentCacheKey()) {
let cacheData = uni.getStorageSync(this.cacheKey) || {};
cacheData[name] = value;
uni.setStorageSync(this.cacheKey, cacheData);
},
//
removeCache(name=this.getCurrentCacheKey()){
removeCache(name = this.getCurrentCacheKey()) {
let cacheData = uni.getStorageSync(this.cacheKey) || {};
delete cacheData[name];
uni.setStorageSync(this.cacheKey, cacheData);
@ -431,6 +432,7 @@
max-height: 600px;
}
}
/* #endif */
.uni-select__selector-empty,