123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- import {
- ApiModel
- } from "../utils/api";
- const _Http = new ApiModel();
- Component({
- /**
- * 组件的属性列表
- */
- properties: {},
- lifetimes: {
- attached() {
- this.unReadMessageCount();
- },
- ready: function () {
- // 在组件实例进入页面节点树时执行
- if (this.data.active == 3) this.unReadMessageCount();
- },
- },
- /**
- * 组件的初始数据
- */
- data: {
- active: 0,
- tabbarList: [{
- icon: '/static/tabbar-icon/home.png',
- iconA: '/static/tabbar-icon/home-a.png',
- text: '首页',
- url: '/pages/tabbar-pages/home/index'
- },
- {
- icon: '/static/tabbar-icon/service.png',
- iconA: '/static/tabbar-icon/service-a.png',
- text: '在线客服',
- url: '/pages/tabbar-pages/customer-service-staff/index'
- },
- {
- icon: '/static/tabbar-icon/bazaar.png',
- iconA: '/static/tabbar-icon/bazaar-a.png',
- text: '供需广场',
- url: '/pages/tabbar-pages/supplyAndDemand/index'
- },
- {
- icon: '/static/tabbar-icon/message.png',
- iconA: '/static/tabbar-icon/message-a.png',
- text: '消息',
- url: '/pages/tabbar-pages/message/index',
- fcount: ""
- },
- {
- icon: '/static/tabbar-icon/user.png',
- iconA: '/static/tabbar-icon/user-a.png',
- text: '我的',
- url: '/pages/tabbar-pages/user/index'
- }
- ],
- show: false,
- phoneNumber: "17757394388"
- },
- /**
- * 组件的方法列表
- */
- methods: {
- /* tabbar */
- onChange(event) {
- if (event.target.dataset.index == 1) return this.setData({
- show: true
- })
- this.setData({
- active: event.target.dataset.index
- });
- wx.switchTab({
- url: this.data.tabbarList[event.target.dataset.index].url
- });
- },
- init() {
- const page = getCurrentPages().pop();
- this.setData({
- active: this.data.tabbarList.findIndex(item => item.url === `/${page.route}`)
- });
- },
- /* 呼叫电话 */
- CallOut() {
- wx.makePhoneCall({
- phoneNumber: this.data.phoneNumber
- }).catch((e) => {
- console.log(123)
- })
- },
- onClose() {
- this.setData({
- show: false
- })
- },
- /* 获取未阅读消息数量查询 */
- unReadMessageCount() {
- _Http.basic({
- "accesstoken": wx.getStorageSync('userData').token,
- "classname": "system.message.Message",
- "method": "unReadMessageCount",
- "content": {}
- }).then(res => {
- console.log("更新", res)
- if (res.msg != '成功') console.log('未读消息数量查询失败')
- this.setData({
- "tabbarList[3].fcount": res.data[0].fcount
- })
- })
- }
- }
- })
|