From ce969720e595e31ed5573c1370e54f0d7c643cbe Mon Sep 17 00:00:00 2001 From: chen <2659004835@qq.com> Date: Fri, 17 Sep 2021 17:40:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.json | 6 +++ custom-tab-bar/index.js | 87 +++++++++++++++++++----------------- custom-tab-bar/index.wxml | 33 ++++++++------ pages/gproduct/gproduct.js | 46 +++++++++++++------ pages/gproduct/gproduct.wxss | 15 ++++--- pages/new-page/index.js | 2 +- 6 files changed, 113 insertions(+), 76 deletions(-) diff --git a/app.json b/app.json index eeb0cd0..077a4b8 100644 --- a/app.json +++ b/app.json @@ -40,6 +40,12 @@ "iconPath": "/img/nav/menu.png", "selectedIconPath": "/img/nav/menuIndex.png", "text": "我要碳中和" + }, + { + "pagePath": "pages/gproduct/gproduct", + "iconPath": "/img/nav/menu.png", + "selectedIconPath": "/img/nav/menuIndex.png", + "text": "我要碳中和" } ] }, diff --git a/custom-tab-bar/index.js b/custom-tab-bar/index.js index 9f3187d..a40fb77 100644 --- a/custom-tab-bar/index.js +++ b/custom-tab-bar/index.js @@ -1,41 +1,48 @@ Component({ - data: { - selected: 0, - color: "#7A7E83", - selectedColor: "#4bb547", - list: [{ - pagePath: "/pages/index/index", - iconPath: "/img/nav/menu.png", - selectedIconPath: "/img/nav/menuIndex.png", - text: "碳知道" - }, - { - pagePath: "/pages/user/user", - iconPath: "/img/nav/user.png", - selectedIconPath: "/img/nav/userIndex.png", - text: "我的" - }, - { - pagePath: "/pages/new-page/index", - iconPath: "/img/nav/tzh_default.png", - selectedIconPath: "/img/nav/content.png", - text: "碳中和" - }, - ] - }, - attached() { - }, - methods: { - switchTab(e) { - // console.log(e) - const data = e.currentTarget.dataset - const url = data.path - wx.switchTab({url}) //可能是改变样式的原因 - }, - gotPageNew(){ - wx.switchTab({ - url: '/pages/new-page/index' - }); - } - }, -}) \ No newline at end of file + data: { + selected: 0, + color: "#7A7E83", + selectedColor: "#4bb547", + list: [{ + pagePath: "/pages/index/index", + iconPath: "/img/nav/menu.png", + selectedIconPath: "/img/nav/menuIndex.png", + text: "碳知道" + }, + { + pagePath: "/pages/user/user", + iconPath: "/img/nav/user.png", + selectedIconPath: "/img/nav/userIndex.png", + text: "我的" + }, + { + pagePath: "/pages/new-page/index", + iconPath: "/img/nav/tzh_default.png", + selectedIconPath: "/img/nav/content.png", + text: "碳中和" + }, + { + "pagePath": "pages/gproduct/gproduct", + "iconPath": "/img/nav/menu.png", + "selectedIconPath": "/img/nav/menuIndex.png", + "text": "我要碳中和" + } + ] + }, + attached() {}, + methods: { + switchTab(e) { + // console.log(e) + const data = e.currentTarget.dataset + const url = data.path + wx.switchTab({ + url + }) //可能是改变样式的原因 + }, + gotPageNew() { + wx.switchTab({ + url: '/pages/new-page/index' + }); + } + }, +}) diff --git a/custom-tab-bar/index.wxml b/custom-tab-bar/index.wxml index 0982242..4b4f13f 100644 --- a/custom-tab-bar/index.wxml +++ b/custom-tab-bar/index.wxml @@ -1,21 +1,26 @@ - + - - - {{list[0].text}} - - - - {{list[2].text}} - - - - {{list[1].text}} - + + + {{list[0].text}} + + + + {{list[2].text}} + + + + {{list[1].text}} + - diff --git a/pages/gproduct/gproduct.js b/pages/gproduct/gproduct.js index d1ff3cd..bbecf4b 100644 --- a/pages/gproduct/gproduct.js +++ b/pages/gproduct/gproduct.js @@ -38,7 +38,7 @@ Page({ isShif: false, cases_position_id: '' }, - senChange(event) { + senChange(event) { this.setData({ senIndex: event.detail.value, newType: this.data.senList[event.detail.value].type, @@ -47,7 +47,7 @@ Page({ tree_num: {}, flag:true, }) - if (event.detail.value == 1) { + if (this.data.senList[event.detail.value].type == 'forest_management') { this.setData({ isShif: true, newDo_type: this.data.senList[this.data.senIndex].type @@ -226,7 +226,14 @@ Page({ /** * 生命周期函数--监听页面加载 */ - onLoad: function(options) { + onLoad: function(options) { + console.log('options',options); + if (typeof this.getTabBar === 'function' && + this.getTabBar()) { + this.getTabBar().setData({ + selected: 2 + }) + } if (options.icon != undefined) { this.setData({ icon: options.icon, @@ -254,14 +261,14 @@ Page({ id: id, 'openid': wx.getStorageSync('openid'), }, - success(res) { + success(res) { + console.log('res213',res); if (res.data.result == 'success') { - console.log(JSON.parse(res.data.data)) that.setData({ list: JSON.parse(res.data.data), carbon: carbon, id: id - }) + }) } else { console.log(res.data.msg); //失败 } @@ -277,26 +284,38 @@ Page({ 'openid': wx.getStorageSync('openid') }, success(res) { - console.log('res:',res); if (res.data.result == 'success') { var threeList = JSON.parse(res.data.data).cases; - console.log(threeList); if(threeList[0].type=='forest_management'){ that.setData({ isXiangm:true }) - } + } + let arr = that.data.senList + arr.forEach((item,index)=>{ + if(item.type == threeList[that.data.curCaseIndex].default_type){ + let obj = arr[index]; + arr.splice(index,1) + arr.unshift(obj) + } + }) + if(arr[0].type=='forest_management'){ + that.setData({ + isShif:true + }) + } + that.setData({ + senList:arr + }) that.setData({ threeList: threeList, - newDo_type: threeList[that.data.curCaseIndex].type, cases_position_id: threeList[that.data.curCaseIndex].address[that.data.addressIndex].id, - newDo_type:that.data.senList[0].type, + newDo_type:arr[0].type, //TODO 这里赋值应该用数组 // curThreeCode: [JSON.parse(res.data.data).trees[0].coding], // carbon:JSON.parse(res.data.data).trees[0].carbon_base, // paid_money: money.toFixed(2) }) - console.log(that.data.threeList); } else { console.log(res.data.msg); //失败 } @@ -341,7 +360,6 @@ Page({ var that = this var tree_items = [] var management_items = [] - console.log(this.data.newDo_type); if (this.data.newDo_type == 'afforestation') { for (var p in this.data.priceList) { tree_items.push({ @@ -356,7 +374,7 @@ Page({ amount: this.data.priceList[p].num }) } - } + } wx.request({ url: urlPath.postPayDataV2, data: { diff --git a/pages/gproduct/gproduct.wxss b/pages/gproduct/gproduct.wxss index a167d5d..3c1ccf5 100644 --- a/pages/gproduct/gproduct.wxss +++ b/pages/gproduct/gproduct.wxss @@ -200,26 +200,27 @@ } .bottom-nav { - position: fixed; - left: 0; - right: 0; - bottom: 0; + /* position: fixed; */ + /* left: 0; */ + /* right: 0; */ + /* bottom: 0; */ height: 120rpx; - box-shadow: 0rpx 10rpx 20rpx 0rpx #4bb547; + /* box-shadow: 0rpx 10rpx 20rpx 0rpx #4bb547; */ background: #fff; z-index: 99; line-height: 120rpx; font-weight: bold; color: #333; font-size: 36rpx; - padding-left: 20rpx; + padding-left: 0rpx; + margin-top: 20rpx; /* background-color: red; */ } .xiadan { float: right; height: 120rpx; - line-height: 100rpx; + line-height: 84rpx; width: 80rpx; background: #4bb547; color: #fff; diff --git a/pages/new-page/index.js b/pages/new-page/index.js index 2c434b1..912f0a4 100644 --- a/pages/new-page/index.js +++ b/pages/new-page/index.js @@ -284,7 +284,7 @@ Page({ url: '/pages/footprint/footprint?', }) } else { - wx.navigateTo({ + wx.reLaunch({ url: '/pages/gproduct/gproduct?id=' + JSON.parse(res.data.data) .id + "&&carbon=" + that.data.actual_total_carbon + "&&icon=" + that.data.icon,