From 52862a4970d6d28ee03456c6efaca5303976c90d Mon Sep 17 00:00:00 2001 From: xpz2018 <107107461@qq.com> Date: Thu, 7 Jan 2021 14:30:57 +0800 Subject: [PATCH] no message --- app.js | 58 ++--------- app.json | 2 +- colorui/components/cu-custom.js | 47 ++++++--- colorui/components/cu-custom.wxml | 8 +- pages/article/article-item/index.js | 7 +- pages/article/factory/index.js | 4 +- pages/article/hot-index/index.js | 146 ++------------------------- pages/article/index/index.js | 26 ++--- pages/article/point-index/index.js | 32 ++---- pages/article/point-index/index.wxml | 24 ++--- pages/article/price-index/index.js | 86 +--------------- pages/article/queue-index/index.js | 140 +------------------------ pages/home/index/index.js | 41 ++++++-- pages/home/index/index.wxml | 58 +++-------- pages/home/qrcode/index.js | 1 - pages/index/index.js | 115 +++++++++++++-------- pages/login/index.js | 89 +--------------- pages/login/index.wxml | 6 +- pages/mall/index/index.js | 70 +++++++------ pages/mall/index/index.wxml | 24 ++--- pages/ztbvip/index.js | 10 +- utils/request.js | 2 +- utils/util.js | 37 ++++++- 23 files changed, 323 insertions(+), 710 deletions(-) diff --git a/app.js b/app.js index 4614058..2ebadc9 100644 --- a/app.js +++ b/app.js @@ -1,5 +1,5 @@ //app.js -App({ + App({ //----------------------------------------------globalData-------------------------------------- release: 0, httpUrl: 'https://api.qniao.cn', @@ -8,7 +8,7 @@ App({ version: 152, xAppId: '470236309865238528', globalData: { - userInfo: {}, + userInfo: null, openId: null, token: null, isIPhoneX: false, @@ -18,49 +18,11 @@ App({ inited: false, //-----------------------------------------onLaunch--------------------------------------------- onLaunch: function () { - if (this.release) { - this.httpUrl = 'https://api.qniao.cn' - } else { - this.httpUrl = 'http://47.113.118.47:9000' - // this.httpUrl = 'https://api-test.qniao.cn' - } - }, - // 获取高度 - onShow: function(){ - wx.getSystemInfo({ - success: e => { - this.globalData.isIPhoneX = this.checkIPhoneX(e) - this.globalData.isIos = this.checkIos(e) - this.globalData.dev = e.platform == 'devtools' - let custom = wx.getMenuButtonBoundingClientRect() - this.globalData.Custom = custom - // 顶部操作栏高度 - this.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight + (this.globalData.isIos ? 4 : 0) - let windowHeight = e.windowHeight * (750 / e.windowWidth) - let statusBarHeight = this.globalData.CustomBar * (750 / e.windowWidth) - // 状态栏高度 - this.globalData.StatusBar = e.statusBarHeight * (750 / e.windowWidth) - this.globalData.statusBarHeight = statusBarHeight - // fragmentHeight:指的是整个页面statusBarHeight以下的高度 - this.globalData.fragmentHeight = windowHeight - statusBarHeight - this.globalData.windowWidth = e.windowWidth - } - }) - }, - //-----------------------------------------checkIPhoneX--------------------------------------------- - checkIos: function (e) { - if ('ios' === e.platform) { - return true - } - if (e.system.startsWith('iOS')) { - return true - } - return false - }, - checkIPhoneX: function (e) { - var t = e.model, - o = e.platform; - return (/iPhone 11/.test(t) || /iPhone X/.test(t) || /iPhone 12/.test(t)) && 'ios' === o - } - -}) \ No newline at end of file + if (this.release) { + this.httpUrl = 'https://api.qniao.cn' + } else { + this.httpUrl = 'http://47.113.118.47:9000' + // this.httpUrl = 'https://api-test.qniao.cn' + } + } + }) \ No newline at end of file diff --git a/app.json b/app.json index 2059dd9..524e9d9 100644 --- a/app.json +++ b/app.json @@ -1,8 +1,8 @@ { "pages": [ + "pages/index/index", "pages/login/index", "pages/paper/index", - "pages/index/index", "pages/home/about/index", "pages/home/service/index", "pages/home/mobile/index", diff --git a/colorui/components/cu-custom.js b/colorui/components/cu-custom.js index 46a844f..13a3c5a 100644 --- a/colorui/components/cu-custom.js +++ b/colorui/components/cu-custom.js @@ -1,3 +1,4 @@ +const event = require('../../utils/event') const app = getApp() Component({ @@ -15,7 +16,7 @@ Component({ bgColor: { type: String, default: '' - }, + }, isCustom: { type: [Boolean, String], default: false @@ -24,6 +25,10 @@ Component({ type: [Boolean, String], default: false }, + shadow: { + type: Boolean, + default: false + }, intercept: { type: Boolean, default: false @@ -44,30 +49,44 @@ Component({ lifetimes: { // 生命周期函数,可以为函数,或一个在methods段中定义的方法名 attached: function () { - this.setData({ - StatusBar: app.globalData.StatusBar || 40, - CustomBar: app.globalData.CustomBar || (app.globalData.isIos ? 64 : 60), - Custom: app.globalData.Custom - }) + if(app.globalData.Custom){ + this.setData({ + StatusBar: app.globalData.StatusBar || 40, + CustomBar: app.globalData.CustomBar || (app.globalData.isIos ? 64 : 80), + Custom: app.globalData.Custom + }) + } else { + event.on('InitMessage', this, this.onEvent) + } + }, + detached: function(){ + if(!app.globalData.Custom){ + event.remove('InitMessage', this) + } } }, /** * 组件的方法列表 */ methods: { - backPage() { - if(this.data.intercept){ + backspace() { + if (this.data.intercept) { this.triggerEvent('customevent', null) return } - if(getCurrentPages().length == 1){ - this.toHome() - } else { - wx.navigateBack() + wx.navigateBack() + }, + onEvent: function(message){ + if (message.what == 8) { + this.setData({ + StatusBar: app.globalData.StatusBar || 40, + CustomBar: app.globalData.CustomBar || (app.globalData.isIos ? 64 : 80), + Custom: app.globalData.Custom + }) } }, - toHome(){ - if(app.globalData.userInfo.userId){ + toHome() { + if (app.globalData.userInfo.userId) { wx.redirectTo({ url: '/pages/index/index' }) } else { wx.reLaunch({ url: '/pages/login/index' }) diff --git a/colorui/components/cu-custom.wxml b/colorui/components/cu-custom.wxml index 422efc0..3d4ed0d 100644 --- a/colorui/components/cu-custom.wxml +++ b/colorui/components/cu-custom.wxml @@ -1,11 +1,11 @@ - - - + + + - + diff --git a/pages/article/article-item/index.js b/pages/article/article-item/index.js index 3bb3d7f..d698ab6 100644 --- a/pages/article/article-item/index.js +++ b/pages/article/article-item/index.js @@ -1,6 +1,7 @@ // pages/stock/index.js const request = require('../../../utils/request') //导入模块 const util = require('../../../utils/util') +const app = getApp() Component({ options: { @@ -19,9 +20,13 @@ Component({ wx.navigateTo({ url: '/pages/agent/factory/index?tabIndex=1&id=' + this.data.item.millPaperId }) }, lookItem: function(e){ - wx.navigateTo({ url: '/pages/article/detail/index?id=' + this.data.item.id }) + util.navigateTo('/pages/article/detail/index?id=' + this.data.item.id) }, likeItem: function(e){ + if(!app.globalData.userInfo){ + wx.navigateTo({ url: '/pages/login/index' }) + return + } if(this.data.item.isLiked){ util.showToast('请勿重复点赞') return diff --git a/pages/article/factory/index.js b/pages/article/factory/index.js index ce1b87a..1855ea9 100644 --- a/pages/article/factory/index.js +++ b/pages/article/factory/index.js @@ -24,7 +24,7 @@ Page({ this.data.type = Number(options.type) } wx.showLoading({ title: '加载中', mask: true }) - if(this.data.type == 0){ + if(this.data.type == 0 && app.globalData.userInfo){ this.data.recommendedString = storage.get('recommended' + app.globalData.userInfo.userId) if(!util.isEmpty(this.data.recommendedString)){ this.data.recommendedList = JSON.parse(this.data.recommendedString) @@ -119,7 +119,7 @@ Page({ if(fList.length <= 4){ return } - if(fString != this.data.recommendedString){ + if(fString != this.data.recommendedString && app.globalData.userInfo){ storage.put('recommended' + app.globalData.userInfo.userId, fString) event.emit('EventMessage', { what: 505, desc: 'RecommendedChange' }) } diff --git a/pages/article/hot-index/index.js b/pages/article/hot-index/index.js index c511675..8da97d3 100644 --- a/pages/article/hot-index/index.js +++ b/pages/article/hot-index/index.js @@ -2,12 +2,8 @@ const request = require('../../../utils/request') //导入模块 const util = require('../../../utils/util') const storage = require('../../../utils/storage') -const math = require('../../../utils/math') const event = require('../../../utils/event.js') -var wxCharts = require('../../../utils/wxcharts.js') const app = getApp() -var lineChart = null -const colors = ['#FF4229', '#FFAD2A', '#297BFF', '#29FF46', '#AD29FF'] Component({ options: { @@ -37,7 +33,6 @@ Component({ lifetimes: { // 生命周期函数,可以为函数,或一个在methods段中定义的方法名 attached: function () { - this.setData({ height: app.globalData.safeFragmentHeight - 190 }) event.on('EventMessage', this, this.onEvent) }, detached: function () { @@ -47,8 +42,7 @@ Component({ methods: { onRestart: function () { if (!this.data.firstShow) { - // this.fetchChartList() - + this.setData({ height: app.globalData.safeFragmentHeight - 190 }) this.onRefreshList() } if(!this.data.noticeList.length && !this.data.status){ @@ -57,22 +51,19 @@ Component({ this.data.firstShow = true }, onEvent: function (message) { - if (message.what == 502) { - // this.fetchChartList() - } else if (message.what == 505) { - // 纸厂排队的纸厂选择 - this.fetchFactoryList() - } else if (message.what == 570 || message.what == 571 || message.what == 572 || message.what == 573) { + if (message.what == 570 || message.what == 571 || message.what == 572 || message.what == 573) { // 帖子发布刷新 this.onRefreshList() } }, //***********************************参与纸厂讨论*****************************************// fetchFactoryList: function(){ - var recommendedString = storage.get('recommended' + app.globalData.userInfo.userId) - if(!util.isEmpty(recommendedString)){ - this.setData({ factoryList: JSON.parse(recommendedString) }) - return + if(app.globalData.userInfo){ + var recommendedString = storage.get('recommended' + app.globalData.userInfo.userId) + if(!util.isEmpty(recommendedString)){ + this.setData({ factoryList: JSON.parse(recommendedString) }) + return + } } // /recycle-service/get/paper-mill-list request.get('/recycle-service/get/all-paper-mill').then(result => { @@ -90,108 +81,6 @@ Component({ toPaperList: function(){ wx.navigateTo({ url: '/pages/moment/paper/index' }) }, - //***********************************fetchChartList*****************************************// - // fetchChartList: function(){ - // var cateIds = storage.get('cateIdList' + app.globalData.userInfo.userId) - // if(!util.isEmpty(cateIds)){ - // this.data.idList = cateIds - // } - // request.get('/information-center/getPaperCategoryPrice', {idList: this.data.idList}).then(result => { - // //成功回调 - // if(result.data.length <= 0){ - // return - // } - // var respList = result.data - // var categoriesList = [] - // var serieList = [] - // var min = Number.MAX_VALUE - // var max = 0 - // for (let index = 0; index < respList.length; index++) { - // const element = respList[index] - // var dataList = [] - // if(index == 0){ - // element.list.forEach(item => { - // categoriesList.push(item.data.substring(5)) - // var price = math.times(item.unitPrice, 1000) - // if(min > price){ - // min = price - // } - // if(max < price){ - // max = price - // } - // dataList.push(price) - // }) - // } else { - // element.list.forEach(item => { - // var price = math.times(item.unitPrice, 1000) - // if(min > price){ - // min = price - // } - // dataList.push(price) - // }) - // } - // var series = { - // name: element.list[0].name, - // data: dataList, - // format: function (val, name) { - // return val + '元/吨' - // }, - // color: colors[index] - // } - // serieList.push(series) - // } - // this.setData({ chartList: { categories: categoriesList, serieList: serieList } }) - // // if(min < 50){ - // // min = 50 - // // } - // this.initChart(min - 50, max + 50) - // }) - // }, - // touchHandler: function (e) { - // if(lineChart){ - // lineChart.scrollStart(e) - // } - // }, - // moveHandler: function (e) { - // if(lineChart){ - // lineChart.scroll(e) - // } - // }, - // touchEndHandler: function (e) { - // if(lineChart){ - // lineChart.scrollEnd(e) - // lineChart.showToolTip(e, { - // format: function (item, category) { - // return category + ' ' + item.name + ':' + item.data - // } - // }) - // } - // }, - // initChart: function (min, max) { - // lineChart = new wxCharts({ - // canvasId: 'lineChart', - // type: 'line', - // categories: this.data.chartList.categories, - // animation: false, - // title: { name: '纸品单价 (元/吨)' }, - // series: this.data.chartList.serieList, - // xAxis: { disableGrid: false }, - // yAxis: { - // // title: '纸品单价 (元/吨)', - // format: function (val) { - // return val - // }, - // min, - // max - // }, - // width: 350, - // height: 200, - // dataLabel: false, - // dataPointShape: 'circle', - // enableScroll: true, - // extra: { lineStyle: 'curve' } - // }, this) - // }, //*************************************************momentList************************************************// onRefreshList: function () { this.setData({ @@ -230,25 +119,6 @@ Component({ this.setData({ requesting: false }) }) }, - lookItem: function(e){ - var item = this.data.momentList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] - wx.navigateTo({ url: '/pages/article/detail/index?id=' + item.id }) - }, - likeItem: function(e){ - var item = this.data.momentList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] - if(item.isLiked){ - util.showToast('请勿重复点赞') - return - } - request.post('/information-center/like-or-cancel/post', {postId: item.id}).then(result => { - this.setData({ - ['momentList[' + e.currentTarget.dataset.page + '][' + e.currentTarget.dataset.index + '].likeQuantity']: result.data.likeQuantity, - ['momentList[' + e.currentTarget.dataset.page + '][' + e.currentTarget.dataset.index + '].isLiked']: 1 - }) - }).catch(error => { - util.showToast(error) - }) - }, //*************************************************noticeList************************************************// fetchNoticeList: function(){ if (this.data.loopRequesting) { diff --git a/pages/article/index/index.js b/pages/article/index/index.js index 6921beb..e8d562d 100644 --- a/pages/article/index/index.js +++ b/pages/article/index/index.js @@ -16,13 +16,6 @@ Component({ tabList: [ '热门', '纸品价格', '车辆排队', '纸厂扣点' ], tabIndex: 0 }, - lifetimes: { - // 生命周期函数,可以为函数,或一个在methods段中定义的方法名 - attached: function () { - this.setData({ height: app.globalData.safeFragmentHeight - 190 }) - - } - }, methods: { onRestart: function () { var fragment = this.selectComponent('#fragment' + this.data.tabIndex) @@ -30,16 +23,15 @@ Component({ fragment.onRestart() } if (!this.data.firstShow) { - this.setData({tabList: this.data.tabList}) - // /article-category/get/article-category-list 查询所有文章分类 - request.get('/information-center/article-category/get/article-category-list').then(result => { - for (let index = 0; index < result.data.length; index++) { - this.data.tabList[index + 1] = result.data[index].name - } - // this.setData({tabList: this.data.tabList}) - }).catch(err => { - //异常回调 - }) + this.setData({ height: app.globalData.safeFragmentHeight - 190, tabList: this.data.tabList}) + // request.get('/information-center/article-category/get/article-category-list').then(result => { + // for (let index = 0; index < result.data.length; index++) { + // this.data.tabList[index + 1] = result.data[index].name + // } + // // this.setData({tabList: this.data.tabList}) + // }).catch(err => { + // //异常回调 + // }) } this.data.firstShow = true }, diff --git a/pages/article/point-index/index.js b/pages/article/point-index/index.js index 4ae78f0..2c0f90d 100644 --- a/pages/article/point-index/index.js +++ b/pages/article/point-index/index.js @@ -1,7 +1,6 @@ // pages/stock/index.js const request = require('../../../utils/request') //导入模块 const event = require('../../../utils/event.js') -const util = require('../../../utils/util') const app = getApp() Component({ @@ -14,7 +13,7 @@ Component({ */ data: { height: app.globalData.safeFragmentHeight - 190, - vip: false, + userInfo: null, momentList: [], requesting: false, finished: false, @@ -26,7 +25,6 @@ Component({ lifetimes: { // 生命周期函数,可以为函数,或一个在methods段中定义的方法名 attached: function () { - this.setData({ height: app.globalData.safeFragmentHeight - 190, vip: app.globalData.userInfo.isVIP }) event.on('EventMessage', this, this.onEvent) }, detached: function () { @@ -35,7 +33,10 @@ Component({ }, methods: { onRestart: function () { - if (!this.data.firstShow || this.data.momentList.length <= 0) { + if (!this.data.firstShow) { + this.setData({ height: app.globalData.safeFragmentHeight - 190, userInfo: app.globalData.userInfo }) + } + if (this.data.momentList.length <= 0) { this.onRefreshList() } this.data.firstShow = true @@ -46,7 +47,7 @@ Component({ this.onRefreshList() } else if(message.what == 200){ // Vip的变化 - this.setData({ vip: app.globalData.userInfo.isVIP }) + this.setData({ userInfo: app.globalData.userInfo }) this.onRefreshList() } }, @@ -85,26 +86,11 @@ Component({ this.setData({ requesting: false }) }) }, - lookItem: function(e){ - var item = this.data.momentList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] - wx.navigateTo({ url: '/pages/article/detail/index?id=' + item.id }) - }, - likeItem: function(e){ - var item = this.data.momentList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] - if(item.isLiked){ - util.showToast('请勿重复点赞') + toVip: function(){ + if(!app.globalData.userInfo){ + wx.navigateTo({ url: '/pages/login/index' }) return } - request.post('/information-center/like-or-cancel/post', {postId: item.id}).then(result => { - this.setData({ - ['momentList[' + e.currentTarget.dataset.page + '][' + e.currentTarget.dataset.index + '].likeQuantity']: result.data.likeQuantity, - ['momentList[' + e.currentTarget.dataset.page + '][' + e.currentTarget.dataset.index + '].isLiked']: 1 - }) - }).catch(error => { - util.showToast(error) - }) - }, - toVip: function(){ wx.navigateTo({ url: '/pages/ztbvip/index' }) } } diff --git a/pages/article/point-index/index.wxml b/pages/article/point-index/index.wxml index 56726b6..5fc1bde 100644 --- a/pages/article/point-index/index.wxml +++ b/pages/article/point-index/index.wxml @@ -2,18 +2,7 @@ - - - - - - 需要开通会员才能查看纸厂扣点信息 - 限时优惠开通会员,获取更多货源、尊享会员权益,买卖更赚钱 - - - 立即开通 - - + @@ -50,5 +39,16 @@ + + + + + + 需要开通会员才能查看纸厂扣点信息 + 限时优惠开通会员,获取更多货源、尊享会员权益,买卖更赚钱 + + + 立即开通 + \ No newline at end of file diff --git a/pages/article/price-index/index.js b/pages/article/price-index/index.js index 6335978..f7777f6 100644 --- a/pages/article/price-index/index.js +++ b/pages/article/price-index/index.js @@ -1,7 +1,5 @@ // pages/stock/index.js const request = require('../../../utils/request') //导入模块 -const util = require('../../../utils/util') -const storage = require('../../../utils/storage') const event = require('../../../utils/event.js') const app = getApp() @@ -15,25 +13,18 @@ Component({ */ data: { height: app.globalData.safeFragmentHeight - 190, - chartList: null, + firstShow: false, momentList: [], requesting: false, finished: false, - idList: '', form: { categoryId: 1, pageNum: 1 - }, - factoryList: [], - priceId: null, - priceName: '', - priceList: [] + } }, lifetimes: { // 生命周期函数,可以为函数,或一个在methods段中定义的方法名 attached: function () { - this.setData({ height: app.globalData.safeFragmentHeight - 190, kg: app.globalData.kg }) - this.data.priceId = storage.get('priceId' + app.globalData.userInfo.userId) event.on('EventMessage', this, this.onEvent) }, detached: function () { @@ -43,18 +34,13 @@ Component({ methods: { onRestart: function () { if (!this.data.firstShow) { - // this.fetchPriceList(this.data.priceId) + this.setData({ height: app.globalData.safeFragmentHeight - 190, kg: app.globalData.kg }) this.onRefreshList() } this.data.firstShow = true }, onEvent: function (message) { - if (message.what == 555) { - // 纸厂价格的纸厂选择 - this.data.priceId = message.obj.paperMillId - storage.put('priceId' + app.globalData.userInfo.userId, this.data.priceId) - // this.fetchPriceList(this.data.priceId) - } else if (message.what == 571) { + if (message.what == 571) { // 帖子发布刷新 this.onRefreshList() } @@ -93,68 +79,6 @@ Component({ //异常回调 this.setData({ requesting: false }) }) - }, - lookItem: function(e){ - var item = this.data.momentList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] - wx.navigateTo({ url: '/pages/article/detail/index?id=' + item.id }) - }, - likeItem: function(e){ - var item = this.data.momentList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] - if(item.isLiked){ - util.showToast('请勿重复点赞') - return - } - request.post('/information-center/like-or-cancel/post', {postId: item.id}).then(result => { - this.setData({ - ['momentList[' + e.currentTarget.dataset.page + '][' + e.currentTarget.dataset.index + '].likeQuantity']: result.data.likeQuantity, - ['momentList[' + e.currentTarget.dataset.page + '][' + e.currentTarget.dataset.index + '].isLiked']: 1 - }) - }).catch(error => { - util.showToast(error) - }) - }, - //*************************************************noticeList************************************************// - fetchNoticeList: function(){ - if (this.data.loopRequesting) { - return - } - this.data.loopRequesting = true - request.get('/recycle-service/get/index-info-id').then(result => { - //成功回调 - this.data.loopRequesting = false - this.data.noticeList = result.data - if(result.data && result.data.length){ - this.data.noticeIndex = 0 - this.data.loopIndex = 0 - this.setData({ content: result.data[0].title}) - } - }).catch(err => { - //异常回调 - this.data.loopRequesting = false - }) - }, - onLoop: function(){ - if(!this.data.noticeList.length){ - this.data.loopIndex++ - if(this.data.loopIndex >= 600){ - this.fetchNoticeList() - } - return - } - this.data.noticeIndex++ - if(this.data.noticeIndex >= this.data.noticeList.length){ - this.data.loopIndex++ - this.data.noticeIndex = 0 - } - if(this.data.loopIndex >= 60){ - this.fetchNoticeList() - } - this.setData({ content: this.data.noticeList[this.data.noticeIndex].title }) - this.notice = this.notice || this.selectComponent('#wux-notice-bar') - this.notice.resetAnimation() - }, - onClick: function(){ - wx.navigateTo({ url: '/pages/html/notice/index?id=' + this.data.noticeList[this.data.noticeIndex].id }) - } + } } }) \ No newline at end of file diff --git a/pages/article/queue-index/index.js b/pages/article/queue-index/index.js index 46a33fb..a0235a0 100644 --- a/pages/article/queue-index/index.js +++ b/pages/article/queue-index/index.js @@ -1,12 +1,7 @@ // pages/stock/index.js const request = require('../../../utils/request') //导入模块 -const util = require('../../../utils/util') -const storage = require('../../../utils/storage') -const event = require('../../../utils/event.js') -var wxCharts = require('../../../utils/wxcharts.js') +const event = require('../../../utils/event') const app = getApp() -var queueChart = null -const colors = ['#FF4229', '#FFAD2A', '#297BFF', '#29FF46', '#AD29FF'] Component({ options: { @@ -18,21 +13,16 @@ Component({ */ data: { dev: app.globalData.dev, + firstShow: false, height: app.globalData.safeFragmentHeight - 190, momentList: [], requesting: false, finished: false, - form: { categoryId: 2, pageNum: 1 }, - queueId: null, - queueName: '', - chartList: null, + form: { categoryId: 2, pageNum: 1 } }, lifetimes: { // 生命周期函数,可以为函数,或一个在methods段中定义的方法名 attached: function () { - this.setData({ dev: app.globalData.dev, height: app.globalData.safeFragmentHeight - 190 }) - this.data.queueId = storage.get('queueId' + app.globalData.userInfo.userId) - this.data.queueName = storage.get('queueName' + app.globalData.userInfo.userId) event.on('EventMessage', this, this.onEvent) }, detached: function () { @@ -42,117 +32,17 @@ Component({ methods: { onRestart: function () { if (!this.data.firstShow) { - // this.fetchQueueList(this.data.queueId) + this.setData({ dev: app.globalData.dev, height: app.globalData.safeFragmentHeight - 190 }) this.onRefreshList() } this.data.firstShow = true }, onEvent: function (message) { - if (message.what == 556) { - // 纸厂排队的纸厂选择 - this.data.queueId = message.obj.paperMillId - this.data.queueName = message.obj.name - storage.put('queueId' + app.globalData.userInfo.userId, this.data.queueId) - storage.put('queueName' + app.globalData.userInfo.userId, this.data.queueName) - // this.fetchQueueList(this.data.queueId) - } else if (message.what == 572) { + if (message.what == 572) { // 帖子发布刷新 this.onRefreshList() } }, - //***********************************fetchChartList*****************************************// - // touchHandler: function (e) { - // if(queueChart){ - // queueChart.scrollStart(e) - // } - // }, - // moveHandler: function (e) { - // if(queueChart){ - // queueChart.scroll(e) - // } - // }, - // touchEndHandler: function (e) { - // if(queueChart){ - // queueChart.scrollEnd(e) - // queueChart.showToolTip(e, { - // format: function (item, category) { - // return category + ' ' + item.name + ':' + item.data - // } - // }) - // } - // }, - // // 纸品价格>>>>选择纸厂 - // selectFactory: function(event){ - // wx.navigateTo({ url: '/pages/article/factory/index?type=2'}) - // }, - // fetchQueueList: function(millId){ - // if(!millId){ - // request.get('/recycle-service/get/paper-mill-list').then(result => { - // this.data.queueName = result.data.records[1].name - // this.fetchQueueList(result.data.records[1].paperMillId) - // }) - // return - // } - // // recycle-service/get/paper-mill-received-weight-trend - // request.get('/recycle-service/get/paper-mill-received-weight-trend', {paperMillId: millId}).then(result => { - // //成功回调 - // if(result.data.length <= 0){ - // this.setData({chartList: [], queueName: this.data.queueName}) - // return - // } - // var categoriesList = [] - // var serieList = [] - // var dataList = [[]] - // for (let index = 0; index < result.data.length; index++) { - // const element = result.data[index] - // categoriesList.push(element.time.substring(5)) - // dataList[0].push(element.totalQuantity) - // // dataList[1].push(element.retainedQuantity) - // } - // var names = ['收货车辆总数', '排队车辆数'] - // for (let index = 0; index < dataList.length; index++) { - // var series = { - // name: names[index], - // data: dataList[index], - // format: function (val, name) { - // return val + '辆' - // }, - // color: colors[index] - // } - // serieList.push(series) - // } - // this.setData({ chartList: { categories: categoriesList, serieList: serieList }, queueName: this.data.queueName }) - // this.initChart(0, 0) - // }) - // }, - // initChart: function (min, max) { - // queueChart = new wxCharts({ - // canvasId: 'queueChart', - // type: 'line', - // legend: false, - // categories: this.data.chartList.categories, - // animation: false, - // series: this.data.chartList.serieList, - // xAxis: { disableGrid: false }, - // yAxis: { - // // title: '纸品单价 (元/吨)', - // format: function (val) { - // return val; - // }, - // min, - // max - // }, - // width: 350, - // height: 200, - // dataLabel: false, - // dataPointShape: 'circle', - // enableScroll: true, - // extra: { lineStyle: 'curve' } - // }, this) - // }, - // queueList: function(){ - // wx.navigateTo({ url: '/pages/article/queue-detail/index' }) - // }, //*************************************************momentList************************************************// onRefreshList: function () { this.setData({ @@ -187,26 +77,6 @@ Component({ //异常回调 this.setData({ requesting: false }) }) - }, - lookItem: function(e){ - var item = this.data.momentList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] - wx.navigateTo({ url: '/pages/article/detail/index?id=' + item.id }) - }, - likeItem: function(e){ - var item = this.data.momentList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] - if(item.isLiked){ - util.showToast('请勿重复点赞') - return - } - // /article/like-or-cancel/article-reply/{id} 点赞评论 - request.post('/information-center/like-or-cancel/post', {postId: item.id}).then(result => { - this.setData({ - ['momentList[' + e.currentTarget.dataset.page + '][' + e.currentTarget.dataset.index + '].likeQuantity']: result.data.likeQuantity, - ['momentList[' + e.currentTarget.dataset.page + '][' + e.currentTarget.dataset.index + '].isLiked']: 1 - }) - }).catch(error => { - util.showToast(error) - }) } } }) \ No newline at end of file diff --git a/pages/home/index/index.js b/pages/home/index/index.js index 64eb398..b03131d 100644 --- a/pages/home/index/index.js +++ b/pages/home/index/index.js @@ -1,8 +1,8 @@ // pages/stock/index.js const request = require('../../../utils/request'); //导入模块 -const util = require('../../../utils/util'); -const event = require('../../../utils/event.js') -const math = require('../../../utils/math.js'); +const util = require('../../../utils/util') +const event = require('../../../utils/event') +const math = require('../../../utils/math') const app = getApp() Component({ @@ -25,8 +25,7 @@ Component({ lifetimes: { // 生命周期函数,可以为函数,或一个在methods段中定义的方法名 attached: function () { - this.setData({ height: app.globalData.safeFragmentHeight, userInfo: app.globalData.userInfo }) - this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog') + event.on('EventMessage', this, this.onEvent) }, detached: function () { @@ -36,8 +35,10 @@ Component({ methods: { // resume的处理; onRestart: function () { + if(!this.data.firstShow){ + this.setData({ height: app.globalData.safeFragmentHeight, userInfo: app.globalData.userInfo }) + } this.fetchUserInfo() - // this.fetchMoney() this.data.firstShow = true }, onEvent: function (message) { @@ -47,7 +48,9 @@ Component({ } }, fetchUserInfo: function () { - // /user/userInfo 获取用户信息 + if(!app.globalData.token){ + return + } request.get('/recycle-service/user/get/base-info').then(result => { app.globalData.userInfo = result.data var nickname = '' @@ -71,8 +74,28 @@ Component({ this.setData({ messageNumber: result.data.messageNumber + result.data.notificationNumber }) }) }, - toShop: function () { - wx.navigateTo({ url: '/pages/shop/index/index' }) + toPage: function(e){ + if(e.currentTarget.id == 'bidding'){ + util.navigateTo('/pages/bidding/index/index') + } else if(e.currentTarget.id == 'shop'){ + util.navigateTo('/pages/shop/index/index') + } else if(e.currentTarget.id == 'ordering'){ + util.navigateTo('/pages/morder/index/index') + } else if(e.currentTarget.id == 'agent'){ + util.navigateTo('/pages/agent/order/index') + } else if(e.currentTarget.id == 'message'){ + util.navigateTo('/pages/message/index/index') + } else if(e.currentTarget.id == 'balance'){ + util.navigateTo('/pages/withdrawal/balance/index') + } else if(e.currentTarget.id == 'integral'){ + util.navigateTo('/pages/html/integral/index') + } else if(e.currentTarget.id == 'article'){ + util.navigateTo('/pages/article/list/index') + } else if(e.currentTarget.id == 'adress'){ + util.navigateTo('/pages/adress/list/index') + } else if(e.currentTarget.id == 'setting'){ + util.navigateTo('/pages/home/setting/index') + } }, checkout: function () { wx.navigateTo({ url: '/pages/withdrawal/checkout/index' }) diff --git a/pages/home/index/index.wxml b/pages/home/index/index.wxml index 6ec0431..447e6e7 100644 --- a/pages/home/index/index.wxml +++ b/pages/home/index/index.wxml @@ -1,6 +1,6 @@ - - 我的 + + 我的 @@ -33,40 +33,6 @@ - @@ -74,7 +40,7 @@ - + @@ -82,19 +48,19 @@ - + - + - + - + @@ -106,12 +72,12 @@ - + {{formate.numberFormat2(accountMoney)}} - + @@ -119,7 +85,7 @@ {{userInfo.memberRewardPoint || 0}} - + @@ -130,7 +96,7 @@ - + @@ -138,7 +104,7 @@ - + diff --git a/pages/home/qrcode/index.js b/pages/home/qrcode/index.js index a155d7f..f7aec84 100644 --- a/pages/home/qrcode/index.js +++ b/pages/home/qrcode/index.js @@ -8,7 +8,6 @@ Page({ * 页面的初始数据 */ data: { - value: app.globalData.userInfo.userId, fgColor: 'black', userInfo: null, avatarUrl: null, diff --git a/pages/index/index.js b/pages/index/index.js index 397975a..374e09b 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -11,11 +11,10 @@ Page({ { index: 2, value: 'home', badge: 0, name: '我的' } ], pageIndex: 1, - safeBottom: app.globalData.safeBottom + safeBottom: app.globalData.safeBottom, + inited: false }, - /** - * 生命周期函数--监听页面加载 - */ + /************************************** 初始化流程 ********************************************/ onLoad: function (options) { const updateManager = wx.getUpdateManager() updateManager.onCheckForUpdate(function (res) { @@ -26,48 +25,90 @@ Page({ // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 updateManager.applyUpdate() }) - if(app.inited){ - this.setData({fragment: app.globalData.safeFragmentHeight + app.globalData.statusBarHeight - 100, safeBottom: app.globalData.safeBottom }) - } else{ - var devJson = storage.get('ztbdev') - if(devJson){ - var devInfo = JSON.parse(devJson) - app.globalData.statusBarHeight =devInfo.statusBarHeight - app.globalData.safeBottom = devInfo.safeBottom - app.globalData.safeFragmentHeight = devInfo.safeFragmentHeight - app.globalData.fragmentHeight = devInfo.fragmentHeight - app.globalData.windowWidth = devInfo.windowWidth - app.globalData.isIPhoneX = devInfo.isIPhoneX - app.globalData.isIos = devInfo.isIos - app.globalData.dev = devInfo.dev - app.globalData.CustomBar = devInfo.CustomBar - app.globalData.Custom = devInfo.Custom - this.setData({fragment: app.globalData.safeFragmentHeight + app.globalData.statusBarHeight - 100, safeBottom: app.globalData.safeBottom }) + }, + onReady: function () { + wx.showLoading({ title: '获取中', mask: true }) + wx.getSystemInfo({ + success: e => { + app.globalData.isIPhoneX = this.checkIPhoneX(e) + app.globalData.isIos = this.checkIos(e) + app.globalData.dev = e.platform == 'devtools' + + let custom = wx.getMenuButtonBoundingClientRect() + app.globalData.Custom = custom + // 顶部操作栏高度 + app.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight + (app.globalData.isIos ? 4 : 0) + let windowHeight = e.windowHeight * (750 / e.windowWidth) + + let safeBottom = e.windowHeight - e.safeArea.bottom + if(safeBottom > e.windowHeight){ + safeBottom = 34 + } + app.globalData.safeBottom = safeBottom * (750 / e.windowWidth) + // 状态栏高度 + app.globalData.StatusBar = e.statusBarHeight * (750 / e.windowWidth) + let statusBarHeight = app.globalData.CustomBar * (750 / e.windowWidth) + app.globalData.statusBarHeight = statusBarHeight + // fragmentHeight:指的是整个页面statusBarHeight以下的高度 + app.globalData.fragmentHeight = windowHeight - statusBarHeight + app.globalData.safeFragmentHeight = windowHeight - statusBarHeight - app.globalData.safeBottom + app.globalData.windowWidth = e.windowWidth + + this.data.inited = true + const fheght = (app.globalData.safeFragmentHeight + app.globalData.statusBarHeight) - 100 + event.emit('InitMessage', { what: 8, desc: 'Logined' }) + this.setData({fragment: fheght, safeBottom: app.globalData.safeBottom }) + var authorization = app.globalData.token || storage.get('Authorization') + if(authorization){ + app.globalData.token = authorization + this.fetchUserInfo() + } else { + wx.hideLoading() + this.onResume() + } } + }) + }, + checkIos: function (e) { + if ('ios' === e.platform) { + return true } - event.on('EventMessage', this, this.onEvent) - if(!app.globalData.userInfo.mobile){ - request.get('/recycle-service/user/get/base-info').then(result => { - app.globalData.userInfo = result.data - }) + if (e.system.startsWith('iOS')) { + return true } + return false }, - //事件处理函数 - onNavChange(e) { - // 处理用户的登录校验 - this.setData({ pageIndex: Number(e.currentTarget.dataset.tab) }) + checkIPhoneX: function (e) { + var t = e.model + return (/iPhone 11/.test(t) || /iPhone X/.test(t) || /iPhone 12/.test(t)) && this.checkIos(e) + }, + fetchUserInfo:function(){ + request.get('/recycle-service/user/get/base-info').then(result => { + app.globalData.userInfo = result.data + wx.hideLoading() + this.onResume() + }).catch(err => { + wx.hideLoading() + }) + }, + onResume: function(){ var pageView = this.selectComponent('#' + this.data.TabList[this.data.pageIndex].value) - if (pageView) { + if (pageView && this.data.inited) { pageView.onRestart() } }, + //事件处理函数 + onNavChange: function(e) { + // 处理用户的登录校验 + this.setData({ pageIndex: Number(e.currentTarget.dataset.tab) }) + this.onResume() + }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - var pageView = this.selectComponent('#' + this.data.TabList[this.data.pageIndex].value) - if (pageView) { - pageView.onRestart() + if(this.data.inited){ + this.onResume() } }, onEvent: function (message) { @@ -77,11 +118,5 @@ Page({ }, stopTouchMove: function(e){ return false - }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - event.remove('EventMessage', this) } }) diff --git a/pages/login/index.js b/pages/login/index.js index 1c4914c..e4c1262 100644 --- a/pages/login/index.js +++ b/pages/login/index.js @@ -3,6 +3,7 @@ import { $wuxCountDown } from '../../components/index' const storage = require('../../utils/storage') const request = require('../../utils/request') //导入模块 const util = require('../../utils/util') +const event = require('../../utils/event') const app = getApp() Page({ @@ -26,7 +27,6 @@ Page({ version15: false, path: null }, - onLoad: function (options) { if (options.mobile) { this.setData({ ['form.mobile']: options.mobile }) @@ -86,63 +86,6 @@ Page({ this.wxLogin() } }, - onReady: function () { - wx.getSystemInfo({ - success: e => { - app.globalData.isIPhoneX = this.checkIPhoneX(e) - app.globalData.isIos = this.checkIos(e) - app.globalData.dev = e.platform == 'devtools' - - let custom = wx.getMenuButtonBoundingClientRect() - app.globalData.Custom = custom - // 顶部操作栏高度 - app.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight + (app.globalData.isIos ? 4 : 0) - let windowHeight = e.windowHeight * (750 / e.windowWidth) - - let safeBottom = e.windowHeight - e.safeArea.bottom - if(safeBottom > e.windowHeight){ - safeBottom = 34 - } - app.globalData.safeBottom = safeBottom * (750 / e.windowWidth) - // 状态栏高度 - app.globalData.StatusBar = e.statusBarHeight * (750 / e.windowWidth) - let statusBarHeight = app.globalData.CustomBar * (750 / e.windowWidth) - app.globalData.statusBarHeight = statusBarHeight - // fragmentHeight:指的是整个页面statusBarHeight以下的高度 - app.globalData.fragmentHeight = windowHeight - statusBarHeight - app.globalData.safeFragmentHeight = windowHeight - statusBarHeight - app.globalData.safeBottom - app.globalData.windowWidth = e.windowWidth - this.saveDevInfo() - this.checkLogin() - app.inited = true - } - }) - }, - saveDevInfo: function(){ - var devIno = { Custom: app.globalData.Custom, CustomBar: app.globalData.CustomBar } - devIno.statusBarHeight = app.globalData.statusBarHeight - devIno.fragmentHeight = app.globalData.fragmentHeight - devIno.safeFragmentHeight = app.globalData.safeFragmentHeight - devIno.safeBottom = app.globalData.safeBottom - devIno.windowWidth = app.globalData.windowWidth - devIno.isIPhoneX = app.globalData.isIPhoneX - devIno.isIos = app.globalData.isIos - devIno.dev = app.globalData.dev - storage.put('ztbdev', JSON.stringify(devIno)) - }, - checkIos: function (e) { - if ('ios' === e.platform) { - return true - } - if (e.system.startsWith('iOS')) { - return true - } - return false - }, - checkIPhoneX: function (e) { - var t = e.model - return (/iPhone 11/.test(t) || /iPhone X/.test(t) || /iPhone 12/.test(t)) && this.checkIos(e) - }, changePwd: function () { if (this.data.pwdType === 'password') { this.setData({ pwdType: 'text' }) @@ -150,7 +93,6 @@ Page({ this.setData({ pwdType: 'password' }) } }, - bindInput: function (e) { this.data.form[e.target.id] = e.detail.value if ('account' == e.target.id) { @@ -172,7 +114,6 @@ Page({ this.setData({ loginEnable: true }) } }, - loginForm: function () { if (!(/^1\d{10}$/.test(this.data.form.account)) || this.data.form.account.length < 11) { util.showToast('请输入11位手机号码') @@ -216,31 +157,9 @@ Page({ app.globalData.userToken = result.data.userToken } app.globalData.userInfo = result.data - if(this.data.path){ - wx.redirectTo({ url: this.data.path }) - } else if (this.data.version15 == 15) { - wx.hideLoading() - wx.redirectTo({ url: '/pages/paper/index' }) - } else if(util.isEmpty(app.globalData.userToken)){ - wx.hideLoading() - wx.redirectTo({ url: '/pages/index/index' }) - } else { - // /receive/v150/get/OrderExists 判断该用户是否有订单存在 1存在 2不存在 - request.get('/saas-trade/receive/v150/get/OrderExists').then(result => { - wx.hideLoading() - if (Number(result.data) != 1 || !app.release) { - wx.redirectTo({ url: '/pages/index/index' }) - } else { - wx.redirectTo({ url: '/pages/paper/index' }) - } - }).catch(err => { - //异常回调 - wx.hideLoading() - wx.redirectTo({ url: '/pages/index/index' }) - }) - } + event.emit('EventMessage', { what: 888, desc: 'Logined' }) + wx.navigateBack() }, - changeType: function () { if (this.data.type == 1) { this.setData({ type: 0, ['form.captcha']: null, loginEnable: true }) @@ -248,7 +167,6 @@ Page({ this.setData({ type: 1, ['form.password']: null, loginEnable: true }) } }, - fetchCode: function (e) { if (!(/^1\d{10}$/.test(this.data.form.account)) || this.data.form.account.length < 11) { util.showToast('请输入11位手机号码') @@ -276,7 +194,6 @@ Page({ util.showToast(error) }) }, - onGotPhoneNumber: function (e) { request.phoneWechat(e.detail).then(result => { this.setData({ ['form.account']: result.data.phoneNumber, mobileEnable: true }) diff --git a/pages/login/index.wxml b/pages/login/index.wxml index e5e2418..4397ce4 100644 --- a/pages/login/index.wxml +++ b/pages/login/index.wxml @@ -1,5 +1,9 @@ - + + 登录 + + + diff --git a/pages/mall/index/index.js b/pages/mall/index/index.js index 15c3e3f..3319651 100644 --- a/pages/mall/index/index.js +++ b/pages/mall/index/index.js @@ -1,6 +1,7 @@ // pages/message/index.js const request = require('../../../utils/request') //导入模块 const event = require('../../../utils/event') +const util = require('../../../utils/util') const app = getApp() Component({ @@ -15,6 +16,7 @@ Component({ height: app.globalData.safeFragmentHeight - 100, kg: app.globalData.kg, stickyTop: app.globalData.CustomBar, + firstShow: false, scrollTop: 0, fixed: false, toView: null, @@ -42,9 +44,7 @@ Component({ lifetimes: { // 生命周期函数,可以为函数,或一个在methods段中定义的方法名 attached: function () { - this.setData({ height: app.globalData.safeFragmentHeight - 100, kg: app.globalData.kg, stickyTop: app.globalData.CustomBar }) event.on('EventMessage', this, this.onEvent) - this.onRefreshList() }, detached: function () { event.remove('EventMessage', this) @@ -52,6 +52,16 @@ Component({ }, methods: { onRestart: function () { + if(!this.data.firstShow){ + this.setData({ + height: app.globalData.safeFragmentHeight - 100, + kg: app.globalData.kg, + stickyTop: app.globalData.CustomBar, + firstShow: true + }) + this.onRefreshList() + } + this.data.firstShow = true if(!this.data.noticeList.length){ this.fetchBannerList() } @@ -81,72 +91,70 @@ Component({ tapBanner: function(e){ var item = this.data.bannerList[e.currentTarget.dataset.index] if(item.redirectInfo.targetView == 'showH5'){ - wx.navigateTo({ url: '/pages/html/html/index?link=' + item.redirectInfo.params.id + '?title=' + item.title}) + util.navigateTo('/pages/html/html/index?link=' + item.redirectInfo.params.id + '?title=' + item.title) } else if(item.redirectInfo.targetView == 'showImage'){ - wx.navigateTo({ url: '/pages/html/banner/index?src=' + item.redirectInfo.params.id}) + util.navigateTo('/pages/html/banner/index?src=' + item.redirectInfo.params.id) } if(item.redirectInfo.targetView == 'showBidList'){ - wx.navigateTo({ url: '/pages/goods/ablility/index' }) + util.navigateTo('/pages/goods/ablility/index') } else if(item.redirectInfo.targetView == 'showProxyList'){ // wx.navigateTo({ url: '/pages/goods/ablility/index' }) } else if(item.redirectInfo.targetView == 'showQNPrice'){ - wx.navigateTo({ url: '/pages/mall/price-index/index' }) + util.navigateTo('/pages/mall/price-index/index') } else if(item.redirectInfo.targetView == 'showFactoryPrice'){ - wx.navigateTo({ url: '/pages/article/price-detail/index' }) - } else if(item.redirectInfo.targetView == 'showFactoryQueue'){ - wx.navigateTo({ url: '/pages/article/queue-detail/index' }) + util.navigateTo('/pages/article/price-detail/index') } else if(item.redirectInfo.targetView == 'showFactoryQueue'){ - wx.navigateTo({ url: '/pages/article/queue-detail/index' }) + util.navigateTo('/pages/article/queue-detail/index') } else if(item.redirectInfo.targetView == 'showArticleHome'){ // 情报首页 event.emit('EventMessage', { what: 250, desc: 'page-article', index: 0 }) } else if(item.redirectInfo.targetView == 'myArticle'){ - wx.navigateTo({ url: '/pages/article/list/index' }) + util.navigateTo('/pages/article/list/index') } else if(item.redirectInfo.targetView == 'myMessage'){ - wx.navigateTo({ url: '/pages/message/index/index' }) + util.navigateTo('/pages/message/index/index') } else if(item.redirectInfo.targetView == 'member'){ - wx.navigateTo({ url: '/pages/ztbvip/index' }) + util.navigateTo('/pages/ztbvip/index') } else if(item.redirectInfo.targetView == 'showPurchaseList'){ - wx.navigateTo({ url: '/pages/purchase/ablility/index' }) + util.navigateTo('/pages/purchase/ablility/index') } else if(item.redirectInfo.targetView == 'showProductList'){ - wx.navigateTo({ url: '/pages/goods/ablility/index?type=1' }) + util.navigateTo('/pages/goods/ablility/index?type=1') } else if(item.redirectInfo.targetView == 'logistics'){ - wx.navigateTo({ url: '/pages/html/logistics/index' }) + util.navigateTo('/pages/html/logistics/index') } else if(item.redirectInfo.targetView == 'contract'){ - wx.navigateTo({ url: '/pages/home/service/index' }) + util.navigateTo('/pages/home/service/index') } else if(item.redirectInfo.targetView == 'myAddress'){ - wx.navigateTo({ url: '/pages/adress/list/index' }) + util.navigateTo('/pages/adress/list/index') } else if(item.redirectInfo.targetView == 'myBankCard'){ - wx.navigateTo({ url: '/pages/bank/vindex/index' }) + util.navigateTo('/pages/bank/vindex/index') } else if(item.redirectInfo.targetView == 'personalBillDetail'){ - wx.navigateTo({ url: '/pages/bank/bill/index' }) + util.navigateTo('/pages/bank/bill/index') } else if(item.redirectInfo.targetView == 'myScore'){ - wx.navigateTo({ url: '/pages/html/integral/index' }) + util.navigateTo('/pages/html/integral/index') } else if(item.redirectInfo.targetView == 'myBalance'){ - wx.navigateTo({ url: '/pages/withdrawal/balance/index' }) + util.navigateTo('/pages/withdrawal/balance/index') } else if(item.redirectInfo.targetView == 'myProxyList'){ - wx.navigateTo({ url: '/pages/agent/order/index' }) + util.navigateTo('/pages/agent/order/index') } else if(item.redirectInfo.targetView == 'myBidList'){ - wx.navigateTo({ url: '/pages/bidding/index/index' }) + util.navigateTo('/pages/bidding/index/index') } else if(item.redirectInfo.targetView == 'myShop'){ - wx.navigateTo({ url: '/pages/shop/index/index' }) + util.navigateTo('/pages/shop/index/index') } }, onGridTap: function(e){ var index = e.currentTarget.dataset.index if (index === 0) { - wx.navigateTo({ url: '/pages/goods/ablility/index' }) + util.navigateTo('/pages/goods/ablility/index') } else if (index === 1) { - wx.navigateTo({ url: '/pages/purchase/ability/index' }) + util.navigateTo('/pages/purchase/ability/index') } else if (index === 2) { - wx.navigateTo({ url: '/pages/agent/index/index' }) + util.navigateTo('/pages/agent/index/index') } else if (index === 3) { - wx.navigateTo({ url: '/pages/mall/price-index/index' }) + util.navigateTo('/pages/mall/price-index/index') } else if (index === 4) { - wx.navigateTo({ url: '/pages/article/price-detail/index' }) + util.navigateTo('/pages/article/price-detail/index') } else if (index === 5) { - wx.navigateTo({ url: '/pages/article/queue-detail/index' }) + util.navigateTo('/pages/article/queue-detail/index') } }, onTabChange: function({detail}){ diff --git a/pages/mall/index/index.wxml b/pages/mall/index/index.wxml index 56aa58a..22333d6 100644 --- a/pages/mall/index/index.wxml +++ b/pages/mall/index/index.wxml @@ -4,18 +4,18 @@ 交易 - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/pages/ztbvip/index.js b/pages/ztbvip/index.js index 63ce9ae..6324c09 100644 --- a/pages/ztbvip/index.js +++ b/pages/ztbvip/index.js @@ -28,15 +28,13 @@ Page({ }) this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog') }, - - /** - * 生命周期函数--监听页面显示 - */ onShow: function () { this.fetchUserInfo() }, - fetchUserInfo: function () { + if(!app.globalData.userInfo){ + return + } wx.showLoading({ title: '处理中', mask: true }) // /user/userInfo 获取用户信息 request.get('/recycle-service/user/get/base-info').then(result => { @@ -59,7 +57,7 @@ Page({ }, toAuthor: function(){ if(!this.data.userInfo.isAuth){ - wx.navigateTo({ url: '/pages/home/idcard/index' }) + util.navigateTo('/pages/home/idcard/index') } }, /** diff --git a/utils/request.js b/utils/request.js index f1c0ebb..97a5896 100644 --- a/utils/request.js +++ b/utils/request.js @@ -58,7 +58,7 @@ function fun(url, method, data, header) { showCancel: false, success: function (res) { if (res.confirm) { - wx.reLaunch({ url: '/pages/login/index' }) + wx.navigateTo({ url: '/pages/login/index' }) } }, complete: function(){ diff --git a/utils/util.js b/utils/util.js index 76179ae..8282917 100644 --- a/utils/util.js +++ b/utils/util.js @@ -1,3 +1,5 @@ +const app = getApp() + const formatTime = date => { const year = date.getFullYear() const month = date.getMonth() + 1 @@ -167,6 +169,38 @@ function checkId(id) { } } +const tokenList = [ + 'pages/mall/price-index/index', + '/pages/article/price-detail/index', + '/pages/article/queue-detail/index', + '/pages/article/detail/index', + '/pages/shop/index/index', + '/pages/bidding/index/index', + '/pages/morder/index/index', + '/pages/message/index/index', + '/pages/home/setting/index', + '/pages/adress/list/index', + '/pages/article/list/index', + '/pages/html/integral/index', + '/pages/withdrawal/balance/index', + '/pages/agent/order/index', + '/pages/home/idcard/index' +] + +function navigateTo(url){ + var white = false + for (let index = 0; index < tokenList.length; index++) { + if(url.indexOf(tokenList[index]) != -1){ + white = true + break + } + } + if(white && !app.globalData.userInfo){ + wx.navigateTo({ url: '/pages/login/index' }) + return + } + wx.navigateTo({ url }) +} module.exports = { isEmpty: isEmpty, @@ -180,5 +214,6 @@ module.exports = { playDing: playDing, showBackToast: showBackToast, checkPhone: checkPhone, - checkId: checkId + checkId: checkId, + navigateTo: navigateTo } \ No newline at end of file