去除被子选项
This commit is contained in:
parent
064be93e1b
commit
e2cf0a4711
|
@ -15,8 +15,8 @@ Page({
|
||||||
goodName: options.goodName,
|
goodName: options.goodName,
|
||||||
goodPrice: options.goodPrice,
|
goodPrice: options.goodPrice,
|
||||||
goodDetail: options.goodDetail,
|
goodDetail: options.goodDetail,
|
||||||
goodImage: decodeURIComponent(options.goodImage).split(','),
|
goodImage: decodeURIComponent(options.goodImage).split(","),
|
||||||
};
|
}
|
||||||
const specList = [
|
const specList = [
|
||||||
{
|
{
|
||||||
specId: 2,
|
specId: 2,
|
||||||
|
@ -31,87 +31,91 @@ Page({
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
this.setData({ goods, specList, viewGood: goods.goodImage[0] });
|
this.setData({ goods, specList, viewGood: goods.goodImage[0] })
|
||||||
},
|
},
|
||||||
|
|
||||||
openPopup() {
|
openPopup() {
|
||||||
this.setData({ showPopup: true });
|
this.setData({ showPopup: true })
|
||||||
},
|
},
|
||||||
|
|
||||||
handlePopupHide() {
|
handlePopupHide() {
|
||||||
this.setData({ showPopup: false });
|
this.setData({ showPopup: false })
|
||||||
},
|
},
|
||||||
|
|
||||||
selectSpec(e) {
|
selectSpec(e) {
|
||||||
const { specid, id, val } = e.currentTarget.dataset;
|
const { specid, id, val } = e.currentTarget.dataset
|
||||||
|
|
||||||
// 动态更改价格
|
// 动态更改价格
|
||||||
let updatedPrice = this.data.goods.goodPrice;
|
let updatedPrice = this.data.goods.goodPrice
|
||||||
if (val === "普通蓬松枕") {
|
if (val === "普通蓬松枕") {
|
||||||
updatedPrice = 220; // 设置为220
|
updatedPrice = 220 // 设置为220
|
||||||
}
|
}
|
||||||
if (val === "压缩高级枕") {
|
if (val === "压缩高级枕") {
|
||||||
updatedPrice = 240; // 设置为240
|
updatedPrice = 240 // 设置为240
|
||||||
}
|
}
|
||||||
|
|
||||||
let specList = this.data.specList.map(spec => {
|
let specList = this.data.specList.map((spec) => {
|
||||||
if (spec.specId === specid) {
|
if (spec.specId === specid) {
|
||||||
spec.specValueList = spec.specValueList.map(item => {
|
spec.specValueList = spec.specValueList.map((item) => {
|
||||||
item.isSelected = item.specValueId == id;
|
item.isSelected = item.specValueId == id
|
||||||
return item;
|
return item
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
return spec;
|
return spec
|
||||||
});
|
})
|
||||||
|
|
||||||
this.setData({
|
this.setData({
|
||||||
specList,
|
specList,
|
||||||
viewGood: e.currentTarget.dataset.goodimage,
|
viewGood: e.currentTarget.dataset.goodimage,
|
||||||
'goods.goodPrice': updatedPrice // 更新价格
|
"goods.goodPrice": updatedPrice, // 更新价格
|
||||||
});
|
})
|
||||||
this.updateSelectedSpecs();
|
this.updateSelectedSpecs()
|
||||||
},
|
},
|
||||||
goToHome() {
|
goToHome() {
|
||||||
wx.switchTab({
|
wx.switchTab({
|
||||||
url: '/page/component/index' // 使用switchTab跳转到首页(tabbar页面)
|
url: "/page/component/index", // 使用switchTab跳转到首页(tabbar页面)
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
updateSelectedSpecs() {
|
updateSelectedSpecs() {
|
||||||
const selectedSpecs = this.data.specList.map(spec => {
|
const selectedSpecs = this.data.specList
|
||||||
const selectedItem = spec.specValueList.find(item => item.isSelected);
|
.map((spec) => {
|
||||||
return selectedItem ? selectedItem.specValue : null;
|
const selectedItem = spec.specValueList.find((item) => item.isSelected)
|
||||||
}).filter(item => item);
|
return selectedItem ? selectedItem.specValue : null
|
||||||
this.setData({ selectedSpecs });
|
})
|
||||||
|
.filter((item) => item)
|
||||||
|
this.setData({ selectedSpecs })
|
||||||
},
|
},
|
||||||
|
|
||||||
handleBuyNumChange(e) {
|
handleBuyNumChange(e) {
|
||||||
this.setData({
|
this.setData({
|
||||||
buyNum: e.detail.value
|
buyNum: e.detail.value,
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
confirmSpecs() {
|
confirmSpecs() {
|
||||||
console.log(this.data.selectedSpecs)
|
console.log(this.data.selectedSpecs)
|
||||||
if (this.data.selectedSpecs.length < this.data.specList.length) {
|
// if (this.data.selectedSpecs.length < this.data.specList.length) {
|
||||||
wx.showToast({
|
// wx.showToast({
|
||||||
title: '请选择所有规格',
|
// title: "请选择所有规格",
|
||||||
icon: 'none'
|
// icon: "none",
|
||||||
});
|
// })
|
||||||
return;
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
this.setData({ showPopup: false });
|
this.setData({ showPopup: false })
|
||||||
|
|
||||||
// wx.getUserProfile({
|
// wx.getUserProfile({
|
||||||
// desc: '用于完善会员资料',
|
// desc: '用于完善会员资料',
|
||||||
// success: (res) => {
|
// success: (res) => {
|
||||||
// this.setData({ userInfo: res.userInfo });
|
// this.setData({ userInfo: res.userInfo });
|
||||||
|
|
||||||
const { id, goodName, goodImage, goodPrice } = this.data.goods;
|
const { id, goodName, goodImage, goodPrice } = this.data.goods
|
||||||
const num = this.data.buyNum;
|
const num = this.data.buyNum
|
||||||
const url = `../orders/orders?goodsId=${id}&title=${goodName}&image=${goodImage[0]}&price=${goodPrice}&num=${num}&specs=${this.data.selectedSpecs.join(',')}`;
|
const url = `../orders/orders?goodsId=${id}&title=${goodName}&image=${
|
||||||
|
goodImage[0]
|
||||||
|
}&price=${goodPrice}&num=${num}&specs=${this.data.selectedSpecs.join(",")}`
|
||||||
|
|
||||||
wx.navigateTo({ url });
|
wx.navigateTo({ url })
|
||||||
// },
|
// },
|
||||||
// fail: (err) => {
|
// fail: (err) => {
|
||||||
// wx.showToast({
|
// wx.showToast({
|
||||||
|
@ -120,5 +124,5 @@ Page({
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
}
|
},
|
||||||
});
|
})
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
</view>
|
</view>
|
||||||
<view class="popup-sku-body">
|
<view class="popup-sku-body">
|
||||||
<view class="goods-size">默认统一被褥1.5m*2.0m</view>
|
<view class="goods-size">默认统一被褥1.5m*2.0m</view>
|
||||||
<view class="popup-sku-group-container">
|
<!-- <view class="popup-sku-group-container">
|
||||||
<view class="popup-sku-row" wx:for="{{specList}}" wx:key="specId">
|
<view class="popup-sku-row" wx:for="{{specList}}" wx:key="specId">
|
||||||
<view class="popup-sku-row__title">{{item.title}}</view>
|
<view class="popup-sku-row__title">{{item.title}}</view>
|
||||||
<view class="popup-sku-row__item-container">
|
<view class="popup-sku-row__item-container">
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
</block>
|
</block>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view> -->
|
||||||
<view class="popup-sku-stepper-stock">
|
<view class="popup-sku-stepper-stock">
|
||||||
<view class="popup-sku-stepper-container">
|
<view class="popup-sku-stepper-container">
|
||||||
<view class="popup-sku__stepper-title">购买数量</view>
|
<view class="popup-sku__stepper-title">购买数量</view>
|
||||||
|
|
|
@ -79,7 +79,7 @@ Page({
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
const wxConfig = {
|
const wxConfig = {
|
||||||
appid: "wx865aefa5a7115ae0",
|
appid: "wx865aefa5a7115ae0",
|
||||||
secret: "df0817d59696a6160de2770222d8ec53",
|
secret: "4f883606afdbca0599b732753856b5b5",
|
||||||
code: res.code
|
code: res.code
|
||||||
}
|
}
|
||||||
console.log("code: " + res.code)
|
console.log("code: " + res.code)
|
||||||
|
|
|
@ -53,14 +53,14 @@ Page({
|
||||||
console.log("code:" + res.code)
|
console.log("code:" + res.code)
|
||||||
const wxConfig = {
|
const wxConfig = {
|
||||||
appid: "wx865aefa5a7115ae0",
|
appid: "wx865aefa5a7115ae0",
|
||||||
secret: "3f9849429894435abc935eea88178dfd",
|
secret: "4f883606afdbca0599b732753856b5b5",
|
||||||
code: res.code
|
code: res.code
|
||||||
}
|
}
|
||||||
wx.request({
|
wx.request({
|
||||||
url: "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfig.appid + "&secret=" + wxConfig.secret + "&code=" + wxConfig.code + "&js_code=" + wxConfig.code + '&grant_type=authorization_code',
|
url: "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfig.appid + "&secret=" + wxConfig.secret + "&code=" + wxConfig.code + "&js_code=" + wxConfig.code + '&grant_type=authorization_code',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
wx.setStorageSync('openid', res.data.openid);
|
wx.setStorageSync('openid', res.data.openid);
|
||||||
console.log(res);
|
console.log("res",res);
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
console.error('wx.login 失败', err);
|
console.error('wx.login 失败', err);
|
||||||
|
|
Loading…
Reference in New Issue