|
|
@@ -19,7 +19,9 @@ Page({
|
|
|
nowpage:1,
|
|
|
cartMore:true,
|
|
|
cent:0,
|
|
|
- centlist: []
|
|
|
+ centlist: [],
|
|
|
+ showDialog: false,
|
|
|
+ checkbox:'',
|
|
|
},
|
|
|
handleMovableChange: function(e) {
|
|
|
// this.data.currentX = e.detail.x;
|
|
|
@@ -53,6 +55,9 @@ Page({
|
|
|
submitlock: false,
|
|
|
selectedall: false
|
|
|
});
|
|
|
+ this.setData({submitlock: false});
|
|
|
+ this.setData({selectedall: false});
|
|
|
+ this.getIphoneX()
|
|
|
},
|
|
|
onShow: function () {
|
|
|
// this.getCartListAndSelected();
|
|
|
@@ -98,6 +103,7 @@ Page({
|
|
|
res.data.list[i]['movex'] = 0;
|
|
|
res.data.list[i]['IsBuy'] = false;
|
|
|
res.data.list[i]['count'] = 1;
|
|
|
+ res.data.list[i]['overtype'] = res.data.list[i]['have_size'] ? false:true;
|
|
|
}
|
|
|
that.setData({
|
|
|
cartMore: res.data.list_count > that.data.cartList.length,
|
|
|
@@ -272,16 +278,34 @@ Page({
|
|
|
this.getCartList();
|
|
|
},
|
|
|
itemselected:function(e){
|
|
|
- console.log(this)
|
|
|
- var nowitems = this.data.selectedItems;
|
|
|
- let index = e.currentTarget.dataset.index;
|
|
|
- var bool = this.data.cartList[index].IsBuy;
|
|
|
- console.log('bool',bool)
|
|
|
- this.setData({
|
|
|
- ['cartList[' + index + '].IsBuy']: !bool
|
|
|
- })
|
|
|
-
|
|
|
- this.checkSelected();
|
|
|
+ console.log(this)
|
|
|
+ var nowitems = this.data.selectedItems;
|
|
|
+ let index = e.currentTarget.dataset.index;
|
|
|
+ var bool = this.data.cartList[index].IsBuy;
|
|
|
+ var overtype = this.data.cartList[index].overtype;
|
|
|
+ console.log('bool',bool)
|
|
|
+ if(overtype){
|
|
|
+ if(this.data.cartList[index].is_deliver && (this.data.cartList[index].deliver_state == 1 || this.data.cartList[index].deliver_state == 3)){
|
|
|
+ var txt = this.data.cartList[index].deliver_state == 1 ? '商品正在预售中暂未开放购买~' : '商品已售罄~';
|
|
|
+ wx.showToast({
|
|
|
+ title: txt,
|
|
|
+ icon: 'none',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ this.setData({
|
|
|
+ ['cartList[' + index + '].IsBuy']: !bool
|
|
|
+ })
|
|
|
+
|
|
|
+ this.checkSelected();
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ wx.showToast({
|
|
|
+ title: '商品 '+this.data.cartList[index].name+' 请先选择规格~',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
allSelect:function(){
|
|
|
if(this.data.selectedall){
|
|
|
@@ -295,9 +319,26 @@ Page({
|
|
|
})
|
|
|
}else{
|
|
|
for(var i in this.data.cartList){
|
|
|
- this.setData({
|
|
|
- ['cartList[' + i + '].IsBuy']: true
|
|
|
- })
|
|
|
+ if(this.data.cartList[i].overtype){
|
|
|
+ if(this.data.cartList[i].is_deliver && (this.data.cartList[i].deliver_state == 1 || this.data.cartList[i].deliver_state == 3)){
|
|
|
+ var txt = this.data.cartList[i].deliver_state == 1 ? '商品正在预售中暂未开放购买~' : '商品已售罄~';
|
|
|
+ wx.showToast({
|
|
|
+ title: txt,
|
|
|
+ icon: 'none',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ this.setData({
|
|
|
+ ['cartList[' + i + '].IsBuy']: true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ wx.showToast({
|
|
|
+ title: '商品 '+this.data.cartList[i].name+' 请先选择规格~',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
this.setData({
|
|
|
selectedall: true
|
|
|
@@ -438,5 +479,237 @@ Page({
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/projects/project-detail/project-detail?id=' + id + '&read=1'
|
|
|
})
|
|
|
- }
|
|
|
+ },
|
|
|
+ getIphoneX () {
|
|
|
+ var that = this
|
|
|
+ wx.getSystemInfo({
|
|
|
+ success: function (res) {
|
|
|
+ if (res.model.toLowerCase().indexOf('iphone x') > -1) {
|
|
|
+ that.setData({
|
|
|
+ value: 34
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ selectSize:function(val){
|
|
|
+ var that = this
|
|
|
+ var id = val.currentTarget.dataset.val;
|
|
|
+ var item = val.currentTarget.dataset.item;
|
|
|
+ that.setData({
|
|
|
+ selectProjectid: id,
|
|
|
+ selectProjectItem: item
|
|
|
+ });
|
|
|
+
|
|
|
+ console.log('id',id);
|
|
|
+ that.getProjectDetail();
|
|
|
+ that.getProductSize();
|
|
|
+
|
|
|
+ var animation = wx.createAnimation({
|
|
|
+ duration: 200,
|
|
|
+ timingFunction: "ease-out"
|
|
|
+ })
|
|
|
+ this.animation = animation
|
|
|
+ animation.translateY(500).step()
|
|
|
+ this.setData({
|
|
|
+ animationData: animation.export(),
|
|
|
+ showDialog: true
|
|
|
+ })
|
|
|
+
|
|
|
+ setTimeout(function () {
|
|
|
+ animation.translateY(0).step()
|
|
|
+ this.setData({
|
|
|
+ animationData: animation.export()
|
|
|
+ })
|
|
|
+ }.bind(this), 200)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ getProjectDetail() {
|
|
|
+ var that = this
|
|
|
+ var url = "v1/product/" + that.data.selectProjectid;
|
|
|
+ var params = {}
|
|
|
+ var success = function (val) {
|
|
|
+ var p = val.data.detail
|
|
|
+ that.setData({
|
|
|
+ selectProject: val.data
|
|
|
+ });
|
|
|
+ if(val.data.have_size){
|
|
|
+ // that.getProductSize();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ _request.$get(url, params, success)
|
|
|
+ },
|
|
|
+ getProductSize(){
|
|
|
+ var that = this
|
|
|
+ var url = "v1/product_size/" + that.data.selectProjectid;
|
|
|
+ var params = {}
|
|
|
+ var success = function (val) {
|
|
|
+ let cbox = [];
|
|
|
+ for(let i in val.data){
|
|
|
+ if(i != 'product' && val.data[i]) cbox.push(i);
|
|
|
+ }
|
|
|
+ console.log('cbox',cbox)
|
|
|
+ that.setData({
|
|
|
+ selectProjectSize: val.data,
|
|
|
+ checkbox:cbox
|
|
|
+ });
|
|
|
+ }
|
|
|
+ _request.$get(url, params, success)
|
|
|
+ },
|
|
|
+ hideDialog:function(e){
|
|
|
+ var that = this
|
|
|
+ that.data.showDialog = !that.data.showDialog
|
|
|
+ if (that.data.showDialog) {
|
|
|
+ that.showModal(1)
|
|
|
+ } else {
|
|
|
+ that.hideModal(1)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 显示弹框
|
|
|
+ showModal: function (type) {
|
|
|
+ var animation = wx.createAnimation({
|
|
|
+ duration: 200,
|
|
|
+ timingFunction: "ease-out"
|
|
|
+ })
|
|
|
+ this.animation = animation
|
|
|
+ animation.translateY(500).step()
|
|
|
+ if(type == 1){
|
|
|
+ this.setData({
|
|
|
+ animationData: animation.export(),
|
|
|
+ showDialog: true
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ this.setData({
|
|
|
+ animationData: animation.export(),
|
|
|
+ showCartDialog: true
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ setTimeout(function () {
|
|
|
+ animation.translateY(0).step()
|
|
|
+ this.setData({
|
|
|
+ animationData: animation.export()
|
|
|
+ })
|
|
|
+ }.bind(this), 200)
|
|
|
+ },
|
|
|
+ // 隐藏弹框
|
|
|
+ hideModal: function (type = 1) {
|
|
|
+ var animation = wx.createAnimation({
|
|
|
+ duration: 200,
|
|
|
+ timingFunction: "ease-out"
|
|
|
+ })
|
|
|
+ this.animation = animation
|
|
|
+ animation.translateY(500).step()
|
|
|
+ this.setData({
|
|
|
+ animationData: animation.export(),
|
|
|
+ })
|
|
|
+ setTimeout(function () {
|
|
|
+ animation.translateY(0).step()
|
|
|
+ if(type == 1){
|
|
|
+ this.setData({
|
|
|
+ animationData: animation.export(),
|
|
|
+ showDialog: false
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ this.setData({
|
|
|
+ animationData: animation.export(),
|
|
|
+ showCartDialog: false
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ }.bind(this), 200)
|
|
|
+ },
|
|
|
+ checkSize(event){
|
|
|
+ var type = event.currentTarget.dataset.type;
|
|
|
+ var id = event.currentTarget.dataset.id;
|
|
|
+ var list = event.currentTarget.dataset.list;
|
|
|
+ var tname = event.currentTarget.dataset.tname;
|
|
|
+ var that = this;
|
|
|
+ var tkey = type=='color_list'?'cname':'sname';
|
|
|
+ var reproduct = this.data.selectProjectSize;
|
|
|
+ // console.log('reproduct',reproduct)
|
|
|
+ for(var i in reproduct[type]['attr_values']){
|
|
|
+ // console.log('reproduct[type][i].is_select',reproduct[type]['attr_values'][i].is_select)
|
|
|
+ reproduct[type]['attr_values'][i].is_select = false;
|
|
|
+ if(reproduct[type]['attr_values'][i].id == id) reproduct[type]['attr_values'][i].is_select = true;
|
|
|
+ }
|
|
|
+ // console.log('reproduct',reproduct)
|
|
|
+
|
|
|
+ that.setData({
|
|
|
+ selectProjectSize :reproduct,
|
|
|
+ [type]:id,
|
|
|
+ [tkey]:tname
|
|
|
+ })
|
|
|
+ console.log('that.data[type]',that.data[type])
|
|
|
+ let cflag = true;
|
|
|
+ for(let i in that.data.checkbox){
|
|
|
+ if(that.data[that.data.checkbox[i]] == 0) cflag = false;
|
|
|
+ }
|
|
|
+ if(cflag){
|
|
|
+ that.getProductDetail();
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ getProductDetail () {
|
|
|
+ var that = this;
|
|
|
+ console.log(that.data.size_list);
|
|
|
+ console.log(that.data.color_list);
|
|
|
+ var sizelist = that.data.size_list ? that.data.size_list : 0;
|
|
|
+ var colorlist = that.data.color_list ? that.data.color_list : 0;
|
|
|
+
|
|
|
+ var url = "v1/product_detail/" + that.data.selectProjectid + "/" + sizelist + "/" + colorlist;
|
|
|
+ var params = {}
|
|
|
+ var success = function (val) {
|
|
|
+ console.log('val',val)
|
|
|
+ if(val.data.product){
|
|
|
+ that.setData({
|
|
|
+ canpay:true,
|
|
|
+ selectProject:val.data.product,
|
|
|
+ selectProjectid:val.data.product.id,
|
|
|
+ noproduct:false
|
|
|
+ })
|
|
|
+ that.setData({
|
|
|
+ canpay:true,
|
|
|
+ selectProject:val.data.product,
|
|
|
+ selectProjectid:val.data.product.id,
|
|
|
+ noproduct:false
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ that.setData({
|
|
|
+ canpay:false,
|
|
|
+ noproduct:true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var fail = function(err){
|
|
|
+
|
|
|
+ }
|
|
|
+ _request.$get(url, params, success, fail)
|
|
|
+ },
|
|
|
+ selectType:function(){
|
|
|
+ var that = this;
|
|
|
+ var itemindex = this.data.selectProjectItem;
|
|
|
+ var itemdata = this.data.selectProject;
|
|
|
+ console.log('xuanzzzzz')
|
|
|
+ console.log(this.data.cartList)
|
|
|
+ console.log(this.data.selectProject)
|
|
|
+ console.log(this.data.selectProjectItem)
|
|
|
+ itemdata['count']=1;
|
|
|
+ itemdata['IsBuy']=false;
|
|
|
+ itemdata['movex']=0;
|
|
|
+ itemdata['overtype']=true;
|
|
|
+ that.setData({
|
|
|
+ ['cartList[' + itemindex + ']']:itemdata
|
|
|
+ })
|
|
|
+ that.hideModal(1);
|
|
|
+ },
|
|
|
+ selectTypeno:function(){
|
|
|
+ wx.showToast({
|
|
|
+ title: '选中的规格暂无库存,请选择其他规格~',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ }
|
|
|
})
|