From 43efe480c8e369784564bc8df6493a206c4dc3fd Mon Sep 17 00:00:00 2001 From: xpz2018 <107107461@qq.com> Date: Thu, 23 Sep 2021 09:50:52 +0800 Subject: [PATCH] no message --- pages/home/city-select/index.js | 8 +++++- pages/home/city-select/index.wxml | 11 ++++++-- pages/index/index.js | 45 +++++++++++++------------------ pages/mall/fragment/index.js | 17 +++++++++--- pages/mall/fragment/index.json | 1 + pages/mall/fragment/index.wxml | 12 ++++++--- 6 files changed, 57 insertions(+), 37 deletions(-) diff --git a/pages/home/city-select/index.js b/pages/home/city-select/index.js index b720f94..aee6a23 100644 --- a/pages/home/city-select/index.js +++ b/pages/home/city-select/index.js @@ -13,6 +13,7 @@ Page({ data: { value: '', height: app.globalData.fragmentHeight - 100, + nowCity: null,//当前定位城市 localCity: null,//当前定位城市 hotCity: [], // 热门城市 lists:[],//城市列表 @@ -39,11 +40,15 @@ Page({ if(app.nowLocation && !util.isEmpty(app.nowLocation.cityName)){ localCity = app.nowLocation.cityName } + var nowCity = null + if(app.nowCity){ + nowCity = app.nowCity.cityName + } var hotstring = storage.get('ztb-hot-list') if(!util.isEmpty(hotstring)){ hotList = JSON.parse(hotstring) } - this.setData({ height, itemHeight, indexHeight: this.data.indexHeight, titleHeight, localCity, lists: city.list, hotCity: hotList }) + this.setData({ height, itemHeight, indexHeight: this.data.indexHeight, titleHeight, localCity, nowCity, lists: city.list, hotCity: hotList }) }, getInputValue(e){ this.setData({ value:e.detail.value },()=>{ @@ -122,6 +127,7 @@ Page({ hotList.push(item) storage.put('ztb-hot-list', JSON.stringify(hotList)) } + storage.put('ztb-now-city', JSON.stringify(app.nowCity)) event.emit('EventMessage', { what: 444, desc: 'nowLocation' }) wx.navigateBack() } diff --git a/pages/home/city-select/index.wxml b/pages/home/city-select/index.wxml index 70e0152..d8bc76e 100644 --- a/pages/home/city-select/index.wxml +++ b/pages/home/city-select/index.wxml @@ -14,8 +14,15 @@ - - 定位城市:{{localCity}} + + + 当前城市: + {{nowCity || '暂无'}} + + + 定位城市: + {{localCity || '暂无定位城市'}} + diff --git a/pages/index/index.js b/pages/index/index.js index 8886331..ffb3f50 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -41,6 +41,11 @@ Page({ this.data.path += '?' + options.key + '=' + options.value } } + var citystring = storage.get('ztb-now-city') + if(!util.isEmpty(citystring)){ + app.nowCity = JSON.parse(citystring) + this.data.cityName = app.nowCity.cityName + } var min = new Date() min.setHours(0, 0, 0) var maxDate = util.formatDate(min, 'Y-M-D') @@ -51,7 +56,7 @@ Page({ this.data.inited = true wx.showLoading({ title: '加载中', mask: true }) const fheght = (app.globalData.safeFragmentHeight + app.globalData.statusBarHeight) - 100 - this.setData({ fragment: fheght, safeBottom: app.globalData.safeBottom, maxDate, minDate, calendar }) + this.setData({ fragment: fheght, safeBottom: app.globalData.safeBottom, maxDate, minDate, calendar, cityName: this.data.cityName }) var authorization = app.globalData.token || storage.get('Authorization') if (authorization) { app.globalData.token = authorization @@ -137,36 +142,24 @@ Page({ this.wuxDialog.open({ resetOnClose: true, title: '温馨提示', - content: '小程序没有定位权限,无法进行送餐服务,请前往设置微信小程序的定位权限。', + content: '小程序没有定位权限,无法提供准确的纸厂报价和相关信息服务,请前往设置微信小程序的定位权限。', buttons: [{ text: '前往设置', type: 'primary', onTap(e) { wx.openSetting({ success(result){ - if(result && (result.authSetting["scope.userLocation"] !== undefined && result.authSetting["scope.userLocation"] ===true)){ + if(result && (result.authSetting["scope.userLocation"] !== undefined && result.authSetting["scope.userLocation"] === true)){ // 成功设置 that.locationing() } else { - that.detectSettings() + // that.detectSettings() } } }) } }] }) - Dialog.alert({ title: '温馨提示', message: '小程序没有定位权限,无法进行送餐服务,请前往设置微信小程序的定位权限。', confirmButtonText: '前往设置' }).then(() => { - wx.openSetting({ - success(result){ - if(result && (result.authSetting["scope.userLocation"] !== undefined && result.authSetting["scope.userLocation"] ===true)){ - // 成功设置 - that.locationing() - } else { - that.detectSettings() - } - } - }) - }) }, toIndex: function () { this.fetchRegionList() @@ -219,7 +212,7 @@ Page({ this.onResume() } // 如果定位完成,但是还是没有获取城市信息,那么就要进行城市选择 - if(this.located && util.isEmpty(this.data.cityName)){ + if(this.located && util.isEmpty(app.nowCity)){ wx.navigateTo({url: `/pages/home/city-select/index?type=1` }) } if(app.globalData.userInfo && !app.globalData.userInfo.identityTag){ @@ -290,16 +283,16 @@ Page({ if(!util.isEmpty(e.currentTarget.dataset.index)){ var item = this.data.cityList[e.currentTarget.dataset.index] var flag = false - for (let index = 0; index < this.data.cityList.length; index++) { - if(this.data.cityList[index].cityId == item.cityId){ - flag = true - break + for (let index = 0; index < this.data.cityList.length; index++) { + if(this.data.cityList[index].cityId == item.cityId){ + flag = true + break + } + } + if(!flag){ + hotList.push(item) + storage.put('ztb-hot-list', JSON.stringify(hotList)) } - } - if(!flag){ - hotList.push(item) - storage.put('ztb-hot-list', JSON.stringify(hotList)) - } } }, onUnload: function(){ diff --git a/pages/mall/fragment/index.js b/pages/mall/fragment/index.js index 349ca82..adddd90 100644 --- a/pages/mall/fragment/index.js +++ b/pages/mall/fragment/index.js @@ -1,5 +1,5 @@ // pages/message/index.js -import { getFactoryPrice, getBannerList } from "../../../api/ztb" +import { getMessageNumber, getBannerList } from "../../../api/ztb" import { getCategoryType, getPreferList, getMomentList } from "../../../api/moment" const event = require('../../../utils/event') const storage = require('../../../utils/storage') @@ -40,6 +40,7 @@ Component({ {sort: 5, text: '排队降序'} ], sortIndex: 0, + messageNumber: 0 }, lifetimes: { // 生命周期函数,可以为函数,或一个在methods段中定义的方法名 @@ -70,10 +71,10 @@ Component({ tabList.push(typeList[index].categoryName) } form.categoryId = typeList[0].categoryId - console.log(form) this.setData({ tabList }) this.fetchAgentList() }) + this.initLogin() } this.data.firstShow = true var bannerstring = storage.get('ztb-banner-list') @@ -90,12 +91,19 @@ Component({ onEvent: function (message) { console.log('mall>>fragment>>onEvent', message) if(message.what == 888){ - this.fetchAgentList() + this.initLogin() } else if(message.what == 444){ this.setData({ cityName: app.nowCity.cityName }) this.fetchAgentList() } }, + initLogin: function(){ + if(app.globalData.userInfo){ + getMessageNumber().then(result => { + this.setData({ messageNumber: result.data.messageNumber + result.data.notificationNumber }) + }) + } + }, searchList: function(){ wx.navigateTo({url: `/pages/mall/search-list/index` }) }, @@ -116,6 +124,8 @@ Component({ util.navigateTo('/pages/article/index/index') } else if(e.currentTarget.id == 'city'){ wx.navigateTo({url: `/pages/home/city-select/index?type=1` }) + } else if(e.currentTarget.id == 'message'){ + util.navigateTo('/pages/message/index/index') } }, tapBanner: function(e){ @@ -154,7 +164,6 @@ Component({ } this.setData({ requesting: true, orderList: [] }) getMomentList(form).then(result => { - console.log(result) if (result.data.records.length) { this.setData({ orderList: result.data.records, requesting: false }) } else { diff --git a/pages/mall/fragment/index.json b/pages/mall/fragment/index.json index d1f6b8c..e49db14 100644 --- a/pages/mall/fragment/index.json +++ b/pages/mall/fragment/index.json @@ -7,6 +7,7 @@ "wux-skeleton-paragraph": "/components/skeleton-paragraph/index", "bubble-popup": "/components/bubble-popup/index", "wux-image": "/components/image/index", + "wux-badge": "/components/badge/index", "refresh-view": "/components/refresher/index", "wux-sticky": "/components/sticky/index", "wux-divider": "/components/divider/index", diff --git a/pages/mall/fragment/index.wxml b/pages/mall/fragment/index.wxml index bd07d26..50946a4 100644 --- a/pages/mall/fragment/index.wxml +++ b/pages/mall/fragment/index.wxml @@ -2,16 +2,20 @@ - + {{cityName}} - 输入纸名/品名/纸厂/规格 + 搜索 + + + + @@ -30,11 +34,11 @@ - - + +