|
|
@@ -37,7 +37,11 @@ Page({
|
|
|
// msecond: '00',
|
|
|
clock: '',
|
|
|
todaysend: Date.parse(new Date()) / 1000,
|
|
|
- showpay: true
|
|
|
+ showpay: true,
|
|
|
+ productSize:'',//产品规格
|
|
|
+ size_list:0,
|
|
|
+ color_list:0,
|
|
|
+ canpay:true
|
|
|
},
|
|
|
onLoad: function (options) {
|
|
|
this.data.productId = options.id;
|
|
|
@@ -147,9 +151,45 @@ Page({
|
|
|
if (val.data.seckill_state == 'seckill') {
|
|
|
that.starttime()
|
|
|
}
|
|
|
+
|
|
|
+ if(val.data.have_size){
|
|
|
+ that.getProductSize();
|
|
|
+ }
|
|
|
}
|
|
|
_request.$get(url, params, success)
|
|
|
},
|
|
|
+ getProductSize(){
|
|
|
+ var that = this
|
|
|
+ var url = "v1/product_size/" + that.data.productId;
|
|
|
+ var params = {}
|
|
|
+ var success = function (val) {
|
|
|
+ that.setData({
|
|
|
+ productSize: val.data,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ _request.$get(url, params, success)
|
|
|
+ },
|
|
|
+ getProductDetail () {
|
|
|
+ var that = this;
|
|
|
+ console.log(that.data.size_list);
|
|
|
+ console.log(that.data.color_list);
|
|
|
+ var url = "v1/product_detail/" + that.data.productId + "/" + that.data.size_list + "/" + that.data.color_list;
|
|
|
+ var params = {}
|
|
|
+ var success = function (val) {
|
|
|
+ console.log('val',val)
|
|
|
+ that.setData({
|
|
|
+ canpay:true,
|
|
|
+ project:val.data,
|
|
|
+ productId:val.data.id
|
|
|
+ })
|
|
|
+ }
|
|
|
+ var fail = function(err){
|
|
|
+ that.setData({
|
|
|
+ canpay:false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ _request.$get(url, params, success, fail)
|
|
|
+ },
|
|
|
add: function () {
|
|
|
if (this.data.count < this.data.project.left_count) {
|
|
|
var count = this.data.count + 1
|
|
|
@@ -309,7 +349,8 @@ Page({
|
|
|
}
|
|
|
},
|
|
|
addCart:function(){
|
|
|
- var that = this
|
|
|
+ var that = this;
|
|
|
+ console.log('that.data.productId',that.data.productId)
|
|
|
var url = "v1/cart/" + that.data.productId + "/" + that.data.count
|
|
|
var params = {}
|
|
|
var success = function (res) {
|
|
|
@@ -635,4 +676,25 @@ Page({
|
|
|
},100),
|
|
|
});
|
|
|
},
|
|
|
+ checkSize(event){
|
|
|
+ var type = event.currentTarget.dataset.type;
|
|
|
+ var id = event.currentTarget.dataset.id;
|
|
|
+ var list = event.currentTarget.dataset.list;
|
|
|
+ var that = this;
|
|
|
+
|
|
|
+ var reproduct = this.data.productSize;
|
|
|
+// 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({
|
|
|
+ productSize :reproduct,
|
|
|
+ [type]:id
|
|
|
+ })
|
|
|
+// console.log('that.data[type]',that.data[type])
|
|
|
+ that.getProductDetail();
|
|
|
+ }
|
|
|
})
|