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>
<view class="shop-bottom" v-if="item.products != null && item.products.length > 0"> <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' <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"> <view class="menu-img">
<img :src="item1.productPicture" lazy-load alt=""> <img :src="item1.productPicture" lazy-load alt="">
</view> </view>

66
package1/group/groupBuySingle.vue

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

109
package1/myCenter/addGoods.vue

@ -65,8 +65,8 @@
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="商品属性" name="attributeList1"> <uni-forms-item label="商品属性" name="attributeList1">
<view style="display: flex;flex-direction: column;"> <view style="display: flex;flex-direction: column;">
<view v-for="(value,key) in Array.from(formData.attributeList1)" :key="index" style="display: flex;"> <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[0]}}(可选{{value[1].canbuy || 1}}):
<view v-for="(item,index) in value[1].title" :key="index"> <view v-for="(item,index) in value[1].title" :key="index">
{{item}} {{item}}
</view> </view>
@ -135,11 +135,13 @@
<view v-for="(item,index) in categorySonData" :key="index" @tap="checkSpecValue(index)" class="content-low" :class="item.checked?'checked':''"> <view v-for="(item,index) in categorySonData" :key="index" @tap="checkSpecValue(index)" class="content-low" :class="item.checked?'checked':''">
{{item.title}} {{item.title}}
</view> </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>
<view slot="footer" style="display: flex;padding-left: 40rpx;margin-top: 20rpx;"> <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="$refs.addTypeDialog.close()" style="margin-right: 20rpx;">取消</button>
<button type="text" @tap="guigeSubmit">提交</button> <button type="text" @tap="guigeSubmit">提交</button>
</view> </view>
@ -155,6 +157,8 @@
dataList: {}, dataList: {},
modalType:0, modalType:0,
maxSelect:1, maxSelect:1,
currentCanbuy:1,
canbuyMap:{},
categoryData:[], categoryData:[],
categoryIndex: 0, categoryIndex: 0,
modalclassType:'', modalclassType:'',
@ -430,23 +434,32 @@
}, },
guigeSubmit(){ guigeSubmit(){
if(this.modalclassType == 'shuxing'){ 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++){ 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){ if(this.formData.attributeList1.size == 0){
//set has get //set has get
let data = { let data = {
title:[] title:[],
canbuy: canbuyVal
} }
data.title.push(this.attrValueArr[i].title) data.title.push(this.attrValueArr[i].title)
this.formData.attributeList1.set(this.attrValueArr[i].parentName,data) this.formData.attributeList1.set(parentName,data)
}else{ }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){ if(this.formData.attributeList1.has(parentName) && this.formData.attributeList1.get(parentName).title.indexOf(this.attrValueArr[i].title) == -1){
this.formData.attributeList1.get(this.attrValueArr[i].parentName).title.push(this.attrValueArr[i].title) this.formData.attributeList1.get(parentName).title.push(this.attrValueArr[i].title)
this.formData.attributeList1.get(parentName).canbuy = canbuyVal
}else{ }else{
let data = { let data = {
title:[] title:[],
canbuy: canbuyVal
} }
data.title.push(this.attrValueArr[i].title) 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); let data = JSON.parse(str);
console.log('111111',data) console.log('111111',data)
this.formData = 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) => { 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++){ for(let i = 0;i<value.title.length;i++){
this.attrValueArr.push({ this.attrValueArr.push({
parentName:key, 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 this.formData.sellTime = this.formData.sellBeginTime != '' ? 1 : 0
@ -569,6 +605,10 @@
}, },
// //
clickLeftBtn(index) { clickLeftBtn(index) {
// canbuy
if(this.typeToAttrName){
this.canbuyMap[this.typeToAttrName] = parseInt(this.currentCanbuy) || 1
}
for (var i = 0; i < this.categoryData.length; i++) { for (var i = 0; i < this.categoryData.length; i++) {
if (i == index) { if (i == index) {
this.categoryData[i].parentId = true this.categoryData[i].parentId = true
@ -578,6 +618,8 @@
} }
this.categoryIndex = index this.categoryIndex = index
this.typeToAttrName = this.categoryData[this.categoryIndex].title this.typeToAttrName = this.categoryData[this.categoryIndex].title
// canbuy
this.currentCanbuy = this.canbuyMap[this.typeToAttrName] || 1
this.getCateGorySon(this.categoryData[this.categoryIndex].id) this.getCateGorySon(this.categoryData[this.categoryIndex].id)
}, },
pictureAdd(id, huan) { pictureAdd(id, huan) {
@ -620,6 +662,8 @@
} }
//parent //parent
this.typeToAttrName = res.result.content[this.categoryIndex].title this.typeToAttrName = res.result.content[this.categoryIndex].title
// canbuy
this.currentCanbuy = this.canbuyMap[this.typeToAttrName] || 1
this.getCateGorySon(res.result.content[this.categoryIndex].id) this.getCateGorySon(res.result.content[this.categoryIndex].id)
} }
}).catch(() => {}); }).catch(() => {});
@ -636,40 +680,31 @@
}, false, true).then((res) => { }, false, true).then((res) => {
if(res.code == 200){ if(res.code == 200){
this.categorySonData = res.result.content 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'){ if(this.modalclassType == 'shuxing'){
for (var i = 0; i < this.categorySonData.length; i++) { for (var i = 0; i < this.categorySonData.length; i++) {
if(this.attrValueArr.length>0){ for (var m = 0; m < this.attrValueArr.length; m++) {
let index1 = false if(this.attrValueArr[m].title == this.categorySonData[i].title && this.attrValueArr[m].parentName == this.typeToAttrName){
for (var m = 0; m < this.attrValueArr.length; m++) { this.$set(this.categorySonData[i], 'checked', true)
if(this.attrValueArr[m].title == this.categorySonData[i].title && this.attrValueArr[m].parentName == this.typeToAttrName){
index1 = true
this.categorySonData[i].checked = true
}
} }
if(index1){
this.categorySonData[i].checked = true
}
}else{
this.categorySonData[i].checked = false
} }
} }
}else{ }else{
//guige //guige
for (var i = 0; i < this.categorySonData.length; i++) { for (var i = 0; i < this.categorySonData.length; i++) {
if(this.specValueArr.length>0){ for (var m = 0; m < this.specValueArr.length; m++) {
for (var m = 0; m < this.specValueArr.length; m++) { if(this.specValueArr[m].id == this.categorySonData[i].id){
if(this.specValueArr[m].id == this.categorySonData[i].id){ this.$set(this.categorySonData[i], 'checked', true)
this.categorySonData[i].checked = true
}
} }
}else{
this.categorySonData[i].checked = false
} }
} }
} }
this.$forceUpdate()
} }
}).catch(() => {}); }).catch(() => {});
}, },

Loading…
Cancel
Save