@@ -50,27 +50,6 @@ Page({ | |||||
}) | }) | ||||
} | } | ||||
}, | }, | ||||
onShow: function () { | |||||
let that = this; | |||||
Http.get({ | |||||
url: config.api.businessList | |||||
}).then(res => { | |||||
console.log(res) | |||||
let businessObj = [{ id: 0, title: "全部", type: 1, createDate: 0}]; | |||||
that.setData({ | |||||
tabs: res.data.concat(businessObj).sort(compare("createDate")) | |||||
}); | |||||
console.log(that.data.tabs) | |||||
}) | |||||
.catch(err => { | |||||
wx.showToast({ | |||||
title: err.errMsg, | |||||
icon: 'none', | |||||
duration: 2000, | |||||
mask: false | |||||
}); | |||||
}) | |||||
}, | |||||
//点击跳转到券详情页面 | //点击跳转到券详情页面 | ||||
gotouse: function (e) { | gotouse: function (e) { | ||||
console.log(e.currentTarget.dataset.couponid) | console.log(e.currentTarget.dataset.couponid) | ||||
@@ -21,7 +21,6 @@ Page({ | |||||
jumpIndex(e) { | jumpIndex(e) { | ||||
let that = this; | let that = this; | ||||
let index = e.currentTarget.dataset.menuindex; | let index = e.currentTarget.dataset.menuindex; | ||||
console.log(index) | |||||
that.setData({ | that.setData({ | ||||
indexId: index, | indexId: index, | ||||
businessId: index | businessId: index | ||||
@@ -43,7 +42,7 @@ Page({ | |||||
* 生命周期函数--监听页面加载 | * 生命周期函数--监听页面加载 | ||||
*/ | */ | ||||
onLoad: function (options) { | onLoad: function (options) { | ||||
var that = this | |||||
let that = this; | |||||
wx.getSystemInfo({ | wx.getSystemInfo({ | ||||
success: function (res) { | success: function (res) { | ||||
that.setData({ | that.setData({ | ||||
@@ -51,34 +50,26 @@ Page({ | |||||
}); | }); | ||||
} | } | ||||
}); | }); | ||||
}, | |||||
/** | |||||
* 生命周期函数--监听页面显示 | |||||
*/ | |||||
onShow: function () { | |||||
let that = this; | |||||
that.getBussiness(); | that.getBussiness(); | ||||
that.getList(1,0); | |||||
that.getList(1, 0); | |||||
}, | }, | ||||
getBussiness:function(){ | getBussiness:function(){ | ||||
let that = this; | let that = this; | ||||
Http.get({ | Http.get({ | ||||
url: config.api.businessList, | url: config.api.businessList, | ||||
}).then(res => { | }).then(res => { | ||||
console.log(res) | |||||
let businessObj = [{ id: 0, title: "全部", type: 1, createDate:0}]; | |||||
that.setData({ | that.setData({ | ||||
lists: res.data.concat(businessObj).sort(compare("createDate")) | |||||
lists: [{ id: 0, title: "全部", type: 1 }].concat(res.data) | |||||
}); | |||||
}) | |||||
.catch(err => { | |||||
wx.showToast({ | |||||
title: err.errMsg, | |||||
icon: 'none', | |||||
duration: 2000, | |||||
mask: false | |||||
}); | }); | ||||
}) | }) | ||||
.catch(err => { | |||||
wx.showToast({ | |||||
title: err.errMsg, | |||||
icon: 'none', | |||||
duration: 2000, | |||||
mask: false | |||||
}); | |||||
}) | |||||
}, | }, | ||||
getList: function (page, businessId) { | getList: function (page, businessId) { | ||||
let that = this; | let that = this; | ||||
@@ -148,16 +139,3 @@ Page({ | |||||
} | } | ||||
} | } | ||||
}) | }) | ||||
function compare(pro) { | |||||
return function (obj2, obj1) { | |||||
var val1 = obj1[pro]; | |||||
var val2 = obj2[pro]; | |||||
if (val1 < val2) { | |||||
return 1; | |||||
} else if (val1 > val2) { | |||||
return -1; | |||||
} else { | |||||
return 0; | |||||
} | |||||
} | |||||
} |
@@ -3,11 +3,11 @@ | |||||
<view style='float: left' class='left'> | <view style='float: left' class='left'> | ||||
<scroll-view scroll-y scroll-with-animation scroll-left="{{scrollLength}}" class='scrollY' style='height: {{winHeight}}px'> | <scroll-view scroll-y scroll-with-animation scroll-left="{{scrollLength}}" class='scrollY' style='height: {{winHeight}}px'> | ||||
<view class='all clear'> | <view class='all clear'> | ||||
<block wx:key="lists" wx:for="{{lists}}"> | |||||
<view bindtap='jumpIndex' data-menuindex='{{index}}'> | |||||
<block wx:for="{{lists}}" wx:key="{{index}}"> | |||||
<view bindtap='jumpIndex' data-menuindex='{{item.id}}'> | |||||
<view class='text-style'> | <view class='text-style'> | ||||
<text class="{{indexId==index?'active1':''}}">{{item.title}}</text> | |||||
<text class="{{indexId==index?'active':''}}"></text> | |||||
<text class="{{indexId==item.id?'active1':''}}">{{item.title}}</text> | |||||
<text class="{{indexId==item.id?'active':''}}"></text> | |||||
</view> | </view> | ||||
</view> | </view> | ||||
</block> | </block> | ||||
@@ -185,12 +185,9 @@ Component({ | |||||
Http.get({ | Http.get({ | ||||
url: config.api.businessList | url: config.api.businessList | ||||
}).then(res => { | }).then(res => { | ||||
console.log(res) | |||||
let businessObj = [{ id: 0, title: "全部", type: 1, createDate:0}]; | |||||
that.setData({ | that.setData({ | ||||
tabs: res.data.concat(businessObj).sort(compare("createDate")) | |||||
tabs: [{ id: 0, title: "全部", type: 1 }].concat(res.data) | |||||
}); | }); | ||||
console.log(that.data.tabs) | |||||
}) | }) | ||||
.catch(err => { | .catch(err => { | ||||
wx.showToast({ | wx.showToast({ | ||||
@@ -2,5 +2,6 @@ | |||||
"navigationBarTitleText": "拼团详情", | "navigationBarTitleText": "拼团详情", | ||||
"usingComponents": {}, | "usingComponents": {}, | ||||
"navigationBarBackgroundColor": "#F13C42", | "navigationBarBackgroundColor": "#F13C42", | ||||
"navigationBarTextStyle": "white", | |||||
"enablePullDownRefresh": true | "enablePullDownRefresh": true | ||||
} | } |