You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

886 lines
29 KiB

<!-- 底部菜单--库存--新增商品 -->
<template>
<view class="page1">
3 weeks ago
<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'}">
3 weeks ago
新增商品
3 weeks ago
</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">
3 weeks ago
<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>
3 weeks ago
<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>
3 weeks ago
<uni-forms-item label="商品分类" name="editTitle">
3 weeks ago
<view style="border: 4rpx solid #eee;display: flex;flex: 1;border-radius: 10rpx;">
3 weeks ago
<input type="text" placeholder="请选择商品分类" disabled v-model="typeItem.categoryName"
class="content-input" @tap="goGategoryLow" style="border: 0;">
<uni-icons type="right" size="16"
style="margin-left: 40rpx;line-height: 70rpx;"></uni-icons>
</view>
</uni-forms-item>
3 weeks ago
<uni-forms-item label="商品规格" name="attributeListPrice">
<view>
3 weeks ago
<view v-for="(item,index) in formData.attributeListPrice" :key="index" style="display: flex;margin-top:10rpx;">
<input class="content-input" v-model="item.specName" v-if="item.specName != ''&& formData.attributeListPrice.length != 1" style="padding-right: 20rpx;" disabled />
<input class="content-input" v-model="item.specPrice" style="padding-right: 20rpx;margin-right: 20rpx;" @click="changePrice(index)" placeholder="商品价格" />
<input class="content-input" v-model="item.specNum" style="padding-right: 20rpx;" @click="changecount(index)" placeholder="商品库存"/>
<button @click="deldantiaoguige(index)" v-if="formData.attributeListPrice.length>1" style="width: 240rpx;height: 60rpx;line-height: 60rpx;color: red;border:none;background: #fff;">删除</button>
3 weeks ago
</view>
3 weeks ago
<!-- <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);">
3 weeks ago
选择规格
3 weeks ago
</view> -->
</view>
</uni-forms-item>
3 weeks ago
<uni-forms-item label="拼团信息" name="productGroupBuyPrices">
<view>
3 weeks ago
<view v-for="(item,index) in formData.productGroupBuyPrices" :key="index" style="display: flex;margin-top:10rpx;">
<input class="content-input" v-model="item.groupCount" style="padding-right: 20rpx;margin-right: 20rpx;" placeholder="成团人数" />
<input class="content-input" v-model="item.groupPrice" style="padding-right: 20rpx;" placeholder="成团价格"/>
<button @click="delGroup(index)" v-if="formData.productGroupBuyPrices.length>1" style="width: 240rpx;height: 60rpx;line-height: 60rpx;color: red;border:none;background: #fff;">删除</button>
</view>
3 weeks ago
<view @click="addGroup()" style="margin-top: 10rpx;width: 160rpx;height: 60rpx;text-align: center;line-height: 60rpx;background: rgba(0, 35, 28, 1);border-radius: 60rpx;color: rgba(166, 255, 234, 1);">
3 weeks ago
新增拼团
</view>
</view>
</uni-forms-item>
3 weeks ago
<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>
3 weeks ago
<view @click="checkSpec('shuxing')" style="width: 160rpx;height: 60rpx;text-align: center;line-height: 60rpx;background: rgba(0, 35, 28, 1);border-radius: 60rpx;color: rgba(166, 255, 234, 1);">
3 weeks ago
选择属性
</view>
</view>
</uni-forms-item>
3 weeks ago
<uni-forms-item label="可售时间" name="sellTime">
<view style="display: flex;flex-direction: column;">
3 weeks ago
<view style="line-height: 74rpx;">
3 weeks ago
<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>
3 weeks ago
<view style="width: 50rpx;height: 50rpx;line-height: 50rpx;text-align: center;">-</view>
3 weeks ago
<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>
3 weeks ago
<uni-forms-item label="设置加料" name="isMoreBuy">
3 weeks ago
<view style="line-height: 74rpx;">
3 weeks ago
<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>
3 weeks ago
<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>
<!-- 添加分类弹出层 -->
3 weeks ago
<uni-popup ref="addTypeDialog" background-color="#fff">
<view class="add-popup-content">
3 weeks ago
<view style="height:900rpx;">
3 weeks ago
<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)">
3 weeks ago
<text style="width: 100%;height: 100rpx;line-height: 100rpx;display: inline-block;overflow: hidden;"
3 weeks ago
:class="item.parentId ? 'red' :''">{{item.title}}</text>
</view>
</view>
3 weeks ago
<view v-for="(item,index) in categorySonData" :key="index" @tap="checkSpecValue(index)" class="content-low" :class="item.checked?'checked':''">
{{item.title}}
</view>
</view>
3 weeks ago
<view slot="footer" style="display: flex;padding-left: 40rpx;margin-top: 20rpx;">
<button type="text" @tap="$refs.addTypeDialog.close()" style="margin-right: 20rpx;">取消</button>
3 weeks ago
<button type="text" @tap="guigeSubmit">提交</button>
</view>
</view>
</uni-popup>
</view>
</template>
<script>
export default {
data() {
return {
3 weeks ago
dataList: {},
modalType:0,
3 weeks ago
categoryData:[],
categoryIndex: 0,
modalclassType:'',
categorySonData:[],
specValueArr:[],
attrValueArr:[],
editorIns: null,
3 weeks ago
typeItem: {},
3 weeks ago
menuButtonInfo: {},
formData: {
3 weeks ago
id: '',
shopId: '',
categoryId: '', //商品分类id
categoryName: '', //商品分类名称
productPicture: '', //商品图标
productName: '', //商品名称
orderFiled: '', //商品名称
lunchBox: 0, //餐盒
startPayNum: '', //起售数量
attributeListPrice: [{ //商品规格
specPrice: "",
specNum: 9999
}],
3 weeks ago
shopId:'',
3 weeks ago
sellTime: 0, //可售时间
isMoreBuy: 0,
3 weeks ago
sellBeginTime: '', //可售时段自定义---开始时间
sellEndTime: '', //可售时段自定义---结束时间
3 weeks ago
attributeList: '',
productGroupBuyPrices: [],
attributeList1: new Map(), //商品属性
productIntro: "" //详细图文
},
rules: {
productName: {
rules: [{
required: true,
3 weeks ago
errorMessage: '请输入名称',
}]
3 weeks ago
},
categoryId: {
rules: [{
required: true,
errorMessage: '请选择商品分类',
}, ],
},
3 weeks ago
},
}
},
filters: {
3 weeks ago
},
onShow() {
3 weeks ago
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
3 weeks ago
uni.authorize({
scope: 'scope.writePhotosAlbum',
success() {
},
fail() {
this.tui.toast("您未授权,图片上传功能可能会出现错误")
}
})
this.typeItem = JSON.parse(JSON.stringify(this.typeItem)) || ''
if (this.typeItem) {
this.formData.categoryId = this.typeItem.id
}
this.formData.shopId = uni.getStorageSync('shopId')
},
onLoad(option) {
3 weeks ago
this.getGategoryList()
if (option.dataList) {
this.dataList = JSON.parse(option.dataList)
this.tui.request("/app/product/getById/" + this.dataList.id, "POST", {
}, false, true).then((res) => {
if (res.code == 200) {
this.modalType = 1
this.formData.id = res.result.id
this.formData.shopId = res.result.shopId
this.formData.categoryName = res.result.categoryName
this.formData.orderFiled = res.result.orderFiled
this.formData.lunchBox = res.result.lunchBox
this.formData.startPayNum = res.result.startPayNum
this.formData.attributeListPrice = JSON.parse(res.result.attributeListPrice)
this.formData.shopId = res.result.shopId
this.formData.sellTime = res.result.sellBeginTime !=''?1:0
this.formData.isMoreBuy = res.result.isMoreBuy
this.formData.sellBeginTime = res.result.sellBeginTime
this.formData.sellEndTime = res.result.sellEndTime
this.formData.attributeList = res.result.attributeList
this.formData.productGroupBuyPrices = res.result.productGroupBuyPrices
this.formData.attributeList1 = new Map()
this.formData.productName = res.result.productName
this.formData.productPicture = res.result.productPicture
this.formData.productIntro = res.result.productIntro
this.formData.categoryId = res.result.categoryId
this.edit(this.formData)
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
}
},
methods: {
3 weeks ago
/**
* 获取输入内容
* @param {Object} e {html,text} 内容的html文本和text文本
*/
inputOver(e) {
// 可以在此处获取到编辑器已编辑的内容
console.log('==== inputOver :', e)
this.productIntro = e
},
3 weeks ago
/**
* 超出最大内容限制
* @param {Object} e {html,text} 内容的html文本和text文本
*/
overMax(e) {
// 若设置了最大字数限制,可在此处触发超出限制的回调
console.log('==== overMax :', e)
},
3 weeks ago
/**
* 编辑器就绪
* @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() {}
})
3 weeks ago
// #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()
// }
// })
// })
},
3 weeks ago
//跳转分类页
goGategoryLow() {
uni.navigateTo({
url: '/package1/myCenter/addType'
})
},
//初始化获取分类列表
getGategoryList() {
this.tui.request("/app/productCategory/list", "get", {
shopId:uni.getStorageSync('shopId')
}, false, true).then((res) => {
if (res.code == 200) {
if (res.result.length > 0) {
if(this.formData.categoryId != '' && this.formData.categoryId != undefined){
for(let i=0;i<res.result.length;i++){
if(res.result[i].id == this.formData.categoryId){
this.typeItem = res.result[i]
}
}
}else{
this.typeItem = res.result[0]
this.formData.categoryId = this.typeItem.id
}
}
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
},
3 weeks ago
// 触发提交表单
submit() {
let that = this;
3 weeks ago
// this.$refs.form.validate((valid) => {
// if (valid) {
3 weeks ago
if (this.modalType == 0) {
// 添加 避免编辑后传入id等数据 记得删除
delete this.formData.id;
if(this.formData.isMoreBuy != 1){
this.formData.isMoreBuy = 0
}
3 weeks ago
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("操作成功");
3 weeks ago
uni.navigateBack()
}
3 weeks ago
}).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("操作成功");
3 weeks ago
uni.navigateBack()
}
3 weeks ago
}).catch(() => {});
}
3 weeks ago
// }
// });
},
3 weeks ago
back() {
uni.navigateBack()
},
3 weeks ago
checkisMoreBuy(type){
this.formData.isMoreBuy = type;
},
3 weeks ago
checkSellTime(type){
this.formData.sellTime = type;
},
3 weeks ago
selectDateRange(e,type){
if(type == 'start'){
this.formData.sellBeginTime = e.detail.value
}else{
this.formData.sellEndTime = e.detail.value
}
},
3 weeks ago
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:[]
}
3 weeks ago
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:[]
}
3 weeks ago
data.title.push(this.attrValueArr[i].title)
this.formData.attributeList1.set(this.attrValueArr[i].parentName,data)
}
}
}
}else{
3 weeks ago
//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
}
}
3 weeks ago
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
})
}
3 weeks ago
this.formData.attributeListPrice = message
}
3 weeks ago
this.$forceUpdate()
this.$refs.addTypeDialog.close()
},
3 weeks ago
add() {
if (!this.selectNode.id) {
this.$Message.warning("请先选择一个分类");
return;
}
3 weeks ago
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;
},
3 weeks ago
edit(v) {
this.modalType = 1;
// 转换null为""
for (let attr in v) {
if (v[attr] == null) {
v[attr] = "";
}
}
3 weeks ago
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)
3 weeks ago
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)
}
}
}
3 weeks ago
}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)
}
}
}
}
3 weeks ago
this.$forceUpdate()
},
3 weeks ago
//点击左侧菜单切换
clickLeftBtn(index) {
for (var i = 0; i < this.categoryData.length; i++) {
if (i == index) {
this.categoryData[i].parentId = true
} else {
3 weeks ago
this.categoryData[i].parentId = false
}
3 weeks ago
}
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'],
3 weeks ago
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)
}
}
})
},
3 weeks ago
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)
3 weeks ago
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">
3 weeks ago
page {
width: 100%;
height: 100%;
font-size: 24rpx;
background: #F5F8F5;
color: #00231C;
}
3 weeks ago
.page1 {
width: 100%;
height: 100%;
font-size: 24rpx;
position: relative;
}
3 weeks ago
.title {
background: url('https://jewel-shop.oss-cn-beijing.aliyuncs.com/8bc15960c2dc40268e295d6dd23aecce.png') no-repeat;
width: 100%;
height: 54%;
}
3 weeks ago
.title-sreach {
width: 100%;
display: flex;
3 weeks ago
height: 200rpx;
position: relative;
}
3 weeks ago
.back-btn {
position: absolute;
bottom: 0;
left: 0;
}
3 weeks ago
.title-name {
3 weeks ago
padding-top: 110rpx;
3 weeks ago
font-size: 36rpx;
font-weight: 700;
flex: 1;
text-align: center;
}
3 weeks ago
.formBox {
padding: 20rpx 26rpx;
border-radius: 14rpx;
3 weeks ago
box-shadow: 0 1px 20rpx 4rpx #e2e2e2;
3 weeks ago
background-color: #fff;
position: fixed;
3 weeks ago
top: 200rpx;
3 weeks ago
left: 2.5%;
width: 95%;
overflow: scroll;
height: 85%;
}
3 weeks ago
.upload-img {
width: 160rpx;
height: 160rpx;
}
button {
height: 90rpx;
line-height: 90rpx;
font-size: 36rpx;
3 weeks ago
background: linear-gradient(90deg, rgba(227, 255, 150, 1), rgba(166, 255, 234, 1));
3 weeks ago
border-radius: 20rpx;
3 weeks ago
font-weight: 700;
flex: 1;
}
.content-input {
width: auto;
position: relative;
overflow: hidden;
flex: 1;
line-height: 1;
font-size: 28rpx;
height: 70rpx;
3 weeks ago
border: 4rpx solid #eee;
padding-left: 20rpx;
3 weeks ago
border-radius: 10rpx;
}
.add-popup-content {
align-items: center;
justify-content: center;
3 weeks ago
padding: 30rpx 30rpx 30rpx 0;
3 weeks ago
width: 600rpx;
height: 1050rpx;
background-color: #fff;
overflow: scroll;
3 weeks ago
border-radius: 20rpx;
}
3 weeks ago
.xiangxi-box{
flex: 1;
border: 1px solid #eee;
3 weeks ago
border-radius: 20rpx;
}
3 weeks ago
.left-box {
width: 100%;
3 weeks ago
height: 100rpx;
font-size: 28rpx;
3 weeks ago
text-align: center;
3 weeks ago
line-height: 100rpx;
3 weeks ago
border-bottom: 1px solid #fff;
}
3 weeks ago
.left-box-hover {
width: 100%;
3 weeks ago
height: 100rpx;
font-size: 28rpx;
3 weeks ago
text-align: center;
3 weeks ago
line-height: 50rpx;
3 weeks ago
border-bottom: 1px solid #fff;
background-color: #fff;
}
3 weeks ago
.content-left {
3 weeks ago
width: 160rpx;
3 weeks ago
background: #eee;
3 weeks ago
height: 900rpx;
3 weeks ago
overflow: scroll;
scrollbar-width: none;
}
3 weeks ago
.content-low{
3 weeks ago
height: 60rpx;
padding: 0 10rpx;
3 weeks ago
border: 1px solid #eee;
display: inline-block;
3 weeks ago
margin: 10rpx;
3 weeks ago
font-weight: bold;
3 weeks ago
line-height: 60rpx;
}
3 weeks ago
.checked{
background: #60F3FF;
color: #fff !important;
}
3 weeks ago
.uni-input{
3 weeks ago
width: 200rpx;
height: 50rpx;
line-height: 50rpx;
border-radius: 10rpx;
3 weeks ago
border: 1px solid #eee;
text-align: center;
}
</style>