去除被子选项
This commit is contained in:
parent
064be93e1b
commit
e2cf0a4711
|
@ -15,8 +15,8 @@ Page({
|
|||
goodName: options.goodName,
|
||||
goodPrice: options.goodPrice,
|
||||
goodDetail: options.goodDetail,
|
||||
goodImage: decodeURIComponent(options.goodImage).split(','),
|
||||
};
|
||||
goodImage: decodeURIComponent(options.goodImage).split(","),
|
||||
}
|
||||
const specList = [
|
||||
{
|
||||
specId: 2,
|
||||
|
@ -31,87 +31,91 @@ Page({
|
|||
]
|
||||
}
|
||||
];
|
||||
this.setData({ goods, specList, viewGood: goods.goodImage[0] });
|
||||
this.setData({ goods, specList, viewGood: goods.goodImage[0] })
|
||||
},
|
||||
|
||||
openPopup() {
|
||||
this.setData({ showPopup: true });
|
||||
this.setData({ showPopup: true })
|
||||
},
|
||||
|
||||
handlePopupHide() {
|
||||
this.setData({ showPopup: false });
|
||||
this.setData({ showPopup: false })
|
||||
},
|
||||
|
||||
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 === "普通蓬松枕") {
|
||||
updatedPrice = 220; // 设置为220
|
||||
updatedPrice = 220 // 设置为220
|
||||
}
|
||||
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) {
|
||||
spec.specValueList = spec.specValueList.map(item => {
|
||||
item.isSelected = item.specValueId == id;
|
||||
return item;
|
||||
});
|
||||
spec.specValueList = spec.specValueList.map((item) => {
|
||||
item.isSelected = item.specValueId == id
|
||||
return item
|
||||
})
|
||||
}
|
||||
return spec;
|
||||
});
|
||||
return spec
|
||||
})
|
||||
|
||||
this.setData({
|
||||
specList,
|
||||
viewGood: e.currentTarget.dataset.goodimage,
|
||||
'goods.goodPrice': updatedPrice // 更新价格
|
||||
});
|
||||
this.updateSelectedSpecs();
|
||||
"goods.goodPrice": updatedPrice, // 更新价格
|
||||
})
|
||||
this.updateSelectedSpecs()
|
||||
},
|
||||
goToHome() {
|
||||
wx.switchTab({
|
||||
url: '/page/component/index' // 使用switchTab跳转到首页(tabbar页面)
|
||||
});
|
||||
url: "/page/component/index", // 使用switchTab跳转到首页(tabbar页面)
|
||||
})
|
||||
},
|
||||
updateSelectedSpecs() {
|
||||
const selectedSpecs = this.data.specList.map(spec => {
|
||||
const selectedItem = spec.specValueList.find(item => item.isSelected);
|
||||
return selectedItem ? selectedItem.specValue : null;
|
||||
}).filter(item => item);
|
||||
this.setData({ selectedSpecs });
|
||||
const selectedSpecs = this.data.specList
|
||||
.map((spec) => {
|
||||
const selectedItem = spec.specValueList.find((item) => item.isSelected)
|
||||
return selectedItem ? selectedItem.specValue : null
|
||||
})
|
||||
.filter((item) => item)
|
||||
this.setData({ selectedSpecs })
|
||||
},
|
||||
|
||||
handleBuyNumChange(e) {
|
||||
this.setData({
|
||||
buyNum: e.detail.value
|
||||
});
|
||||
buyNum: e.detail.value,
|
||||
})
|
||||
},
|
||||
|
||||
confirmSpecs() {
|
||||
console.log(this.data.selectedSpecs)
|
||||
if (this.data.selectedSpecs.length < this.data.specList.length) {
|
||||
wx.showToast({
|
||||
title: '请选择所有规格',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
// if (this.data.selectedSpecs.length < this.data.specList.length) {
|
||||
// wx.showToast({
|
||||
// title: "请选择所有规格",
|
||||
// icon: "none",
|
||||
// })
|
||||
// return
|
||||
// }
|
||||
|
||||
this.setData({ showPopup: false });
|
||||
this.setData({ showPopup: false })
|
||||
|
||||
// wx.getUserProfile({
|
||||
// desc: '用于完善会员资料',
|
||||
// success: (res) => {
|
||||
// this.setData({ userInfo: res.userInfo });
|
||||
|
||||
const { id, goodName, goodImage, goodPrice } = this.data.goods;
|
||||
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 { id, goodName, goodImage, goodPrice } = this.data.goods
|
||||
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(",")}`
|
||||
|
||||
wx.navigateTo({ url });
|
||||
wx.navigateTo({ url })
|
||||
// },
|
||||
// fail: (err) => {
|
||||
// wx.showToast({
|
||||
|
@ -120,5 +124,5 @@ Page({
|
|||
// });
|
||||
// }
|
||||
// });
|
||||
}
|
||||
});
|
||||
},
|
||||
})
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
</view>
|
||||
<view class="popup-sku-body">
|
||||
<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__title">{{item.title}}</view>
|
||||
<view class="popup-sku-row__item-container">
|
||||
|
@ -66,7 +66,7 @@
|
|||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="popup-sku-stepper-stock">
|
||||
<view class="popup-sku-stepper-container">
|
||||
<view class="popup-sku__stepper-title">购买数量</view>
|
||||
|
|
|
@ -79,7 +79,7 @@ Page({
|
|||
success: (res) => {
|
||||
const wxConfig = {
|
||||
appid: "wx865aefa5a7115ae0",
|
||||
secret: "df0817d59696a6160de2770222d8ec53",
|
||||
secret: "4f883606afdbca0599b732753856b5b5",
|
||||
code: res.code
|
||||
}
|
||||
console.log("code: " + res.code)
|
||||
|
|
|
@ -53,14 +53,14 @@ Page({
|
|||
console.log("code:" + res.code)
|
||||
const wxConfig = {
|
||||
appid: "wx865aefa5a7115ae0",
|
||||
secret: "3f9849429894435abc935eea88178dfd",
|
||||
secret: "4f883606afdbca0599b732753856b5b5",
|
||||
code: res.code
|
||||
}
|
||||
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',
|
||||
success: (res) => {
|
||||
wx.setStorageSync('openid', res.data.openid);
|
||||
console.log(res);
|
||||
console.log("res",res);
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('wx.login 失败', err);
|
||||
|
|
Loading…
Reference in New Issue