Commit d2b39a3a authored by liubinyu's avatar liubinyu

首页

parent e43e7e0f
......@@ -2,9 +2,11 @@
export default {
onLaunch: function() {
console.log('App Launch')
uni.hideTabBar();
},
onShow: function() {
console.log('App Show')
uni.hideTabBar();
},
onHide: function() {
console.log('App Hide')
......@@ -34,22 +36,22 @@
}
@font-face {
font-family: HuXiaoBoZhenShuaiTi;
src: url(@/static/font/HuXiaoBoZhenShuaiTi-2.otf);
font-family: 'FengYaShiSong';
src: url(@/static/font/FengYaShiSong-2.otf);
}
@font-face {
font-family: LianMengQiYiLuShuaiZhengRuiHeiTi;
src: url(@/static/font/LianMengQiYiLuShuaiZhengRuiHeiTi-2.ttf);
font-family: 'MeiGuiZhuangYuanTi';
src: url(@/static/font/AaMeiGuiZhuangYuanTi-2.ttf);
}
@font-face {
font-family: NotoSerif;
font-family: 'NotoSerif';
src: url(@/static/font/NotoSerif.ttf);
}
@font-face {
font-family: ZhanKuWenYiTi;
src: url(@/static/font/ZhanKuWenYiTi-2.ttf);
font-family: 'LiuShengChangPianJi';
src: url(@/static/font/LiuShengChangPianJi-2.ttf);
}
</style>
\ No newline at end of file
import http from './interceptor.js'
export function list(data) {
return http.request({ url: '/system/astrologyForecastDaily/list', method: 'get', data })
}
/**
* @todo 把请求对象,转为url参数
* @param {Object} obj 请求对象
* @return {String} 例如?name=aa&age=11
*/
function tr(obj) {
let str = '?';
for (let key in obj) {
str += key + '=' + obj[key] + '&';
}
str = str.substr(0, str.length - 1)
return str;
}
\ No newline at end of file
import http from './request.js'
import $g from '@/utils/const'
http.setConfig({
baseUrl: $g.baseUrl,
});
http.interceptor.request = (config) => {
if (config.token) {
const token = uni.getStorageSync('token');
config.header.Authorization = token;
}
// console.log('请求:', config);
return config;
}
http.interceptor.response = (res) => {
// console.log('响应:', res);
if (res.code === 200) return res
else {
uni.showToast({
title: res.data?.msg || '请求失败!',
icon: 'none'
})
}
}
export default http
\ No newline at end of file
function validateUrl(value) {
return /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w-.\/?%&=]*)?/.test(value)
}
class Request {
setConfig(customConfig) {
this.config = Object.assign(this.config, customConfig);
}
request(options = {}) {
if (this.interceptor.request && typeof this.interceptor.request === 'function') {
let tmpConfig = {};
let interceptorRequest = this.interceptor.request(options);
if (interceptorRequest === false) {
return new Promise(() => {});
}
this.options = interceptorRequest;
}
options.dataType = options.dataType || this.config.dataType;
options.responseType = options.responseType || this.config.responseType;
options.url = options.url || '';
options.params = options.params || {};
options.header = Object.assign({}, this.config.header, options.header);
options.method = options.method || this.config.method;
return new Promise((resolve, reject) => {
options.complete = (response) => {
uni.hideLoading();
clearTimeout(this.config.timer);
this.config.timer = null;
if (response.statusCode == 200) {
const res = this.config.originalData ? response : response.data;
if (this.interceptor.response && typeof this.interceptor.response === 'function') {
let resInterceptors = this.interceptor.response(res);
resolve(resInterceptors);
} else {
resolve(res);
}
} else {
uni.showToast({
title: response.errMsg || response.data?.msg || '请求异常!',
icon: 'none'
});
resolve()
}
}
options.url = validateUrl(options.url) ? options.url : (this.config.baseUrl + (options.url.indexOf('/') ==
0 ? options.url : '/' + options.url));
if (this.config.showLoading && !this.config.timer) {
this.config.timer = setTimeout(() => {
uni.showLoading({
title: this.config.loadingText,
mask: this.config.loadingMask
})
this.config.timer = null;
}, this.config.loadingTime);
}
uni.request(options);
})
}
constructor() {
this.config = {
baseUrl: '', // 请求的根域名
header: {},
method: 'POST',
dataType: 'json',
responseType: 'text',
showLoading: true,
loadingText: '请求中...',
loadingTime: 800,
timer: null,
originalData: false,
loadingMask: true,
token: false,
}
this.interceptor = {
request: null,
response: null
}
}
}
export default new Request
\ No newline at end of file
......@@ -8,7 +8,7 @@
<image class="icon" src="@/static/icon-chat.png" mode="aspectFit"></image>
<view class="name">{{ $t('Astrologer') }}</view>
</view>
<view class="item">
<view class="item" @click="go('/pages/user/user')">
<image class="icon" src="@/static/icon-user.png" mode="aspectFit"></image>
<view class="name">{{ $t('Profile') }}</view>
</view>
......@@ -19,16 +19,17 @@
export default {
name: "tabbar",
data() {
return {
};
return {};
},
beforeCreate() {
uni.hideTabBar();
},
methods: {
go(url) {
const pages = getCurrentPages();
const page = pages[pages.length - 1].route;
if (url.indexOf(page) > -1) return;
uni.reLaunch({ url })
uni.switchTab({ url })
},
},
}
......@@ -42,6 +43,7 @@
right: 0;
height: 140rpx;
background-color: rgba(255, 255, 255, 0.2);
backdrop-filter: blur(40rpx);
display: flex;
justify-content: space-evenly;
align-items: center;
......@@ -61,7 +63,7 @@
}
.name {
font-family: NotoSerif;
font-family: 'NotoSerif';
font-size: 20rpx;
color: #FFFFFF;
}
......
......@@ -12,8 +12,6 @@
name: "xzzp",
data() {
return {
// 12星座
xzList: this.$_const.ConstellationList,
// 旋转相关
rotate: {
centerX: null, // 旋转的中心点 X 坐标
......@@ -44,7 +42,7 @@
this.currentWebviewRefresh = !!this.currentWebview.getStyle().pullToRefresh
// #endif
// 移动到第一个
this.rotate.containerA = this.xzList[0].angle
this.rotate.containerA = this.$g.ConstellationList[0].angle
this.moveToXZ()
},
methods: {
......@@ -116,7 +114,7 @@
if (a < 0) a = 360 + a;
let diff = 360;
let item;
this.xzList.forEach(xz => {
this.$g.ConstellationList.forEach(xz => {
const d = xz.angle - a;
if (Math.abs(d) < Math.abs(diff)) {
diff = d;
......
......@@ -28,5 +28,10 @@
"User": "用户",
"Home": "首页",
"Astrologer": "占星",
"Profile": "个人中心"
"Profile": "个人中心",
"Language Settings": "语言设置",
"Constellation Selection": "星座选择",
"En": "英文",
"Cn": "简体中文",
"Tc": "繁体中文"
}
\ No newline at end of file
......@@ -28,5 +28,10 @@
"User": "User",
"Home": "Home",
"Astrologer": "Astrologer",
"Profile": "Profile"
"Profile": "Profile",
"Language Settings": "Language Settings",
"Constellation Selection": "Constellation Selection",
"En": "English",
"Cn": "Simplified Chinese",
"Tc": "Chinese Traditional"
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ import Tc from './tc.json'
Vue.use(VueI18n)
const locale = uni.getStorageSync('locale') || 'Cn'
const locale = uni.getStorageSync('locale') || 'Tc'
const i18n = new VueI18n({
locale,
......
......@@ -28,5 +28,10 @@
"User": "用戶",
"Home": "首頁",
"Astrologer": "占星",
"Profile": "個人中心"
"Profile": "個人中心",
"Language Settings": "語言設置",
"Constellation Selection": "星座選擇",
"En": "英文",
"Cn": "簡體中文",
"Tc": "繁體中文"
}
\ No newline at end of file
......@@ -3,13 +3,19 @@ import App from './App'
// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
import * as _const from '@/utils/const'
import store from '@/store';
import i18n from './i18n'
Vue.config.productionTip = false
Vue.prototype.$_const = _const
import $g from '@/utils/const'
Vue.prototype.$g = $g
import * as $api from '@/api'
Vue.prototype.$api = $api
App.mpType = 'app'
let vuexStore = require('@/store/mixin.js');
Vue.mixin(vuexStore);
const app = new Vue({
...App,
store,
i18n
})
app.$mount()
......
......@@ -20,6 +20,13 @@
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/user/user",
"style": {
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
}
],
"globalStyle": {
......@@ -31,5 +38,14 @@
"bounce": "none"
}
},
"tabBar": {
"list": [{
"pagePath": "pages/home/home"
}, {
"pagePath": "pages/chat/chat"
}, {
"pagePath": "pages/user/user"
}]
},
"uniIdRouter": {}
}
\ No newline at end of file
<template>
<view class="page bg2">
<view class="box">
<scroll-view scroll-y class="content" scroll-into-view="last">
<view class="tips">
<view class="line">——</view>
AI{{ $t('Stargazer') }}-{{ $t('XiaoXi') }} {{ $t('The astrological') }}
<view class="line">——</view>
</view>
<view class="msg">
<view v-for="(item,index) in recordList" :key="index" class="msg-item" :class="item.user ? 'right' : ''">
<template v-if="item.showAvatar">
<view v-if="item.user" class="avatar">
<image class="avatar" src="@/static/avatar-user.png"></image>
<view class="txt">{{ $t('User') }}</view>
</view>
<image v-else class="avatar" src="@/static/avatar.png" />
</template>
<view class="content">{{item.content}}</view>
</view>
</view>
<view id="last"></view>
</scroll-view>
<view class="question">
<input v-model="inputText" class="input" :placeholder="$t('Enter your question')"
placeholder-style="color: #060504;" @confirm="confirm" />
</view>
</view>
<tabbar />
</view>
</template>
......@@ -8,12 +34,117 @@
export default {
data() {
return {
recordList: [
{ content: '2025年2月28日 星期五\n★★★☆☆\n稳健发展 财运平稳 健康良好\n今日金牛座整体运势平稳,财务方面可能有小收获。', showAvatar: true },
{ content: '如果你想窥探详细的星座运程,你可以告诉我你的生日。' },
{ content: '我的生日是2000年2月24日。', user: true, showAvatar: true },
{ content: '2000年2月24日是双鱼座.....', showAvatar: true },
],
inputText: '',
};
},
methods: {
confirm() {
console.log(123, this.inputText);
},
}
}
</script>
<style lang="scss" scoped>
.box {
border-radius: 56rpx 56rpx 0 0;
background-color: #CFCFCF;
position: fixed;
bottom: 140rpx;
left: 0;
right: 0;
height: 60vh;
padding-top: 60rpx;
.content {
height: calc(100% - 130rpx);
.tips {
text-align: center;
color: #797979;
display: flex;
justify-content: center;
align-items: center;
padding: 0 40rpx;
margin-bottom: 20rpx;
.line {
margin: 0 20rpx;
}
}
.msg {
padding: 0 40rpx;
.msg-item {
margin-bottom: 30rpx;
.avatar {
width: 84rpx;
height: 84rpx;
border-radius: 50%;
float: left;
position: relative;
.txt {
position: absolute;
inset: 0;
font-size: 24rpx;
color: #FFF;
text-align: center;
vertical-align: 50%;
line-height: 84rpx;
}
}
.content {
margin-left: 110rpx;
margin-right: 30rpx;
font-weight: 500;
font-size: 28rpx;
color: #000824;
line-height: 44rpx;
background: #EDEDED;
border-radius: 42rpx;
padding: 20rpx 34rpx;
width: 530rpx;
white-space: pre-wrap;
}
}
.msg-item.right {
.avatar {
float: right;
}
.content {
margin-left: 30rpx;
margin-right: 110rpx;
}
}
}
}
.question {
width: 694rpx;
height: 70rpx;
background-color: #EDEDED;
border-radius: 18rpx;
margin: 30rpx auto 0;
padding: 0 40rpx;
display: flex;
align-items: center;
.input {
width: 100%;
color: #060504;
}
}
}
</style>
\ No newline at end of file
<template>
<view class="page">
<view class="card" :class="{ back: isBack }"
:style="{ transitionDuration: `${duration}s`, transform: `scaleX(${scale})` }" @click="start">
<template v-if="!isBack && info">
<view class="title">{{ $t(x_xz.key) }}</view>
<view class="date">{{ today }}</view>
<view class="star-list">
<image v-for="i in Number(info.luckyStar)" class="star" src="@/static/star.png" />
<template v-if="Number(info.luckyStar) <= 5">
<image v-for="i in 5 - Number(info.luckyStar)" class="star" src="@/static/star1.png" />
</template>
</view>
<view class="word-list">
<view v-for="word in getWordList(info[`keyWord${$i18n.locale}`])" class="word">{{ word }}</view>
</view>
<scroll-view scroll-y class="scroll-wrap">
<view class="desc">{{ info[`fortune${$i18n.locale}`] }}</view>
</scroll-view>
</template>
</view>
<view class="btns">
<view v-if="isZS" class="btn" hover-class="btn-hover" @click="start">
{{ $t('Start') }}{{ $t('Exclusive Horoscope') }}
</view>
<view v-else class="btn" hover-class="btn-hover" @click="start">
{{ $t('Exclusive Horoscope') }}{{ $t('(') }}{{ $t('Free') }}{{ $t(')') }}
</view>
</view>
<tabbar />
</view>
</template>
<script>
import { dateFormat } from '@/utils'
export default {
data() {
return {
isZS: false, // 是否是专属运程
isBack: true, // 是否是背面,也就是无信息的那面
scale: 1, // 收缩状态
duration: 0.3, // 动画时间(s)
today: '',
info: undefined,
};
},
onLoad() {
if (!this.x_xz) {
uni.reLaunch({
url: '/pages/index/index'
})
}
},
methods: {
start() {
if (!this.isBack) return;
this.getInfo()
this.scale = 0
setTimeout(() => {
this.isBack = false
this.scale = 1
}, this.duration * 1000)
},
async getInfo() {
const now = new Date()
const res = await this.$api.list({
zodiacSignId: this.x_xz.zodiacSignId,
fortuneDate: dateFormat(now),
pageSize: 20,
});
this.info = res?.rows?.[0]
this.today = dateFormat(now, this.$i18n.locale === 'En' ? `${now.toDateString()} e` : 'YYYY年MM月DD日 z')
},
getWordList(word) {
return word?.split(/[,、]/).filter(i => !!i).map(i => i.trim()) || []
},
},
}
</script>
<style lang="scss" scoped>
.page {
padding-top: 96rpx;
.card {
width: 554rpx;
height: calc(100vh - 140rpx - 98rpx - 200rpx);
background-image: url(@/static/card-front.png);
background-size: 100% 100%;
margin: 0 auto;
padding: 160rpx 60rpx 0;
transition-property: transform;
.title {
font-size: 68rpx;
text-align: center;
}
.date {
font-size: 24rpx;
color: #888;
text-align: center;
margin: 20rpx 0 16rpx;
}
.star-list {
display: flex;
justify-content: center;
align-items: center;
gap: 8rpx;
.star {
width: 60rpx;
height: 60rpx;
}
}
.word-list {
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
gap: 16rpx;
margin: 50rpx 0 50rpx;
.word {
padding: 8rpx 20rpx 12rpx;
border-radius: 100rpx;
background: rgba(116, 100, 255, 0.1);
font-size: 26rpx;
color: #674bd9;
}
}
.scroll-wrap {
height: calc(100% - 500rpx);
}
.desc {
font-size: 30rpx;
color: #333;
line-height: 40rpx;
white-space: pre-wrap;
}
}
.card.back {
background-image: url(@/static/card-back.png);
}
.btns {
display: flex;
gap: 40rpx;
.btn {
width: fit-content;
min-width: 534rpx;
height: 98rpx;
padding: 0 40rpx;
margin: 54rpx auto 0;
background-image: linear-gradient(to right, #0038F5, #9F03FF);
border-radius: 14rpx;
display: flex;
justify-content: center;
align-items: center;
font-family: 'LiuShengChangPianJi';
font-size: 46rpx;
color: #FCFCFC;
}
.btn-hover {
filter: brightness(1.1);
}
}
}
</style>
\ No newline at end of file
<template>
<view class="page">
<view class="page" :class="lang">
<view class="title">{{ $t('Please Choose') }}</view>
<view class="xz">
<view class="line1"></view>
......@@ -21,12 +21,17 @@
xz: {},
}
},
onLoad() {},
computed: {
lang() {
return this.$i18n.locale
}
},
methods: {
changeXZ(xz) {
this.xz = xz
},
go() {
this.vuex('x_xz', this.xz)
uni.reLaunch({
url: '/pages/home/home'
})
......@@ -41,7 +46,7 @@
text-align: center;
.title {
font-family: HuXiaoBoZhenShuaiTi;
font-family: 'FengYaShiSong';
font-size: 62rpx;
color: #fff;
margin-bottom: 44rpx;
......@@ -56,13 +61,13 @@
justify-content: space-between;
.name {
font-family: LianMengQiYiLuShuaiZhengRuiHeiTi;
font-family: 'MeiGuiZhuangYuanTi';
font-size: 90rpx;
color: #EAE6FF;
}
.key {
font-family: NotoSerif;
font-family: 'NotoSerif';
font-size: 46rpx;
background-image: linear-gradient(to right, #A18FFF, #EBEBEC);
-webkit-background-clip: text;
......@@ -89,15 +94,17 @@
}
.btn {
width: 534rpx;
width: fit-content;
min-width: 534rpx;
height: 98rpx;
padding: 0 40rpx;
margin: 156rpx auto 0;
background-image: linear-gradient(to right, #0038F5, #9F03FF);
border-radius: 14rpx;
display: flex;
justify-content: center;
align-items: center;
font-family: ZhanKuWenYiTi;
font-family: 'LiuShengChangPianJi';
font-size: 46rpx;
color: #FCFCFC;
}
......@@ -106,4 +113,8 @@
filter: brightness(1.1);
}
}
.page.En {
padding-top: 130rpx;
}
</style>
\ No newline at end of file
<template>
<view class="page">
<view class="list">
<view class="item">
<view class="txt">{{ $t('Language Settings') }}</view>
<picker mode="selector" :range="locales" :value="localeIndex" @change="changeLang">
<view class="txt">{{ $t(lang) }}</view>
</picker>
</view>
<view class="item">
<view class="txt">{{ $t('Constellation Selection') }}</view>
<image class="icon" src="@/static/icon-right.svg" @click="go('/pages/index/index')"></image>
</view>
</view>
<tabbar />
</view>
</template>
<script>
export default {
data() {
return {
locales: [],
localeIndex: 0,
}
},
computed: {
lang() {
return this.$i18n.locale
}
},
onLoad() {
this.getLocales()
},
methods: {
getLocales() {
this.locales = this.$i18n.availableLocales.map((i, index) => {
if (i === this.lang) this.localeIndex = index;
return this.$t(i)
})
},
changeLang(e) {
const val = this.$i18n.availableLocales[e.detail.value]
this.$i18n.locale = val
uni.setStorageSync('locale', val)
this.getLocales()
},
go(url) {
uni.navigateTo({ url })
},
}
}
</script>
<style lang="scss" scoped>
.page {
padding-top: 500rpx;
.list {
width: 600rpx;
background-color: #fff;
border-radius: 20rpx;
margin: 0 auto;
padding: 10rpx 40rpx;
.item {
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1rpx solid #ccc;
padding: 20rpx 0;
.txt {
font-size: 30rpx;
color: #333;
}
.icon {
width: 40rpx;
height: 40rpx;
}
}
.item:last-of-type {
border-bottom: none;
}
}
}
</style>
\ No newline at end of file
static/icon-chat.png

411 Bytes | W: | H:

static/icon-chat.png

1.42 KB | W: | H:

static/icon-chat.png
static/icon-chat.png
static/icon-chat.png
static/icon-chat.png
  • 2-up
  • Swipe
  • Onion skin
static/icon-home.png

280 Bytes | W: | H:

static/icon-home.png

1.15 KB | W: | H:

static/icon-home.png
static/icon-home.png
static/icon-home.png
static/icon-home.png
  • 2-up
  • Swipe
  • Onion skin
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1749115202126" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4563" width="64" height="64" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M704 514.368a52.864 52.864 0 0 1-15.808 37.888L415.872 819.2a55.296 55.296 0 0 1-73.984-2.752 52.608 52.608 0 0 1-2.816-72.512l233.6-228.928-233.6-228.992a52.736 52.736 0 0 1-17.536-53.056 53.952 53.952 0 0 1 40.192-39.424c19.904-4.672 40.832 1.92 54.144 17.216l272.32 266.88c9.92 9.792 15.616 23.04 15.808 36.8z" fill="#2c2c2c" fill-opacity=".88" p-id="4564"></path></svg>
\ No newline at end of file
static/icon-user.png

257 Bytes | W: | H:

static/icon-user.png

867 Bytes | W: | H:

static/icon-user.png
static/icon-user.png
static/icon-user.png
static/icon-user.png
  • 2-up
  • Swipe
  • Onion skin
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
let lifeData = {};
try {
lifeData = uni.getStorageSync('lifeData');
console.log('本地储存:', lifeData)
} catch (e) {}
let saveStateKeys = ['x_xz'];
const saveLifeData = function(key, value) {
if (saveStateKeys.indexOf(key) != -1) {
let tmp = uni.getStorageSync('lifeData');
tmp = tmp ? tmp : {};
tmp[key] = value;
uni.setStorageSync('lifeData', tmp);
}
}
const store = new Vuex.Store({
state: {
x_xz: lifeData.x_xz,
},
mutations: {
xStore(state, payload) {
let nameArr = payload.name.split('.');
let saveKey = '';
let len = nameArr.length;
if (len >= 2) {
let obj = state[nameArr[0]];
for (let i = 1; i < len - 1; i++) {
obj = obj[nameArr[i]];
}
obj[nameArr[len - 1]] = payload.value;
saveKey = nameArr[0];
} else {
state[payload.name] = payload.value;
saveKey = payload.name;
}
saveLifeData(saveKey, state[saveKey])
}
}
})
export default store
\ No newline at end of file
import { mapState } from 'vuex'
import store from "@/store"
let storeKey = [];
try {
storeKey = store.state ? Object.keys(store.state) : [];
} catch (e) {}
module.exports = {
beforeCreate() {
this.vuex = (name, value) => {
this.$store.commit('xStore', {
name,
value
})
}
},
computed: {
...mapState(storeKey)
}
}
\ No newline at end of file
export const ConstellationList = [
// 全局常量
export default {
baseUrl: 'http://47.243.113.209:8081', // 本地环境
// baseUrl: '/api', // 正式环境
// 星座列表
ConstellationList: [
{ key: 'Aries', date: ['3.21', '4.19'], zodiacSignId: '1', angle: 330 },
{ key: 'Taurus', date: ['4.20', '5.20'], zodiacSignId: '2', angle: 300 },
{ key: 'Gemini', date: ['5.21', '6.21'], zodiacSignId: '3', angle: 270 },
......@@ -11,4 +16,5 @@ export const ConstellationList = [
{ key: 'Capricornus', date: ['12.22', '1.19'], zodiacSignId: '10', angle: 60 },
{ key: 'Aquarius', date: ['1.20', '2.18'], zodiacSignId: '11', angle: 30 },
{ key: 'Pisces', date: ['2.19', '3.20'], zodiacSignId: '12', angle: 0 },
]
\ No newline at end of file
]
}
\ No newline at end of file
export function dateFormat(date, fmt = 'YYYY-MM-DD') {
if (!date || !fmt) return date;
date instanceof Date || (date = new Date(date));
const o = {
'Y+': date.getFullYear(),
'M+': date.getMonth() + 1,
'D+': date.getDate(),
'H+': date.getHours(),
'm+': date.getMinutes(),
's+': date.getSeconds(),
'z': ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'][date.getDay()], // 中文星期
'e': ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', ][date.getDay()], // 英文星期
};
for (let k in o) {
const ret = new RegExp('(' + k + ')').exec(fmt)
if (ret) {
const v = String(o[k])
if (/(Y+)/.test(k)) {
fmt = fmt.replace(ret[1], v.substring(4 - ret[1].length))
} else {
fmt = fmt.replace(ret[1], ret[1].length === 1 ? v : v.padStart(ret[1].length, '0'))
}
}
}
return fmt;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment