|
@@ -150,7 +150,7 @@
|
|
|
</view> -->
|
|
</view> -->
|
|
|
|
|
|
|
|
<!-- 规格 -->
|
|
<!-- 规格 -->
|
|
|
- <view class="spec-box">
|
|
|
|
|
|
|
+ <!-- <view class="spec-box">
|
|
|
<view v-for="(item,index) in attrs" :key="index">
|
|
<view v-for="(item,index) in attrs" :key="index">
|
|
|
<view class="title">{{item.attrName}}</view>
|
|
<view class="title">{{item.attrName}}</view>
|
|
|
<view class="spec-list">
|
|
<view class="spec-list">
|
|
@@ -160,6 +160,23 @@
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
+ </view> -->
|
|
|
|
|
+ <view class="spec-box">
|
|
|
|
|
+ <!-- 外层循环:用 item.id 做 key,不要用 index -->
|
|
|
|
|
+ <view v-for="(item,index) in attrs" :key="item.id || index">
|
|
|
|
|
+ <view class="title">{{item.attrName}}</view>
|
|
|
|
|
+ <view class="spec-list">
|
|
|
|
|
+ <!-- 内层循环:必须用 subItem 唯一值,不要用 subindex!! -->
|
|
|
|
|
+ <view
|
|
|
|
|
+ v-for="(subItem,subindex) in item.values"
|
|
|
|
|
+ :key="subItem + '-' + subindex"
|
|
|
|
|
+ :class="subindex == item.index ? 'item active' : 'item'"
|
|
|
|
|
+ @click="choseSpec(index,subindex)"
|
|
|
|
|
+ >
|
|
|
|
|
+ {{ subItem }}
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
</view>
|
|
</view>
|
|
|
<!-- 数量 -->
|
|
<!-- 数量 -->
|
|
|
<view class="price-num">
|
|
<view class="price-num">
|
|
@@ -204,9 +221,10 @@ import {CustomToast} from '@/components/custom-toast.vue';
|
|
|
getUserInfo
|
|
getUserInfo
|
|
|
} from '@/api/user'
|
|
} from '@/api/user'
|
|
|
import {
|
|
import {
|
|
|
- getStoreProductDetail
|
|
|
|
|
- } from '@/api/companyOrder.js'
|
|
|
|
|
|
|
+ getStoreProductDetail
|
|
|
|
|
+ } from '@/api/companyOrder.js'
|
|
|
import {
|
|
import {
|
|
|
|
|
+ getProductDetails,
|
|
|
getCartCount,
|
|
getCartCount,
|
|
|
addCart
|
|
addCart
|
|
|
} from '@/api/product'
|
|
} from '@/api/product'
|
|
@@ -259,13 +277,25 @@ import {CustomToast} from '@/components/custom-toast.vue';
|
|
|
singlePurchaseLimit:null,//商品购买上限
|
|
singlePurchaseLimit:null,//商品购买上限
|
|
|
isSingle:false,
|
|
isSingle:false,
|
|
|
purchaseLimit:0, // 总限购数量
|
|
purchaseLimit:0, // 总限购数量
|
|
|
- courseId:null,
|
|
|
|
|
- companyUserId:null,
|
|
|
|
|
- companyId:null
|
|
|
|
|
|
|
+ courseId:null
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
onLoad(options) {
|
|
onLoad(options) {
|
|
|
- console.log("qxj options:",options);
|
|
|
|
|
|
|
+ console.log("qxj options:" + JSON.stringify(options));
|
|
|
|
|
+ uni.setStorageSync('urlInfo', options);
|
|
|
|
|
+ if (options.userId != null) {
|
|
|
|
|
+ uni.setStorageSync('tuiUserId', options.userId);
|
|
|
|
|
+ } else if (options.hasOwnProperty('q') && options.q) {
|
|
|
|
|
+ // 通过下面这步解码,可以拿到url的值
|
|
|
|
|
+ const url = decodeURIComponent(options.q)
|
|
|
|
|
+ this.url = url;
|
|
|
|
|
+ // // 对url中携带的参数提取处理
|
|
|
|
|
+ const obj = this.utils.urlToObj(url)
|
|
|
|
|
+ uni.setStorageSync('tuiUserId', obj.userId);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(options.courseId){
|
|
|
|
|
+ this.courseId=options.courseId
|
|
|
|
|
+ }
|
|
|
uni.showShareMenu({
|
|
uni.showShareMenu({
|
|
|
withShareTicket: true,
|
|
withShareTicket: true,
|
|
|
//小程序的原生菜单中显示分享按钮,才能够让发送给朋友与分享到朋友圈两个按钮可以点击
|
|
//小程序的原生菜单中显示分享按钮,才能够让发送给朋友与分享到朋友圈两个按钮可以点击
|
|
@@ -275,6 +305,9 @@ import {CustomToast} from '@/components/custom-toast.vue';
|
|
|
this.productId = options.productId;
|
|
this.productId = options.productId;
|
|
|
this.companyUserId= options.companyUserId
|
|
this.companyUserId= options.companyUserId
|
|
|
this.companyId = options.companyId
|
|
this.companyId = options.companyId
|
|
|
|
|
+ // if (this.utils.checkToken()) {
|
|
|
|
|
+ // this.getCartCount();
|
|
|
|
|
+ // }
|
|
|
},
|
|
},
|
|
|
onShow() {
|
|
onShow() {
|
|
|
this.getProductDetails();
|
|
this.getProductDetails();
|
|
@@ -290,7 +323,7 @@ import {CustomToast} from '@/components/custom-toast.vue';
|
|
|
var user = JSON.parse(uni.getStorageSync('userInfo'))
|
|
var user = JSON.parse(uni.getStorageSync('userInfo'))
|
|
|
return {
|
|
return {
|
|
|
title: this.product.productName,
|
|
title: this.product.productName,
|
|
|
- path: '/pages_company/managerOrder/productDetails?productId=' + this.product.productId + "&userId=" + user.userId +"&companyId="+this.companyId+"&companyUserId="+this.companyUserId,
|
|
|
|
|
|
|
+ path: '/pages/shopping/productDetails?productId=' + this.product.productId + "&userId=" + user.userId +"&companyId="+this.companyId+"&companyUserId="+this.companyUserId,
|
|
|
imageUrl: 'https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/app/vip/share.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
|
|
imageUrl: 'https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/app/vip/share.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -305,7 +338,7 @@ import {CustomToast} from '@/components/custom-toast.vue';
|
|
|
imageUrl: 'https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/app/vip/share.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
|
|
imageUrl: 'https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/app/vip/share.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
getuser() {
|
|
getuser() {
|
|
@@ -402,10 +435,10 @@ import {CustomToast} from '@/components/custom-toast.vue';
|
|
|
if (type == "buy") {
|
|
if (type == "buy") {
|
|
|
uni.navigateTo({
|
|
uni.navigateTo({
|
|
|
url: '/pages/shopping/confirmOrder?type=' + this.type + "&cartIds=" + res
|
|
url: '/pages/shopping/confirmOrder?type=' + this.type + "&cartIds=" + res
|
|
|
- .id + "&orderType=" + this.orderType + "&storeId=" + this.storeId +"&companyId="+this.companyId+"&companyUserId="+this.companyUserId
|
|
|
|
|
|
|
+ .id + "&orderType=" + this.orderType + "&storeId=" + this.storeId +"&courseId="+this.courseId
|
|
|
})
|
|
})
|
|
|
} else {
|
|
} else {
|
|
|
- //this.getCartCount()
|
|
|
|
|
|
|
+ this.getCartCount()
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
icon: 'success',
|
|
icon: 'success',
|
|
|
title: "添加成功",
|
|
title: "添加成功",
|
|
@@ -424,7 +457,7 @@ import {CustomToast} from '@/components/custom-toast.vue';
|
|
|
},
|
|
},
|
|
|
getProductDetails() {
|
|
getProductDetails() {
|
|
|
let data = {
|
|
let data = {
|
|
|
- productId:this.productId,
|
|
|
|
|
|
|
+ productId: this.productId,
|
|
|
companyId:this.companyId,
|
|
companyId:this.companyId,
|
|
|
companyUserId:this.companyUserId
|
|
companyUserId:this.companyUserId
|
|
|
};
|
|
};
|
|
@@ -433,7 +466,7 @@ import {CustomToast} from '@/components/custom-toast.vue';
|
|
|
this.loadding = false
|
|
this.loadding = false
|
|
|
if (res.code == 200) {
|
|
if (res.code == 200) {
|
|
|
this.product = res.product;
|
|
this.product = res.product;
|
|
|
- this.remainingPurchaseLimit = res.remainingPurchaseLimit;
|
|
|
|
|
|
|
+ this.remainingPurchaseLimit = res.product.purchaseLimit;
|
|
|
this.singlePurchaseLimit = res.product.singlePurchaseLimit!==0?res.product.singlePurchaseLimit:null
|
|
this.singlePurchaseLimit = res.product.singlePurchaseLimit!==0?res.product.singlePurchaseLimit:null
|
|
|
// 如果接口返回了总限购数量和已购买数量,也保存
|
|
// 如果接口返回了总限购数量和已购买数量,也保存
|
|
|
if (res.product.purchaseLimit !== null) {
|
|
if (res.product.purchaseLimit !== null) {
|
|
@@ -472,11 +505,11 @@ import {CustomToast} from '@/components/custom-toast.vue';
|
|
|
icon: 'none',
|
|
icon: 'none',
|
|
|
title: res.msg,
|
|
title: res.msg,
|
|
|
});
|
|
});
|
|
|
- // setTimeout(function() {
|
|
|
|
|
- // uni.reLaunch({
|
|
|
|
|
- // url: '/pages/home/index',
|
|
|
|
|
- // })
|
|
|
|
|
- // }, 2000)
|
|
|
|
|
|
|
+ setTimeout(function() {
|
|
|
|
|
+ uni.reLaunch({
|
|
|
|
|
+ url: '/pages/home/index',
|
|
|
|
|
+ })
|
|
|
|
|
+ }, 2000)
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
@@ -551,8 +584,8 @@ import {CustomToast} from '@/components/custom-toast.vue';
|
|
|
},
|
|
},
|
|
|
// 规格选择
|
|
// 规格选择
|
|
|
choseSpec(index, subIndex) {
|
|
choseSpec(index, subIndex) {
|
|
|
- this.attrs[index].index = subIndex;
|
|
|
|
|
- this.$forceUpdate();
|
|
|
|
|
|
|
+ //this.attrs[index].index = subIndex;
|
|
|
|
|
+ this.$set(this.attrs[index], 'index', subIndex);
|
|
|
let productAttr = this.attrs;
|
|
let productAttr = this.attrs;
|
|
|
let values = [];
|
|
let values = [];
|
|
|
for (let i = 0; i < productAttr.length; i++) {
|
|
for (let i = 0; i < productAttr.length; i++) {
|
|
@@ -572,7 +605,7 @@ import {CustomToast} from '@/components/custom-toast.vue';
|
|
|
if (valueSelect != null && valueSelect.length > 0) {
|
|
if (valueSelect != null && valueSelect.length > 0) {
|
|
|
this.productValueSelect = valueSelect[0];
|
|
this.productValueSelect = valueSelect[0];
|
|
|
}
|
|
}
|
|
|
- //console.log("qxj productValueSelect:" + JSON.stringify(this.productValueSelect));
|
|
|
|
|
|
|
+ console.log("qxj productValueSelect:" + JSON.stringify(this.productValueSelect));
|
|
|
this.updateSpecNum();
|
|
this.updateSpecNum();
|
|
|
|
|
|
|
|
},
|
|
},
|