diff --git a/api/store.js b/api/store.js
index cc981d5..55a6e35 100644
--- a/api/store.js
+++ b/api/store.js
@@ -25,6 +25,15 @@ export function getProductDetail(id, data) {
});
}
+/*
+ * 商品规格选中
+ * */
+export function getProductSkuBySelected(id, data) {
+ return request.get("api/product/getSkuBySelected/" + id, data, {
+ login: true
+ });
+}
+
/*
* 商品分销二维码
* */
diff --git a/components/ProductWindow.vue b/components/ProductWindow.vue
index 7726c75..a4b50ef 100644
--- a/components/ProductWindow.vue
+++ b/components/ProductWindow.vue
@@ -19,21 +19,25 @@
-
+
{{ item.attrName }}
- {{ itemn.attr }}
- 缺货
+ {{ subItem.attr }}
+ 缺货
@@ -88,56 +92,42 @@ export default {
}
},
methods: {
- previewImg:function(imgUrl){
+ previewImg(imgUrl) {
uni.previewImage({
urls:[imgUrl]
})
},
- closeAttr: function() {
+ closeAttr() {
this.$emit("changeFun", { action: "changeattr", value: false })
},
- CartNumDes: function() {
+ CartNumDes() {
this.$emit("changeFun", { action: "ChangeCartNum", value: false })
},
- CartNumAdd: function() {
+ CartNumAdd() {
this.$emit("changeFun", { action: "ChangeCartNum", value: 1 })
},
- getAttrItemData(attr) {
- let result = {
- stock: 0
- }
- if (this.attr.productAttr.length === 1) {
- this.productValueArr.map(item => {
- if (item.attrItemkey === attr) {
- result = item
- }
- })
- } else {
- result.stock = 1
- }
- return result
- },
- tapAttr: function(indexw, indexn, itemn) {
- if (this.getAttrItemData(itemn.attr).stock === 0) {
+ tapAttr(index, subIndex, subItem) {
+ // 缺货的点击了没效果
+ if (!subItem.canUsed) {
return
}
// 修改商品规格不生效的原因:
// H5端下面写法,attr更新,但是除H5外其他端不支持,
// 尽量避免下面的骚写法,不要在子组件内更新props
// 这里修改是为了能获取到被选中的属性
- this.attr.productAttr[indexw].index = indexn
+ this.attr.productAttr[index].index = subIndex
const value = this.getCheckedValue().sort().join(",")
this.$emit("changeFun", {
action: "ChangeAttr",
value: {
value,
- indexw,
- indexn
+ index,
+ subIndex
}
})
},
// 获取被选中属性
- getCheckedValue: function() {
+ getCheckedValue() {
const productAttr = this.attr.productAttr
const value = []
for (let i = 0; i < productAttr.length; i++) {
diff --git a/pages/shop/GoodsCon/index.vue b/pages/shop/GoodsCon/index.vue
index 5227a94..cda6184 100644
--- a/pages/shop/GoodsCon/index.vue
+++ b/pages/shop/GoodsCon/index.vue
@@ -451,10 +451,11 @@