Showing
8 changed files
with
132 additions
and
76 deletions
| 1 | // components/book/tabBar/tabBar.js | 1 | // components/book/tabBar/tabBar.js |
| 2 | import util from '../../../utils/util' | 2 | import util from '../../../utils/util' |
| 3 | +import App from '../../../utils/api'; | ||
| 4 | +const {regeneratorRuntime} = global | ||
| 3 | Component({ | 5 | Component({ |
| 4 | /** | 6 | /** |
| 5 | * 组件的属性列表 | 7 | * 组件的属性列表 |
| 6 | */ | 8 | */ |
| 7 | - properties: { | ||
| 8 | - | ||
| 9 | - }, | 9 | + properties: {}, |
| 10 | 10 | ||
| 11 | /** | 11 | /** |
| 12 | * 组件的初始数据 | 12 | * 组件的初始数据 |
| 13 | */ | 13 | */ |
| 14 | data: { | 14 | data: { |
| 15 | - pi:0, | 15 | + pi: 0, |
| 16 | + dot:0, | ||
| 17 | + }, | ||
| 18 | + attached(){ | ||
| 19 | + let pages = getCurrentPages(); | ||
| 20 | + let p = pages[pages.length - 1]; | ||
| 21 | + let pi = ['/pages/book/b_addnew', '/pages/book/b_index', '/pages/book/b_setting', '/pages/book/setting/index']; | ||
| 22 | + for (let x in pi) { | ||
| 23 | + console.log('tabBar', pi[x], p); | ||
| 24 | + if (pi[x].indexOf(p.route) > -1) { | ||
| 25 | + this.setData({ | ||
| 26 | + pi: x | ||
| 27 | + }) | ||
| 28 | + break; | ||
| 29 | + } | ||
| 30 | + } | ||
| 31 | + }, | ||
| 32 | + ready(){ | ||
| 33 | + this.hasDot() | ||
| 16 | }, | 34 | }, |
| 17 | - attached(){ | ||
| 18 | - let pages=getCurrentPages(); | ||
| 19 | - let p=pages[pages.length-1]; | ||
| 20 | - let pi=['/pages/book/b_addnew','/pages/book/b_index','/pages/book/b_setting','/pages/book/setting/index']; | ||
| 21 | - for(let x in pi){ | ||
| 22 | - console.log('tabBar',pi[x],p); | ||
| 23 | - if(pi[x].indexOf(p.route)>-1){ | ||
| 24 | - this.setData({ | ||
| 25 | - pi:x | ||
| 26 | - }) | ||
| 27 | - break; | ||
| 28 | - } | ||
| 29 | - } | ||
| 30 | - }, | ||
| 31 | /** | 35 | /** |
| 32 | * 组件的方法列表 | 36 | * 组件的方法列表 |
| 33 | */ | 37 | */ |
| 34 | methods: { | 38 | methods: { |
| 35 | - redirectTo(e){ | ||
| 36 | - let url=util.attr(e,'url'); | ||
| 37 | - let pages=getCurrentPages(); | ||
| 38 | - let p=pages[pages.length-1]; | ||
| 39 | - if(url.indexOf(p.route)<0){ | ||
| 40 | - wx.redirectTo({ | ||
| 41 | - url:url, | ||
| 42 | - }) | ||
| 43 | - } | 39 | + redirectTo(e){ |
| 40 | + let url = util.attr(e, 'url'); | ||
| 41 | + let pages = getCurrentPages(); | ||
| 42 | + let p = pages[pages.length - 1]; | ||
| 43 | + if (url.indexOf(p.route) < 0) { | ||
| 44 | + wx.redirectTo({ | ||
| 45 | + url: url, | ||
| 46 | + }) | ||
| 44 | } | 47 | } |
| 48 | + }, | ||
| 49 | + hasDot(){ | ||
| 50 | + App.Reserve.GetNewCustomerTotal().then(res => { | ||
| 51 | + let dot=res.data.total||0 | ||
| 52 | + this.setData({ | ||
| 53 | + dot:dot | ||
| 54 | + }) | ||
| 55 | + this.triggerEvent('NewCustomer',{total:dot}) | ||
| 56 | + }); | ||
| 57 | + } | ||
| 45 | } | 58 | } |
| 46 | }) | 59 | }) |
| @@ -20,7 +20,9 @@ | @@ -20,7 +20,9 @@ | ||
| 20 | </formids> | 20 | </formids> |
| 21 | <formids class="item flex-vc" bindtap="redirectTo" data-url="/pages/book/setting/index"> | 21 | <formids class="item flex-vc" bindtap="redirectTo" data-url="/pages/book/setting/index"> |
| 22 | <view class="flex-vc {{pi==3?'checked':''}}"> | 22 | <view class="flex-vc {{pi==3?'checked':''}}"> |
| 23 | - <view class="icon setting"></view> | 23 | + <view class="icon setting"> |
| 24 | + <view class="dot" wx:if="{{dot>0}}"></view> | ||
| 25 | + </view> | ||
| 24 | <view class="text">设置</view> | 26 | <view class="text">设置</view> |
| 25 | </view> | 27 | </view> |
| 26 | </formids> | 28 | </formids> |
| @@ -17,11 +17,21 @@ | @@ -17,11 +17,21 @@ | ||
| 17 | .tabBar .item{ | 17 | .tabBar .item{ |
| 18 | width: 25%; | 18 | width: 25%; |
| 19 | } | 19 | } |
| 20 | +.dot{ | ||
| 21 | + position: absolute; | ||
| 22 | + width: 16rpx; | ||
| 23 | + height: 16rpx; | ||
| 24 | + background-color: #F05522; | ||
| 25 | + border-radius: 50%; | ||
| 26 | + right:-14rpx; | ||
| 27 | + top:-8rpx; | ||
| 28 | +} | ||
| 20 | .tabBar .icon{ | 29 | .tabBar .icon{ |
| 21 | width: 48rpx; | 30 | width: 48rpx; |
| 22 | height: 48rpx; | 31 | height: 48rpx; |
| 23 | margin-bottom: 10rpx; | 32 | margin-bottom: 10rpx; |
| 24 | background-size: 100%; | 33 | background-size: 100%; |
| 34 | + position: relative; | ||
| 25 | } | 35 | } |
| 26 | .tabBar .icon image{ | 36 | .tabBar .icon image{ |
| 27 | width: 100%; | 37 | width: 100%; |
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | import util from '../../../utils/util'; | 2 | import util from '../../../utils/util'; |
| 3 | import App from '../../../utils/api'; | 3 | import App from '../../../utils/api'; |
| 4 | const {regeneratorRuntime} = global | 4 | const {regeneratorRuntime} = global |
| 5 | +import PubSub from '../../../utils/PubSub' | ||
| 5 | Page({ | 6 | Page({ |
| 6 | offset: 0, | 7 | offset: 0, |
| 7 | limit: 10, | 8 | limit: 10, |
| @@ -29,6 +30,7 @@ Page({ | @@ -29,6 +30,7 @@ Page({ | ||
| 29 | }) | 30 | }) |
| 30 | this.seller_id=options.seller_id||this.enter_params.seller_id; | 31 | this.seller_id=options.seller_id||this.enter_params.seller_id; |
| 31 | this.getMembers(); | 32 | this.getMembers(); |
| 33 | + App.Reserve.GetNewCustomerTotal({},'clean'); | ||
| 32 | }, | 34 | }, |
| 33 | 35 | ||
| 34 | /** | 36 | /** |
| @@ -51,6 +53,12 @@ Page({ | @@ -51,6 +53,12 @@ Page({ | ||
| 51 | onHide: function () { | 53 | onHide: function () { |
| 52 | 54 | ||
| 53 | }, | 55 | }, |
| 56 | + onUnload(){ | ||
| 57 | + PubSub.emit( | ||
| 58 | + 'flushNewCustomer', | ||
| 59 | + [] | ||
| 60 | + ) | ||
| 61 | + }, | ||
| 54 | /** | 62 | /** |
| 55 | * 页面上拉触底事件的处理函数 | 63 | * 页面上拉触底事件的处理函数 |
| 56 | */ | 64 | */ |
| @@ -2,61 +2,74 @@ | @@ -2,61 +2,74 @@ | ||
| 2 | import util from '../../../utils/util'; | 2 | import util from '../../../utils/util'; |
| 3 | import App from '../../../utils/api'; | 3 | import App from '../../../utils/api'; |
| 4 | const {regeneratorRuntime} = global | 4 | const {regeneratorRuntime} = global |
| 5 | +import PubSub from '../../../utils/PubSub' | ||
| 5 | Page({ | 6 | Page({ |
| 6 | 7 | ||
| 7 | - /** | ||
| 8 | - * 页面的初始数据 | ||
| 9 | - */ | ||
| 10 | - data: { | 8 | + /** |
| 9 | + * 页面的初始数据 | ||
| 10 | + */ | ||
| 11 | + data: { | ||
| 12 | + NewCustomerTotal:0, | ||
| 13 | + }, | ||
| 11 | 14 | ||
| 12 | - }, | ||
| 13 | - | ||
| 14 | - /** | ||
| 15 | - * 生命周期函数--监听页面加载 | ||
| 16 | - */ | ||
| 17 | - enter_params:{}, | ||
| 18 | - onLoad: function (options) { | ||
| 19 | - this.enter_params=util.cache('enter_params'); | ||
| 20 | - App.Reserve.SellerInfo(this.enter_params).then(res=>{ | ||
| 21 | - this.setData({ | ||
| 22 | - seller:res.data.seller, | ||
| 23 | - user:res.data.seller_user | ||
| 24 | - }) | 15 | + /** |
| 16 | + * 生命周期函数--监听页面加载 | ||
| 17 | + */ | ||
| 18 | + enter_params: {}, | ||
| 19 | + onLoad: function (options) { | ||
| 20 | + this.enter_params = util.cache('enter_params'); | ||
| 21 | + App.Reserve.SellerInfo(this.enter_params).then(res => { | ||
| 22 | + this.setData({ | ||
| 23 | + seller: res.data.seller, | ||
| 24 | + user: res.data.seller_user | ||
| 25 | }) | 25 | }) |
| 26 | - }, | 26 | + }) |
| 27 | + PubSub.on( | ||
| 28 | + 'flushNewCustomer', | ||
| 29 | + data=>{ | ||
| 30 | + console.log('flushNewCustomer',data) | ||
| 31 | + this.selectComponent('#tabBar').hasDot(); | ||
| 32 | + } | ||
| 33 | + ) | ||
| 34 | + }, | ||
| 27 | 35 | ||
| 28 | - /** | ||
| 29 | - * 生命周期函数--监听页面初次渲染完成 | ||
| 30 | - */ | ||
| 31 | - onReady: function () { | 36 | + /** |
| 37 | + * 生命周期函数--监听页面初次渲染完成 | ||
| 38 | + */ | ||
| 39 | + onReady: function () { | ||
| 32 | 40 | ||
| 33 | - }, | 41 | + }, |
| 34 | 42 | ||
| 35 | - /** | ||
| 36 | - * 生命周期函数--监听页面显示 | ||
| 37 | - */ | ||
| 38 | - onShow: function () { | ||
| 39 | - App.Reserve.SmsInfo({seller_id:this.enter_params.seller_id}).then(res=>{ | ||
| 40 | - if(res.ret==404){ | ||
| 41 | - res.data={ | ||
| 42 | - last_num:100, | ||
| 43 | - meals:[ | ||
| 44 | - {id:1,total:550,price_ave:0.09,price_old:50,price:50,discount:0}, | ||
| 45 | - {id:2,total:1200,price_ave:0.083,price_old:100,price:100,discount:0}, | ||
| 46 | - {id:3,total:3650,price_ave:0.082,price_old:328,price:300,discount:9.1}, | ||
| 47 | - ], | ||
| 48 | - }; | ||
| 49 | - } | ||
| 50 | - this.setData({ | ||
| 51 | - sms:res.data, | ||
| 52 | - }) | 43 | + /** |
| 44 | + * 生命周期函数--监听页面显示 | ||
| 45 | + */ | ||
| 46 | + onShow: function () { | ||
| 47 | + App.Reserve.SmsInfo({seller_id: this.enter_params.seller_id}).then(res => { | ||
| 48 | + if (res.ret == 404) { | ||
| 49 | + res.data = { | ||
| 50 | + last_num: 100, | ||
| 51 | + meals: [ | ||
| 52 | + {id: 1, total: 550, price_ave: 0.09, price_old: 50, price: 50, discount: 0}, | ||
| 53 | + {id: 2, total: 1200, price_ave: 0.083, price_old: 100, price: 100, discount: 0}, | ||
| 54 | + {id: 3, total: 3650, price_ave: 0.082, price_old: 328, price: 300, discount: 9.1}, | ||
| 55 | + ], | ||
| 56 | + }; | ||
| 57 | + } | ||
| 58 | + this.setData({ | ||
| 59 | + sms: res.data, | ||
| 53 | }) | 60 | }) |
| 54 | - }, | 61 | + }) |
| 62 | + }, | ||
| 55 | 63 | ||
| 56 | - /** | ||
| 57 | - * 生命周期函数--监听页面隐藏 | ||
| 58 | - */ | ||
| 59 | - onHide: function () { | 64 | + /** |
| 65 | + * 生命周期函数--监听页面隐藏 | ||
| 66 | + */ | ||
| 67 | + onHide: function () { | ||
| 60 | 68 | ||
| 61 | - }, | 69 | + }, |
| 70 | + NewCustomer(e){ | ||
| 71 | + this.setData({ | ||
| 72 | + NewCustomerTotal:e.detail.total | ||
| 73 | + }) | ||
| 74 | + } | ||
| 62 | }) | 75 | }) |
| @@ -28,6 +28,7 @@ | @@ -28,6 +28,7 @@ | ||
| 28 | <view class="row flex-lr" style="padding-top: 34rpx;"> | 28 | <view class="row flex-lr" style="padding-top: 34rpx;"> |
| 29 | <view>我的客户</view> | 29 | <view>我的客户</view> |
| 30 | <view class="flex-rr"> | 30 | <view class="flex-rr"> |
| 31 | + <text class="right" wx:if="{{NewCustomerTotal>0}}" style="color: #F05522;">新增{{NewCustomerTotal}}位</text> | ||
| 31 | <view class="more"></view> | 32 | <view class="more"></view> |
| 32 | </view> | 33 | </view> |
| 33 | </view> | 34 | </view> |
| @@ -57,4 +58,4 @@ | @@ -57,4 +58,4 @@ | ||
| 57 | </view> | 58 | </view> |
| 58 | </formids> | 59 | </formids> |
| 59 | </view> | 60 | </view> |
| 60 | -<tabBar></tabBar> | 61 | +<tabBar bindNewCustomer="NewCustomer" id="tabBar"></tabBar> |
| @@ -32,11 +32,14 @@ http://qn.colorcun.com/custom/lite-yd/image/icon-cz.png | @@ -32,11 +32,14 @@ http://qn.colorcun.com/custom/lite-yd/image/icon-cz.png | ||
| 32 | .row{ | 32 | .row{ |
| 33 | font-size: 34rpx; | 33 | font-size: 34rpx; |
| 34 | height: 106rpx; | 34 | height: 106rpx; |
| 35 | + line-height: 106rpx; | ||
| 35 | border-bottom: 2rpx solid #F1F0F4; | 36 | border-bottom: 2rpx solid #F1F0F4; |
| 36 | } | 37 | } |
| 37 | .row .right{ | 38 | .row .right{ |
| 38 | font-size: 30rpx; | 39 | font-size: 30rpx; |
| 39 | color:#999999; | 40 | color:#999999; |
| 41 | + height: 42rpx; | ||
| 42 | + line-height: 42rpx; | ||
| 40 | } | 43 | } |
| 41 | .row .more{ | 44 | .row .more{ |
| 42 | margin-left: 20rpx; | 45 | margin-left: 20rpx; |
| @@ -235,4 +235,10 @@ export default { | @@ -235,4 +235,10 @@ export default { | ||
| 235 | 235 | ||
| 236 | //上传图片,只能上传单个图片文件 | 236 | //上传图片,只能上传单个图片文件 |
| 237 | 'App.Examples_Upload.UploadQn':null, | 237 | 'App.Examples_Upload.UploadQn':null, |
| 238 | + | ||
| 239 | + //获得客户经理新顾客数 | ||
| 240 | + 'App.Reserve.GetNewCustomerTotal':{ | ||
| 241 | + openid:'openid', | ||
| 242 | + cachetime: 60, | ||
| 243 | + }, | ||
| 238 | } | 244 | } |
-
Please register or login to post a comment