|
|
|
|
<!-- 底部菜单--库存--新增商品 -->
|
|
|
|
|
<template>
|
|
|
|
|
<view class="page1">
|
|
|
|
|
<view class="title">
|
|
|
|
|
<view class="title-sreach">
|
|
|
|
|
<view class="back-btn" @tap="back" :style="{'top': menuButtonInfo.top +'px'}">
|
|
|
|
|
<uni-icons type="left" size="28"></uni-icons>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="title-name" :style="{'padding-top': menuButtonInfo.top +'px'}">
|
|
|
|
|
商家详情
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="formBox">
|
|
|
|
|
<uni-forms ref="form" :modelValue="formData" :rules="rules" labelWidth="170rpx">
|
|
|
|
|
<uni-forms-item label="商品名称" name="productName" required>
|
|
|
|
|
<uni-easyinput type="text" v-model="formData.productName" placeholder="请输入商品名称" trim="all" />
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="商品主图" name="productPicture">
|
|
|
|
|
<view class="upload-img" @tap="pictureAdd"
|
|
|
|
|
style="background: #eee;text-align: center;line-height: 160rpx;">
|
|
|
|
|
<uni-icons type="camera" size="28" color="#777"></uni-icons>
|
|
|
|
|
</view>
|
|
|
|
|
<view style="overflow-x: scroll;display: flex;width: 350rpx;">
|
|
|
|
|
<view v-if="formData.productPicture !=''" style="width: 160rpx;height: 160rpx;margin-left: 20rpx;">
|
|
|
|
|
<img :src="formData.productPicture" alt="" class="upload-img">
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="排名" name="orderFiled">
|
|
|
|
|
<input type="digit" class="content-input" v-model="formData.orderFiled" placeholder="请输入排名">
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="店铺分类" name="editTitle">
|
|
|
|
|
<input type="digit" class="content-input" v-model="editTitle" disabled>
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="商品规格" name="attributeListPrice">
|
|
|
|
|
<view>
|
|
|
|
|
<view v-for="(item,index) in formData.attributeListPrice" :key="index" style="display: flex;margin-top:5px;">
|
|
|
|
|
<input class="content-input" v-model="item.specName" v-if="item.specName != ''&& formData.attributeListPrice.length != 1" style="padding-right: 10px;" disabled />
|
|
|
|
|
<input class="content-input" v-model="item.specPrice" style="padding-right: 10px;margin-right: 10px;" @click="changePrice(index)" placeholder="商品价格" />
|
|
|
|
|
<input class="content-input" v-model="item.specNum" style="padding-right: 10px;" @click="changecount(index)" placeholder="商品库存"/>
|
|
|
|
|
<button @click="deldantiaoguige(index)" v-if="formData.attributeListPrice.length>1" style="width: 120px;height: 30px;line-height: 30px;color: red;border:none;background: #fff;">删除</button>
|
|
|
|
|
</view>
|
|
|
|
|
<view @click="checkSpec('guige')" style="margin-top: 5px;width: 80px;height: 30px;text-align: center;line-height: 30px;background: rgba(0, 35, 28, 1);border-radius: 30px;color: rgba(166, 255, 234, 1);">
|
|
|
|
|
选择规格
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="拼团信息" name="productGroupBuyPrices">
|
|
|
|
|
<view>
|
|
|
|
|
<view v-for="(item,index) in formData.productGroupBuyPrices" :key="index" style="display: flex;margin-top:5px;">
|
|
|
|
|
<input class="content-input" v-model="item.groupCount" style="padding-right: 10px;margin-right: 10px;" placeholder="成团人数" />
|
|
|
|
|
<input class="content-input" v-model="item.groupPrice" style="padding-right: 10px;" placeholder="成团价格"/>
|
|
|
|
|
<button @click="delGroup(index)" v-if="formData.productGroupBuyPrices.length>1" style="width: 120px;height: 30px;line-height: 30px;color: red;border:none;background: #fff;">删除</button>
|
|
|
|
|
</view>
|
|
|
|
|
<view @click="addGroup()" style="margin-top: 5px;width: 80px;height: 30px;text-align: center;line-height: 30px;background: rgba(0, 35, 28, 1);border-radius: 30px;color: rgba(166, 255, 234, 1);">
|
|
|
|
|
新增拼团
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="商品属性" name="attributeList1">
|
|
|
|
|
<view style="display: flex;flex-direction: column;">
|
|
|
|
|
<view v-for="(value,key) in Array.from(formData.attributeList1)" :key="index" style="display: flex;">
|
|
|
|
|
{{value[0]}}:
|
|
|
|
|
<view v-for="(item,index) in value[1].title" :key="index">
|
|
|
|
|
{{item}}、
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view @click="checkSpec('shuxing')" style="width: 80px;height: 30px;text-align: center;line-height: 30px;background: rgba(0, 35, 28, 1);border-radius: 30px;color: rgba(166, 255, 234, 1);">
|
|
|
|
|
选择属性
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="可售时间" name="sellTime">
|
|
|
|
|
<view style="display: flex;flex-direction: column;">
|
|
|
|
|
<view style="line-height: 37px;">
|
|
|
|
|
<radio :checked="formData.sellTime==0" name="sellTime" @click="checkSellTime(0)" />全时段售卖
|
|
|
|
|
<radio :checked="formData.sellTime==1" name="sellTime" @click="checkSellTime(1)" />自定义时段
|
|
|
|
|
</view>
|
|
|
|
|
<view style="display: flex;" v-if="formData.sellTime == 1">
|
|
|
|
|
<picker mode="time" v-model="formData.sellBeginTime" start="00:00" end="23:59" @change="selectDateRange($event,'start')">
|
|
|
|
|
<view class="uni-input">{{formData.sellBeginTime}}</view>
|
|
|
|
|
</picker>
|
|
|
|
|
<view style="width: 25px;height: 25px;line-height: 25px;text-align: center;">-</view>
|
|
|
|
|
<picker mode="time" v-model="formData.sellEndTime" start="00:00" end="23:59" @change="selectDateRange($event,'end')">
|
|
|
|
|
<view class="uni-input">{{formData.sellEndTime}}</view>
|
|
|
|
|
</picker>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="设置加料" name="isMoreBuy">
|
|
|
|
|
<view style="line-height: 37px;">
|
|
|
|
|
<radio :checked="formData.isMoreBuy==0" name="isMoreBuy" @click="checkisMoreBuy('0')" />否
|
|
|
|
|
<radio :checked="formData.isMoreBuy==1" name="isMoreBuy" @click="checkisMoreBuy('1')" />是
|
|
|
|
|
</view>
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="餐盒费" name="lunchBox">
|
|
|
|
|
<input type="digit" class="content-input" v-model="formData.lunchBox" placeholder="请输入餐盒费">
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="起售数量" name="startPayNum">
|
|
|
|
|
<input type="digit" class="content-input" v-model="formData.startPayNum" placeholder="请输入起售数量">
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
<uni-forms-item label="详细图文" name="startPayNum">
|
|
|
|
|
<view class="xiangxi-box">
|
|
|
|
|
<sp-editor
|
|
|
|
|
:keys="keys"
|
|
|
|
|
@init="initEditor"
|
|
|
|
|
@input="inputOver"
|
|
|
|
|
@upinImage="upinImage"
|
|
|
|
|
@overMax="overMax">
|
|
|
|
|
</sp-editor>
|
|
|
|
|
</view>
|
|
|
|
|
</uni-forms-item>
|
|
|
|
|
</uni-forms>
|
|
|
|
|
<view>
|
|
|
|
|
<button @tap.stop="submit()">保存</button>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 添加分类弹出层 -->
|
|
|
|
|
<uni-popup ref="addTypeDialog" background-color="#fff">
|
|
|
|
|
<view class="add-popup-content">
|
|
|
|
|
<view style="height:450px;">
|
|
|
|
|
<view class="content-left" style="float: left;">
|
|
|
|
|
<view class="left-box" v-for="(item,index) in categoryData" :key="index"
|
|
|
|
|
:class="item.parentId ? 'left-box-hover':''" @tap="clickLeftBtn(index)">
|
|
|
|
|
<text style="width: 100%;height: 50px;line-height: 50px;display: inline-block;overflow: hidden;"
|
|
|
|
|
:class="item.parentId ? 'red' :''">{{item.title}}</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view v-for="(item,index) in categorySonData" :key="index" @tap="checkSpecValue(index)" class="content-low" :class="item.checked?'checked':''">
|
|
|
|
|
{{item.title}}
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view slot="footer" style="display: flex;padding-left: 20px;margin-top: 10px;">
|
|
|
|
|
<button type="text" @tap="$refs.addTypeDialog.close()" style="margin-right: 10px;">取消</button>
|
|
|
|
|
<button type="text" @tap="guigeSubmit">提交</button>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</uni-popup>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
categoryData:[],
|
|
|
|
|
categoryIndex: 0,
|
|
|
|
|
modalclassType:'',
|
|
|
|
|
categorySonData:[],
|
|
|
|
|
specValueArr:[],
|
|
|
|
|
attrValueArr:[],
|
|
|
|
|
editorIns: null,
|
|
|
|
|
menuButtonInfo: {},
|
|
|
|
|
formData: {
|
|
|
|
|
id: '',
|
|
|
|
|
shopId: '',
|
|
|
|
|
categoryId: '', //商品分类id
|
|
|
|
|
categoryName: '', //商品分类名称
|
|
|
|
|
productPicture: '', //商品图标
|
|
|
|
|
productName: '', //商品名称
|
|
|
|
|
orderFiled: '', //商品名称
|
|
|
|
|
lunchBox: 0, //餐盒
|
|
|
|
|
startPayNum: '', //起售数量
|
|
|
|
|
attributeListPrice: [{ //商品规格
|
|
|
|
|
specPrice: "",
|
|
|
|
|
specNum: 9999
|
|
|
|
|
}],
|
|
|
|
|
sellTime: 0, //可售时间
|
|
|
|
|
isMoreBuy: 0,
|
|
|
|
|
sellBeginTime: '00:00', //可售时段自定义---开始时间
|
|
|
|
|
sellEndTime: '00:00', //可售时段自定义---结束时间
|
|
|
|
|
attributeList: '',
|
|
|
|
|
productGroupBuyPrices: [],
|
|
|
|
|
attributeList1: new Map(), //商品属性
|
|
|
|
|
productIntro: "" //详细图文
|
|
|
|
|
},
|
|
|
|
|
rules: {
|
|
|
|
|
productName: {
|
|
|
|
|
rules: [{
|
|
|
|
|
required: true,
|
|
|
|
|
errorMessage: '请输入名称',
|
|
|
|
|
}]
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
filters: {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
onShow() {
|
|
|
|
|
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
|
|
|
|
|
},
|
|
|
|
|
onLoad(option) {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
/**
|
|
|
|
|
* 获取输入内容
|
|
|
|
|
* @param {Object} e {html,text} 内容的html文本,和text文本
|
|
|
|
|
*/
|
|
|
|
|
inputOver(e) {
|
|
|
|
|
// 可以在此处获取到编辑器已编辑的内容
|
|
|
|
|
console.log('==== inputOver :', e)
|
|
|
|
|
this.productIntro = e
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 超出最大内容限制
|
|
|
|
|
* @param {Object} e {html,text} 内容的html文本,和text文本
|
|
|
|
|
*/
|
|
|
|
|
overMax(e) {
|
|
|
|
|
// 若设置了最大字数限制,可在此处触发超出限制的回调
|
|
|
|
|
console.log('==== overMax :', e)
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 编辑器就绪
|
|
|
|
|
* @param {Object} editor 编辑器实例,你可以自定义调用editor实例的方法
|
|
|
|
|
* @tutorial editor组件 https://uniapp.dcloud.net.cn/component/editor.html#editor-%E7%BB%84%E4%BB%B6
|
|
|
|
|
* @tutorial 相关api https://uniapp.dcloud.net.cn/api/media/editor-context.html
|
|
|
|
|
*/
|
|
|
|
|
initEditor(editor) {
|
|
|
|
|
this.editorIns = editor // 保存编辑器实例
|
|
|
|
|
// 保存编辑器实例后,可以在此处获取后端数据,并赋值给编辑器初始化内容
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 直接运行示例工程插入图片无法正常显示的看这里
|
|
|
|
|
* 因为插件默认采用云端存储图片的方式
|
|
|
|
|
* 以$emit('upinImage', tempFiles, this.editorCtx)的方式回调
|
|
|
|
|
* @param {Object} tempFiles
|
|
|
|
|
* @param {Object} editorCtx
|
|
|
|
|
*/
|
|
|
|
|
upinImage(tempFiles, editorCtx) {
|
|
|
|
|
/**
|
|
|
|
|
* 本地临时插入图片预览
|
|
|
|
|
* 注意:这里仅是示例本地图片预览,因为需要将图片先上传到云端,再将图片插入到编辑器中
|
|
|
|
|
* 正式开发时,还请将此处注释,并解开下面 使用 uniCloud.uploadFile 上传图片的示例方法 的注释
|
|
|
|
|
* @tutorial https://uniapp.dcloud.net.cn/api/media/editor-context.html#editorcontext-insertimage
|
|
|
|
|
*/
|
|
|
|
|
// #ifdef MP-WEIXIN
|
|
|
|
|
// 注意微信小程序的图片路径是在tempFilePath字段中
|
|
|
|
|
editorCtx.insertImage({
|
|
|
|
|
src: tempFiles[0].tempFilePath,
|
|
|
|
|
width: '80%', // 默认不建议铺满宽度100%,预留一点空隙以便用户编辑
|
|
|
|
|
success: function() {}
|
|
|
|
|
})
|
|
|
|
|
// #endif
|
|
|
|
|
|
|
|
|
|
// #ifndef MP-WEIXIN
|
|
|
|
|
editorCtx.insertImage({
|
|
|
|
|
src: tempFiles[0].path,
|
|
|
|
|
width: '80%', // 默认不建议铺满宽度100%,预留一点空隙以便用户编辑
|
|
|
|
|
success: function() {}
|
|
|
|
|
})
|
|
|
|
|
// #endif
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 使用 uniCloud.uploadFile 上传图片的示例方法(可适用多选上传)
|
|
|
|
|
* 正式开发环境中,请将上面 本地临时插入图片预览 注释后,模仿以下写法
|
|
|
|
|
*/
|
|
|
|
|
// tempFiles.forEach(async (item) => {
|
|
|
|
|
// uni.showLoading({
|
|
|
|
|
// title: '上传中请稍后',
|
|
|
|
|
// mask: true
|
|
|
|
|
// })
|
|
|
|
|
// let upfile = await uniCloud.uploadFile({
|
|
|
|
|
// filePath: item.path,
|
|
|
|
|
// // 同名会导致报错 policy_does_not_allow_file_overwrite
|
|
|
|
|
// // cloudPath可由 想要存储的文件夹/文件名 拼接,若不拼文件夹名则默认存储在cloudstorage文件夹中
|
|
|
|
|
// cloudPath: `cloudstorage/${item.name}`,
|
|
|
|
|
// cloudPathAsRealPath: true
|
|
|
|
|
// })
|
|
|
|
|
// editorCtx.insertImage({
|
|
|
|
|
// src: upfile.fileID,
|
|
|
|
|
// width: '80%', // 默认不建议铺满宽度100%,预留一点空隙以便用户编辑
|
|
|
|
|
// success: function () {
|
|
|
|
|
// uni.hideLoading()
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 触发提交表单
|
|
|
|
|
submit() {
|
|
|
|
|
let that = this;
|
|
|
|
|
this.$refs.form.validate((valid) => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
if (this.modalType == 0) {
|
|
|
|
|
// 添加 避免编辑后传入id等数据 记得删除
|
|
|
|
|
delete this.formData.id;
|
|
|
|
|
if(this.formData.isMoreBuy != 1){
|
|
|
|
|
this.formData.isMoreBuy = 0
|
|
|
|
|
}
|
|
|
|
|
this.formData.attributeListPrice = JSON.stringify(this.formData.attributeListPrice)
|
|
|
|
|
this.formData.attributeList = Object.fromEntries(this.formData.attributeList1)
|
|
|
|
|
this.formData.attributeList = JSON.stringify(this.formData.attributeList)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.tui.request("/app/product/save", "post", this.formData, false, false).then((res) => {
|
|
|
|
|
if(res.code == 200){
|
|
|
|
|
that.tui.toast("操作成功");
|
|
|
|
|
}
|
|
|
|
|
}).catch(() => {});
|
|
|
|
|
} else if (this.modalType == 1) {
|
|
|
|
|
// 编辑
|
|
|
|
|
this.formData.attributeListPrice = JSON.stringify(this.formData.attributeListPrice)
|
|
|
|
|
this.formData.attributeList = Object.fromEntries(this.formData.attributeList1)
|
|
|
|
|
this.formData.attributeList = JSON.stringify(this.formData.attributeList)
|
|
|
|
|
this.formData.productPictures = []
|
|
|
|
|
this.tui.request("/app/product/edit", "post", this.formData, false, false).then((res) => {
|
|
|
|
|
if(res.code == 200){
|
|
|
|
|
that.tui.toast("操作成功");
|
|
|
|
|
}
|
|
|
|
|
}).catch(() => {});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
back() {
|
|
|
|
|
uni.navigateBack()
|
|
|
|
|
},
|
|
|
|
|
checkisMoreBuy(type){
|
|
|
|
|
this.formData.isMoreBuy = type;
|
|
|
|
|
},
|
|
|
|
|
checkSellTime(type){
|
|
|
|
|
this.formData.sellTime = type;
|
|
|
|
|
},
|
|
|
|
|
selectDateRange(e,type){
|
|
|
|
|
if(type == 'start'){
|
|
|
|
|
this.formData.sellBeginTime = e.detail.value
|
|
|
|
|
}else{
|
|
|
|
|
this.formData.sellEndTime = e.detail.value
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
guigeSubmit(){
|
|
|
|
|
if(this.modalclassType == 'shuxing'){
|
|
|
|
|
for(let i=0;i<this.attrValueArr.length;i++){
|
|
|
|
|
if(this.formData.attributeList1.size == 0){
|
|
|
|
|
//set has get
|
|
|
|
|
let data = {
|
|
|
|
|
title:[]
|
|
|
|
|
}
|
|
|
|
|
data.title.push(this.attrValueArr[i].title)
|
|
|
|
|
this.formData.attributeList1.set(this.attrValueArr[i].parentName,data)
|
|
|
|
|
}else{
|
|
|
|
|
if(this.formData.attributeList1.has(this.attrValueArr[i].parentName) && this.formData.attributeList1.get(this.attrValueArr[i].parentName).title.indexOf(this.attrValueArr[i].title) == -1){
|
|
|
|
|
this.formData.attributeList1.get(this.attrValueArr[i].parentName).title.push(this.attrValueArr[i].title)
|
|
|
|
|
}else{
|
|
|
|
|
let data = {
|
|
|
|
|
title:[]
|
|
|
|
|
}
|
|
|
|
|
data.title.push(this.attrValueArr[i].title)
|
|
|
|
|
this.formData.attributeList1.set(this.attrValueArr[i].parentName,data)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
//guige
|
|
|
|
|
let message = []
|
|
|
|
|
for(let i=0;i<this.specValueArr.length;i++){
|
|
|
|
|
for(let m=0;m<this.formData.attributeListPrice.length;m++){
|
|
|
|
|
if(this.specValueArr[i].id == this.formData.attributeListPrice[m].id){
|
|
|
|
|
this.specValueArr[i].specPrice = this.formData.attributeListPrice[m].specPrice
|
|
|
|
|
this.specValueArr[i].specName = this.formData.attributeListPrice[m].specName
|
|
|
|
|
this.specValueArr[i].specNum = this.formData.attributeListPrice[m].specNum
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
message.push({
|
|
|
|
|
id:this.specValueArr[i].id,
|
|
|
|
|
specName:this.specValueArr[i].specName == undefined ? this.specValueArr[i].title : this.specValueArr[i].specName,
|
|
|
|
|
specPrice:this.specValueArr[i].specPrice == undefined ? '' : this.specValueArr[i].specPrice,
|
|
|
|
|
specNum:this.specValueArr[i].specNum == undefined ? 9999 : this.specValueArr[i].specNum
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
this.formData.attributeListPrice = message
|
|
|
|
|
}
|
|
|
|
|
this.$forceUpdate()
|
|
|
|
|
this.$refs.addTypeDialog.close()
|
|
|
|
|
},
|
|
|
|
|
add() {
|
|
|
|
|
if (!this.selectNode.id) {
|
|
|
|
|
this.$Message.warning("请先选择一个分类");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.modalType = 0;
|
|
|
|
|
this.$refs.form.resetFields();
|
|
|
|
|
this.form.sort = this.data.length + 1;
|
|
|
|
|
this.formData = {
|
|
|
|
|
id:'',
|
|
|
|
|
shopId:'',
|
|
|
|
|
categoryId:'', //商品分类id
|
|
|
|
|
categoryName:'', //商品分类名称
|
|
|
|
|
productPicture:'', //商品图标
|
|
|
|
|
productName:'', //商品名称
|
|
|
|
|
lunchBox:0, //餐盒
|
|
|
|
|
startPayNum:'', //起售数量
|
|
|
|
|
orderFiled:'',//排名
|
|
|
|
|
attributeListPrice:[{ //商品规格
|
|
|
|
|
specPrice:"",
|
|
|
|
|
specNum:9999
|
|
|
|
|
}],
|
|
|
|
|
sellTime:0, //可售时间
|
|
|
|
|
sellBeginTime:'', //可售时段自定义---开始时间
|
|
|
|
|
sellEndTime:'', //可售时段自定义---结束时间
|
|
|
|
|
attributeList:'',
|
|
|
|
|
productGroupBuyPrices:[],
|
|
|
|
|
attributeList1:new Map(), //商品属性
|
|
|
|
|
productIntro:"" //详细图文
|
|
|
|
|
}
|
|
|
|
|
this.specValueArr = []
|
|
|
|
|
this.attrValueArr = []
|
|
|
|
|
this.formData.shopId = this.shopId
|
|
|
|
|
this.formData.categoryId = this.selectNode.id
|
|
|
|
|
this.formData.categoryName = this.selectNode.categoryName
|
|
|
|
|
this.modalVisible = true;
|
|
|
|
|
},
|
|
|
|
|
edit(v) {
|
|
|
|
|
this.modalType = 1;
|
|
|
|
|
// 转换null为""
|
|
|
|
|
for (let attr in v) {
|
|
|
|
|
if (v[attr] == null) {
|
|
|
|
|
v[attr] = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let str = JSON.stringify(v);
|
|
|
|
|
let data = JSON.parse(str);
|
|
|
|
|
console.log('111111',data)
|
|
|
|
|
this.formData = data;
|
|
|
|
|
this.formData.attributeList1 = JSON.parse(this.formData.attributeList)
|
|
|
|
|
this.formData.attributeList1 = new Map(Object.entries(this.formData.attributeList1));
|
|
|
|
|
this.formData.attributeListPrice = JSON.parse(this.formData.attributeListPrice)
|
|
|
|
|
|
|
|
|
|
console.log("this.formData.attributeList1",this.formData.attributeList1)
|
|
|
|
|
console.log("this.formData.attributeListPrice",this.formData.attributeListPrice)
|
|
|
|
|
|
|
|
|
|
this.formData.attributeList1.forEach((value, key) => {
|
|
|
|
|
for(let i = 0;i<value.title.length;i++){
|
|
|
|
|
this.attrValueArr.push({
|
|
|
|
|
parentName:key,
|
|
|
|
|
title:value.title[i]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.specValueArr = this.formData.attributeListPrice
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.formData.sellTime = this.formData.sellBeginTime != '' ? 1 : 0
|
|
|
|
|
this.modalVisible = true;
|
|
|
|
|
},
|
|
|
|
|
checkSpecValue(index){
|
|
|
|
|
this.categorySonData[index].checked = !this.categorySonData[index].checked
|
|
|
|
|
if(this.modalclassType == 'shuxing'){
|
|
|
|
|
if(this.categorySonData[index].checked == true){
|
|
|
|
|
this.categorySonData[index].parentName = this.typeToAttrName
|
|
|
|
|
this.attrValueArr.push(this.categorySonData[index])
|
|
|
|
|
}else{
|
|
|
|
|
for(let i=0;i<this.attrValueArr.length;i++){
|
|
|
|
|
if(this.categorySonData[index].title == this.attrValueArr[i].title){
|
|
|
|
|
this.attrValueArr.splice(i,1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
//guige
|
|
|
|
|
if(this.categorySonData[index].checked == true){
|
|
|
|
|
this.specValueArr.push(this.categorySonData[index])
|
|
|
|
|
}else{
|
|
|
|
|
for(let i=0;i<this.specValueArr.length;i++){
|
|
|
|
|
if(this.categorySonData[index].id == this.specValueArr[i].id){
|
|
|
|
|
this.specValueArr.splice(i,1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.$forceUpdate()
|
|
|
|
|
},
|
|
|
|
|
//点击左侧菜单切换
|
|
|
|
|
clickLeftBtn(index) {
|
|
|
|
|
for (var i = 0; i < this.categoryData.length; i++) {
|
|
|
|
|
if (i == index) {
|
|
|
|
|
this.categoryData[i].parentId = true
|
|
|
|
|
} else {
|
|
|
|
|
this.categoryData[i].parentId = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.categoryIndex = index
|
|
|
|
|
this.typeToAttrName = this.categoryData[this.categoryIndex].title
|
|
|
|
|
this.getCateGorySon(this.categoryData[this.categoryIndex].id)
|
|
|
|
|
},
|
|
|
|
|
pictureAdd(id, huan) {
|
|
|
|
|
let that = this
|
|
|
|
|
uni.chooseMedia({
|
|
|
|
|
count: 9,
|
|
|
|
|
mediaType: ['image'],
|
|
|
|
|
sourceType: ['album', 'camera'],
|
|
|
|
|
success(res) {
|
|
|
|
|
uni.showLoading({
|
|
|
|
|
title: '加载中...',
|
|
|
|
|
mask: true
|
|
|
|
|
})
|
|
|
|
|
for (let i = 0; i < res.tempFiles.length; i++) {
|
|
|
|
|
that.upLoadFile(res.tempFiles[i].tempFilePath)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
checkSpec(type){
|
|
|
|
|
this.$refs.addTypeDialog.open()
|
|
|
|
|
this.modalclassType = type
|
|
|
|
|
this.tui.request("/dictData/getByCondition", "GET", {
|
|
|
|
|
name: "",
|
|
|
|
|
status: "",
|
|
|
|
|
pageNumber: 1,
|
|
|
|
|
pageSize: 100000,
|
|
|
|
|
sort: 'sortOrder',
|
|
|
|
|
order: 'asc',
|
|
|
|
|
dictId: '2026945661353725952'
|
|
|
|
|
}, false, true).then((res) => {
|
|
|
|
|
if(res.code == 200){
|
|
|
|
|
this.categoryData = res.result.content
|
|
|
|
|
for (var i = 0; i < this.categoryData.length; i++) {
|
|
|
|
|
if (i == this.categoryIndex) {
|
|
|
|
|
this.categoryData[i].parentId = true
|
|
|
|
|
} else {
|
|
|
|
|
this.categoryData[i].parentId = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//如果是选择属性,需要拿一个分类名,保存成parent
|
|
|
|
|
this.typeToAttrName = res.result.content[this.categoryIndex].title
|
|
|
|
|
this.getCateGorySon(res.result.content[this.categoryIndex].id)
|
|
|
|
|
}
|
|
|
|
|
}).catch(() => {});
|
|
|
|
|
},
|
|
|
|
|
getCateGorySon(id){
|
|
|
|
|
this.tui.request("/dictData/getByCondition", "GET", {
|
|
|
|
|
name: "",
|
|
|
|
|
status: "",
|
|
|
|
|
pageNumber: 1,
|
|
|
|
|
pageSize: 100000,
|
|
|
|
|
sort: 'sortOrder',
|
|
|
|
|
order: 'asc',
|
|
|
|
|
dictId: id
|
|
|
|
|
}, false, true).then((res) => {
|
|
|
|
|
if(res.code == 200){
|
|
|
|
|
this.categorySonData = res.result.content
|
|
|
|
|
if(this.modalclassType == 'shuxing'){
|
|
|
|
|
for (var i = 0; i < this.categorySonData.length; i++) {
|
|
|
|
|
if(this.attrValueArr.length>0){
|
|
|
|
|
let index1 = false
|
|
|
|
|
for (var m = 0; m < this.attrValueArr.length; m++) {
|
|
|
|
|
if(this.attrValueArr[m].title == this.categorySonData[i].title){
|
|
|
|
|
index1 = true
|
|
|
|
|
this.categorySonData[i].checked = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(index1){
|
|
|
|
|
this.categorySonData[i].checked = true
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
this.categorySonData[i].checked = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
//guige
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < this.categorySonData.length; i++) {
|
|
|
|
|
if(this.specValueArr.length>0){
|
|
|
|
|
for (var m = 0; m < this.specValueArr.length; m++) {
|
|
|
|
|
if(this.specValueArr[m].id == this.categorySonData[i].id){
|
|
|
|
|
this.categorySonData[i].checked = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
this.categorySonData[i].checked = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}).catch(() => {});
|
|
|
|
|
},
|
|
|
|
|
deldantiaoguige(index){
|
|
|
|
|
for (var m = 0; m < this.specValueArr.length; m++) {
|
|
|
|
|
if(this.specValueArr[m].id == this.formData.attributeListPrice[index].id){
|
|
|
|
|
this.specValueArr.splice(m,1)
|
|
|
|
|
this.formData.attributeListPrice.splice(index,1)
|
|
|
|
|
console.log("11",this.formData.attributeListPrice)
|
|
|
|
|
if(this.formData.attributeListPrice.length == 1){
|
|
|
|
|
this.formData.attributeListPrice = []
|
|
|
|
|
this.formData.attributeListPrice.push({
|
|
|
|
|
specName:"",
|
|
|
|
|
specPrice:'',
|
|
|
|
|
specNum:9999
|
|
|
|
|
})
|
|
|
|
|
this.specValueArr = []
|
|
|
|
|
}
|
|
|
|
|
this.$forceUpdate()
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
delGroup(index){
|
|
|
|
|
this.formData.productGroupBuyPrices.splice(index,1)
|
|
|
|
|
},
|
|
|
|
|
changePrice(index){
|
|
|
|
|
this.specValueArr[index].specPrice = this.formData.attributeListPrice[index].specPrice
|
|
|
|
|
},
|
|
|
|
|
changeCount(index){
|
|
|
|
|
this.specValueArr[index].specNum = this.formData.attributeListPrice[index].specNum
|
|
|
|
|
},
|
|
|
|
|
addGroup(){
|
|
|
|
|
let data = {
|
|
|
|
|
groupCount:'',
|
|
|
|
|
groupPrice:0
|
|
|
|
|
}
|
|
|
|
|
this.formData.productGroupBuyPrices.push(data)
|
|
|
|
|
},
|
|
|
|
|
async upLoadFile(path) {
|
|
|
|
|
let that = this;
|
|
|
|
|
let hiver_token = uni.getStorageSync("hiver_token")
|
|
|
|
|
await uni.uploadFile({
|
|
|
|
|
url: that.tui.interfaceUrl() + '/upload/file',
|
|
|
|
|
filePath: path,
|
|
|
|
|
name: 'file',
|
|
|
|
|
header: {
|
|
|
|
|
"content-type": "multipart/form-data",
|
|
|
|
|
'accessToken': hiver_token
|
|
|
|
|
},
|
|
|
|
|
formData: {},
|
|
|
|
|
success: (uploadFileRes) => {
|
|
|
|
|
let pathData = JSON.parse(uploadFileRes.data)
|
|
|
|
|
that.formData.productPicture = pathData.result
|
|
|
|
|
that.$forceUpdate()
|
|
|
|
|
},
|
|
|
|
|
fail: (err) => {
|
|
|
|
|
uni.hideLoading();
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: JSON.stringify(err),
|
|
|
|
|
icon: 'none'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
await setTimeout(res => {
|
|
|
|
|
uni.hideLoading();
|
|
|
|
|
}, 1000)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
page {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
font-size: 24rpx;
|
|
|
|
|
background: #F5F8F5;
|
|
|
|
|
color: #00231C;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.page1 {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
font-size: 24rpx;
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.title {
|
|
|
|
|
background: url('https://jewel-shop.oss-cn-beijing.aliyuncs.com/8bc15960c2dc40268e295d6dd23aecce.png') no-repeat;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 54%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.title-sreach {
|
|
|
|
|
width: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
height: 200rpx;
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.back-btn {
|
|
|
|
|
position: absolute;
|
|
|
|
|
bottom: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.title-name {
|
|
|
|
|
padding-top: 55px;
|
|
|
|
|
font-size: 36rpx;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
flex: 1;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.formBox {
|
|
|
|
|
padding: 20rpx 26rpx;
|
|
|
|
|
border-radius: 14rpx;
|
|
|
|
|
box-shadow: 0px 1px 10px 2px #e2e2e2;
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
position: fixed;
|
|
|
|
|
top: 100px;
|
|
|
|
|
left: 2.5%;
|
|
|
|
|
width: 95%;
|
|
|
|
|
overflow: scroll;
|
|
|
|
|
height: 85%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.upload-img {
|
|
|
|
|
width: 160rpx;
|
|
|
|
|
height: 160rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
button {
|
|
|
|
|
height: 90rpx;
|
|
|
|
|
line-height: 90rpx;
|
|
|
|
|
font-size: 36rpx;
|
|
|
|
|
background: linear-gradient(90deg, rgba(227, 255, 150, 1), rgba(166, 255, 234, 1));
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
flex: 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.content-input {
|
|
|
|
|
width: auto;
|
|
|
|
|
position: relative;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
flex: 1;
|
|
|
|
|
line-height: 1;
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
height: 70rpx;
|
|
|
|
|
border: 2px solid #eee;
|
|
|
|
|
padding-left: 20rpx;
|
|
|
|
|
border-radius: 5px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.add-popup-content {
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
padding: 30rpx 30rpx 30rpx 0;
|
|
|
|
|
width: 300px;
|
|
|
|
|
height: 1050rpx;
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
overflow: scroll;
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
}
|
|
|
|
|
.xiangxi-box{
|
|
|
|
|
flex: 1;
|
|
|
|
|
border: 1px solid #eee;
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
}
|
|
|
|
|
.left-box {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 50px;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
line-height: 50px;
|
|
|
|
|
border-bottom: 1px solid #fff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.left-box-hover {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 50px;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
line-height: 50px;
|
|
|
|
|
border-bottom: 1px solid #fff;
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
}
|
|
|
|
|
.content-left {
|
|
|
|
|
width: 80px;
|
|
|
|
|
background: #eee;
|
|
|
|
|
height: 450px;
|
|
|
|
|
overflow: scroll;
|
|
|
|
|
scrollbar-width: none;
|
|
|
|
|
}
|
|
|
|
|
.content-low{
|
|
|
|
|
height: 30px;
|
|
|
|
|
padding: 0 5px;
|
|
|
|
|
border: 1px solid #eee;
|
|
|
|
|
display: inline-block;
|
|
|
|
|
margin: 5px;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
line-height: 30px;
|
|
|
|
|
}
|
|
|
|
|
.checked{
|
|
|
|
|
background: #60F3FF;
|
|
|
|
|
color: #fff !important;
|
|
|
|
|
}
|
|
|
|
|
.uni-input{
|
|
|
|
|
width: 100px;
|
|
|
|
|
height: 25px;
|
|
|
|
|
line-height: 25px;
|
|
|
|
|
border-radius: 5px;
|
|
|
|
|
border: 1px solid #eee;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
</style>
|