From 773efe87ca5e77da66ec9588e4958c6dffe428a6 Mon Sep 17 00:00:00 2001
From: zmj <1493694146@qq.com>
Date: Tue, 23 Apr 2024 18:01:32 +0800
Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E7=AE=A1=E7=90=86=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/product/addGood/addGood.vue | 53 +-
pages/product/addGoodDetail/addGoodDetail.vue | 256 ++-
pages/product/addGoodDetail/goodsPrice.vue | 92 +-
pages/product/list/index - 副本.vue | 1367 +++++++++++++++++
pages/product/list/index.vue | 309 +++-
pages/product/updateStock/updateStock.vue | 52 +-
utils/util.js | 1 -
7 files changed, 1935 insertions(+), 195 deletions(-)
create mode 100644 pages/product/list/index - 副本.vue
diff --git a/pages/product/addGood/addGood.vue b/pages/product/addGood/addGood.vue
index 5dbee42..ded1b87 100644
--- a/pages/product/addGood/addGood.vue
+++ b/pages/product/addGood/addGood.vue
@@ -12,7 +12,7 @@
-
+
上传时应注重真实性、清晰度
@@ -68,14 +68,16 @@
+ placeholder="请输入零售价" type='number' v-model="formData.attrValue[0].price"
+ slot='right'>
+ placeholder="请输入批发价格" type='number' v-model="formData.attrValue[0].wholesale_price"
+ slot='right'>
-
@@ -194,20 +196,29 @@
"imageList": [
],
+ attr: [{
+ detail: [],
+ value: ""
+ }, ],
"attrValue": [{
+ detail: {
+ 规格名: 'attr[index]value',
+ },
"price": "",
"unit_name": "",
"wholesale_unit_name": "",
"wholesale_price": '',
"cost": "",
"stock": "",
+ sku: '',
"ot_price": "",
"procure_price": "",
"bar_code": "",
"weight": "",
- "volume": "",
"extension_one": "",
"extension_two": "",
+ uuid: "",
+ volume: "",
"is_use": 0,
}],
"cate_name": "",
@@ -218,10 +229,7 @@
],
"mer_cate_name": "",
"spec_type": "0",
- attr: [{
- detail: [],
- value: ""
- }, ],
+
"specifica": "",
"delivery_way": [
@@ -263,12 +271,13 @@
maxLength: 30,
showSex: false,
rules: {
- title: {
- type: 'string',
- required: true,
- message: '请选择',
- trigger: ['blur', 'change']
- }
+ "formData.imageList": [{
+ validator: (rule, value, callback) => {
+ return this.formData.imageList.length >= 2
+ },
+ message: '请至少上传2张图片',
+ trigger: ['change', 'blur'],
+ }]
},
};
@@ -418,7 +427,7 @@
});
},
- async submit() {
+ handAdd() {
let data = uni.$u.deepClone(this.formData)
data.image = data.imageList[0]
data.slider_image = data.imageList.splice(0, 1)
@@ -432,17 +441,25 @@
uni.$emit('importAttrValueOK', this.setFormData.import_id);
uni.navigateBack();
} else uni.redirectTo({
- url: `/pages/product/goodsOnSale/index?mer_id=${this.mer_id}&type=6`
+ url: `/pages/product/list/index?mer_id=${this.mer_id}&type=6`
})
}).catch(() => {
uni.redirectTo({
- url: `/pages/nongKe/gather/select_warehouse?mer_id=${this.mer_id}&stype=2`
+ url: `/pages/product/list/index?mer_id=${this.mer_id}&type=2`
})
})
})
.catch(rej => {
// Toast(rej);
});
+ },
+ async submit() {
+ this.$refs.formData.validate().then(res => {
+ this.handAdd()
+ }).catch(errors => {
+ uni.$u.toast(errors[0].message)
+ })
+
}
},
onLoad(option) {
diff --git a/pages/product/addGoodDetail/addGoodDetail.vue b/pages/product/addGoodDetail/addGoodDetail.vue
index 13c1809..efaba34 100644
--- a/pages/product/addGoodDetail/addGoodDetail.vue
+++ b/pages/product/addGoodDetail/addGoodDetail.vue
@@ -1,19 +1,21 @@
-
-
+
{{value1.length}}/{{maxLength}}
+ style="background-color: #F9F9F9;height: 166rpx;" :maxlength='maxLength'>
+
-
+
上传时应注重真实性、清晰度
+
@@ -43,11 +45,11 @@
-
+
-
+
上传图片/视频
@@ -57,7 +59,7 @@
-
+
上传时应注重真实性、清晰度
@@ -66,7 +68,7 @@
style="margin-right: 20rpx;margin-bottom: 20rpx;">
-
+
@@ -85,11 +87,11 @@
-
+
-
+
@@ -108,7 +110,7 @@
商品类目属性
-
+
{{ formData.cate_name|| '请选择'}}
@@ -129,7 +131,7 @@
规格与价格
-
+
{{sets?"已设置":""}}
@@ -141,19 +143,29 @@
-
+
零售价格
- 5000元/斤
+ {{item.price}}元/{{item.unit_name}}
商品库存
- 5000
+ {{item.stock}}
+
+
+
+
+
+ 批发价格
+ {{item.wholesale_price}}元/{{item.wholesale_unit_name}}
+
+
+ 批发单位
+ {{item.stock}}
-
-
@@ -193,15 +205,14 @@
- {{value1.length}}/{{maxLength}}
+ {{value1.length}}/{{300}}
+ style="background-color: #F9F9F9;height: 166rpx;" :maxlength='300'>
-
-
+
+
{
+ return this.formData.imageList.length >= 2
+ },
+ message: '请至少上传2张图片',
+ trigger: ['change', 'blur'],
+ }],
+ "formData.attrValue": [{
+ validator: (rule, value, callback) => {
+ if (!this.isWholeSale) {
+ delete this.attrRules.wholesale_unit_name
+ delete this.attrRules.wholesale_price
+ }
+ let errList = []
+ this.formData.attrValue.forEach(item => {
+ for (let key in this.attrRules) {
+ if (!item[key]) {
+ errList.push(this.rules[key])
+ }
+ }
+ })
+ console.log(errList, 'err')
+ return errList.length == 0
+ },
+ message: '请填写完整商品规格',
+ trigger: ['change', 'blur'],
+ }],
+
+ 'store_name': {
+ type: 'string',
+ required: true,
+ message: '请填写商品标题',
+ trigger: ['blur', 'change']
+ },
+ 'cate_name': {
+ type: 'string',
+ required: true,
+ message: '请填写商品分类',
+ trigger: ['blur', 'change']
+ },
+ 'delivery_way': {
+ validator: (rule, value, callback) => {
+ return this.formData.delivery_way.length > 0
+ },
+ required: true,
+ message: '请选择送货方式',
+ trigger: ['blur', 'change']
+ },
+ 'formData.content.image': {
+ validator: (rule, value, callback) => {
+ return this.formData.content.image.length > 0
+ },
+ required: true,
+ message: '请上传商品详情图',
+ trigger: ['blur', 'change']
+ },
+
},
radio: '',
@@ -416,6 +500,14 @@
};
},
methods: {
+
+ preViewImg(url) {
+ let that = this
+ uni.previewImage({
+ urls: [url],
+ });
+
+ },
deleteImage(index) {
// this.addGoodsSecoundData.video_link = '';
},
@@ -457,7 +549,18 @@
count: 6,
url: 'upload/image'
}, function(res) {
- that.formData.imageList.push(res.data.path);
+ if (that.isDetail) {
+ that.formData.content.image.push(res.data.path.replace(
+ /\\/g, ""));
+
+ } else {
+ that.$set(that.formData.imageList, that.formData.imageList.length, res.data.path.replace(
+ /\\/g,
+ ""));
+
+ }
+
+ // that.formData.imageList.push(res.data.path);
});
},
// 上传视频
@@ -559,7 +662,7 @@
getAttrValue(object) {
this.formData.attrValue = object
},
- async submit() {
+ async handAdd() {
let that = this
let data = uni.$u.deepClone(this.formData)
data.image = data.imageList[0]
@@ -588,9 +691,11 @@
Modal('提交成功', '点击确定,前往商品列表页面').then(() => {
if (this.import == 1) {
uni.$emit('importAttrValueOK', this.setFormData.import_id);
- uni.navigateBack();
+ uni.redirectTo({
+ url: `/pages/product/list/index?mer_id=${this.mer_id}&type=6`
+ })
} else uni.redirectTo({
- url: `/pages/product/goodsOnSale/index?mer_id=${that.mer_id}&type=6`
+ url: `/pages/product/list/index?mer_id=${this.mer_id}&type=6`
})
}).catch(() => {
uni.navigateBack()
@@ -600,8 +705,15 @@
// Toast(rej);
})
},
+ submit() {
+ this.$refs.formData.validate().then(res => {
+ this.handAdd()
+ }).catch(errors => {
+ uni.$u.toast(errors[0].message)
+ })
+
+ },
initFormData(option) {
- this.delivery_way = this.$store.state.app.userInfo?.mer_info.delivery_way.split(',')
this.isWholeSale = this.$store.state.app.userInfo?.mer_info?.wholesale == 2;
this.mer_id = option.mer_id
if (option.formData) {
@@ -616,21 +728,25 @@
this.showSet = option.showSet ? JSON.parse(option.showSet) : this.showSet
let that = this
this.isSet2()
- if (option.product_id) {
- that.formData.product_id = option.product_id
- this.mode = 'edit'
- this.showSet = true
- productDetail(option.mer_id, option.product_id).then(res => {
- this.formData = res.data
- //该死的后端,格式不按添加的格式来
- this.formData.product_attribute = JSON.parse(this.formData.product_attribute)
- this.formData.cate_name = this.formData.storeCategory.cate_name
- this.formData.cate_id = this.formData.storeCategory.store_category_id
- this.formData.imageList = this.formData.image_list
- })
- }
- console.log(this.formData)
- // console.log(this.isSet(this.formData.attrValue))
+ that.formData.delivery_way = that.$store.state.app.userInfo?.mer_info.delivery_way.split(',')
+ console.log(that.formData)
+ // if (option.product_id) {
+ // that.formData.product_id = option.product_id
+ // this.mode = 'edit'
+ // this.showSet = true
+ // productDetail(option.mer_id, option.product_id).then(res => {
+ // this.formData = res.data
+ // //该死的后端,格式不按添加的格式来
+ // this.formData.product_attribute = JSON.parse(this.formData.product_attribute)
+ // this.formData.cate_name = this.formData.storeCategory.cate_name
+ // this.formData.cate_id = this.formData.storeCategory.store_category_id
+ // this.formData.imageList = this.formData.image_list
+ // if (!that.formData.imageList) that.formData.imageList = []
+ // })
+ // }
+
+
+
},
onBackPress: function(e) {
this.showlay = true
diff --git a/pages/product/addGoodDetail/goodsPrice.vue b/pages/product/addGoodDetail/goodsPrice.vue
index cd3c16b..3b77402 100644
--- a/pages/product/addGoodDetail/goodsPrice.vue
+++ b/pages/product/addGoodDetail/goodsPrice.vue
@@ -1,9 +1,7 @@
-
+
@@ -16,8 +14,8 @@
-
+
/
@@ -27,7 +25,7 @@
+ v-model="item.wholesale_price" type='number'>
/
@@ -81,33 +79,107 @@
value: "",
formData: {},
"attrValue": [{
+ detail: {
+ 规格名: 'attr[index]value',
+ },
"price": "",
"unit_name": "",
"wholesale_unit_name": "",
- "wholesale_price": "",
+ "wholesale_price": '',
"cost": "",
"stock": "",
+ sku: 'attr[index]value',
"ot_price": "",
"procure_price": "",
"bar_code": "",
"weight": "",
- "volume": "",
"extension_one": "",
"extension_two": "",
+ uuid: "",
+ volume: "",
"is_use": 0,
- "spec_type": ""
}],
+ rules: {
+ price: '单价不能为空',
+ unit_name: '计量单位不能为空',
+ wholesale_price: '批发价格不能为空',
+ wholesale_unit_name: '批发单位不能为空',
+ stock: '库存不能为空'
+ }
}
},
methods: {
+ pushFn() {
+ this.attrValue.push({
+ detail: {
+ 规格名: 'attr[index]value',
+ },
+ "price": "",
+ "unit_name": "",
+ "wholesale_unit_name": "",
+ "wholesale_price": '',
+ "cost": "",
+ "stock": "",
+ sku: 'attr[index]value',
+ "ot_price": "",
+ "procure_price": "",
+ "bar_code": "",
+ "weight": "",
+ "extension_one": "",
+ "extension_two": "",
+ uuid: "",
+ volume: "",
+ "is_use": true,
+
+ })
+ this.formData.attr.push({
+ value: '',
+ detail: [],
+ })
+
+ },
submit() {
+ let errList = []
+ if (!this.isWholeSale) {
+ delete this.rules.wholesale_unit_name
+ delete this.rules.wholesale_price
+ }
+ this.attrValue.forEach(item => {
+ for (let key in this.rules) {
+ if (!item[key]) {
+ errList.push(this.rules[key])
+ }
+ }
+ })
+ if (errList.length > 0) {
+ uni.$u.toast(errList[0])
+ return
+ }
+ let flag = false
+ if (this.formData.attr.length > 1) {
+ this.formData.attr.forEach(item => {
+ if (!item.value) {
+ flag = true
+ }
+ })
+ }
+ if (flag) {
+ uni.$u.toast('请填写规格名称')
+ return
+ }
this.formData.attrValue = this.attrValue
this.formData.attrValue.forEach(item => {
item.is_use = item.is_use ? '0' : '1'
})
let that = this
+ this.formData.attrValue.forEach((item, index) => {
+ item.detail.规格名 = this.formData.attr[index].value
+ item.sku = this.formData.attr[index].value
+
+ })
+ this.formData.spec_type = this.formData.attrValue.length > 1 ? '1' : '0'
uni.reLaunch({
url: `/pages/product/addGoodDetail/addGoodDetail?mer_id=${that.mer_id}&&formData=${JSON.stringify(that.formData) }&&showSet=${true}`
})
@@ -134,8 +206,6 @@
detail: [],
})
}
- console.log(this.formData)
- console.log(this.attrValue)
}
}
diff --git a/pages/product/list/index - 副本.vue b/pages/product/list/index - 副本.vue
new file mode 100644
index 0000000..457bab2
--- /dev/null
+++ b/pages/product/list/index - 副本.vue
@@ -0,0 +1,1367 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 多规格
+
+
+
+ 礼包
+ {{item.store_name}}
+
+
+
+ 库存: {{item.stock}}
+ 销量: {{item.sales}}
+
+
+
+ {{lable.label_name}}
+
+
+
+
+
+ ¥{{item.attrValue[0].wholesale_price}}
+ 零售价¥{{item.attrValue[0].price}}
+
+ 商品规格错误
+
+ ¥{{item.price}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 修改库存
+
+ 下架
+
+ 上架
+
+ 编辑
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 修改库存
+ 线上入库
+
+
+
+
+
+
+
+
+
+
+
+
+ 数量:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/product/list/index.vue b/pages/product/list/index.vue
index d9e02d4..3b5532c 100644
--- a/pages/product/list/index.vue
+++ b/pages/product/list/index.vue
@@ -41,7 +41,8 @@
-->
-
+
+
+
-
+
-
+
点击预览
- {{item.store_name}}
+
+ {{item.store_name}}
+
- 库存: 96
+ 库存: {{item.attrValue[0].stock}}
- ¥10.00/个
+ 零售: ¥{{item.attrValue[0].price}}/{{item.attrValue[0].unit_name}}
+
+
+ 批发: ¥{{item.attrValue[0].wholesale_price}}/{{item.attrValue[0].wholesale_unit_name}}
-
-
+
+
-
+
+ 删除
+
+
修改库存
-
+
+
下架
-
+
+ 上架
+
+
编辑商品
+
-
+
+
+
+
@@ -232,7 +305,8 @@
productOffApi,
productRecommendApi,
productUpdateFree,
- productTitle
+ productTitle,
+ productDestory
} from "@/api/product";
import {
labelLst
@@ -265,6 +339,13 @@
},
data() {
return {
+ flag1: true,
+ flag: true,
+ xjList: [1, 3, 4],
+ sjList: [2],
+ xjItem: "",
+ showOverly: false,
+ isWholeSale: false,
status: 'loadmore',
current: "",
where: {
@@ -322,20 +403,24 @@
onLoad(options) {
this.getUserInfo()
this.getCategoryList();
-
+ this.isWholeSale = this.$store.state.app.userInfo?.mer_info?.wholesale == 2;
+ if (options.type) {
+ this.tabClick = options.type
+ }
var that = this;
// 获取设备宽度
uni.getSystemInfo({
success(e) {
that.isWidth = e.windowWidth / 5;
+ console.log(that.isWidth)
}
});
},
onPullDownRefresh() {
this.where.page = 1
- this.productList = []
this.loading = false
this.loaded = false
+ this.productList = []
this.getList(this.mer_id, false);
uni.stopPullDownRefresh()
},
@@ -347,20 +432,37 @@
},
methods: {
- preViewImg(url) {
- let that = this
- uni.previewImage({
- urls: [url],
- // longPressActions: {
- // itemList: ['发送给朋友', '保存图片', '收藏'],
- // success: function(data) {
- // console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
- // },
- // fail: function(err) {
- // console.log(err.errMsg);
- // }
- // }
- });
+ Iknow() {
+ if (this.where.type == 2) {
+ this.flag = false
+ } else {
+ this.flag1 = false
+ }
+ this.showOverly = false
+ },
+ showInWarehouse() {
+ if (flag) {
+ this.showOverly = true
+ }
+ },
+ preViewImg(item) {
+
+ uni.navigateTo({
+ url: `/pages/admin/goods_details/index?product_id=${item.product_id}&product_type=0`
+ })
+ // let that = this
+ // uni.previewImage({
+ // urls: [url],
+ // // longPressActions: {
+ // // itemList: ['发送给朋友', '保存图片', '收藏'],
+ // // success: function(data) {
+ // // console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
+ // // },
+ // // fail: function(err) {
+ // // console.log(err.errMsg);
+ // // }
+ // // }
+ // });
},
// 商品分类
@@ -388,8 +490,10 @@
},
// 点击列表头部
- selectMenu(item, index) {
+ selectMenu(item) {
+ let index = this.tabList.findIndex(items => items.name == item.name);
this.where.type = item.type;
+ console.log(this.where.type)
this.loading = this.loaded = false;
this.where.page = 1;
this.shopList = [];
@@ -744,46 +848,56 @@
},
handleRecycle(item, index) {
- let that = this;
- Modal('温馨提示', `商品"${item.store_name}"将被加入回收站,请问是否继续?`).then(res => {
- productDeleteApi(that.mer_id, item.product_id)
- .then(res => {
- that.$util.Tips({
- title: res.message,
- icon: 'success'
- }, () => {
- that.productList.splice(index, 1);
- });
- this.$set(this, 'num', -1);
- })
- .catch(rej => {
- this.$set(this, 'num', -1);
- Toast(`${rej}, 加入回收站失败`);
+ let that = this;
+ productDestory(that.mer_id, item.product_id)
+ .then(res => {
+ that.$util.Tips({
+ title: res.message,
+ icon: 'success'
+ }, () => {
+ // that.productList.splice(index, 1);
});
- });
+ // this.$set(this, 'num', -1);
+ })
+ .catch(rej => {
+
+ this.$set(this, 'num', -1);
+ Toast(`${rej}, 删除失败`);
+ });
+ this.showOverly = false
},
//下架 0
handleShelves(item, status) {
let that = this;
if (status == 0) {
- uni.showModal({
- content: '确定要下架该商品么?',
- success: function(res) {
- if (res.confirm) {
- that.onAndOff(item, 0)
- uni.showToast({
- title: '下架成功',
- icon: 'none'
- })
- that.getList(this.mer_id, false)
- } else if (res.cancel) {
- // console.log('用户点击取消');
- }
- }
- });
+ that.onAndOff(item, 0)
+ uni.showToast({
+ title: '下架成功',
+ icon: 'none'
+ })
+ that.showOverly = false
+ this.productList = []
+ this.getList(this.mer_id, false);
+ // uni.showModal({
+ // content: '确定要下架该商品么?',
+ // success: function(res) {
+ // if (res.confirm) {
+ // that.onAndOff(item, 0)
+ // uni.showToast({
+ // title: '下架成功',
+ // icon: 'none'
+ // })
+ // that.getList(this.mer_id, false)
+ // } else if (res.cancel) {
+ // // console.log('用户点击取消');
+ // }
+ // }
+ // });
} else {
that.onAndOff(item, 1)
+ this.productList = []
+ this.getList(this.mer_id, false);
}
},
//上下架
@@ -907,14 +1021,81 @@
background-color: #FFF1EC;
position: absolute;
bottom: 0;
+ display: flex;
+ // justify-content: space-around;
+ align-items: center;
+ font-size: 24rpx;
+ color: #777777;
+
+ .card-footer-li {
+ text-align: center;
+ border-right: 1rpx solid #BDA9A1;
+ }
}
}
+ .warp {
+ background-color: white;
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+ width: 590rpx;
+ height: 354rpx;
+ border-radius: 16rpx;
+ padding: 50rpx 44rpx;
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
+ align-items: center;
+
+ .warp-tit {
+ font-size: 28rpx;
+ color: #777777;
+ // widows: 490rpx
+ }
+
+ .warp-foot {
+ display: flex;
+ // background-color: red;
+ width: 490rpx;
+ justify-content: space-around;
+
+ .warp-foot-li {
+ width: 236rpx;
+ height: 84rpx;
+ border-radius: 12rpx;
+ }
+
+ }
+ }
+
+ .ellipsis {
+ width: 400rpx;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
.longTab {
display: flex;
width: 100%;
.longItem {
+ width: 200px !important;
height: 50upx;
display: inline-block;
line-height: 50upx;
diff --git a/pages/product/updateStock/updateStock.vue b/pages/product/updateStock/updateStock.vue
index 3151113..c885453 100644
--- a/pages/product/updateStock/updateStock.vue
+++ b/pages/product/updateStock/updateStock.vue
@@ -23,9 +23,9 @@
-
+
- 这是大苏打
+ {{item.sku}}
@@ -34,26 +34,12 @@
个
+ v-model="item.stock">个
-
-
- 这是大苏打
-
-
-
-
- 商品库存
-
-
- 个
-
-
-
-
+
+