|
@@ -24,6 +24,7 @@ Page({
|
|
|
number: 1,
|
|
|
checkedSpecText: '请选择规格数量',
|
|
|
openAttr: false,
|
|
|
+ openAttrByOrder: false,
|
|
|
noCollectImage: "/static/images/icon_collect.png",
|
|
|
hasCollectImage: "/static/images/icon_collect_checked.png",
|
|
|
collectBackImage: "/static/images/icon_collect.png",
|
|
@@ -32,12 +33,12 @@ Page({
|
|
|
cartNumber: 0,
|
|
|
autoplay: false,
|
|
|
defaultFreight: 0,
|
|
|
- current: 0,//banner当前的index
|
|
|
+ current: 0, //banner当前的index
|
|
|
isPlay: true,
|
|
|
indexNum: 0,
|
|
|
windowWidth: 0,
|
|
|
leftWidth: 0,
|
|
|
- startX:0,
|
|
|
+ startX: 0,
|
|
|
curr_id: '',
|
|
|
videoHiddenName: true,
|
|
|
imgHiddenName: false,
|
|
@@ -46,18 +47,18 @@ Page({
|
|
|
detailContent: '',
|
|
|
storeId: '',
|
|
|
detailStoreId: '',
|
|
|
- promId:'',
|
|
|
+ promId: '',
|
|
|
merchSn: '',
|
|
|
openTicketAttr: false,
|
|
|
- ticketDiscountList:[],
|
|
|
+ ticketDiscountList: [],
|
|
|
detailTicketDiscountList: [],
|
|
|
- discountSize: 9999,//查看全部
|
|
|
- discountDetailSize: 3,//详情查看部分
|
|
|
- campDetailSize: 1,//详情查看部分
|
|
|
+ discountSize: 9999, //查看全部
|
|
|
+ discountDetailSize: 3, //详情查看部分
|
|
|
+ campDetailSize: 1, //详情查看部分
|
|
|
detailStoreCampMinusList: [],
|
|
|
- storeCampMinusList:[]
|
|
|
+ storeCampMinusList: []
|
|
|
},
|
|
|
- onLoad: function (options) {
|
|
|
+ onLoad: function(options) {
|
|
|
// 页面初始化 options为页面跳转所带来的参数
|
|
|
//由渠道推广生成的小程序码带来的参数,格式:商品id&门店id&推广id&用户id
|
|
|
// options.scene = "1181115&20&1&26";
|
|
@@ -84,7 +85,7 @@ Page({
|
|
|
});
|
|
|
if (storeId) {
|
|
|
wx.setStorageSync('storeId', storeId);
|
|
|
- wx.setStorageSync('isShare', 'true');//商品详情是由用户分享进入的
|
|
|
+ wx.setStorageSync('isShare', 'true'); //商品详情是由用户分享进入的
|
|
|
}
|
|
|
} else {
|
|
|
//由列表页、与普通用户分享点进来带来的参数,商品id,门店id;商品id,门店id,分享用户
|
|
@@ -103,26 +104,26 @@ Page({
|
|
|
});
|
|
|
wx.setStorageSync('isShare', 'true');
|
|
|
} else {
|
|
|
- wx.removeStorageSync('isShare');//由列表页、与普通用户分享点进来则清除是否分享缓存
|
|
|
+ wx.removeStorageSync('isShare'); //由列表页、与普通用户分享点进来则清除是否分享缓存
|
|
|
}
|
|
|
}
|
|
|
var that = this;
|
|
|
// 高度自适应
|
|
|
wx.getSystemInfo({
|
|
|
- success: function (res) {
|
|
|
- var clientHeight = res.windowHeight,
|
|
|
- clientWidth = res.windowWidth,
|
|
|
- rpxR = 750 / clientWidth;
|
|
|
- var calc = clientHeight * rpxR - 100;
|
|
|
- // console.log(calc);
|
|
|
- that.setData({
|
|
|
- winHeight: calc,
|
|
|
- windowWidth: res.windowWidth
|
|
|
- });
|
|
|
- }
|
|
|
+ success: function(res) {
|
|
|
+ var clientHeight = res.windowHeight,
|
|
|
+ clientWidth = res.windowWidth,
|
|
|
+ rpxR = 750 / clientWidth;
|
|
|
+ var calc = clientHeight * rpxR - 100;
|
|
|
+ // console.log(calc);
|
|
|
+ that.setData({
|
|
|
+ winHeight: calc,
|
|
|
+ windowWidth: res.windowWidth
|
|
|
+ });
|
|
|
+ }
|
|
|
});
|
|
|
},
|
|
|
- onReady: function () {
|
|
|
+ onReady: function() {
|
|
|
let that = this;
|
|
|
this.videoContext = wx.createVideoContext('myVideo');
|
|
|
// 页面渲染完成
|
|
@@ -149,25 +150,35 @@ Page({
|
|
|
});
|
|
|
},
|
|
|
//小程序里的转义方法
|
|
|
- escape2Html: function (str) {
|
|
|
- var arrEntities = { 'lt': '<', 'gt': '>', 'nbsp': ' ', 'amp': '&', 'quot': '"' };
|
|
|
- return str.replace(/&(lt|gt|nbsp|amp|quot);/ig, function (all, t) { return arrEntities[t]; });
|
|
|
+ escape2Html: function(str) {
|
|
|
+ var arrEntities = {
|
|
|
+ 'lt': '<',
|
|
|
+ 'gt': '>',
|
|
|
+ 'nbsp': ' ',
|
|
|
+ 'amp': '&',
|
|
|
+ 'quot': '"'
|
|
|
+ };
|
|
|
+ return str.replace(/&(lt|gt|nbsp|amp|quot);/ig, function(all, t) {
|
|
|
+ return arrEntities[t];
|
|
|
+ });
|
|
|
},
|
|
|
//调用在需要的地方直接调用即可。如:this.escape2Html(contents)
|
|
|
- getGoodsInfo: function () {
|
|
|
+ getGoodsInfo: function() {
|
|
|
wx.showLoading({
|
|
|
title: '加载中...',
|
|
|
});
|
|
|
- setTimeout(function () {
|
|
|
- }, 350)
|
|
|
+ setTimeout(function() {}, 350)
|
|
|
let that = this;
|
|
|
const regex = new RegExp('<img', 'gi');
|
|
|
console.log('分享的storeId' + wx.getStorageSync('storeId'))
|
|
|
// console.log('promId' + that.data.promId)
|
|
|
util.request(api.GoodsDetail, {
|
|
|
- id: that.data.id, referrer: that.data.referrer,
|
|
|
- merchSn: wx.getStorageSync('merchSn'), storeId: wx.getStorageSync('storeId'), promId: that.data.promId
|
|
|
- }).then(function (res) {
|
|
|
+ id: that.data.id,
|
|
|
+ referrer: that.data.referrer,
|
|
|
+ merchSn: wx.getStorageSync('merchSn'),
|
|
|
+ storeId: wx.getStorageSync('storeId'),
|
|
|
+ promId: that.data.promId
|
|
|
+ }).then(function(res) {
|
|
|
if (res.errno === 0) {
|
|
|
that.setData({
|
|
|
goods: res.data.info,
|
|
@@ -228,14 +239,14 @@ Page({
|
|
|
goods_id: that.data.id,
|
|
|
referrer: that.data.referrer,
|
|
|
send_type: 2
|
|
|
- }).then(function (res) {
|
|
|
+ }).then(function(res) {
|
|
|
|
|
|
});
|
|
|
}
|
|
|
//商品列表图
|
|
|
util.request(api.GoodsGallery, {
|
|
|
goods_id: that.data.id
|
|
|
- }).then(function (res) {
|
|
|
+ }).then(function(res) {
|
|
|
if (res.errno === 0) {
|
|
|
that.setData({
|
|
|
gallery: res.data
|
|
@@ -255,7 +266,7 @@ Page({
|
|
|
// }
|
|
|
// });
|
|
|
// },
|
|
|
- clickSkuValue: function (event) {
|
|
|
+ clickSkuValue: function(event) {
|
|
|
let that = this;
|
|
|
let specNameId = event.currentTarget.dataset.nameId;
|
|
|
let specValueId = event.currentTarget.dataset.valueId;
|
|
@@ -285,14 +296,20 @@ Page({
|
|
|
goodsUtil.changeSpecInfo(that);
|
|
|
},
|
|
|
//购物车增加
|
|
|
- addNumber2: function (e) {
|
|
|
+ addNumber2: function(e) {
|
|
|
let that = this;
|
|
|
var goodsId = e.currentTarget.dataset.goodsId;
|
|
|
var productId = e.currentTarget.dataset.productId;
|
|
|
var hotGoods = that.data.hotGoods;
|
|
|
- util.request(api.CartAdd, { goodsId: goodsId, productId: productId, number: 1 }, 'POST').then(function (res) {
|
|
|
+ util.request(api.CartAdd, {
|
|
|
+ goodsId: goodsId,
|
|
|
+ productId: productId,
|
|
|
+ number: 1
|
|
|
+ }, 'POST').then(function(res) {
|
|
|
if (res.errno === 0 && null != res.data) {
|
|
|
- util.request(api.CartGoodsCount, { storeId: wx.getStorageSync('storeId') }).then(function (res) {
|
|
|
+ util.request(api.CartGoodsCount, {
|
|
|
+ storeId: wx.getStorageSync('storeId')
|
|
|
+ }).then(function(res) {
|
|
|
if (res.errno === 0) {
|
|
|
that.setData({
|
|
|
cartGoodsCount: res.data.cartTotal.goodsCount
|
|
@@ -313,7 +330,7 @@ Page({
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- onShow: function () {
|
|
|
+ onShow: function() {
|
|
|
let that = this;
|
|
|
// 页面显示
|
|
|
if (wx.getStorageSync('userInfo') || wx.getStorageSync('token')) {
|
|
@@ -321,14 +338,16 @@ Page({
|
|
|
util.request(api.ChooseStoreId, {
|
|
|
storeId: wx.getStorageSync('storeId'),
|
|
|
merchSn: wx.getStorageSync('merchSn')
|
|
|
- }, 'POST').then(function (res) {
|
|
|
+ }, 'POST').then(function(res) {
|
|
|
if (res.errno === 0) {
|
|
|
wx.setStorageSync('storeId', wx.getStorageSync('storeId'));
|
|
|
wx.setStorageSync('merchSn', wx.getStorageSync('merchSn'));
|
|
|
that.reLoad();
|
|
|
|
|
|
that.getGoodsInfo();
|
|
|
- util.request(api.CartGoodsCount, { storeId: wx.getStorageSync('storeId') }).then(function (res) {
|
|
|
+ util.request(api.CartGoodsCount, {
|
|
|
+ storeId: wx.getStorageSync('storeId')
|
|
|
+ }).then(function(res) {
|
|
|
if (res.errno === 0) {
|
|
|
that.setData({
|
|
|
cartGoodsCount: res.data.cartTotal.goodsCount
|
|
@@ -344,17 +363,18 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- onHide: function () {
|
|
|
+ onHide: function() {
|
|
|
// 页面隐藏
|
|
|
|
|
|
},
|
|
|
- onUnload: function () {
|
|
|
+ onUnload: function() {
|
|
|
// 页面关闭
|
|
|
|
|
|
},
|
|
|
- switchAttrPop: function () {
|
|
|
+ switchAttrPop: function() {
|
|
|
this.setData({
|
|
|
openAttr: !this.data.openAttr,
|
|
|
+ openAttrByOrder: false,
|
|
|
openTicketAttr: false,
|
|
|
openCampMinusAttr: false
|
|
|
})
|
|
@@ -362,44 +382,58 @@ Page({
|
|
|
hideSwitchAttrPop: function() {
|
|
|
this.setData({
|
|
|
openAttr: false,
|
|
|
+ openAttrByOrder: false,
|
|
|
+ openTicketAttr: false,
|
|
|
+ openCampMinusAttr: false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ switchAttrPopByOrder: function () {
|
|
|
+ this.setData({
|
|
|
+ openAttr: false,
|
|
|
+ openAttrByOrder: !this.data.openAttrByOrder,
|
|
|
openTicketAttr: false,
|
|
|
openCampMinusAttr: false
|
|
|
})
|
|
|
},
|
|
|
- reLoad: function () {
|
|
|
+ reLoad: function() {
|
|
|
let that = this;
|
|
|
if (wx.getStorageSync('storeId')) {
|
|
|
if (wx.getStorageSync('userId')) {
|
|
|
wx.request({
|
|
|
url: api.updateLoginUser,
|
|
|
data: {
|
|
|
- userId: wx.getStorageSync('userId'), storeId: wx.getStorageSync('storeId'), merchSn: wx.getStorageSync('merchSn')
|
|
|
+ userId: wx.getStorageSync('userId'),
|
|
|
+ storeId: wx.getStorageSync('storeId'),
|
|
|
+ merchSn: wx.getStorageSync('merchSn')
|
|
|
},
|
|
|
method: 'POST',
|
|
|
header: {
|
|
|
'Content-Type': 'application/json'
|
|
|
},
|
|
|
- success: function (wxRes) {
|
|
|
+ success: function(wxRes) {
|
|
|
if (wxRes.data.errno === 0) {
|
|
|
// console.log("用户信息更新成功");
|
|
|
}
|
|
|
},
|
|
|
- fail: function (err) {
|
|
|
+ fail: function(err) {
|
|
|
console.log("failed");
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- changeProperty: function (e) {
|
|
|
+ changeProperty: function(e) {
|
|
|
var propertyName = e.currentTarget.dataset.propertyName;
|
|
|
console.log(propertyName);
|
|
|
},
|
|
|
- closeAttrOrCollect: function () {
|
|
|
+ closeAttrOrCollect: function() {
|
|
|
let that = this;
|
|
|
//添加或是取消收藏
|
|
|
- util.request(api.CollectAddOrDelete, { typeId: 0, valueId: this.data.id }, "POST")
|
|
|
- .then(function (res) {
|
|
|
+ util.request(api.CollectAddOrDelete, {
|
|
|
+ typeId: 0,
|
|
|
+ valueId: this.data.id
|
|
|
+ }, "POST")
|
|
|
+ .then(function(res) {
|
|
|
let _res = res;
|
|
|
if (_res.errno == 0) {
|
|
|
if (_res.data.type == 'add') {
|
|
@@ -430,17 +464,19 @@ Page({
|
|
|
|
|
|
});
|
|
|
},
|
|
|
- openCartPage: function () {
|
|
|
+ openCartPage: function() {
|
|
|
wx.switchTab({
|
|
|
url: '/pages/cart/cart',
|
|
|
});
|
|
|
},
|
|
|
- addToCart: function () {
|
|
|
+ addToCart: function() {
|
|
|
var that = this;
|
|
|
if (this.data.openAttr == false) {
|
|
|
//打开规格选择窗口
|
|
|
this.setData({
|
|
|
- openAttr: !this.data.openAttr
|
|
|
+ openAttr: !this.data.openAttr,
|
|
|
+ openAttrByOrder: false,
|
|
|
+ number: 1
|
|
|
});
|
|
|
} else {
|
|
|
//提示选择完整规格
|
|
@@ -448,15 +484,23 @@ Page({
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if (that.data.number + that.data.cartNumber > that.data.stockNum){
|
|
|
+ if (that.data.number + that.data.cartNumber > that.data.stockNum) {
|
|
|
// wx.showToast({
|
|
|
// title: '库存不足',
|
|
|
// mask: true
|
|
|
// });
|
|
|
- util.showErrorToast('库存不足');
|
|
|
+ if (that.data.cartNumber == that.data.stockNum){
|
|
|
+ wx.showToast({
|
|
|
+ title: '不能再加了,购物车中已加入库存' + that.data.cartNumber + '个',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ util.showErrorToast('库存不足');
|
|
|
+ }
|
|
|
+ // util.showErrorToast('库存不足');
|
|
|
//找不到对应的product信息,提示没有库存
|
|
|
return false;
|
|
|
- }
|
|
|
+ }
|
|
|
// console.log(that.data.productList)
|
|
|
// //根据选中的规格,判断是否有对应的sku信息
|
|
|
let checkedProduct = goodsUtil.getCheckedProductItem(goodsUtil.getCheckedSpecKey(that), that);
|
|
@@ -477,12 +521,12 @@ Page({
|
|
|
|
|
|
//添加到购物车
|
|
|
util.request(api.CartAdd, {
|
|
|
- goodsId: this.data.goods.id,
|
|
|
- number: this.data.number,
|
|
|
- productId: checkedProduct[0].id,
|
|
|
- promId: that.data.promId
|
|
|
- }, "POST")
|
|
|
- .then(function (res) {
|
|
|
+ goodsId: this.data.goods.id,
|
|
|
+ number: this.data.number,
|
|
|
+ productId: checkedProduct[0].id,
|
|
|
+ promId: that.data.promId
|
|
|
+ }, "POST")
|
|
|
+ .then(function(res) {
|
|
|
let _res = res;
|
|
|
if (_res.errno == 0) {
|
|
|
wx.showToast({
|
|
@@ -490,6 +534,7 @@ Page({
|
|
|
});
|
|
|
that.setData({
|
|
|
openAttr: !that.data.openAttr,
|
|
|
+ openAttrByOrder: false,
|
|
|
cartGoodsCount: _res.data.cartTotal.goodsCount
|
|
|
});
|
|
|
if (that.data.userHasCollect == 1) {
|
|
@@ -515,17 +560,17 @@ Page({
|
|
|
|
|
|
}
|
|
|
},
|
|
|
- cutNumber: function () {
|
|
|
+ cutNumber: function() {
|
|
|
this.setData({
|
|
|
number: (this.data.number - 1 > 1) ? this.data.number - 1 : 1
|
|
|
});
|
|
|
},
|
|
|
- addNumber: function () {
|
|
|
+ addNumber: function() {
|
|
|
this.setData({
|
|
|
number: this.data.number + 1
|
|
|
});
|
|
|
},
|
|
|
- onShareAppMessage: function () {
|
|
|
+ onShareAppMessage: function() {
|
|
|
var that = this;
|
|
|
// console.log("url:" + that.data.goods.list_pic_url);
|
|
|
var userId = wx.getStorageSync('userId');
|
|
@@ -533,15 +578,15 @@ Page({
|
|
|
console.log("detailStoreId:" + that.data.detailStoreId);
|
|
|
console.log("merchSn:" + that.data.merchSn);
|
|
|
console.log("promId:" + that.data.promId);
|
|
|
-
|
|
|
+
|
|
|
var requestUrl = "";
|
|
|
if (that.data.promId) {
|
|
|
- requestUrl = '/pages/goods/goods?scene='+that.data.id+'&'+that.data.detailStoreId+'&'+ that.data.promId
|
|
|
- + '&' + wx.getStorageSync('userId');
|
|
|
+ requestUrl = '/pages/goods/goods?scene=' + that.data.id + '&' + that.data.detailStoreId + '&' + that.data.promId +
|
|
|
+ '&' + wx.getStorageSync('userId');
|
|
|
} else {
|
|
|
- requestUrl = '/pages/goods/goods?id=' + that.data.id + '&&referrer=' + wx.getStorageSync('userId')
|
|
|
- + '&&storeId=' + that.data.detailStoreId
|
|
|
- + '&&merchSn=' + that.data.merchSn;
|
|
|
+ requestUrl = '/pages/goods/goods?id=' + that.data.id + '&&referrer=' + wx.getStorageSync('userId') +
|
|
|
+ '&&storeId=' + that.data.detailStoreId +
|
|
|
+ '&&merchSn=' + that.data.merchSn;
|
|
|
}
|
|
|
// console.log("requestUrl:" + requestUrl);
|
|
|
return {
|
|
@@ -549,10 +594,10 @@ Page({
|
|
|
desc: null != that.data.goods.name ? that.data.goods.name : "商品详情",
|
|
|
imageUrl: that.data.goods.list_pic_url,
|
|
|
path: requestUrl,
|
|
|
- success: function (res) {
|
|
|
+ success: function(res) {
|
|
|
// console.log("转发成功");
|
|
|
- console.log("转发成功12:"+that.data.promId);
|
|
|
- if (that.data.promId){
|
|
|
+ console.log("转发成功12:" + that.data.promId);
|
|
|
+ if (that.data.promId) {
|
|
|
//转发成功记录推广信息转发次数
|
|
|
wx.request({
|
|
|
url: api.GoodsSaveTransNum,
|
|
@@ -562,31 +607,39 @@ Page({
|
|
|
promId: that.data.promId
|
|
|
},
|
|
|
method: 'POST',
|
|
|
- header: { 'Content-Type': 'application/json' },
|
|
|
- success: function (wxRes) {
|
|
|
+ header: {
|
|
|
+ 'Content-Type': 'application/json'
|
|
|
+ },
|
|
|
+ success: function(wxRes) {
|
|
|
console.log("转发成功");
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
- fail: function (res) {
|
|
|
+ fail: function(res) {
|
|
|
console.log("转发失败");
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
//购物车增加
|
|
|
- addCrashNumber: function (e) {
|
|
|
+ addCrashNumber: function(e) {
|
|
|
let that = this;
|
|
|
var goodsId = e.currentTarget.dataset.goodsId;
|
|
|
var productId = e.currentTarget.dataset.productId;
|
|
|
- util.request(api.CartAdd, { goodsId: goodsId, productId: productId, number: 1 }, 'POST').then(function (res) {
|
|
|
+ util.request(api.CartAdd, {
|
|
|
+ goodsId: goodsId,
|
|
|
+ productId: productId,
|
|
|
+ number: 1
|
|
|
+ }, 'POST').then(function(res) {
|
|
|
if (res.errno === 0 && null != res.data) {
|
|
|
var hotGoods = that.data.hotGoods;
|
|
|
- hotGoods.forEach(function (val, index, arr) {
|
|
|
+ hotGoods.forEach(function(val, index, arr) {
|
|
|
if (val.id == goodsId) {
|
|
|
val.cart_num = res.data;
|
|
|
hotGoods[index] = val;
|
|
|
- that.setData({ hotGoods: hotGoods });
|
|
|
+ that.setData({
|
|
|
+ hotGoods: hotGoods
|
|
|
+ });
|
|
|
}
|
|
|
}, that);
|
|
|
}
|
|
@@ -665,7 +718,7 @@ Page({
|
|
|
},
|
|
|
//触摸事件start
|
|
|
touchStart2(e) {
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
touchEnd2(e) {
|
|
|
this.setData({
|
|
@@ -675,9 +728,13 @@ Page({
|
|
|
})
|
|
|
this.videoContext.pause();
|
|
|
},
|
|
|
- getGoodsRelated: function () {
|
|
|
+ getGoodsRelated: function() {
|
|
|
let that = this;
|
|
|
- util.request(api.GoodsRelated, { id: that.data.id, page: that.data.page, size: that.data.size }).then(function (res) {
|
|
|
+ util.request(api.GoodsRelated, {
|
|
|
+ id: that.data.id,
|
|
|
+ page: that.data.page,
|
|
|
+ size: that.data.size
|
|
|
+ }).then(function(res) {
|
|
|
if (res.errno === 0) {
|
|
|
let goodsList = that.data.relatedGoods.concat(res.data.goodsList);
|
|
|
that.setData({
|
|
@@ -697,10 +754,11 @@ Page({
|
|
|
});
|
|
|
that.getGoodsRelated();
|
|
|
},
|
|
|
- switchTicketPop: function () {
|
|
|
+ switchTicketPop: function() {
|
|
|
this.setData({
|
|
|
openTicketAttr: !this.data.openTicketAttr,
|
|
|
openAttr: false,
|
|
|
+ openAttrByOrder: false,
|
|
|
openCampMinusAttr: false
|
|
|
})
|
|
|
if (this.data.openTicketAttr) {
|
|
@@ -725,7 +783,7 @@ Page({
|
|
|
tickDiscId: tickDiscId,
|
|
|
storeTopicId: storeTopicId,
|
|
|
storeId: storeId
|
|
|
- }, 'POST').then(function (res) {
|
|
|
+ }, 'POST').then(function(res) {
|
|
|
if (res.errno === 0) {
|
|
|
wx.showToast({
|
|
|
title: '领取成功'
|
|
@@ -747,11 +805,11 @@ Page({
|
|
|
*/
|
|
|
getTicketDiscountList() {
|
|
|
let that = this;
|
|
|
- util.request(api.DiscountByGoodsIdList, {
|
|
|
- storeId: that.data.storeId,
|
|
|
+ util.request(api.DiscountByGoodsIdList, {
|
|
|
+ storeId: that.data.storeId,
|
|
|
goodsId: that.data.id,
|
|
|
- size: that.data.discountSize
|
|
|
- }).then(function (res) {
|
|
|
+ size: that.data.discountSize
|
|
|
+ }).then(function(res) {
|
|
|
if (res.errno === 0) {
|
|
|
that.setData({
|
|
|
ticketDiscountList: res.data
|
|
@@ -768,7 +826,7 @@ Page({
|
|
|
storeId: that.data.storeId,
|
|
|
goodsId: that.data.id,
|
|
|
size: that.data.discountDetailSize
|
|
|
- }).then(function (res) {
|
|
|
+ }).then(function(res) {
|
|
|
if (res.errno === 0) {
|
|
|
that.setData({
|
|
|
detailTicketDiscountList: res.data
|
|
@@ -785,14 +843,14 @@ Page({
|
|
|
storeId: that.data.storeId,
|
|
|
goodsId: that.data.id,
|
|
|
size: that.data.discountSize
|
|
|
- }).then(function (res) {
|
|
|
+ }).then(function(res) {
|
|
|
if (res.errno === 0) {
|
|
|
that.setData({
|
|
|
storeCampMinusList: res.data
|
|
|
});
|
|
|
let storeCampMinusList = that.data.storeCampMinusList
|
|
|
- for (let i = 0; i < storeCampMinusList.length; i++){
|
|
|
- if (storeCampMinusList[i].campMinusType == '00' && storeCampMinusList[i].minusMode == '00'){
|
|
|
+ for (let i = 0; i < storeCampMinusList.length; i++) {
|
|
|
+ if (storeCampMinusList[i].campMinusType == '00' && storeCampMinusList[i].minusMode == '00') {
|
|
|
that.setData({
|
|
|
minusList0000: true
|
|
|
});
|
|
@@ -824,7 +882,7 @@ Page({
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- });
|
|
|
+ });
|
|
|
},
|
|
|
/**
|
|
|
* 查看满减满折列表,详情页展示
|
|
@@ -835,7 +893,7 @@ Page({
|
|
|
storeId: that.data.storeId,
|
|
|
goodsId: that.data.id,
|
|
|
size: that.data.campDetailSize
|
|
|
- }).then(function (res) {
|
|
|
+ }).then(function(res) {
|
|
|
if (res.errno === 0) {
|
|
|
that.setData({
|
|
|
detailStoreCampMinusList: res.data
|
|
@@ -843,20 +901,22 @@ Page({
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- switchCampMinusPop: function () {
|
|
|
+ switchCampMinusPop: function() {
|
|
|
this.setData({
|
|
|
openCampMinusAttr: !this.data.openCampMinusAttr,
|
|
|
openTicketAttr: false,
|
|
|
+ openAttrByOrder: false,
|
|
|
openAttr: false
|
|
|
})
|
|
|
if (this.data.openCampMinusAttr) {
|
|
|
this.getStoreCampMinusList();
|
|
|
}
|
|
|
},
|
|
|
- hideSwitchCampMinusPop: function () {
|
|
|
+ hideSwitchCampMinusPop: function() {
|
|
|
this.setData({
|
|
|
openCampMinusAttr: false,
|
|
|
openTicketAttr: false,
|
|
|
+ openAttrByOrder: false,
|
|
|
openAttr: false
|
|
|
})
|
|
|
},
|
|
@@ -864,9 +924,66 @@ Page({
|
|
|
var that = this;
|
|
|
let campId = event.currentTarget.dataset.campId;
|
|
|
let campName = event.currentTarget.dataset.campName;
|
|
|
-
|
|
|
+
|
|
|
wx.navigateTo({
|
|
|
url: '../ucenter/campMinus/campMinus?campMinusId=' + campId + '&&storeId=' + that.data.storeId + '&&campName=' + campName + "&&isShare=1"
|
|
|
})
|
|
|
- }
|
|
|
+ },
|
|
|
+ checkoutOrder: function() {
|
|
|
+ //获取已选择的商品
|
|
|
+ let that = this;
|
|
|
+ util.request(api.getCurUser, {
|
|
|
+ userInfo: app.globalData.userInfo
|
|
|
+ }, 'POST').then(function(res) {
|
|
|
+ if (res.errno === 0) {
|
|
|
+ // console.log('that.data.mobile:' + res.data.mobile);
|
|
|
+ if (res.data.mobile == '' || res.data.mobile == null) {
|
|
|
+ wx.showModal({
|
|
|
+ title: '',
|
|
|
+ confirmColor: '#b4282d',
|
|
|
+ showCancel: false,
|
|
|
+ content: '您的手机号码未绑定,请先绑定手机号再进行购买',
|
|
|
+ success: function(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../../pages/auth/newuser/newuser'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ if (that.data.openAttrByOrder == false) {
|
|
|
+ //打开规格选择窗口
|
|
|
+ that.setData({
|
|
|
+ openAttrByOrder: !that.data.openAttrByOrder,
|
|
|
+ openAttr: false,
|
|
|
+ number: 1
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ //提示选择完整规格
|
|
|
+ if (!goodsUtil.isCheckedAllSpec(that)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (that.data.number > that.data.stockNum) {
|
|
|
+ util.showErrorToast('库存不足');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // //根据选中的规格,判断是否有对应的sku信息
|
|
|
+ let checkedProduct = goodsUtil.getCheckedProductItem(goodsUtil.getCheckedSpecKey(that), that);
|
|
|
+ //找不到对应的product信息,提示没有库存
|
|
|
+ if (!checkedProduct || checkedProduct.length <= 0) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '库存不足',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../shopping/checkout/checkout?checkCart=00&&goodsId=' + that.data.id + '&&number=' + that.data.number
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
})
|