| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- const formatTime = date => {
- const year = date.getFullYear()
- const month = date.getMonth() + 1
- const day = date.getDate()
- const hour = date.getHours()
- const minute = date.getMinutes()
- const second = date.getSeconds()
- return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
- }
- const formatNumber = n => {
- n = n.toString()
- return n[1] ? n : `0${n}`
- }
- // 跳转到书籍详情页
- export const goToBookDetail = (options) => {
- // 检查必要参数
- if (!options || (!options.bookId || !options.wxBookId)) {
- console.warn('书籍ID不能为空');
- return;
- }
-
- let url = '';
-
- // 根据不同参数构建不同的URL
- if (options.wxBookId) {
- // 微信书籍ID跳转
- url = `plugin-private://wx293c4b6097a8a4d0/pages/novel/index?bookId=${options.wxBookId}`;
-
- // 如果有章节ID,添加到URL
- if (options.chapterId) {
- url += `&chapterId=${options.chapterId}`;
- }
- if (options.bookId) {
- url += `&innerBookId=${options.bookId}`;
- }
- }
-
- wx.navigateTo({
- url,
- fail: (err) => {
- console.error('跳转书籍详情页失败:', err);
- console.log('url',url);
- wx.showToast({
- title: '跳转失败,请重试',
- icon: 'none'
- });
- }
- });
- };
- module.exports = {
- formatTime,
- goToBookDetail
- }
|