Browse Source

no message

featrue/v4.5
xpz2018 4 years ago
parent
commit
43efe480c8
6 changed files with 57 additions and 37 deletions
  1. 8
      pages/home/city-select/index.js
  2. 11
      pages/home/city-select/index.wxml
  3. 45
      pages/index/index.js
  4. 17
      pages/mall/fragment/index.js
  5. 1
      pages/mall/fragment/index.json
  6. 12
      pages/mall/fragment/index.wxml

8
pages/home/city-select/index.js

@ -13,6 +13,7 @@ Page({
data: { data: {
value: '', value: '',
height: app.globalData.fragmentHeight - 100, height: app.globalData.fragmentHeight - 100,
nowCity: null,//当前定位城市
localCity: null,//当前定位城市 localCity: null,//当前定位城市
hotCity: [], // 热门城市 hotCity: [], // 热门城市
lists:[],//城市列表 lists:[],//城市列表
@ -39,11 +40,15 @@ Page({
if(app.nowLocation && !util.isEmpty(app.nowLocation.cityName)){ if(app.nowLocation && !util.isEmpty(app.nowLocation.cityName)){
localCity = app.nowLocation.cityName localCity = app.nowLocation.cityName
} }
var nowCity = null
if(app.nowCity){
nowCity = app.nowCity.cityName
}
var hotstring = storage.get('ztb-hot-list') var hotstring = storage.get('ztb-hot-list')
if(!util.isEmpty(hotstring)){ if(!util.isEmpty(hotstring)){
hotList = JSON.parse(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){ getInputValue(e){
this.setData({ value:e.detail.value },()=>{ this.setData({ value:e.detail.value },()=>{
@ -122,6 +127,7 @@ Page({
hotList.push(item) hotList.push(item)
storage.put('ztb-hot-list', JSON.stringify(hotList)) storage.put('ztb-hot-list', JSON.stringify(hotList))
} }
storage.put('ztb-now-city', JSON.stringify(app.nowCity))
event.emit('EventMessage', { what: 444, desc: 'nowLocation' }) event.emit('EventMessage', { what: 444, desc: 'nowLocation' })
wx.navigateBack() wx.navigateBack()
} }

11
pages/home/city-select/index.wxml

@ -14,8 +14,15 @@
</view> </view>
</view> </view>
<view wx:else> <view wx:else>
<view class="bg-white" style="padding: 8rpx 32rpx 16rpx 32rpx;" wx:if="{{localCity}}">
<view class="text-gray text-df">定位城市:{{localCity}}</view>
<view class="bg-white flex flex-justify" style="padding: 8rpx 72rpx 16rpx 32rpx;">
<view class="text-df">
<text class="text-gray">当前城市:</text>
<text class="text-blue">{{nowCity || '暂无'}}</text>
</view>
<view class="text-df">
<text class="text-gray">定位城市:</text>
<text class="text-black">{{localCity || '暂无定位城市'}}</text>
</view>
</view> </view>
<!-- 热门城市 --> <!-- 热门城市 -->
<view wx:if="{{hotCity.length}}"> <view wx:if="{{hotCity.length}}">

45
pages/index/index.js

@ -41,6 +41,11 @@ Page({
this.data.path += '?' + options.key + '=' + options.value 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() var min = new Date()
min.setHours(0, 0, 0) min.setHours(0, 0, 0)
var maxDate = util.formatDate(min, 'Y-M-D') var maxDate = util.formatDate(min, 'Y-M-D')
@ -51,7 +56,7 @@ Page({
this.data.inited = true this.data.inited = true
wx.showLoading({ title: '加载中', mask: true }) wx.showLoading({ title: '加载中', mask: true })
const fheght = (app.globalData.safeFragmentHeight + app.globalData.statusBarHeight) - 100 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') var authorization = app.globalData.token || storage.get('Authorization')
if (authorization) { if (authorization) {
app.globalData.token = authorization app.globalData.token = authorization
@ -137,36 +142,24 @@ Page({
this.wuxDialog.open({ this.wuxDialog.open({
resetOnClose: true, resetOnClose: true,
title: '温馨提示', title: '温馨提示',
content: '小程序没有定位权限,无法进行送餐服务,请前往设置微信小程序的定位权限。',
content: '小程序没有定位权限,无法提供准确的纸厂报价和相关信息服务,请前往设置微信小程序的定位权限。',
buttons: [{ buttons: [{
text: '前往设置', text: '前往设置',
type: 'primary', type: 'primary',
onTap(e) { onTap(e) {
wx.openSetting({ wx.openSetting({
success(result){ 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() that.locationing()
} else { } 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 () { toIndex: function () {
this.fetchRegionList() this.fetchRegionList()
@ -219,7 +212,7 @@ Page({
this.onResume() 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` }) wx.navigateTo({url: `/pages/home/city-select/index?type=1` })
} }
if(app.globalData.userInfo && !app.globalData.userInfo.identityTag){ if(app.globalData.userInfo && !app.globalData.userInfo.identityTag){
@ -290,16 +283,16 @@ Page({
if(!util.isEmpty(e.currentTarget.dataset.index)){ if(!util.isEmpty(e.currentTarget.dataset.index)){
var item = this.data.cityList[e.currentTarget.dataset.index] var item = this.data.cityList[e.currentTarget.dataset.index]
var flag = false 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(){ onUnload: function(){

17
pages/mall/fragment/index.js

@ -1,5 +1,5 @@
// pages/message/index.js // pages/message/index.js
import { getFactoryPrice, getBannerList } from "../../../api/ztb"
import { getMessageNumber, getBannerList } from "../../../api/ztb"
import { getCategoryType, getPreferList, getMomentList } from "../../../api/moment" import { getCategoryType, getPreferList, getMomentList } from "../../../api/moment"
const event = require('../../../utils/event') const event = require('../../../utils/event')
const storage = require('../../../utils/storage') const storage = require('../../../utils/storage')
@ -40,6 +40,7 @@ Component({
{sort: 5, text: '排队降序'} {sort: 5, text: '排队降序'}
], ],
sortIndex: 0, sortIndex: 0,
messageNumber: 0
}, },
lifetimes: { lifetimes: {
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名 // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
@ -70,10 +71,10 @@ Component({
tabList.push(typeList[index].categoryName) tabList.push(typeList[index].categoryName)
} }
form.categoryId = typeList[0].categoryId form.categoryId = typeList[0].categoryId
console.log(form)
this.setData({ tabList }) this.setData({ tabList })
this.fetchAgentList() this.fetchAgentList()
}) })
this.initLogin()
} }
this.data.firstShow = true this.data.firstShow = true
var bannerstring = storage.get('ztb-banner-list') var bannerstring = storage.get('ztb-banner-list')
@ -90,12 +91,19 @@ Component({
onEvent: function (message) { onEvent: function (message) {
console.log('mall>>fragment>>onEvent', message) console.log('mall>>fragment>>onEvent', message)
if(message.what == 888){ if(message.what == 888){
this.fetchAgentList()
this.initLogin()
} else if(message.what == 444){ } else if(message.what == 444){
this.setData({ cityName: app.nowCity.cityName }) this.setData({ cityName: app.nowCity.cityName })
this.fetchAgentList() this.fetchAgentList()
} }
}, },
initLogin: function(){
if(app.globalData.userInfo){
getMessageNumber().then(result => {
this.setData({ messageNumber: result.data.messageNumber + result.data.notificationNumber })
})
}
},
searchList: function(){ searchList: function(){
wx.navigateTo({url: `/pages/mall/search-list/index` }) wx.navigateTo({url: `/pages/mall/search-list/index` })
}, },
@ -116,6 +124,8 @@ Component({
util.navigateTo('/pages/article/index/index') util.navigateTo('/pages/article/index/index')
} else if(e.currentTarget.id == 'city'){ } else if(e.currentTarget.id == 'city'){
wx.navigateTo({url: `/pages/home/city-select/index?type=1` }) 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){ tapBanner: function(e){
@ -154,7 +164,6 @@ Component({
} }
this.setData({ requesting: true, orderList: [] }) this.setData({ requesting: true, orderList: [] })
getMomentList(form).then(result => { getMomentList(form).then(result => {
console.log(result)
if (result.data.records.length) { if (result.data.records.length) {
this.setData({ orderList: result.data.records, requesting: false }) this.setData({ orderList: result.data.records, requesting: false })
} else { } else {

1
pages/mall/fragment/index.json

@ -7,6 +7,7 @@
"wux-skeleton-paragraph": "/components/skeleton-paragraph/index", "wux-skeleton-paragraph": "/components/skeleton-paragraph/index",
"bubble-popup": "/components/bubble-popup/index", "bubble-popup": "/components/bubble-popup/index",
"wux-image": "/components/image/index", "wux-image": "/components/image/index",
"wux-badge": "/components/badge/index",
"refresh-view": "/components/refresher/index", "refresh-view": "/components/refresher/index",
"wux-sticky": "/components/sticky/index", "wux-sticky": "/components/sticky/index",
"wux-divider": "/components/divider/index", "wux-divider": "/components/divider/index",

12
pages/mall/fragment/index.wxml

@ -2,16 +2,20 @@
<wxs module="formate" src="../../../pages/formate.wxs"></wxs> <wxs module="formate" src="../../../pages/formate.wxs"></wxs>
<view class="cu-custom top-bg" style="height:{{customHeight}}rpx;z-index: 1;"> <view class="cu-custom top-bg" style="height:{{customHeight}}rpx;z-index: 1;">
<view class="cu-bar fixed " style="height:{{customHeight}}rpx;padding-top:{{StatusBar}}rpx;border-bottom:none"> <view class="cu-bar fixed " style="height:{{customHeight}}rpx;padding-top:{{StatusBar}}rpx;border-bottom:none">
<view class="flex flex-center" style="margin-left: 32rpx;width: 100%;">
<view class="flex flex-center" style="margin-left: 32rpx;width: 100%;flex: 1;">
<view id="city" class="flex flex-center" catchtap="gridTap"> <view id="city" class="flex flex-center" catchtap="gridTap">
<text class="text-white text-lg">{{cityName}}</text> <text class="text-white text-lg">{{cityName}}</text>
<text class="cuIcon-unfold text-white" style="font-size:16px;padding-top: 8rpx;margin-left: 8rpx;"></text> <text class="cuIcon-unfold text-white" style="font-size:16px;padding-top: 8rpx;margin-left: 8rpx;"></text>
</view> </view>
<view class="bg-white flex flex-center" style="margin-left:24rpx;flex: 1;border-radius: 16rpx;height: 60rpx;" catchtap="searchList"> <view class="bg-white flex flex-center" style="margin-left:24rpx;flex: 1;border-radius: 16rpx;height: 60rpx;" catchtap="searchList">
<image src="/assets/image/icon-search.png" style="height: 30rpx;width: 30rpx;margin-left: 16rpx"></image> <image src="/assets/image/icon-search.png" style="height: 30rpx;width: 30rpx;margin-left: 16rpx"></image>
<text class="text-gray text-sm" style="flex: 1;margin-left: 8rpx">输入纸名/品名/纸厂/规格</text>
<text class="text-gray text-sm" style="flex: 1;margin-left: 8rpx">搜索</text>
</view> </view>
</view> </view>
<view class="flex flex-center" style="margin-left: 24rpx;" id="message" bindtap="gridTap">
<image style="height: 40rpx;width: 40rpx;" src="/assets/myinfo/messageWhite.png"></image>
<wux-badge count="{{messageNumber}}" top="-40" right="4"></wux-badge>
</view>
</view> </view>
</view> </view>
<view class="top-bg" style="height: 24rpx;"></view> <view class="top-bg" style="height: 24rpx;"></view>
@ -30,11 +34,11 @@
<view class="flex" style="margin-top:16rpx"> <view class="flex" style="margin-top:16rpx">
<wux-image id="agent" width="{{294}}" height="{{180}}" wux-class="banner" nuit="{{'rpx'}}" src="https://636c-cloud1-1gjilu3e74c1a18a-1305669442.tcb.qcloud.la/icon-agent-home.png?sign=13c5b73d0a6f70fc5d24eca83cd2058f&t=1631672631" mode="aspectFill" bind:click="gridTap"> <wux-image id="agent" width="{{294}}" height="{{180}}" wux-class="banner" nuit="{{'rpx'}}" src="https://636c-cloud1-1gjilu3e74c1a18a-1305669442.tcb.qcloud.la/icon-agent-home.png?sign=13c5b73d0a6f70fc5d24eca83cd2058f&t=1631672631" mode="aspectFill" bind:click="gridTap">
</wux-image>
<wux-image id="trans" width="{{180}}" height="{{180}}" wux-class="banner-left" nuit="{{'rpx'}}" src="https://636c-cloud1-1gjilu3e74c1a18a-1305669442.tcb.qcloud.la/icon-home-trans.png?sign=211460d49ef2a32c508e89d1dbcad541&t=1631672735" mode="aspectFill" bind:click="gridTap">
</wux-image> </wux-image>
<wux-image id="action" width="{{180}}" height="{{180}}" wux-class="banner-left" nuit="{{'rpx'}}" src="https://636c-cloud1-1gjilu3e74c1a18a-1305669442.tcb.qcloud.la/icon-home-active.png?sign=ba47bd3bf9387c3e298d06774a184a81&t=1631672761" mode="aspectFill" bind:click="gridTap"> <wux-image id="action" width="{{180}}" height="{{180}}" wux-class="banner-left" nuit="{{'rpx'}}" src="https://636c-cloud1-1gjilu3e74c1a18a-1305669442.tcb.qcloud.la/icon-home-active.png?sign=ba47bd3bf9387c3e298d06774a184a81&t=1631672761" mode="aspectFill" bind:click="gridTap">
</wux-image> </wux-image>
<wux-image id="trans" width="{{180}}" height="{{180}}" wux-class="banner-left" nuit="{{'rpx'}}" src="https://636c-cloud1-1gjilu3e74c1a18a-1305669442.tcb.qcloud.la/icon-home-trans.png?sign=211460d49ef2a32c508e89d1dbcad541&t=1631672735" mode="aspectFill" bind:click="gridTap">
</wux-image>
</view> </view>
<view class="bg-white" style="margin-top:16rpx;border-radius: 24rpx;"> <view class="bg-white" style="margin-top:16rpx;border-radius: 24rpx;">

Loading…
Cancel
Save