123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- export const LOGIN_USER = "login_user"
- // 获取存储的数据
- export const getStorage = function(key) {
- var val = sessionStorage.getItem(key)
- if (val) {
- return JSON.parse(val)
- } else {
- return false
- }
- }
- // 存储数据
- export const setStorage = function(key, val) {
- sessionStorage.setItem(key, JSON.stringify(val))
- }
- // 删除存储数据
- export const removeStorage = function(key) {
- sessionStorage.removeItem(key)
- }
- // 性别格式化
- export const sexFormater = function(sex) {
- var val = sex
- if (val === 1) {
- return '男'
- } else if (val === 0) {
- return '女'
- } else if (val === -1) {
- return '未知'
- } else {
- return ''
- }
- }
- export const payTypeFormater = function(type) {
- if (type === 1) {
- return '支付宝'
- } else if (type === 2) {
- return '微信'
- } else {
- return '未知'
- }
- }
- export const payStatusFormater = function(payStatus) {
- if (payStatus === 0) {
- return '待支付'
- } else if (payStatus === 10) {
- return '支付完成'
- } else {
- return '未知'
- }
- }
- export const checkStatusFormater = function(checkStatus) {
- if (checkStatus === 0) {
- return '未核对'
- } else if (checkStatus === 10) {
- return '核对成功'
- } else if (checkStatus === 20) {
- return '核对失败'
- } else {
- return '未知'
- }
- }
- export const timeFormater = function(ctime) {
- var time = new Date(ctime * 1000)
- var month = time.getMonth() + 1
- var day = time.getDate()
- if (month < 10) {
- month = '0' + month
- }
- if (day < 10) {
- day = '0' + day
- }
- return time.getFullYear() + '-' + month + '-' + day
- }
- export const timeDetailFormater = function(ctime) {
- var time = new Date(ctime * 1000)
- var month = time.getMonth() + 1
- var day = time.getDate()
- var hour = time.getHours()
- var minu = time.getMinutes()
- var sec = time.getSeconds()
- if (month < 10) {
- month = '0' + month
- }
- if (day < 10) {
- day = '0' + day
- }
- if (hour < 10) {
- hour = '0' + hour
- }
- if (minu < 10) {
- minu = '0' + minu
- }
- if (sec < 10) {
- sec = '0' + sec
- }
- return time.getFullYear() + '-' + month + '-' + day + " " + hour + ":" + minu + ":" + sec
- }
|