wangfukang 1 month ago
parent
commit
cdbbdbca88
  1. 2
      package1/group/groupBuyList.vue
  2. 66
      package1/group/groupBuySingle.vue
  3. 109
      package1/myCenter/addGoods.vue

2
package1/group/groupBuyList.vue

@ -109,7 +109,7 @@
</view>
<view class="shop-bottom" v-if="item.products != null && item.products.length > 0">
<view class="menu-member" v-if='item1.isPush == 1 && item1.delFlag == 1'
v-for="(item1,index1) in item.products" :key="index1" @tap="goDetail('product',item1)">
v-for="(item1,index1) in item.products" :key="index1" @tap="goDetail('shop',item)">
<view class="menu-img">
<img :src="item1.productPicture" lazy-load alt="">
</view>

66
package1/group/groupBuySingle.vue

@ -279,10 +279,10 @@
<view class="goods-spec" v-if="parsedSpecs.length > 0">
<view class="spec1" v-for="(spec, sIndex) in parsedSpecs" :key="sIndex">
<view class="spec11">
{{spec.name}}
{{spec.name}}可选{{spec.canbuy}}
</view>
<view class="spec22">
<view :class="spec.selected === option ? 'spec-check' : 'spec222'"
<view :class="spec.selected.indexOf(option) !== -1 ? 'spec-check' : 'spec222'"
v-for="(option, oIndex) in spec.options" :key="oIndex"
@tap="selectSpec(sIndex, option)">
{{option}}
@ -604,10 +604,6 @@
categoryName: '推荐',
id: 'tuijian',
checked: true
},{
categoryName: '必点',
id: 'bidian',
checked: false
}],
shopRecommend:[],
availableCoupons: [],
@ -802,7 +798,8 @@
that.productItem = [...that.productItem, ...res.result.records];
}
let hasTuijian = false
let bidian = false
let tuijianList = []
let putongList = []
for(let i = 0;i<that.productItem.length;i++){
if(this.productItem[i].sellBeginTime !='' && this.productItem[i].sellEndTime != ''){
let isEndTime = this.isWithinBusinessHours(this.productItem[i].sellBeginTime,this.productItem[i].sellEndTime)
@ -817,19 +814,16 @@
if(that.productItem[i].isPush == 1){
that.productItem[i].categoryId = 'tuijian'
hasTuijian = true
}
if(that.productItem[i].isMust == 1){
that.productItem[i].categoryId = 'bidian'
bidian = true
tuijianList.push(that.productItem[i])
}else{
putongList.push(that.productItem[i])
}
}
if(hasTuijian == false){
that.menuList.splice(0,1)
}else{
that.productItem = [...tuijianList, ...putongList];
}
if(bidian == false){
that.menuList.splice(1,1)
}
console.log('好的',that.productItem)
//
that.getOrderWait();
@ -913,10 +907,12 @@
.attributeList;
for (let key in attrs) {
if (attrs[key] && attrs[key].title && attrs[key].title.length > 0) {
let canbuy = attrs[key].canbuy || 1; // canbuy1
this.parsedSpecs.push({
name: key,
options: attrs[key].title,
selected: attrs[key].title[0] // Default select first
canbuy: canbuy,
selected: [attrs[key].title[0]] //
});
}
}
@ -1040,10 +1036,12 @@
.attributeList;
for (let key in attrs) {
if (attrs[key] && attrs[key].title && attrs[key].title.length > 0) {
let canbuy = attrs[key].canbuy || 1; // canbuy1
this.parsedSpecs.push({
name: key,
options: attrs[key].title,
selected: attrs[key].title[0] // Default select first
canbuy: canbuy,
selected: [attrs[key].title[0]] //
});
}
}
@ -1132,7 +1130,29 @@
}
},
selectSpec(sIndex, option) {
this.parsedSpecs[sIndex].selected = option;
let spec = this.parsedSpecs[sIndex];
let idx = spec.selected.indexOf(option);
if (idx !== -1) {
//
if (spec.selected.length > 1) {
spec.selected.splice(idx, 1);
}
} else {
//
if (spec.selected.length < spec.canbuy) {
//
spec.selected.push(option);
} else if (spec.canbuy === 1) {
// 1
spec.selected = [option];
} else {
//
uni.showToast({
title: spec.name + '最多选' + spec.canbuy + '个',
icon: 'none'
});
}
}
this.$forceUpdate();
},
selectGroupRule(rule) {
@ -1148,7 +1168,7 @@
submitAddToCart() {
let specChoices = {};
for (let spec of this.parsedSpecs) {
specChoices[spec.name] = spec.selected;
specChoices[spec.name] = spec.canbuy === 1 ? spec.selected[0] : spec.selected;
}
this.addToCart(this.currentItem, specChoices);
uni.showToast({
@ -1160,7 +1180,7 @@
submitPintuan(isFaceToFace) {
let specChoices = {};
for (let spec of this.parsedSpecs) {
specChoices[spec.name] = spec.selected;
specChoices[spec.name] = spec.canbuy === 1 ? spec.selected[0] : spec.selected;
}
let packageFee = parseFloat(this.currentItem.lunchBox || 0);
@ -1311,7 +1331,11 @@
if (!specs) return '';
let arr = [];
for (let k in specs) {
arr.push(specs[k]);
if (Array.isArray(specs[k])) {
arr.push(specs[k].join('+'));
} else {
arr.push(specs[k]);
}
}
return arr.join(',');
},

109
package1/myCenter/addGoods.vue

@ -65,8 +65,8 @@
</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="(value,key) in Array.from(formData.attributeList1)" :key="key" style="display: flex;flex-wrap: wrap;align-items: center;margin-bottom: 10rpx;">
{{value[0]}}(可选{{value[1].canbuy || 1}}):
<view v-for="(item,index) in value[1].title" :key="index">
{{item}}
</view>
@ -135,11 +135,13 @@
<view v-for="(item,index) in categorySonData" :key="index" @tap="checkSpecValue(index)" class="content-low" :class="item.checked?'checked':''">
{{item.title}}
</view>
<view>
<uni-forms-item label="可选数量" name="currentCanbuy">
<input type="digit" class="content-input" v-model="currentCanbuy" placeholder="该分类可选几个(默认1)">
</uni-forms-item>
</view>
</view>
<view slot="footer" style="display: flex;padding-left: 40rpx;margin-top: 20rpx;">
<uni-forms-item label="设置最大选择数" name="maxSelect">
<input type="digit" class="content-input" v-model="maxSelect" placeholder="可设置最大选择数">
</uni-forms-item>
<button type="text" @tap="$refs.addTypeDialog.close()" style="margin-right: 20rpx;">取消</button>
<button type="text" @tap="guigeSubmit">提交</button>
</view>
@ -155,6 +157,8 @@
dataList: {},
modalType:0,
maxSelect:1,
currentCanbuy:1,
canbuyMap:{},
categoryData:[],
categoryIndex: 0,
modalclassType:'',
@ -430,23 +434,32 @@
},
guigeSubmit(){
if(this.modalclassType == 'shuxing'){
// canbuy
if(this.typeToAttrName){
this.canbuyMap[this.typeToAttrName] = parseInt(this.currentCanbuy) || 1
}
for(let i=0;i<this.attrValueArr.length;i++){
let parentName = this.attrValueArr[i].parentName
let canbuyVal = parseInt(this.canbuyMap[parentName]) || 1
if(this.formData.attributeList1.size == 0){
//set has get
let data = {
title:[]
title:[],
canbuy: canbuyVal
}
data.title.push(this.attrValueArr[i].title)
this.formData.attributeList1.set(this.attrValueArr[i].parentName,data)
this.formData.attributeList1.set(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)
if(this.formData.attributeList1.has(parentName) && this.formData.attributeList1.get(parentName).title.indexOf(this.attrValueArr[i].title) == -1){
this.formData.attributeList1.get(parentName).title.push(this.attrValueArr[i].title)
this.formData.attributeList1.get(parentName).canbuy = canbuyVal
}else{
let data = {
title:[]
title:[],
canbuy: canbuyVal
}
data.title.push(this.attrValueArr[i].title)
this.formData.attributeList1.set(this.attrValueArr[i].parentName,data)
this.formData.attributeList1.set(parentName,data)
}
}
}
@ -522,11 +535,33 @@
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)
// attributeListstring
let attrObj = this.formData.attributeList
if (typeof attrObj === 'string' && attrObj !== '') {
attrObj = JSON.parse(attrObj)
}
if (!attrObj || typeof attrObj !== 'object') {
attrObj = {}
}
this.formData.attributeList1 = new Map(Object.entries(attrObj));
// attributeListPricestring
let priceArr = this.formData.attributeListPrice
if (typeof priceArr === 'string' && priceArr !== '') {
priceArr = JSON.parse(priceArr)
}
if (!Array.isArray(priceArr)) {
priceArr = [{specPrice: "", specNum: 9999}]
}
this.formData.attributeListPrice = priceArr
// canbuyMapcanbuy1
this.canbuyMap = {}
this.attrValueArr = []
this.formData.attributeList1.forEach((value, key) => {
value.canbuy = value.canbuy || 1
this.canbuyMap[key] = value.canbuy
for(let i = 0;i<value.title.length;i++){
this.attrValueArr.push({
parentName:key,
@ -534,7 +569,8 @@
})
}
});
this.specValueArr = this.formData.attributeListPrice
// attributeListPricespecValueArr
this.specValueArr = JSON.parse(JSON.stringify(this.formData.attributeListPrice))
this.formData.sellTime = this.formData.sellBeginTime != '' ? 1 : 0
@ -569,6 +605,10 @@
},
//
clickLeftBtn(index) {
// canbuy
if(this.typeToAttrName){
this.canbuyMap[this.typeToAttrName] = parseInt(this.currentCanbuy) || 1
}
for (var i = 0; i < this.categoryData.length; i++) {
if (i == index) {
this.categoryData[i].parentId = true
@ -578,6 +618,8 @@
}
this.categoryIndex = index
this.typeToAttrName = this.categoryData[this.categoryIndex].title
// canbuy
this.currentCanbuy = this.canbuyMap[this.typeToAttrName] || 1
this.getCateGorySon(this.categoryData[this.categoryIndex].id)
},
pictureAdd(id, huan) {
@ -620,6 +662,8 @@
}
//parent
this.typeToAttrName = res.result.content[this.categoryIndex].title
// canbuy
this.currentCanbuy = this.canbuyMap[this.typeToAttrName] || 1
this.getCateGorySon(res.result.content[this.categoryIndex].id)
}
}).catch(() => {});
@ -636,40 +680,31 @@
}, false, true).then((res) => {
if(res.code == 200){
this.categorySonData = res.result.content
// checkedfalseVue
console.log("111111",this.specValueArr)
console.log("22222",this.attrValueArr)
for (var i = 0; i < this.categorySonData.length; i++) {
this.$set(this.categorySonData[i], 'checked', false)
}
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 && this.attrValueArr[m].parentName == this.typeToAttrName){
index1 = true
this.categorySonData[i].checked = true
}
for (var m = 0; m < this.attrValueArr.length; m++) {
if(this.attrValueArr[m].title == this.categorySonData[i].title && this.attrValueArr[m].parentName == this.typeToAttrName){
this.$set(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
}
for (var m = 0; m < this.specValueArr.length; m++) {
if(this.specValueArr[m].id == this.categorySonData[i].id){
this.$set(this.categorySonData[i], 'checked', true)
}
}else{
this.categorySonData[i].checked = false
}
}
}
this.$forceUpdate()
}
}).catch(() => {});
},

Loading…
Cancel
Save