diff --git a/pages/grade/grade.js b/pages/grade/grade.js index c40239f..c48eb4d 100644 --- a/pages/grade/grade.js +++ b/pages/grade/grade.js @@ -21,30 +21,37 @@ Page({ /** * 生命周期函数--监听页面显示 */ - onShow: function() { + onShow: function () { let that = this; Http.get({ url: config.api.scoreLevelInfo, data: {} }) - .then(res=>{ - that.setData({ - flags: 'have', - rules: JSON.parse(res.data.score.rules), - rules1: JSON.parse(res.data.score.rules)[1].childs, - levelList: res.data.levelList + .then(res => { + let childs = [] + JSON.parse(res.data.score.rules).forEach(item => { + if (item.id == 2) { + childs = item.childs + } + }) + that.setData({ + flags: 'have', + rules: JSON.parse(res.data.score.rules), + rules1: childs || [], + levelList: res.data.levelList + }) + console.log(that.data.rules) + console.log(that.data.rules1) }) - console.log(that.data.rules) - }) - .catch(res=>{ - that.setData({ - flags: 'nothave' + .catch(res => { + that.setData({ + flags: 'nothave' + }) }) - }) - + }, // 点击跳转到我的特享优惠 - gotospecialcourtesy:function(){ + gotospecialcourtesy: function () { wx.navigateTo({ url: '/pages/specialcourtesy/specialcourtesy', })