import $store from '@/store' export default { msg, getCall, getTime, getDate, NewsPtype, GetDateStr, } function NewsPtype(con) { //1小程序,2H5,3内练,4文本 if (con.ptype == 1) { uni.navigateToMiniProgram({ appId: con.appid, path: con.content, extraData: {}, }) return } if (con.ptype == 3) { uni.navigateTo({ url: con.content }) return } if (con.ptype == 4 || con.ptype == 2) { uni.navigateTo({ url: "/pageTwo/news/detail?id=" + con.id + "&type=" + con.type }) return } } function getCall(authlist, num) { console.log("authlist", authlist,) if (!authlist.length) { $store.commit("changeSecratary", true); } else { authlist.forEach(ite => { if (ite.code.indexOf('phone:show') != -1) { console.log("包含") uni.makePhoneCall({ phoneNumber: num //仅为示例 }).catch((e) => { console.log(e) //用catch(e)来捕获错误{makePhoneCall:fail cancel} }); } else { console.log("不包含") $store.commit("changeSecratary", true); } }) } } function msg(str) { uni.showToast({ title: str, duration: 3000, icon: 'none' }) } function getDate(type) { const date = new Date(); let year = date.getFullYear(); let month = date.getMonth() + 1; let day = date.getDate(); month = month > 9 ? month : '0' + month;; day = day > 9 ? day : '0' + day; if (type === 'start') { year = year; return `${year}-${month}-${day}`; } if (type === 'end') { year = year + 7; return `${year}-${month}-${day}`; } if (type === 'month') { return month + '月' + day + '日' } } function GetDateStr(AddDayCount) { var dd = new Date(); dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期 var y = dd.getFullYear(); var m = (dd.getMonth() + 1) < 10 ? "0" + (dd.getMonth() + 1) : (dd.getMonth() + 1); //获取当前月份的日期,不足10补0 var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate(); //获取当前几号,不足10补0 return y + "-" + m + "-" + d; } function getTime() { var date = new Date() var y = date.getFullYear(); var m = (date.getMonth() + 1) < 10 ? "0" + (date.getMonth() + 1) : (date.getMonth() + 1); //获取当前月份的日期,不足10补0 var d = date.getDate() < 10 ? "0" + date.getDate() : date.getDate(); let H = date.getHours() > 9 ? date.getHours() : '0' + date.getHours() let Min = date.getMinutes() > 9 ? date.getMinutes() : '0' + date.getMinutes() return y + '/' + m + '/' + d + " " + H + ':' + Min }