...
|
...
|
@@ -4,7 +4,6 @@ import { shouldDiscardTap, getImageUrlWithWH } from '../../utils/util'; |
|
|
|
|
|
//获取应用实例
|
|
|
let app = getApp();
|
|
|
// var Picker = require('../goodsDetail/picker/picker.js')
|
|
|
|
|
|
const screenHeight = app.globalData.systemInfo.screenHeight;
|
|
|
const screenWidth = app.globalData.systemInfo.screenWidth;
|
...
|
...
|
@@ -26,6 +25,7 @@ Page({ |
|
|
current_skn: '',
|
|
|
selectedSKU: '',
|
|
|
//picker 需要的数据
|
|
|
pickerShow: false,
|
|
|
pickerData: {
|
|
|
view: {
|
|
|
isShow: false,
|
...
|
...
|
@@ -64,8 +64,6 @@ Page({ |
|
|
this.setData({ promotion_ids, is_gift, status });
|
|
|
|
|
|
this.queryGiftPageData();
|
|
|
var that = this;
|
|
|
// Picker.init(that);
|
|
|
},
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -120,8 +118,6 @@ Page({ |
|
|
let data = event.currentTarget.dataset;
|
|
|
let product_skn = data.productSkn;
|
|
|
this.setData({ current_skn: product_skn });
|
|
|
// Picker.promotion_id = data.item.promotion_id;
|
|
|
// console.log(product_skn);
|
|
|
let param = {
|
|
|
method: 'app.product.gift',
|
|
|
uid: app.getUid(),
|
...
|
...
|
@@ -199,104 +195,19 @@ Page({ |
|
|
});
|
|
|
|
|
|
// Picker.pickerShow(event, that);
|
|
|
this.setData({pickerShow: true});
|
|
|
})
|
|
|
.catch(error => {
|
|
|
|
|
|
});
|
|
|
},
|
|
|
|
|
|
//点击选择颜色
|
|
|
colorTap: function (event) {
|
|
|
//更新各个颜色的选中状态
|
|
|
var that = this
|
|
|
var tempData = that.data.pickerData;
|
|
|
//先遍历将所有颜色、尺码置为未选中状态
|
|
|
// console.log('color')
|
|
|
// console.log(tempData.view.goodsList)
|
|
|
|
|
|
tempData.view.goodsList && tempData.view.goodsList.map((item, index) => {
|
|
|
item.selected = false
|
|
|
item.size_list.map((subItem, index) => {
|
|
|
subItem.selected = false
|
|
|
subItem.enable = subItem.storage_number > 0 ? true : false
|
|
|
});
|
|
|
});
|
|
|
|
|
|
//将当前颜色置为选中状态
|
|
|
var tempItem = event.target.dataset.key
|
|
|
|
|
|
//遍历颜色尺码,根据库存切换显示状态
|
|
|
tempItem && tempItem.size_list && tempItem.size_list.map((item, index) => {
|
|
|
item.enable = item.storage_number > 0 ? true : false
|
|
|
})
|
|
|
|
|
|
tempItem.selected = true
|
|
|
|
|
|
//重置库存、当前选中sku的值
|
|
|
tempData.storageNumber = 0
|
|
|
tempData.selectedSKU = 0
|
|
|
|
|
|
tempData.view.goodsList[Number(event.target.id)] = tempItem
|
|
|
tempData.view.sizeList = tempItem.size_list
|
|
|
|
|
|
//将购买数量设为初始状态
|
|
|
tempData.view.buyNumber = 1
|
|
|
|
|
|
this.setData({
|
|
|
pickerData: tempData,
|
|
|
});
|
|
|
},
|
|
|
|
|
|
//点击选择尺码
|
|
|
sizeTap: function (event) {
|
|
|
var that = this
|
|
|
var tempData = that.data.pickerData
|
|
|
|
|
|
//现遍历将所有尺码置为未选中状态
|
|
|
tempData.view.sizeList && tempData.view.sizeList.map((item, index) => {
|
|
|
item.selected = false
|
|
|
});
|
|
|
|
|
|
//将当前尺码置为选中状态
|
|
|
var tempItem = event.currentTarget.dataset.key
|
|
|
tempItem.selected = true
|
|
|
tempData.view.sizeList[parseInt(event.currentTarget.id)] = tempItem
|
|
|
|
|
|
//设置数量加减按钮启用状态
|
|
|
tempData.view.buyButtonEnable = true
|
|
|
//将购买数量设为初始状态
|
|
|
tempData.view.buyNumber = 1
|
|
|
// console.log(event)
|
|
|
if (tempItem.storage_number <= 0) {
|
|
|
tt.showToast({
|
|
|
title: '该尺码已经售罄',
|
|
|
icon: 'none',
|
|
|
duration: 1000
|
|
|
});
|
|
|
|
|
|
tempData.view.buyButtonEnable = false
|
|
|
}
|
|
|
this.setData({
|
|
|
pickerData: tempData,
|
|
|
selectedSKU: tempItem.storage_number > 0 ? tempItem.product_sku : 0,
|
|
|
storageNumber: tempItem.storage_number,
|
|
|
});
|
|
|
},
|
|
|
|
|
|
//增加购买数量
|
|
|
bindPlus: function (event) {
|
|
|
|
|
|
},
|
|
|
|
|
|
//减少购买数量
|
|
|
bindMinus: function (event) {
|
|
|
|
|
|
},
|
|
|
|
|
|
pickerTap: function (event) {
|
|
|
if (event.target.id == "picker-bg") {
|
|
|
var that = this
|
|
|
// Picker.pickerHide(event, that);
|
|
|
this.setData({pickerShow: false});
|
|
|
|
|
|
this.resetPickerData();
|
|
|
}
|
|
|
},
|
...
|
...
|
@@ -314,12 +225,12 @@ Page({ |
|
|
|
|
|
// 添加加价购商品到购物车
|
|
|
addShopCart: function (event) {
|
|
|
var that = this
|
|
|
|
|
|
this.setData(event.detail);
|
|
|
|
|
|
let select_sku = that.data.selectedSKU;
|
|
|
let select_skn = that.data.current_skn;
|
|
|
let goods_type = that.data.is_gift ? 1 : 2;
|
|
|
let promotion_id = Picker.promotion_id;
|
|
|
|
|
|
if (!select_sku) {
|
|
|
tt.showToast({
|
...
|
...
|
@@ -331,6 +242,8 @@ Page({ |
|
|
}
|
|
|
|
|
|
// Picker.pickerHide(event, that);
|
|
|
this.setData({pickerShow: false});
|
|
|
|
|
|
that.resetPickerData();
|
|
|
|
|
|
let param = {};
|
...
|
...
|
@@ -373,6 +286,43 @@ Page({ |
|
|
});
|
|
|
},
|
|
|
|
|
|
chooseSizeColorCompleted:function(event){
|
|
|
|
|
|
console.log('====================================');
|
|
|
console.log(event);
|
|
|
console.log('====================================');
|
|
|
|
|
|
|
|
|
this.setData(event.detail);
|
|
|
|
|
|
if (!this.data.selectedSKU) {
|
|
|
this.wetoast.toast({
|
|
|
title: '请选择颜色或尺码',
|
|
|
titleClassName: 'wetoast-title',
|
|
|
duration: 1000
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
},
|
|
|
|
|
|
//点击背景,隐藏picker
|
|
|
showChange:function(){
|
|
|
let pickerShow = !this.data.pickerShow
|
|
|
this.setData({pickerShow});
|
|
|
},
|
|
|
|
|
|
errorToast: function(event) {
|
|
|
console.log('====================================');
|
|
|
console.log(event);
|
|
|
console.log('====================================');
|
|
|
let detail = event.detail;
|
|
|
this.wetoast.toast({
|
|
|
title: detail.title,
|
|
|
titleClassName: detail.titleClassName,
|
|
|
duration: 1000
|
|
|
});
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 查询购物车数据,包括普通购物车和预售购物车
|
|
|
*/
|
...
|
...
|
|