1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import wechatConfig from '@/config/index'
- const toolClass = {
- dateFormat: (timestamp) => {
- let date = new Date(timestamp)
- let y = date.getFullYear()
- let m = date.getMonth() + 1
- let d = date.getDate()
- let h = date.getHours()
- let min = date.getMinutes()
- if (m < 10) {
- m = '0' + m
- }
- if (d < 10) {
- d = '0' + d
- }
- if (h < 10) {
- h = '0' + h
- }
- if (min < 10) {
- min = '0' + min
- }
- return y + '-' + m + '-' + d + ' ' + h + ':' + min
- },
- dateFormatM: (timestamp) => {
- let date = new Date(timestamp)
- let m = date.getMonth() + 1
- let d = date.getDate()
- let h = date.getHours()
- let min = date.getMinutes()
- if (m < 10) {
- m = '0' + m
- }
- if (d < 10) {
- d = '0' + d
- }
- if (h < 10) {
- h = '0' + h
- }
- if (min < 10) {
- min = '0' + min
- }
- return m + '-' + d + ' ' + h + ':' + min
- },
- UrlSearch: (urls) => {
- let url = urls // 获取url中"?"符后的字串
- let theRequest = {}
- if (url.indexOf('?') !== -1) {
- let str = url.substr(1)
- let strs = str.split('&')
- for (var i = 0; i < strs.length; i++) {
- theRequest[strs[i].split('=')[0]] = unescape(strs[i].split('=')[1])
- }
- }
- return theRequest
- },
- getCode: (appid) => {
- let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${wechatConfig.redirect_uri}&response_type=${wechatConfig.response_type}&scope=${wechatConfig.scope}&state=${wechatConfig.state}#wechat_redirect`
- window.location.href = url
- }
- }
-
- export default toolClass
|