diff --git a/App.vue b/App.vue index 6523090..87d5562 100644 --- a/App.vue +++ b/App.vue @@ -20,7 +20,7 @@ // #endif }, onShow: function() { - if(uni.getStorageSync('phone_active')){ + if(uni.getStorageSync('token')){ // 刷新token this.$toolAll.tools.refreshToken(); } diff --git a/components/dates/yy-mm-dd-hh-ss.vue b/components/dates/yy-mm-dd-hh-ss.vue new file mode 100644 index 0000000..eab00e0 --- /dev/null +++ b/components/dates/yy-mm-dd-hh-ss.vue @@ -0,0 +1,295 @@ + + + + + diff --git a/components/list/list-one.vue b/components/list/list-one.vue deleted file mode 100644 index 1eb8ed7..0000000 --- a/components/list/list-one.vue +++ /dev/null @@ -1,75 +0,0 @@ - - - - - diff --git a/components/list/list-two.vue b/components/list/list-two.vue deleted file mode 100644 index 7e24653..0000000 --- a/components/list/list-two.vue +++ /dev/null @@ -1,163 +0,0 @@ - - - - - diff --git a/components/lw-notice/iconFont.vue b/components/lw-notice/iconFont.vue deleted file mode 100644 index 2a9093d..0000000 --- a/components/lw-notice/iconFont.vue +++ /dev/null @@ -1,61 +0,0 @@ - - - - - diff --git a/components/lw-notice/icons.js b/components/lw-notice/icons.js deleted file mode 100644 index 67e17e3..0000000 --- a/components/lw-notice/icons.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - 'aixin':'\ue8ab', - 'rules':'\ue909', - 'sound':'\ue8ea', - 'arrowright':'\uee02' -} diff --git a/components/lw-notice/lw-notice.vue b/components/lw-notice/lw-notice.vue deleted file mode 100644 index 3e15a24..0000000 --- a/components/lw-notice/lw-notice.vue +++ /dev/null @@ -1,373 +0,0 @@ - - - - - diff --git a/components/notices/notice-one/notice-one.vue b/components/notices/notice-one/notice-one.vue new file mode 100644 index 0000000..e0cb02c --- /dev/null +++ b/components/notices/notice-one/notice-one.vue @@ -0,0 +1,292 @@ + + + + + diff --git a/components/notices/notice-one/readme.md b/components/notices/notice-one/readme.md new file mode 100644 index 0000000..0b1af96 --- /dev/null +++ b/components/notices/notice-one/readme.md @@ -0,0 +1,75 @@ +### 安装方式 + +本组件符合[easycom](https://uniapp.dcloud.io/collocation/pages?id=easycom)规范,`HBuilderX 2.5.5`起,只需将本组件导入项目,在页面`template`中即可直接使用,无需在页面中`import`和注册`components`。 + +### 说明 +由于官方公告组件uni-notice-bar没有垂直滚动的功能, 所以利用swiper加入了垂直滚动, 加入了常用主题色, 可以自己去添加, 需要用到uni-icons + +```html + + +``` + +```javascript + export default { + data() { + return { + list:[{id:1,title:'公告1'},{id:2,title:'公告2'}] + list2:[{id:1,name:'公告3'},{id:2,name:'公告4'}] + } + }, + methods: { + goItem(item){ + uni.showToast({ + title:'你点击的公告id是'+item.id, + icon:'none' + }) + }, + goMore(){ + uni.showToast({ + title:'点击更多', + icon:'none' + }) + } + } + } +``` + + + +## API + +### Tag Props + +|属性名 |类型 |默认值 |说明 | +|:-: |:-: |:-: |:-: | +|list |Array | |公告数组 | +|theme |String |default |主题 | +|showIcon |Boolean |true |是否显示左侧icon | +|showMore |Boolean |true |是否显示更多 | +|theKey |String |title |公告数组的键名 | +|direction |String |column |滚动的方向 | + + +### Tag Events + +|事件称名 |说明 |返回值 | +|:-: |:-: |:-: | +|@goItem |点击公告 |- | +|@goMore |点击更多 |- | + diff --git a/components/notices/notice-one/uni-icons/icons.js b/components/notices/notice-one/uni-icons/icons.js new file mode 100644 index 0000000..60b7332 --- /dev/null +++ b/components/notices/notice-one/uni-icons/icons.js @@ -0,0 +1,132 @@ +export default { + "pulldown": "\ue588", + "refreshempty": "\ue461", + "back": "\ue471", + "forward": "\ue470", + "more": "\ue507", + "more-filled": "\ue537", + "scan": "\ue612", + "qq": "\ue264", + "weibo": "\ue260", + "weixin": "\ue261", + "pengyouquan": "\ue262", + "loop": "\ue565", + "refresh": "\ue407", + "refresh-filled": "\ue437", + "arrowthindown": "\ue585", + "arrowthinleft": "\ue586", + "arrowthinright": "\ue587", + "arrowthinup": "\ue584", + "undo-filled": "\ue7d6", + "undo": "\ue406", + "redo": "\ue405", + "redo-filled": "\ue7d9", + "bars": "\ue563", + "chatboxes": "\ue203", + "camera": "\ue301", + "chatboxes-filled": "\ue233", + "camera-filled": "\ue7ef", + "cart-filled": "\ue7f4", + "cart": "\ue7f5", + "checkbox-filled": "\ue442", + "checkbox": "\ue7fa", + "arrowleft": "\ue582", + "arrowdown": "\ue581", + "arrowright": "\ue583", + "smallcircle-filled": "\ue801", + "arrowup": "\ue580", + "circle": "\ue411", + "eye-filled": "\ue568", + "eye-slash-filled": "\ue822", + "eye-slash": "\ue823", + "eye": "\ue824", + "flag-filled": "\ue825", + "flag": "\ue508", + "gear-filled": "\ue532", + "reload": "\ue462", + "gear": "\ue502", + "hand-thumbsdown-filled": "\ue83b", + "hand-thumbsdown": "\ue83c", + "hand-thumbsup-filled": "\ue83d", + "heart-filled": "\ue83e", + "hand-thumbsup": "\ue83f", + "heart": "\ue840", + "home": "\ue500", + "info": "\ue504", + "home-filled": "\ue530", + "info-filled": "\ue534", + "circle-filled": "\ue441", + "chat-filled": "\ue847", + "chat": "\ue263", + "mail-open-filled": "\ue84d", + "email-filled": "\ue231", + "mail-open": "\ue84e", + "email": "\ue201", + "checkmarkempty": "\ue472", + "list": "\ue562", + "locked-filled": "\ue856", + "locked": "\ue506", + "map-filled": "\ue85c", + "map-pin": "\ue85e", + "map-pin-ellipse": "\ue864", + "map": "\ue364", + "minus-filled": "\ue440", + "mic-filled": "\ue332", + "minus": "\ue410", + "micoff": "\ue360", + "mic": "\ue302", + "clear": "\ue434", + "smallcircle": "\ue868", + "close": "\ue404", + "closeempty": "\ue460", + "paperclip": "\ue567", + "paperplane": "\ue503", + "paperplane-filled": "\ue86e", + "person-filled": "\ue131", + "contact-filled": "\ue130", + "person": "\ue101", + "contact": "\ue100", + "images-filled": "\ue87a", + "phone": "\ue200", + "images": "\ue87b", + "image": "\ue363", + "image-filled": "\ue877", + "location-filled": "\ue333", + "location": "\ue303", + "plus-filled": "\ue439", + "plus": "\ue409", + "plusempty": "\ue468", + "help-filled": "\ue535", + "help": "\ue505", + "navigate-filled": "\ue884", + "navigate": "\ue501", + "mic-slash-filled": "\ue892", + "search": "\ue466", + "settings": "\ue560", + "sound": "\ue590", + "sound-filled": "\ue8a1", + "spinner-cycle": "\ue465", + "download-filled": "\ue8a4", + "personadd-filled": "\ue132", + "videocam-filled": "\ue8af", + "personadd": "\ue102", + "upload": "\ue402", + "upload-filled": "\ue8b1", + "starhalf": "\ue463", + "star-filled": "\ue438", + "star": "\ue408", + "trash": "\ue401", + "phone-filled": "\ue230", + "compose": "\ue400", + "videocam": "\ue300", + "trash-filled": "\ue8dc", + "download": "\ue403", + "chatbubble-filled": "\ue232", + "chatbubble": "\ue202", + "cloud-download": "\ue8e4", + "cloud-upload-filled": "\ue8e5", + "cloud-upload": "\ue8e6", + "cloud-download-filled": "\ue8e9", + "headphones":"\ue8bf", + "shop":"\ue609" +} diff --git a/components/notices/notice-one/uni-icons/uni-icons.vue b/components/notices/notice-one/uni-icons/uni-icons.vue new file mode 100644 index 0000000..333cc78 --- /dev/null +++ b/components/notices/notice-one/uni-icons/uni-icons.vue @@ -0,0 +1,52 @@ + + + + + diff --git a/components/notices/notice-one/uni-icons/uni.ttf b/components/notices/notice-one/uni-icons/uni.ttf new file mode 100644 index 0000000..60a1968 Binary files /dev/null and b/components/notices/notice-one/uni-icons/uni.ttf differ diff --git a/components/rate.vue b/components/rates/rate-one.vue similarity index 100% rename from components/rate.vue rename to components/rates/rate-one.vue diff --git a/components/shareAll.vue b/components/shareAll.vue deleted file mode 100644 index 7cbd813..0000000 --- a/components/shareAll.vue +++ /dev/null @@ -1,42 +0,0 @@ - - - - - diff --git a/components/status-nav.vue b/components/status-nav.vue deleted file mode 100644 index b0ed12c..0000000 --- a/components/status-nav.vue +++ /dev/null @@ -1,188 +0,0 @@ - - - - - diff --git a/jsFile/tools.js b/jsFile/tools.js index 531362d..2f5df27 100644 --- a/jsFile/tools.js +++ b/jsFile/tools.js @@ -1,6 +1,6 @@ +const app = getApp(); const tools = { timer:'', - timerNot:'', // 埋点倒计时 daoTime(){ let daoTime = uni.getStorageSync('daoTime') @@ -9,13 +9,10 @@ const tools = { daoTime = uni.getStorageSync('daoTime') this.timer = setInterval(()=>{ uni.setStorageSync('daoTime',daoTime--)//设置倒计时 - // console.log('埋点倒计时初次:',daoTime); - // console.log('埋点长度初次:',uni.getStorageSync('maiList').length); if(uni.getStorageSync('daoTime')<=0 || uni.getStorageSync('maiList').length==5){ uni.removeStorageSync('daoTime')//清空倒计时 clearInterval(this.timer)//关闭倒计时 // console.log('上/报,埋点'); - // reportBuriedPoint(uni.getStorageSync('maiList'))//上报事件 uni.removeStorageSync('maiList')//清空上报参数 this.daoTime()//重新倒计时 } @@ -23,13 +20,10 @@ const tools = { } else {//继续当前倒计时倒计 this.timer = setInterval(()=>{ uni.setStorageSync('daoTime',daoTime--)//设置倒计时 - // console.log('埋点倒计时:',daoTime); - // console.log('埋点长度:',uni.getStorageSync('maiList').length); if(uni.getStorageSync('daoTime')<=0 || uni.getStorageSync('maiList').length==5){ uni.removeStorageSync('daoTime')//清空倒计时 clearInterval(this.timer)//关闭倒计时 // console.log('上报,埋点'); - // reportBuriedPoint(uni.getStorageSync('maiList'))//上报事件 uni.removeStorageSync('maiList')//清空上报参数 this.daoTime()//重新倒计时 } @@ -39,15 +33,6 @@ const tools = { closeTimer(){ clearInterval(this.timer)//关闭倒计时 console.log('倒计时清空了'); - clearInterval(this.timerNot)//关闭倒计时 - }, - maiDian(data){//埋点事件 - let maiList = uni.getStorageSync('maiList') - // console.log(maiList); - if(maiList==''){ - maiList = [data] - } else maiList.push(data) - uni.setStorageSync('maiList',maiList) }, weekDate(){//获取未来七天星期几,几号 let date = new Date() @@ -63,10 +48,6 @@ const tools = { isPhone:function(phone){ // 手机号正则表达式 let reg_tel = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/; - // if(!reg_tel.test(phone)){ - // return true - // } - // return false return !reg_tel.test(phone); }, // 电子邮箱验证 @@ -83,6 +64,21 @@ const tools = { hideMPhone(phone){ return `${phone.substr(0, 3)}****${phone.substr(7)}` }, + // 手机号中间加字符 + phoneAddChat(phone,startNum=3,endNum=7,character=' '){ + let phoneStr = phone; + phoneStr = phoneStr.replace(/\s*/g, ""); + var phoneArr = []; + for(var i = 0; i < phoneStr.length; i++){ + if (i==startNum||i==endNum){ + phoneArr.push(`${character}` + phoneStr.charAt(i)); + } else { + phoneArr.push(phoneStr.charAt(i)); + } + } + phone = phoneArr.join(""); + return phone; + }, // 昵称从第一个字开始,后面的都用"*"代替 hideName(name,num){ return `${name.substr(0, 1)}****${name.substr(name.length-1)}` @@ -113,7 +109,7 @@ const tools = { str = str.toFixed(2); str = str+''; } - return str.includes('.') ? str*1 : str = num + '.00'; + return str.includes('.') ? str : str = num + '.00'; }, // type:+加、-减、*乘、/除 // len:小数后保留几位 @@ -229,6 +225,65 @@ const tools = { // console.log(time2);//1398250549123 // console.log(time3);//1398250549000 }, + // 返回当前时间 + returnCurrentTime(format,type) { + let date = new Date(); + let year = date.getFullYear(); // 年 + let month = date.getMonth() + 1; // 月 + let day = date.getDate(); // 日 + let time = date.getHours(); // 时 + let minu = date.getSeconds(); // 分 + let second = date.getMinutes(); // 秒 + + let newTime = ''; + switch (type){ + case 0: + newTime = `${year}${format}${month < 10? '0' + month : month}${format}${day < 10 ? '0' + day : day} ${time < 10 ? '0' + time : time}:${minu < 10 ? '0' + minu : minu}`; // 2022-03-31 16:05 + break; + case 1: + newTime = `${year}${format}${month < 10? '0' + month : month}${format}${day < 10 ? '0' + day : day} ${time < 10 ? '0' + time : time}:${minu < 10 ? '0' + minu : minu}:${second < 10 ? '0' + second : second}`; // 2022-03-31 16:10:07 + break; + } + return newTime; + }, + // 返回时间xx天xx小时xx分钟 + returnTimeFormat(startTime,endTime){ + console.log(startTime,endTime); + let newTimeFormat = ''; + let currentTimestamp = this.timeToTimestamp(endTime) - this.timeToTimestamp(startTime); + return this.returnTimestampToTime(currentTimestamp); + }, + // 返回时间戳转时、分对象 + returnTimestampToTime(timestamp){ + let timeStr = ''; + var day = parseInt((timestamp % (1000 * 60 * 60 * 24 * 12)) / (1000 * 60 * 60 * 24)); + var hours = parseInt((timestamp % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); + var seconds = parseInt((timestamp % (1000 * 60 * 60)) / (1000 * 60)); + day = day < 10 ? ('0' + day) : day; + hours = hours < 10 ? ('0' + hours) : hours; + seconds = seconds < 10 ? ('0' + seconds) : seconds; + if(day*1==0) { + if(hours*1==0) { + seconds*1==0 ? timeStr = 0 : timeStr = `${seconds}分钟`; + } else { + timeStr = `${hours}小时${seconds}分钟`; + } + } else { + timeStr = `${day}天${hours}小时${seconds}分钟`; + } + return timeStr; + }, + // 时间戳转时分秒 00 : 00 : 00 + formatDuring: function(mss) { + // let dangTime = Math.round(new Date()/1000)//获取当前时间戳 + var hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); + var seconds = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60)); + var minutes = (mss % (1000 * 60)) / 1000; + hours = hours < 10 ? ('0' + hours) : hours; + seconds = seconds < 10 ? ('0' + seconds) : seconds; + minutes = minutes < 10 ? ('0' + minutes) : minutes; + return hours + ' : ' + seconds + ' : ' + minutes; + }, // 随机数生成 randomStr(){ var strData = ""; @@ -268,30 +323,18 @@ const tools = { return newObj }, // 提示方法 - showToast: function(msg, icon,time) { - // 弹框图标:none默认无图标、loading、success - var newIncon = 'none'; - if (icon) {newIncon = icon;} + showToast: function(msg, icon='none',time) { // 弹框显示时间:默认2秒 var newTime = 2000 if (time) {newTime = time;} return uni.showToast({ title: msg, - icon: newIncon, + icon: icon, duration:newTime }) }, - formatDuring: function(mss) { - // let dangTime = Math.round(new Date()/1000)//获取当前时间戳 - var hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); - var minutes = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60)); - var seconds = (mss % (1000 * 60)) / 1000; - hours = hours < 10 ? ('0' + hours) : hours; - minutes = minutes < 10 ? ('0' + minutes) : minutes; - seconds = seconds < 10 && seconds >= 1 ? ('0' + seconds) : seconds; - return hours + ' : ' + minutes + ' : ' + seconds; - }, - escape2Html(str) {//富文本 + // 富文本 + escape2Html(str) { var arrEntities = { 'lt': '<', 'gt': '>', 'nbsp': ' ', 'amp': '&', 'quot': '"' }; return str.replace(/&(lt|gt|nbsp|amp|quot|src);/ig, function (all, t) { return arrEntities[t]; @@ -300,39 +343,10 @@ const tools = { .replace(/\ { - if (res.confirm) { - // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 - updateManager.applyUpdate() - } - } - }) - }) - updateManager.onUpdateFailed(function (res) { - // 新版本下载失败 - // console.log('新版本下载失败:',res); - }) - // #endif - }, - networkStatus(){//检查网络状态 + // 检查网络状态 + networkStatus(){ uni.getNetworkType({ - success: function (res) { + success: (res)=> { console.log('当前网络状态:',res.networkType);//none:当前无网络连接 if(res.networkType=='none'){ uni.setStorageSync('isNet',false) @@ -341,12 +355,84 @@ const tools = { // 微信小程序原生API性能优化 // #ifdef MP-WEIXIN // 连网下,检测小程序是否有更新 - tools.updaX(); + this.checkUpdate(); // #endif } } }); }, + // app、小程序的检测版本并更新 + checkUpdate(){ + // 检测app + // #ifdef APP-PLUS + + // #endif + //检测小程序 + // #ifdef MP-WEIXIN + var self = this; + // 获取小程序更新机制兼容 + if (wx.canIUse('getUpdateManager')) { + const updateManager = wx.getUpdateManager();//1. 检查小程序是否有新版本发布 + updateManager.onCheckForUpdate(function(res) {// 请求完新版本信息的回调 + if (res.hasUpdate) { + //检测到新版本,需要更新,给出提示 + wx.showModal({ + title: '更新提示', + content: '检测到新版本,是否下载新版本并重启小程序?', + success: function(res) { + if (res.confirm) { + //2. 用户确定下载更新小程序,小程序下载及更新静默进行 + self.downLoadAndUpdate(updateManager) + // 清除所有缓存 + uni.clearStorage(); + uni.clearStorageSync(); + } else if (res.cancel) { + //用户点击取消按钮的处理,如果需要强制更新,则给出二次弹窗,如果不需要,则这里的代码都可以删掉了 + wx.showModal({ + title: '温馨提示~', + content: '本次版本更新涉及到新的功能添加,旧版本无法正常访问的哦~', + showCancel:false,//隐藏取消按钮 + confirmText:"确定更新",//只保留确定更新按钮 + success: function(res) { + if (res.confirm) { + //下载新版本,并重新应用 + self.downLoadAndUpdate(updateManager) + } + } + }) + } + } + }) + } + }) + } else { // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示 + wx.showModal({ + title: '提示', + content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。' + }) + } + // #endif + }, + /** + * 下载小程序新版本并重启应用 + * */ + downLoadAndUpdate(updateManager){ + var self = this; + wx.showLoading(); //静默下载更新小程序新版本 + updateManager.onUpdateReady(function () { + wx.hideLoading(); //新的版本已经下载好,调用 applyUpdate 应用新版本并重启 + updateManager.applyUpdate(); + // 清除缓存 + uni.clearStorageSync(); + uni.clearStorage(); + }) + updateManager.onUpdateFailed(function () { // 新的版本下载失败 + wx.showModal({ + title: '已经有新版本了哟~', + content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~', + }) + }) + }, // 文本复制 clickCopy(data){ uni.setClipboardData({ @@ -405,7 +491,7 @@ const tools = { if (res.code) { var params = {code:res.code} uni.request({ - url: `${uni.getStorageSync('hostapi')}/api/user/login`, + url: `${app.globalData.hostapi}/api/user/login`, method: 'post', data: params, header: { @@ -430,16 +516,17 @@ const tools = { } }, // 判断是否授权,没授权,前往登录页面授权 + authTimer:null, judgeAuth(){ - let auth = true; - switch (uni.getStorageSync('phone_active')*1){ - case 0: // 未注册 - uni.navigateTo({url:'/pages/login/login'}); - auth = false - break; - case 1: // 已注册 - auth = true - break; + let auth = false; + clearTimeout(this.authTimer); + if(!uni.getStorageSync('token')) { + this.showToast('请登录'); + this.authTimer = setTimeout(()=>{ + uni.navigateTo({url:'/pages/login/login'}); + },2000) + } else { + auth = true; } return auth; }, @@ -456,13 +543,10 @@ const tools = { // console.log(hInfo.envVersion);//develop:开发版 trial:体验版 release:正式版 // if(hInfo.miniProgram.envVersion == "develop"){ if(hInfo.miniProgram.envVersion == "develop" || hInfo.miniProgram.envVersion == "trial"){ - // (开发版,体验版)-配置全局域名 - // uni.setStorageSync('hostapi','https://hengmei.scdxtc.cn/api/'); + } else { // 清除所有输出日志 console.log = () =>{}; - // 正式版-配置全局域名 - // uni.setStorageSync('hostapi','https://hm.hmzfyy.cn/api/'); // 开启埋点倒计时 this.daoTime();//开启埋点倒计时 } @@ -523,7 +607,7 @@ const tools = { const res = uni.getSystemInfoSync(); if(res.platform=='ios'){ uni.makePhoneCall({ - phoneNumber:phone, + phoneNumber:phone*1, success: () => {}, fail: () => {} }) diff --git a/main.js b/main.js index e8eecc4..d6c7be2 100644 --- a/main.js +++ b/main.js @@ -1,5 +1,7 @@ import Vue from 'vue'; import App from './App'; +import store from './store' +Vue.prototype.$store = store import nothingPage from './components/nothing/nothing-page.vue';//引入无内容组件 Vue.component('nothing-page',nothingPage);//全局注册无内容组件 @@ -10,10 +12,12 @@ Vue.component('status-nav',statusNav);//全局注册头部状态栏与导航栏 import containerSubgroupTwo from './components/containers/container-subgroup-two.vue';//引入头部状态栏与导航栏组件 Vue.component('container-subgroup',containerSubgroupTwo);//全局注册头部状态栏与导航栏组件 +// #ifdef MP-WEIXIN import share from './jsFile/share.js';// 全局注册分享事件 Vue.mixin(share); +// #endif -// 常用工具 +// 常用便捷式公共方法 import tools from '@/jsFile/tools.js'; Vue.prototype.$toolAll = tools; // 响应数据 @@ -23,6 +27,7 @@ Vue.prototype.$requst = requst; App.mpType = 'app'; const app = new Vue({ + store, ...App }) app.$mount() diff --git a/pages/tabbar/pagehome/pagehome.vue b/pages/tabbar/pagehome/pagehome.vue index 60465a1..257ae62 100644 --- a/pages/tabbar/pagehome/pagehome.vue +++ b/pages/tabbar/pagehome/pagehome.vue @@ -48,7 +48,6 @@ - @@ -228,14 +227,13 @@ // 暂无更多组件 import pitera from '@/components/nothing/pitera.vue'; // 公告 - import lwNotice from '@/components/lw-notice/lw-notice.vue'; import footTabOne from '@/components/foot-tabs/foot-tab-one.vue'; import containerSubgroupTwo from '@/components/containers/container-subgroup-two.vue'; + import { mapState,mapGetters,mapMutations } from 'vuex'//引入mapState export default { components:{ pitera, statusNavSlot, - lwNotice, 'foot-tab' :footTabOne, containerSubgroupTwo }, @@ -313,6 +311,62 @@ faultsList:[], } }, + // computed:{ + // tokenEv() { + // return this.$store.state.token; + // } + // }, + // computed:mapState({ + // // 从state中拿到数据 箭头函数可使代码更简练 + // token: state => state.token, + // }), + // computed:mapState(['token']), + // computed: { + // ...mapState({ + // token: function (state) { + // return '追加的' + state.token + // }, + // userInfo: state => state.userInfo, + // }) + // }, + // computed: { + // todos() { + // return this.$store.getters.doneTodos + // } + // }, + // computed: { + // doneTodosCount() { + // return this.$store.getters.doneTodosCount + // } + // }, + // computed: { + // getTodoById() { + // return this.$store.getters.getTodoById(1) + // } + // }, + // computed: { + // // 使用对象展开运算符将 getter 混入 computed 对象中 + // ...mapGetters([ + // 'doneTodos', + // 'doneTodosCount', + // 'getTodoById' + // // ... + // ]) + // }, + // computed:{ + // ...mapState([ + // 'token', + // 'userInfo', + // 'count', + // 'obj' + // ]) + // }, + computed: { + ...mapState({ + token: state => state.moduleA.token, + count: state => state.moduleB.count + }), + }, onLoad(options) { // 获取当前页面url this.$toolAll.tools.obtainUrl(); @@ -322,8 +376,29 @@ // this.getIncrementServiceType(); // 调用获取常见故障列表事件 this.getFaultsList(); + // this.$store.commit('setToken', 'token已改变'); + // this.$store.commit('updateUserInfo',{userInfo:'用户信息'}) + // this.$store.commit({ + // type: 'updateUserInfo', + // userInfo: '新方式更新用户信息' + // }) + // console.log(this.userInfo,374); + // this.add(); + // console.log(this.obj); + // this.$store.commit('newProp',{c:'吃火锅'}) + // console.log(this.obj,382); + // this.$store.dispatch('addCountAction') + // this.$store.dispatch('addCountAction2',{amount:10}) + // this.$store.dispatch('addCountAction3',{amount:30}) + // setTimeout(()=>{ + // console.log(this.count,388); + // },3000) + // console.log(this.count,390); + console.log(this.token,397); + console.log(this.count,398); }, methods: { + // ...mapMutations(['add']),//对象展开运算符直接拿到add // 工单跳转 goWorkOrder(index){ if(index==0){ diff --git a/pages/tabbar/project-list/project-list.vue b/pages/tabbar/project-list/project-list.vue index b693514..fef511d 100644 --- a/pages/tabbar/project-list/project-list.vue +++ b/pages/tabbar/project-list/project-list.vue @@ -1,16 +1,19 @@