diff --git a/pages/login/login.vue b/pages/login/login.vue
index ae095bf..d497d01 100644
--- a/pages/login/login.vue
+++ b/pages/login/login.vue
@@ -539,12 +539,20 @@
}
// uni.setStorageSync('area',JSON.stringify(item))
this.shopList = res.result.shop;
- let data = {
- regionId: res.result.worker.region
- }
- uni.setStorageSync('area', JSON.stringify(data))
uni.setStorageSync('peisongyuan', this.peisongyuan)
if (this.peisongyuan) {
+ if (!res.result.worker) {
+ uni.showToast({
+ title: '该账号暂无配送员身份',
+ icon: 'none'
+ })
+ this.getCaptchaImg()
+ return
+ }
+ let data = {
+ regionId: res.result.worker.region
+ }
+ uni.setStorageSync('area', JSON.stringify(data))
this.saveLocal(res.result.worker)
uni.reLaunch({
url: '../worker/index'
diff --git a/pages/shop/addGoods.vue b/pages/shop/addGoods.vue
index a15bdc2..a8d2edc 100644
--- a/pages/shop/addGoods.vue
+++ b/pages/shop/addGoods.vue
@@ -110,6 +110,23 @@
+
+
+ 加载中...
+ 暂无可搭配商品
+
+
+ {{item.productName}}
+ {{isMoreBuyProductSelected(item.id) ? '已选' : '选择'}}
+
+
+
{
+ this.NB.sendRequest("/app/product/save", submitData, false, 'post', 'application/json').then((res) => {
if(res.code == 200){
uni.showToast({
title: "操作成功",
@@ -471,11 +497,13 @@
})
} 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.NB.sendRequest("/app/product/edit", this.formData, false, 'post', 'application/json').then((res) => {
+ let submitData = Object.assign({}, this.formData)
+ submitData.moreBuyProductIds = this.getSubmitMoreBuyProductIds()
+ submitData.attributeListPrice = JSON.stringify(submitData.attributeListPrice)
+ submitData.attributeList = Object.fromEntries(submitData.attributeList1)
+ submitData.attributeList = JSON.stringify(submitData.attributeList)
+ submitData.productPictures = []
+ this.NB.sendRequest("/app/product/edit", submitData, false, 'post', 'application/json').then((res) => {
if(res.code == 200){
uni.showToast({
title: "操作成功",
@@ -624,8 +652,66 @@
blurFormField(){
this.scrollTarget = ''
},
+ normalizeMoreBuyProductIds(value) {
+ if (Array.isArray(value)) {
+ return value.filter(item => item !== '' && item !== null && item !== undefined).map(String)
+ }
+ if (value === '' || value === null || value === undefined) {
+ return []
+ }
+ return String(value).split(',').map(item => item.trim()).filter(item => item)
+ },
+ getSubmitMoreBuyProductIds() {
+ if (this.isMoreBuyEnabled()) {
+ return ''
+ }
+ return this.normalizeMoreBuyProductIds(this.formData.moreBuyProductIds).join(',')
+ },
+ isMoreBuyProductSelected(id) {
+ return this.normalizeMoreBuyProductIds(this.formData.moreBuyProductIds).indexOf(String(id)) != -1
+ },
+ toggleMoreBuyProduct(item) {
+ let selectedIds = this.normalizeMoreBuyProductIds(this.formData.moreBuyProductIds)
+ const id = String(item.id)
+ const index = selectedIds.indexOf(id)
+ if (index == -1) {
+ selectedIds.push(id)
+ } else {
+ selectedIds.splice(index, 1)
+ }
+ this.formData.moreBuyProductIds = selectedIds
+ this.$forceUpdate()
+ },
+ getMoreBuyProductOptions() {
+ const shopId = this.formData.shopId || uni.getStorageSync('shopId')
+ if (!shopId) {
+ this.moreBuyProductOptions = []
+ return
+ }
+ this.moreBuyProductLoading = true
+ this.NB.sendRequest('/app/product/getShareList', {
+ shopId: shopId,
+ isMoreBuy: 1,
+ pageNum: 1,
+ pageSize: 1000
+ }, false, 'post', 'application/json').then((res) => {
+ this.moreBuyProductLoading = false
+ if (res.code == 200 && res.result) {
+ const records = Array.isArray(res.result.records) ? res.result.records : []
+ this.moreBuyProductOptions = records.filter(item => item.id != this.formData.id)
+ }
+ }).catch(() => {
+ this.moreBuyProductLoading = false
+ })
+ },
checkisMoreBuy(type){
this.formData.isMoreBuy = type;
+ if (this.isMoreBuyEnabled()) {
+ this.formData.moreBuyProductIds = []
+ } else {
+ this.formData.moreBuyProductIds = this.normalizeMoreBuyProductIds(this.formData.moreBuyProductIds)
+ this.getMoreBuyProductOptions()
+ }
this.syncLunchBoxByMoreBuy()
},
isMoreBuyEnabled(){
@@ -768,6 +854,8 @@
specNum:9999
}],
sellTime:0, //可售时间
+ isMoreBuy:0,
+ moreBuyProductIds:[],
sellBeginTime:'', //可售时段自定义---开始时间
sellEndTime:'', //可售时段自定义---结束时间
attributeList:'',
@@ -793,6 +881,7 @@
let str = JSON.stringify(v);
let data = JSON.parse(str);
this.formData = data;
+ this.formData.moreBuyProductIds = this.normalizeMoreBuyProductIds(this.formData.moreBuyProductIds)
// 解析attributeList(商品属性),兼容string和已解析的对象
let attrObj = this.formData.attributeList
@@ -833,6 +922,9 @@
this.formData.sellTime = this.formData.sellBeginTime != '' ? 1 : 0
this.syncLunchBoxByMoreBuy()
+ if (!this.isMoreBuyEnabled()) {
+ this.getMoreBuyProductOptions()
+ }
this.modalVisible = true;
},
checkSpecValue(index){
@@ -1190,6 +1282,44 @@
font-weight: 700;
opacity: 0.7;
}
+ .more-buy-select {
+ display: flex;
+ flex-direction: column;
+ gap: 14rpx;
+ }
+ .more-buy-empty {
+ color: #999;
+ line-height: 60rpx;
+ }
+ .more-buy-option {
+ display: flex;
+ align-items: center;
+ min-height: 88rpx;
+ padding: 12rpx;
+ border: 2rpx solid #eee;
+ border-radius: 14rpx;
+ background: #fff;
+ box-sizing: border-box;
+ }
+ .more-buy-option.checked {
+ border-color: #60F3FF;
+ background: rgba(96, 243, 255, 0.16);
+ }
+ .more-buy-option-img {
+ width: 64rpx;
+ height: 64rpx;
+ margin-right: 14rpx;
+ border-radius: 10rpx;
+ }
+ .more-buy-option-name {
+ flex: 1;
+ font-size: 28rpx;
+ color: #00231C;
+ }
+ .more-buy-option-check {
+ color: #008ba0;
+ font-size: 24rpx;
+ }
.group-delete-btn {
flex: 0 0 70rpx;
width: 70rpx;