tianyi 3 weeks ago
parent
commit
4b2b55a2fd
  1. 119
      package1/myCenter/addGoods.vue
  2. 11
      package1/myCenter/addType.vue

119
package1/myCenter/addGoods.vue

@ -7,7 +7,7 @@
<uni-icons type="left" size="28"></uni-icons>
</view>
<view class="title-name" :style="{'padding-top': menuButtonInfo.top +'px'}">
商家详情
新增商品
</view>
</view>
</view>
@ -30,8 +30,13 @@
<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 label="商品分类" name="editTitle">
<view style="border: 2px solid #eee;display: flex;flex: 1;border-radius: 5px;">
<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>
<uni-forms-item label="商品规格" name="attributeListPrice">
<view>
@ -144,6 +149,8 @@
export default {
data() {
return {
dataList: {},
modalType:0,
categoryData:[],
categoryIndex: 0,
modalclassType:'',
@ -151,6 +158,7 @@
specValueArr:[],
attrValueArr:[],
editorIns: null,
typeItem: {},
menuButtonInfo: {},
formData: {
id: '',
@ -166,10 +174,11 @@
specPrice: "",
specNum: 9999
}],
shopId:'',
sellTime: 0, //
isMoreBuy: 0,
sellBeginTime: '00:00', //---
sellEndTime: '00:00', //---
sellBeginTime: '', //---
sellEndTime: '', //---
attributeList: '',
productGroupBuyPrices: [],
attributeList1: new Map(), //
@ -181,7 +190,13 @@
required: true,
errorMessage: '请输入名称',
}]
}
},
categoryId: {
rules: [{
required: true,
errorMessage: '请选择商品分类',
}, ],
},
},
}
},
@ -190,9 +205,55 @@
},
onShow() {
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
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) {
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: {
/**
@ -279,12 +340,41 @@
// })
// })
},
//
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) => {})
},
//
submit() {
let that = this;
this.$refs.form.validate((valid) => {
if (valid) {
// this.$refs.form.validate((valid) => {
// if (valid) {
if (this.modalType == 0) {
// id
delete this.formData.id;
@ -299,6 +389,7 @@
this.tui.request("/app/product/save", "post", this.formData, false, false).then((res) => {
if(res.code == 200){
that.tui.toast("操作成功");
uni.navigateBack()
}
}).catch(() => {});
} else if (this.modalType == 1) {
@ -310,11 +401,12 @@
this.tui.request("/app/product/edit", "post", this.formData, false, false).then((res) => {
if(res.code == 200){
that.tui.toast("操作成功");
uni.navigateBack()
}
}).catch(() => {});
}
}
});
// }
// });
},
back() {
uni.navigateBack()
@ -430,9 +522,6 @@
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({

11
package1/myCenter/addType.vue

@ -12,7 +12,7 @@
</view>
<view class="card-list">
<ul>
<li v-for="(item, index) in indexList" :key="index" style="height: 50px;line-height: 50px;padding-left: 20px;border-bottom: 1px solid #eee;overflow: hidden;">
<li @tap="clickList(item)" v-for="(item, index) in indexList" :key="index" style="height: 50px;line-height: 50px;padding-left: 20px;border-bottom: 1px solid #eee;overflow: hidden;">
<view class="name">
<text>{{item.categoryName}}</text>
</view>
@ -219,6 +219,15 @@
}
},
//
clickList(item) {
let pages = getCurrentPages();
let prevPage = pages[pages.length - 2];
prevPage.$vm.typeItem = item
uni.navigateBack({
delta: 1
})
},
back() {
uni.navigateBack()
},

Loading…
Cancel
Save