├── .gitignore
├── README.md
├── README
├── Screenshot1.png
├── Screenshot1.webp
├── Screenshot2.png
├── Screenshot2.webp
├── Screenshot3.png
├── Screenshot3.webp
├── Screenshot4.png
├── Screenshot4.webp
├── Screenshot5.png
├── Screenshot5.webp
├── WordReadingCode.jpg
└── WordReadingCode.webp
├── app.js
├── app.json
├── app.wxss
├── data
├── icon
│ ├── back.svg
│ ├── back_w.svg
│ ├── book.png
│ ├── book.svg
│ ├── bookshelf.svg
│ ├── cancel.svg
│ ├── catalog.svg
│ ├── clipboard.svg
│ ├── clipboard_blue.svg
│ ├── cloud.svg
│ ├── cloud_blue.svg
│ ├── cloud_download.svg
│ ├── cloud_grey.svg
│ ├── delete.svg
│ ├── delete_red.svg
│ ├── directory.svg
│ ├── explainBox2.svg
│ ├── image.svg
│ ├── import.svg
│ ├── me.png
│ ├── me.svg
│ ├── more.svg
│ ├── phone.svg
│ ├── plus.svg
│ ├── plus_b.svg
│ ├── read.svg
│ ├── read_blue.svg
│ ├── rename.svg
│ ├── rename_cursor.svg
│ ├── save.svg
│ ├── save_blue.svg
│ ├── save_w.svg
│ ├── search.svg
│ ├── search_w.svg
│ ├── share.svg
│ ├── share_grey.svg
│ ├── sound.svg
│ ├── store.png
│ ├── tag.svg
│ ├── tag_w.svg
│ └── word.png
├── image.png
├── noneBookmark.svg
├── nullBookshelf.svg
└── tabbar
│ ├── bookshelf.png
│ ├── bookshelf_b.png
│ ├── find.png
│ ├── find_b.png
│ ├── me.png
│ ├── me.svg
│ ├── me_b.png
│ ├── word.png
│ ├── word_b.png
│ ├── 书架 (1).svg
│ ├── 书架.svg
│ ├── 发现 (1).svg
│ └── 词库管理.svg
├── js
├── bookshelfMgr.js
├── clipboard.js
├── dict.js
└── setNavHeight.wxs
├── pages
├── bookshelf
│ ├── README.md
│ ├── bookshelf.js
│ ├── bookshelf.json
│ ├── bookshelf.wxml
│ ├── bookshelf.wxs
│ └── bookshelf.wxss
├── logs
│ ├── logs.js
│ ├── logs.json
│ ├── logs.wxml
│ └── logs.wxss
├── me
│ ├── me.js
│ ├── me.json
│ ├── me.wxml
│ ├── me.wxs
│ └── me.wxss
├── reading
│ ├── reading.js
│ ├── reading.json
│ ├── reading.wxml
│ ├── reading.wxs
│ └── reading.wxss
├── store
│ ├── store.js
│ ├── store.json
│ ├── store.wxml
│ ├── store.wxs
│ └── store.wxss
├── storeList
│ ├── storeList.js
│ ├── storeList.json
│ ├── storeList.wxml
│ ├── storeList.wxs
│ └── storeList.wxss
└── wordbook
│ ├── wordbook.js
│ ├── wordbook.json
│ ├── wordbook.wxml
│ └── wordbook.wxss
├── project.config.json
├── sitemap.json
├── template
├── template.wxml
└── template.wxss
└── utils
└── util.js
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows
2 | [Dd]esktop.ini
3 | Thumbs.db
4 | $RECYCLE.BIN/
5 |
6 | # macOS
7 | .DS_Store
8 | .fseventsd
9 | .Spotlight-V100
10 | .TemporaryItems
11 | .Trashes
12 |
13 | # Node.js
14 | node_modules/
15 |
16 | # CloudFunction 云函数
17 | cloudFunction/
18 |
19 | # WordReading
20 | js/bookshelfMgr.md
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 划词英语阅读
2 | 微信小程序-划词英语阅读是一款学习类小程序。
3 | 划词英语阅读实现了点击查词,横向滑动翻译,单词朗读、句子朗读,是学习英语的好助手。阅读内容可由剪贴板导入。
4 |
5 | 此项目目前还有很多不完善的地方,由于时间精力的原因生词本功能还未实现。也欢迎大家对此提出意见和建议,不断优化更新,一起学习进步。
6 |
7 | 😁star鼓励下?
8 |
9 |
10 | # 扫码体验-划词英语阅读
11 | 
12 |
13 |
14 | # 截图
15 | ### 书架页
16 | 
17 | ### 阅读页 - 点击查词
18 | 
19 | ### 阅读页 - 横向滑动翻译
20 | 
21 | ### 阅读页 - 翻译框内点击查词
22 | 
23 | ### 阅读页 - 输入查词
24 | 
25 |
26 | # 目前遇到的问题及设想
27 | ## 问题一:错词
28 | 由pdf、ppt等格式导入的文本中常常会出现两个单词连在一起的现象(中间缺少空格),或是OCR识别的文本常常含有错词。这种情况下查词效率很低,ps:可以通过键盘输入查词。
29 | 需要开发一个可以纠正错词,拆分连在一起的两个词的程序或者接口。
30 |
31 | ## 问题二:阅读排版格式
32 | 目前阅读界面的所有文本字体大小颜色都一样,阅读时重点不突出,且没有图片。阅读较为枯燥。
33 |
34 | 目前设想过让阅读界面支持Markdown语法或是简单的一些HTML标签,但是在小程序这个平台约束较多。
35 |
36 | # 项目说明
37 | 此项目的所有源文件仅可用做学习用途!
38 |
--------------------------------------------------------------------------------
/README/Screenshot1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/README/Screenshot1.png
--------------------------------------------------------------------------------
/README/Screenshot1.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/README/Screenshot1.webp
--------------------------------------------------------------------------------
/README/Screenshot2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/README/Screenshot2.png
--------------------------------------------------------------------------------
/README/Screenshot2.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/README/Screenshot2.webp
--------------------------------------------------------------------------------
/README/Screenshot3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/README/Screenshot3.png
--------------------------------------------------------------------------------
/README/Screenshot3.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/README/Screenshot3.webp
--------------------------------------------------------------------------------
/README/Screenshot4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/README/Screenshot4.png
--------------------------------------------------------------------------------
/README/Screenshot4.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/README/Screenshot4.webp
--------------------------------------------------------------------------------
/README/Screenshot5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/README/Screenshot5.png
--------------------------------------------------------------------------------
/README/Screenshot5.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/README/Screenshot5.webp
--------------------------------------------------------------------------------
/README/WordReadingCode.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/README/WordReadingCode.jpg
--------------------------------------------------------------------------------
/README/WordReadingCode.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/README/WordReadingCode.webp
--------------------------------------------------------------------------------
/app.js:
--------------------------------------------------------------------------------
1 | //app.js
2 | App({
3 | onLaunch: function () {
4 | // 展示本地存储能力
5 | var logs = wx.getStorageSync('logs') || []
6 | logs.unshift(Date.now())
7 | wx.setStorageSync('logs', logs)
8 |
9 | // 登录
10 | wx.login({
11 | success: res => {
12 | // 发送 res.code 到后台换取 openId, sessionKey, unionId
13 | // console.log('wx.getUserInfo -> res',res)
14 | }
15 | })
16 | // 获取用户信息
17 | wx.getSetting({
18 | success: res => {
19 | if (res.authSetting['scope.userInfo']) {
20 | // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
21 | wx.getUserInfo({
22 | success: res => {
23 | // 可以将 res 发送给后台解码出 unionId
24 | this.globalData.userInfo = res.userInfo
25 |
26 | // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
27 | // 所以此处加入 callback 以防止这种情况
28 | if (this.userInfoReadyCallback) {
29 | this.userInfoReadyCallback(res)
30 | }
31 | }
32 | })
33 | }
34 | }
35 | })
36 | // 云服务初始化
37 | wx.cloud.init({
38 | env: 'release-bf6b22'
39 | })
40 | // 检查是否获取到OpenId
41 | var app = this
42 | wx.getStorage({
43 | key:'openid',
44 | success(res){
45 | console.log('getStorage openid ->',res)
46 | if(res.data == ''){
47 | console.log('storage openid 为空')
48 | app.storageOpenId()
49 | }
50 | },
51 | fail(res){
52 | console.log('getStorage fail ->',res)
53 | // 获取并缓存OpenID
54 | app.storageOpenId()
55 | }
56 | })
57 |
58 | },
59 | globalData: {
60 | userInfo: null,
61 | settings: {},
62 | },
63 | getOpenId:async function(){
64 | // 调用云函数 ->获取OpenId,
65 | var openId = await new Promise ((resolve,reject)=>{
66 | wx.cloud.callFunction({
67 | name: 'getOpenId',
68 | // complete: res => {
69 | // // console.log('call function test result', res)
70 | // wx.setStorage({
71 | // key: 'openid',
72 | // data: res.result.openid
73 | // })
74 | // resolve(res.result)
75 | // }
76 | }).then(res=>{
77 | // console.log('promise then ->',res.result.openid)
78 | var openid = res.result.openid
79 | resolve(openid)
80 | })
81 | })
82 | // console.log('getopenID return openid =======',openId)
83 | return openId
84 | },
85 | storageOpenId: async function(){
86 | // console.log('--------缓存openId -----------')
87 | var openId = await this.getOpenId()
88 | console.log('point - openid awit after')
89 | wx.setStorage({
90 | key:'openid',
91 | data:openId
92 | })
93 | console.log('------------------storage - openID -> ',openId)
94 | },
95 | setBookHistory:function(index,id,history){
96 | let bookmgr = require('./js/bookshelfMgr.js');
97 | let bookMgr = new bookmgr.bookshelfClass()
98 | bookMgr.setHistory(index, id, history)
99 | console.log('set history finish...')
100 | },
101 | setting: function(key,value){
102 | // key设置键名 value设置值, setting对value不做识别、判断,只负责储存、同步
103 | let setting = wx.getStorageInfoSync('setting');
104 | if (Object.prototype.toString.call(setting) != "[object Object]"){
105 | // 异常, 重置
106 | setting = {}
107 | }
108 |
109 | //添加&更新
110 | setting[key] = value;
111 | this.globalData.setting = setting;
112 |
113 | // 储存
114 | wx.setStorageSync({
115 | key:'setting',
116 | data:setting
117 | })
118 | },
119 |
120 | })
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": [
3 | "pages/bookshelf/bookshelf",
4 | "pages/reading/reading",
5 | "pages/logs/logs",
6 | "pages/wordbook/wordbook",
7 | "pages/me/me",
8 | "pages/store/store",
9 | "pages/storeList/storeList"
10 | ],
11 | "window": {
12 | "navigationStyle": "custom",
13 | "backgroundTextStyle": "light",
14 | "navigationBarBackgroundColor": "#fff",
15 | "navigationBarTitleText": "WeChat",
16 | "navigationBarTextStyle": "black"
17 | },
18 | "requiredBackgroundModes": [
19 | "audio"
20 | ],
21 | "tabBar": {
22 | "color": "#888888",
23 | "selectedColor": "#1c80ff",
24 | "borderStyle": "black",
25 | "backgroundColor": "#ffffff",
26 | "list": [
27 | {
28 | "pagePath": "pages/bookshelf/bookshelf",
29 | "iconPath": "data/tabbar/bookshelf_b.png",
30 | "selectedIconPath": "data/tabbar/bookshelf.png",
31 | "text": "书架"
32 | },
33 | {
34 | "pagePath": "pages/store/store",
35 | "iconPath": "data/tabbar/find_b.png",
36 | "selectedIconPath": "data/tabbar/find.png",
37 | "text": "发现"
38 | },
39 | {
40 | "pagePath": "pages/wordbook/wordbook",
41 | "iconPath": "data/tabbar/word_b.png",
42 | "selectedIconPath": "data/tabbar/word.png",
43 | "text": "生词本"
44 | },
45 | {
46 | "pagePath": "pages/me/me",
47 | "iconPath": "data/tabbar/me_b.png",
48 | "selectedIconPath": "data/tabbar/me.png",
49 | "text": "我"
50 | }
51 | ]
52 | },
53 | "plugins": {
54 | "WechatSI": {
55 | "version": "0.3.0",
56 | "provider": "wx069ba97219f66d99"
57 | }
58 | },
59 | "sitemapLocation": "sitemap.json"
60 | }
--------------------------------------------------------------------------------
/app.wxss:
--------------------------------------------------------------------------------
1 | /**app.wxss**/
2 | .container {
3 | height: 100%;
4 | display: flex;
5 | flex-direction: column;
6 | align-items: center;
7 | justify-content: space-between;
8 | padding: 200rpx 0;
9 | box-sizing: border-box;
10 | }
--------------------------------------------------------------------------------
/data/icon/back.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/back_w.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/book.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/data/icon/book.png
--------------------------------------------------------------------------------
/data/icon/book.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/bookshelf.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
15 |
--------------------------------------------------------------------------------
/data/icon/cancel.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/catalog.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/clipboard.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/clipboard_blue.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/data/icon/cloud.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/cloud_blue.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
13 |
--------------------------------------------------------------------------------
/data/icon/cloud_download.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/data/icon/cloud_grey.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/delete.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/delete_red.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/data/icon/directory.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/explainBox2.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/image.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/import.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/me.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/data/icon/me.png
--------------------------------------------------------------------------------
/data/icon/me.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/more.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/phone.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/plus.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/plus_b.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/read.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/read_blue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/rename.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/rename_cursor.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
12 |
--------------------------------------------------------------------------------
/data/icon/save.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/save_blue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/save_w.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/search.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/search_w.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/share.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
14 |
--------------------------------------------------------------------------------
/data/icon/share_grey.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
14 |
--------------------------------------------------------------------------------
/data/icon/sound.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/store.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/data/icon/store.png
--------------------------------------------------------------------------------
/data/icon/tag.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/tag_w.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/icon/word.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/data/icon/word.png
--------------------------------------------------------------------------------
/data/image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/data/image.png
--------------------------------------------------------------------------------
/data/noneBookmark.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/nullBookshelf.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/tabbar/bookshelf.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/data/tabbar/bookshelf.png
--------------------------------------------------------------------------------
/data/tabbar/bookshelf_b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/data/tabbar/bookshelf_b.png
--------------------------------------------------------------------------------
/data/tabbar/find.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/data/tabbar/find.png
--------------------------------------------------------------------------------
/data/tabbar/find_b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/data/tabbar/find_b.png
--------------------------------------------------------------------------------
/data/tabbar/me.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/data/tabbar/me.png
--------------------------------------------------------------------------------
/data/tabbar/me.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/tabbar/me_b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/data/tabbar/me_b.png
--------------------------------------------------------------------------------
/data/tabbar/word.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/data/tabbar/word.png
--------------------------------------------------------------------------------
/data/tabbar/word_b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/data/tabbar/word_b.png
--------------------------------------------------------------------------------
/data/tabbar/书架 (1).svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/tabbar/书架.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/tabbar/发现 (1).svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/tabbar/词库管理.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/js/clipboard.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/js/clipboard.js
--------------------------------------------------------------------------------
/js/setNavHeight.wxs:
--------------------------------------------------------------------------------
1 |
2 |
3 | function setNavHeight(systemInfo, oldValue, ownerInstance, instance){
4 | console.log('set nav height--------------------------------')
5 | if(systemInfo){
6 | console.log('适应 nav bar 高度========')
7 | var navBar = ownerInstance.selectComponent('.navigationBar')
8 | var navHeight;
9 | var system = systemInfo.system
10 | if (systemInfo.system.substring(0,2) == 'iOS') {
11 | navHeight = '44px'
12 | } else {
13 | navHeight = '48px'
14 | }
15 | navBar.setStyle({
16 | 'padding-top': systemInfo.statusBarHeight + 'px',
17 | 'height': navHeight
18 | })
19 | }
20 | }
21 |
22 | function setNavPadding(systemInfo, oldValue, ownerInstance, instance){
23 | console.log('set nav height--------------------------------')
24 | if (systemInfo) {
25 | console.log('适应 nav bar 高度========')
26 | var navBar = ownerInstance.selectComponent('.navigationBar')
27 | var navHeight;
28 | var system = systemInfo.system
29 | // if (systemInfo.system.substring(0, 2) == 'iOS') {
30 | // navHeight = '44px'
31 | // } else {
32 | // navHeight = '48px'
33 | // }
34 | navBar.setStyle({
35 | 'padding-top': systemInfo.statusBarHeight + 'px',
36 | })
37 | }
38 | }
39 |
40 |
41 | module.exports = {
42 | setNavHeight:setNavHeight,
43 | setNavPadding: setNavPadding
44 | }
--------------------------------------------------------------------------------
/pages/bookshelf/README.md:
--------------------------------------------------------------------------------
1 | book-more-box:
2 | 高度:42 x itemNum
3 | 42 x 6 = 252px
4 |
5 | more-box的操作菜单
6 | 取消
7 | 上传
8 | 分享
9 | 取消分享
10 | 重命名
11 | 删除
12 | 更多
13 |
14 |
15 | 不同情况
16 | 情况1:本地 未上传 未分享 |
17 |
18 | 情况2:本地 上传 未分享 |
19 |
20 | 情况3:本地 上传 分享 | 取消分享 分享码
21 |
22 | 情况4:云端 上传 未分享 |
23 |
24 | 情况5:云端 上传 分享
25 |
26 | 1-4: 本地
27 | 1-2:未上传
28 | 1:未分享
29 | 3-4:上传
30 | 3:未分享
31 | 4:分享
32 | 5-8:云端
33 | 5-6:上传
34 | 5:未分享
35 | 6:分享
36 |
37 |
38 | 待解决:
39 | 查词失败await没有返回,没有提示
40 | 句子读音能否播放的参数 变换 时间不太合理
41 |
42 |
--------------------------------------------------------------------------------
/pages/bookshelf/bookshelf.js:
--------------------------------------------------------------------------------
1 | // pages/bookshelf/bookshelf.js
2 | const bookmgr = require('../../js/bookshelfMgr.js');
3 | var bookMgr;
4 | var currentBook; // 当前将要进行操作的book, 使用完清空,避免误操作,{id:''}
5 | var inputText; // 记录输入的内容,使用完清空,避免混染
6 | var inputDo; // 记录调用input的原因,要干什么
7 | var booksList;
8 | var cloudBooksList;
9 | var bookshelf; // 当前页面引用, 用户setData或调用页面内函数
10 |
11 |
12 | async function getClipboardData(){
13 | var data = await new Promise((resolve) => {
14 | wx.getClipboardData({
15 | success(res) {
16 | resolve(res.data)
17 | }
18 | })
19 | })
20 | return data
21 | }
22 |
23 | /**返回text指定长度(l),多余的以‘...’显示
24 | * type='0' ,表示不区分中文、英文; 默认
25 | * type ='1', 表示区分中英文,一个中文相当于两个英文字母,l表示中文字数
26 | *
27 | */
28 | function myTextSlice(text, l, type = '0') {
29 | if (text) {
30 | if (type == '0') {
31 | if (text.length >= 0) {
32 | return text.substring(0, l) + '...'
33 | } else {
34 | console.log('type 0 , 较短字符')
35 | return text
36 | }
37 | } else if (type == '1') {
38 | var returnText = ''
39 | var hanPattern = /[^\x00-\xff]/
40 | if (text.length > l) {
41 | l = l * 2
42 | for (var i = 0; i < l; i++) {
43 | if (text.substring(i, i + 1).match(hanPattern)) {
44 | // 全角字符 \ 双字节字符
45 | returnText = returnText + text.substring(i, i + 1)
46 | l = l - 1
47 | } else if (text.substring(i, i + 1) == '') {
48 | console.log('遇到字符串结尾')
49 | // 字符串结尾
50 | return text
51 | } else {
52 | // 半角字符
53 | returnText = returnText + text.substring(i, i + 1)
54 | }
55 | }
56 | returnText = returnText + '...'
57 | } else {
58 | console.log('较短字符')
59 | returnText = text
60 | }
61 | return returnText
62 | }
63 | }
64 | }
65 |
66 | /**对书按时间排序 */
67 | function collate(bookList){
68 | let recentList = [bookList[0]];
69 | for(let i=1; i=0;j--){
71 | try{
72 | var ri = recentList[j]['history']['time']
73 | }catch(e){
74 | var ri = 0
75 | }
76 | try {
77 | var bi = bookList[i]['history']['time']
78 | } catch (e) {
79 | var bi = 0
80 | }
81 | if(ri >= bi){
82 | recentList.splice(j+1, 0, bookList[i])
83 | break
84 | }else if(j == 0){
85 | recentList.splice(j, 0, bookList[i])
86 | }
87 | }
88 | }
89 | console.log('排序结果->',recentList)
90 | return recentList
91 | }
92 |
93 | function historyInit(booksList){
94 | let bookmgr = require('../../js/bookshelfMgr.js');
95 | let bookMgr = new bookmgr.bookshelfClass()
96 |
97 | for(var i =0; i')
160 | bookMgr = new bookmgr.bookshelfClass()
161 | booksList = bookMgr.getBooksInfo()
162 | historyInit(booksList) // 兼容性初始化
163 | this.setData({
164 | systemInfo:wx.getSystemInfoSync(),
165 | booksList:booksList
166 | })
167 | // 云端book, 包含setData显示
168 | this.setCloudBookList()
169 | // collate(booksList)
170 |
171 | // test
172 | // getNewUserBooks()
173 | },
174 |
175 | /**
176 | * 生命周期函数--监听页面初次渲染完成
177 | */
178 | onReady: function () {
179 |
180 | },
181 |
182 | /**
183 | * 生命周期函数--监听页面显示
184 | */
185 | onShow: function () {
186 | this.refreshPage()
187 | },
188 |
189 | /**
190 | * 生命周期函数--监听页面隐藏
191 | */
192 | onHide: function () {
193 |
194 | },
195 |
196 | /**
197 | * 生命周期函数--监听页面卸载
198 | */
199 | onUnload: function () {
200 |
201 | },
202 |
203 | /**
204 | * 页面相关事件处理函数--监听用户下拉动作
205 | */
206 | onPullDownRefresh: function () {
207 |
208 | },
209 |
210 | /**
211 | * 页面上拉触底事件的处理函数
212 | */
213 | onReachBottom: function () {
214 |
215 | },
216 |
217 | /**
218 | * 用户点击右上角分享
219 | */
220 | onShareAppMessage: function () {
221 |
222 | },
223 |
224 | /**点击书,进入目录或开始阅读 */
225 | tapBook:async function(e){
226 | console.log('tapBook ->', e.currentTarget.dataset.id)
227 | var id = e.currentTarget.dataset.id
228 | // 判断此Id是否在本地booKs中
229 | let check = bookMgr.getBookInfo(id)
230 | if(check[0] != undefined){
231 | wx.navigateTo({
232 | url: '../../pages/reading/reading?bookId=' + id
233 | })
234 | }else{
235 | // 判断是否在cloudBooks中
236 | let cloudCheck;
237 | for (let i in cloudBooksList){
238 | if(id == cloudBooksList[i]['id']){
239 | cloudCheck = true
240 | break
241 | }
242 | }
243 | if (cloudCheck){
244 | // 存在于cloudBooks中
245 | wx.showLoading({
246 | title:'下载中...'
247 | })
248 | var ok;
249 | try{
250 | ok = await bookMgr.downloadBook(id)
251 | }catch(e){}
252 | wx.hideLoading()
253 | if(ok = true){
254 | wx.navigateTo({
255 | url: '../../pages/reading/reading?bookId=' + id
256 | })
257 | }else{
258 | wx.showToast({
259 | title:'下载出错,请重试!',
260 | icon:'none'
261 | })
262 | }
263 |
264 | }
265 | }
266 |
267 | },
268 |
269 | /**进入阅读界面,不传参数 */
270 | toReadPage:function(){
271 | wx.navigateTo({
272 | url: '../../pages/reading/reading'
273 | })
274 | },
275 |
276 | /**进入阅读界面,并尝试获取剪贴板内容, */
277 | getClipboard:function(){
278 | wx.navigateTo({
279 | url: '../../pages/reading/reading?todo=' + 'openClipboard'
280 | })
281 | },
282 |
283 | /**记录当前要操作或将要操作的book */
284 | setCurrentBook:function(e){
285 | console.log('set currentBook----')
286 | let id = e.currentTarget.dataset.id;
287 | // console.log('set current book ->',currentBook,e)
288 | let currentBookInfo = getBookInfo(id)
289 | let local;
290 | let upload;
291 | let share;
292 | let type = 1;
293 | if ('cloud' in currentBookInfo){
294 | local = true;
295 | type = 1
296 | if (currentBookInfo.cloud.length > 0){
297 | upload = true;
298 | type = 3
299 | }
300 | }else{
301 | type = 5
302 | }
303 | // 全局变量记录
304 | currentBook = {
305 | id: id,
306 | bookshelf: e.currentTarget.dataset.w,
307 | type:type
308 | }
309 | if ('share' in currentBookInfo){
310 | if (currentBookInfo.share.shareLink.length > 0){
311 | share = true;
312 | type += 1
313 | }
314 | }
315 |
316 | let title = myTextSlice(currentBookInfo['title'], 6, '1')
317 | var page_currentBook = {
318 | title: title ,
319 | type:type.toString()
320 | }
321 | this.setData({
322 | currentBook: page_currentBook
323 | })
324 | },
325 |
326 | /**刷新页面数据*/
327 | refreshPage:async function(){
328 | var newBooksList = bookMgr.getBooksInfo()
329 | booksList = newBooksList
330 | this.setData({
331 | booksList: booksList
332 | })
333 | this.setCloudBookList(request=false)
334 | },
335 |
336 | deleteBook:async function(e){
337 | // test delete book
338 | var id = e.currentTarget.dataset.id
339 | let bookshelf;
340 | if(id == undefined && 'id' in currentBook){
341 | id = currentBook['id']
342 | bookshelf = currentBook.bookshelf
343 | currentBook = {} // 使用完清空
344 | }
345 | console.log('bookshelf ->',bookshelf)
346 |
347 | var bookInfo = bookMgr.getBookInfo(id)
348 | let isCloud = (bookshelf=="cloud")?'云端':''
349 | var tip = `确认删除${isCloud}《${bookInfo[1]['title']}》吗?`
350 | var certain = await new Promise((resolve,reject)=>{
351 | wx.showModal({
352 | title: '删除',
353 | content: tip,
354 | success(res) {
355 | resolve(res.confirm)
356 | }
357 | })
358 | })
359 |
360 | if(certain && bookshelf=="cloud"){
361 | // 仅删除云端
362 | console.log('仅删除云端')
363 | await bookMgr.deleteCloudBook(id)
364 | } else if (certain){
365 | // 没有指定cloud,全删
366 | console.log('没有指定cloud,全删')
367 | await bookMgr.deleteBook(id)
368 | }
369 | // console.log('test_delete_book modal tip ->',certain)
370 | let that = this
371 | setTimeout(() => {
372 | this.refreshPage()
373 | }, 200)
374 | },
375 |
376 | getInput: function(e){
377 | inputText = e.detail.value
378 |
379 | },
380 |
381 | inputDo:function(e){
382 | if(inputDo == "newBook"){
383 | this.saveBookByClipboard(e)
384 | }else{
385 | this.renameTitle(e)
386 | }
387 | inputDo = ''
388 | },
389 |
390 | renameTitle: function (e) {
391 | // console.log(e)
392 | if (e.currentTarget.dataset.certain == 'true') {
393 | //重命名
394 | var id = currentBook['id']
395 | bookMgr.renameBook(id, inputText)
396 | inputText = '' // 清空
397 | this.refreshPage()
398 | } else {
399 | // 取消重命名
400 | wx.showToast({
401 | title: '取消保存',
402 | icon: 'none'
403 | })
404 | }
405 | if (this.data.inputBox) {
406 | this.setData({
407 | inputBox: false,
408 | bookTitle: ''
409 | })
410 | } else {
411 | this.setData({
412 | inputBox: true,
413 | bookTitle: ''
414 | })
415 | }
416 | inputText = '' // 用完清空,避免混染
417 | },
418 |
419 | setInputText:function(e){
420 | // inputText
421 | let type = e.currentTarget.dataset.type
422 | if (type == "bookTitle"){
423 | // 给inputText赋值bookTitle,重命名书
424 | let id = currentBook['id']
425 | let isCloud = currentBook['bookshelf']
426 | let bookTitle = bookMgr.getBookInfo(id)[1]['title']
427 | inputDo = "rename"
428 | this.setData({
429 | inputText: bookTitle
430 | })
431 |
432 | }else if(type == "newBook"){
433 | // 设置默认新书书名
434 | inputDo = "newBook"
435 | this.setData({
436 | inputText: 'new Book'
437 | })
438 | inputText = 'new Book'
439 | }
440 | },
441 |
442 | upload:async function(e){
443 | // 上传至云端
444 | var id = e.currentTarget.dataset.id
445 | if (id == undefined && 'id' in currentBook) {
446 | id = currentBook['id']
447 | currentBook = {} // 使用完清空
448 | }
449 | await bookMgr.uploadBook(id)
450 | that = this
451 |
452 | setTimeout((that)=>{
453 | that.refreshPage()
454 | },200)
455 |
456 | },
457 |
458 | shareBook:async function(e){
459 | var id = e.currentTarget.dataset.id
460 | if (id == undefined && 'id' in currentBook) {
461 | id = currentBook['id']
462 | currentBook = {} // 使用完清空
463 | }
464 | let shareLink = await bookMgr.shareBook(id)
465 | let bookTitle = bookMgr.getBookInfo(id)[1]['title']
466 | shareLink = `我分享给你了《${bookTitle}》,快用英语划词阅读打开吧!share://${shareLink}/。`
467 | // shareLink复制到系统剪贴板
468 | wx.setClipboardData({
469 | data: shareLink
470 | })
471 | },
472 |
473 | test:function(e){
474 | console.log('test ->',e)
475 | },
476 |
477 | tapBook_del:function(e){
478 | console.log('e ->',e)
479 | },
480 |
481 | // 获取分享的书,通过shareLink, 检查剪贴板
482 | getShareBook:async function (e) {
483 | let clip_data =await getClipboardData()
484 | if(clip_data.length <= 1000){
485 | let shareLinkExtract = /^[\s\S]*?\b(\w+?&.+?&\w+?)\b[\s\S]*$/
486 | let shareLink = clip_data.replace(shareLinkExtract,'$1')
487 | console.log('提取后的shareLink->',shareLink)
488 | if (shareLink.match(/\w+?&.+?&\w+?/) != null){
489 | // 有效shareLink
490 | var bookMgr = new bookmgr.bookshelfClass()
491 | wx.showLoading({
492 | title:'获取中...'
493 | })
494 | console.log('shareLink ->',shareLink)
495 | var status = await bookMgr.addBookByShare(shareLink)
496 | wx.hideLoading()
497 | if(status.stats == 'ok'){
498 | wx.showToast({
499 | title:'添加成功!'
500 | })
501 | // 刷新页面显示, 改在后面刷新
502 | // setTimeout((bookshelf) => {
503 | // bookshelf.refreshPage()
504 | // }, 200)
505 | }else{
506 | wx.showToast({
507 | title:"添加失败",
508 | icon:"none"
509 | })
510 | }
511 | }else{
512 | wx.showToast({
513 | title: '剪贴板未发现分享链接!',
514 | icon: "none"
515 | })
516 | }
517 | }else{
518 | wx.showToast({
519 | title:'剪贴板未发现分享链接!',
520 | icon:"none"
521 | })
522 | }
523 | // 刷新页面显示
524 | setTimeout(() => {
525 | bookshelf.refreshPage()
526 | }, 200)
527 | },
528 |
529 | // 保存剪贴板内容
530 | saveBookByClipboard: async function (e) {
531 | // 先隐藏inputBox
532 | // console.log(e)
533 | if (e.currentTarget.dataset.certain == 'true') {
534 | // 保存
535 | // var bookMgr = new bookmgr.bookshelfClass()
536 | // bookMgr.addBookByText(article.article, inputText)
537 | let clipboardData = await getClipboardData()
538 | // console.log('clipboard data ->',gcb.clipboardData)
539 | var bookMgr = new bookmgr.bookshelfClass()
540 | console.log('inputTest ->',inputText)
541 | await bookMgr.addBookByText(clipboardData, inputText)
542 | } else {
543 | // 取消保存
544 | wx.showToast({
545 | title: '取消保存',
546 | icon: 'none'
547 | })
548 | }
549 | // 无论是否保存,清空page.data中的inputText
550 | if (this.data.inputBox) {
551 | this.setData({
552 | inputBox: false,
553 | inputText: ''
554 | })
555 | } else {
556 | this.setData({
557 | inputBox: true,
558 | inputText: ''
559 | })
560 | }
561 | inputText = '' // 用完清空,避免混染
562 | this.refreshPage()
563 | },
564 |
565 | /**显示云端book list*/
566 | setCloudBookList:async function(request=true){
567 | if (request) cloudBooksList = await bookMgr.getCloudBooksList()
568 | // 检查bookList 在本地有没有
569 | for(let i in cloudBooksList){
570 | cloudBooksList[i]['info'] = {len:cloudBooksList[i]['len']};
571 | delete cloudBooksList.len;
572 | for (let j in booksList){
573 | if(cloudBooksList[i]['id'] == booksList[j]['id']){
574 | // cloud book 同时在本地存在
575 | // 重命名 不会更改 云端title
576 | booksList[j]['title'] = cloudBooksList[i]['title']
577 | cloudBooksList[i] = booksList[j];
578 | break;
579 | }
580 | }
581 | }
582 | // 显示
583 | if (cloudBooksList){
584 | this.setData({
585 | cloudBooksList: cloudBooksList
586 | })
587 | }
588 | },
589 |
590 | /**下载云端book */
591 | download:async function(e){
592 | var id = e.currentTarget.dataset.id
593 | if (id == undefined && 'id' in currentBook) {
594 | id = currentBook['id']
595 | bookshelf = currentBook.bookshelf
596 | currentBook = {} // 使用完清空
597 | }
598 | // 判断是否在cloudBooks中
599 | let cloudCheck;
600 | for (let i in cloudBooksList) {
601 | if (id == cloudBooksList[i]['id']) {
602 | cloudCheck = true
603 | break
604 | }
605 | }
606 | if (cloudCheck) {
607 | // 存在于cloudBooks中
608 | var ok;
609 | wx.showToast({
610 | title: '开始下载...',
611 | icon:'none'
612 | })
613 | try {
614 | ok = await bookMgr.downloadBook(id)
615 | } catch (e) { }
616 | wx.showToast({
617 | title: '下载完成!'
618 | })
619 | }else{
620 | wx.showToast({
621 | title: '发生错误,未下载!',
622 | icon:'none'
623 | })
624 | }
625 | },
626 |
627 | /**取消分享, 取消后,用分享口令无法获取到这本书*/
628 | cancelShare:async function(e){
629 |
630 | }
631 |
632 | })
633 |
634 |
--------------------------------------------------------------------------------
/pages/bookshelf/bookshelf.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {}
3 | }
--------------------------------------------------------------------------------
/pages/bookshelf/bookshelf.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | 最近{{(booksList.length >= 5)?' - 5':' - ' + booksList.length}}
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | 本地{{' - ' + booksList.length}}
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | 云端{{' - ' + cloudBooksList.length}}
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
70 |
74 |
78 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 | {{currentBook.title}}
91 |
92 |
93 | 取消
94 |
95 |
96 |
97 | 上传
98 |
99 |
100 |
101 | 下载
102 |
103 |
104 |
105 | 分享
106 |
107 |
108 |
109 | 复制分享口令
110 |
111 |
112 |
113 | 取消分享
114 |
115 |
116 |
117 | 重命名
118 |
119 |
120 |
121 | 删除
122 |
123 |
124 |
125 | 更多
126 |
127 |
128 |
129 |
130 |
131 |
132 | 请输入标题:
133 |
134 | 取消
135 | 确定
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 | {{book['title']}}
144 |
145 | {{(book['history']['time'])?bookshelf.timeFormatting(book['history']['time']) + ' · ':''}}{{bookshelf.numberFormating(book['info']['len'])}}字
146 |
147 |
148 |
149 |
150 |
151 |
152 |
--------------------------------------------------------------------------------
/pages/bookshelf/bookshelf.wxs:
--------------------------------------------------------------------------------
1 |
2 | /**显示more操作框 */
3 | function showMoreBox(e, ownerInstance){
4 | console.log('wxs showMoreBox ->',e)
5 | var instance = ownerInstance.selectComponent('.book-more-box')
6 | var masking = ownerInstance.selectComponent('.page-masking')
7 | var pos = calcMoreBoxPosition(e)
8 | instance.addClass(pos[1])
9 | // instance.setStyle({
10 | // top:pos[0] + 'px'
11 | // })
12 | masking.addClass('masking-show')
13 | return false
14 | }
15 |
16 | function hiddenMoreBox(e,ownerInstance){
17 | console.log('wxs hiddenMoreBox ->', e)
18 | var instance = ownerInstance.selectComponent('.book-more-box')
19 | var masking = ownerInstance.selectComponent('.page-masking')
20 | instance.removeClass('more-box-show')
21 | instance.removeClass('more-box-show-up')
22 | masking.removeClass('masking-show')
23 | }
24 |
25 | function calcMoreBoxPosition(e){
26 | var y = e.touches[0]['clientY']
27 | var expY = 252 + 80 + 20 // more-box Height, navativeBar Hieght, surplus height
28 | if(y > expY){
29 | var top = y - 252 // more-box Height
30 | var className = 'more-box-show-up'
31 | }else{
32 | var top = y - 20 // 20 为自定义的一个调整量,无关其他
33 | var className = 'more-box-show'
34 | }
35 | return [top,className]
36 | }
37 |
38 | var menuButtonOpen = false
39 | function showAddMenu(e,ownerInstance){
40 | console.log('wxs showAddMenu ->',e)
41 | var instanceList = ownerInstance.selectAllComponents('.menu-button')
42 | var masking = ownerInstance.selectComponent('.page-masking')
43 | console.log(instanceList)
44 |
45 | if(!menuButtonOpen){
46 | // 展开
47 | for (var i = 0; i < instanceList.length; i++) {
48 | var instance = instanceList[i]
49 | console.log('instance ->', instance)
50 | var id = instance.getDataset()['id']
51 | console.log('getDataset id ->', id, menuButtonOpen)
52 | instance.setStyle({
53 | 'transform': 'translateY(-' + id * 70 + 'px)',
54 | 'opacity':'1'
55 | })
56 | instance.addClass('menu-button-show')
57 | }
58 | menuButtonOpen = true
59 | var addButton = ownerInstance.selectComponent('.add-button')
60 | addButton.setStyle({
61 | 'transform': 'rotate(135deg)',
62 | })
63 | masking.addClass('masking-show')
64 | }else{
65 | // 收起
66 | for (var i = 0; i < instanceList.length; i++) {
67 | var instance = instanceList[i]
68 | console.log('instance ->', instance)
69 | var id = instance.getDataset()['id']
70 | console.log('getDataset id ->', id, menuButtonOpen)
71 | instance.setStyle({
72 | 'transform': 'translateY(0px)',
73 | 'opacity':'0'
74 | })
75 | instance.removeClass('menu-button-show')
76 | }
77 | menuButtonOpen = false
78 | var addButton = ownerInstance.selectComponent('.add-button')
79 | addButton.setStyle({
80 | 'transform': 'rotate(0deg)',
81 | })
82 | masking.removeClass('masking-show')
83 | }
84 |
85 | }
86 |
87 |
88 | /**input输入框显示与否 */
89 | function inputTitle(e, ownerInstance) {
90 | console.log('ownerInstance ->', ownerInstance)
91 | if (ownerInstance != undefined) {
92 | var instance = ownerInstance.selectComponent('.input')
93 | var inputShow = instance.hasClass('test-input-show')
94 | if (inputShow) {
95 | instance.removeClass('input-show')
96 | } else {
97 | instance.addClass('input-show')
98 | // 设置inputText为书Title
99 | instance.callMethod('setInputText',e)
100 | }
101 | }
102 | }
103 | /**input输入框显示与否*/
104 | function inputBox(newValue, oldValue, ownerInstance, instance) {
105 | if (typeof (newValue) == "boolean") {
106 | var instance = ownerInstance.selectComponent('.input')
107 | var inputShow = instance.hasClass('input-show')
108 | if (inputShow) {
109 | instance.removeClass('input-show')
110 | } else {
111 | instance.addClass('input-show')
112 | }
113 | }
114 | }
115 |
116 | /**点击蒙层,关闭弹窗 */
117 | function tapMasking(e, ownerInstance){
118 | hiddenMoreBox(e, ownerInstance);
119 | if (menuButtonOpen){
120 | showAddMenu(e,ownerInstance) // 隐藏
121 | }
122 | }
123 |
124 |
125 | /**折叠书架 */
126 | function foldBookshelf(e,ownerInstance){
127 | var iclass= e.currentTarget.dataset.iclass
128 | var fclass = e.currentTarget.dataset.fclass
129 | var tclass = e.currentTarget.dataset.tclass
130 | var icon = ownerInstance.selectComponent('.'+ iclass)
131 | var title = ownerInstance.selectComponent('.' + tclass)
132 | var folds = ownerInstance.selectAllComponents('.' + fclass)
133 | if (icon.hasClass('b-icon-fold')){
134 | icon.removeClass('b-icon-fold')
135 | title.removeClass('b-title-fold')
136 | for (var i = 0; i < folds.length; i++) {
137 | var fold = folds[i]
138 | var top = 65 * i
139 | fold.setStyle({
140 | height:'60px',
141 | 'margin-top': '1px',
142 | opacity:1
143 | })
144 | }
145 | }else{
146 | icon.addClass('b-icon-fold')
147 | title.addClass('b-title-fold')
148 | for (var i = 0; i < folds.length; i++) {
149 | var fold = folds[i]
150 | var top = 65 * i
151 | fold.setStyle({
152 | height:'0px',
153 | 'margin-top':'0',
154 | opacity:0
155 | })
156 | }
157 | }
158 |
159 | }
160 |
161 |
162 | /**对书按时间排序 */
163 | function collate(bookList) {
164 | var recentList = [bookList[0]];
165 | for (var i = 1; i < bookList.length; i++) {
166 | for (var j = recentList.length - 1; j >= 0; j--) {
167 | // 判断兼容早期history为字符串类型
168 | var ri = recentList[j]['history']['time']
169 | var bi = bookList[i]['history']['time']
170 | if (ri >= bi) {
171 | recentList.splice(j + 1, 0, bookList[i])
172 | break
173 | } else if (j == 0) {
174 | recentList.splice(j, 0, bookList[i])
175 | }
176 | }
177 | }
178 | // console.log('排序结果->',recentList)
179 | return recentList
180 | }
181 |
182 |
183 | /**时间格式化-将getTime()时间格式化 */
184 | function timeFormatting(time){
185 | var date = getDate()
186 | var n_y = date.getFullYear()
187 | var n_m = date.getMonth() + 1
188 | var n_d = date.getDate()
189 | date.setTime(time)
190 | var y = date.getFullYear()
191 | var m = date.getMonth() + 1
192 | var d = date.getDate()
193 | var h = date.getHours()
194 | var mm = date.getMinutes()
195 | if(m < 10) m = '0' + m;
196 | if(d <10) d = '0' + d;
197 | if(h <10) h = '0' + h;
198 | if(mm <10) mm ='0' +mm;
199 |
200 | if(n_y == y){
201 | // 今年
202 | if(n_m == m){
203 | // 本月
204 | if(n_d == d){
205 | // 今天
206 | var formatTime = '今天 · ' + h + ':' + mm
207 | return formatTime
208 | }else if(n_d == d + 1){
209 | // 昨天
210 | var formatTime = '昨天 · ' + h + ':' + mm
211 | return formatTime
212 | }else if(n_d == d + 2){
213 | // 前天
214 | var formatTime = '前天 · ' + h + ':' + mm
215 | return formatTime
216 | }else{
217 | var formatTime = m + '月' + d + '日' + h + ':' + mm
218 | return formatTime
219 | }
220 | }
221 | var formatTime = y + '年' + m + '月' + d + '日'
222 | return formatTime
223 | }else{
224 | var formatTime = y + '年' + m + '月' + d + '日'
225 | return formatTime
226 | }
227 |
228 | }
229 |
230 |
231 | /**字数格式化-将具体数字格式化为12.3W格式 */
232 | function numberFormating(n){
233 | if(n < 1000){
234 | return n
235 | }else if(n < 10000){
236 | var fn = n / 1000
237 | fn = fn.toFixed(2)
238 | return fn + 'k'
239 | }else if(n < 1000000){
240 | var fn = n / 10000
241 | fn = fn.toFixed(2)
242 | return fn + 'w'
243 | }else{
244 | // 字数超过100万
245 | var fn = n / 10000
246 | fn = fn.toFixed(2)
247 | return fn + 'w'
248 | }
249 | }
250 |
251 | /**判断书属于那种类型,本地,剪贴板缓存 or 仅云端 */
252 | function whatType(fileType){
253 | if(fileType == ".txt"){
254 | return 'local'
255 | }else if(fileType == "catch"){
256 | return 'catch'
257 | }else if(!fileType){
258 | return 'cloud'
259 | }
260 | }
261 |
262 |
263 | /**more box 对不同书适配 */
264 | function moreBoxFit(newValue, oldValue, ownerInstance, instance){
265 | var type = newValue;
266 | console.log('moreBoxFit ->',type)
267 | var m_u = ownerInstance.selectComponent('.m-u') // 上传
268 | var m_d = ownerInstance.selectComponent('.m-d') // 下载
269 | var m_s = ownerInstance.selectComponent('.m-s') // 分享
270 | var m_cs = ownerInstance.selectComponent('.m-cs') // 复制分享口令
271 | var m_sc = ownerInstance.selectComponent('.m-sc') // 取消分享
272 | var m_r = ownerInstance.selectComponent('.m-r') // 重命名
273 | var m_de = ownerInstance.selectComponent('.m-de') // 删除
274 | var all_list = [m_u,m_d,m_s,m_cs,m_sc,m_r,m_de]
275 | // 初始化
276 | for(var i=0; i= 0) {
316 | return text.substring(0, l) + '...'
317 | } else {
318 | console.log('type 0 , 较短字符')
319 | return text
320 | }
321 | } else if (type == '1') {
322 | var returnText = ''
323 | var hanPattern = getRegExp("/[^\x00-\xff]/")
324 | if (text.length > l) {
325 | l = l * 2
326 | for (var i = 0; i < l; i++) {
327 | if (text.substring(i, i + 1).match(hanPattern)) {
328 | // 全角字符 \ 双字节字符
329 | returnText = returnText + text.substring(i, i + 1)
330 | l = l - 1
331 | } else if (text.substring(i, i + 1) == '') {
332 | console.log('遇到字符串结尾')
333 | // 字符串结尾
334 | return text
335 | } else {
336 | // 半角字符
337 | returnText = returnText + text.substring(i, i + 1)
338 | }
339 | }
340 | returnText = returnText + '...'
341 | } else {
342 | console.log('较短字符')
343 | returnText = text
344 | }
345 | return returnText
346 | }
347 | }
348 | }
349 |
350 |
351 |
352 | module.exports = {
353 | showMoreBox: showMoreBox,
354 | hiddenMoreBox: hiddenMoreBox,
355 | showAddMenu: showAddMenu,
356 | inputTitle: inputTitle,
357 | inputBox: inputBox,
358 | tapMasking: tapMasking,
359 | foldBookshelf: foldBookshelf,
360 | collate: collate,
361 | timeFormatting: timeFormatting,
362 | numberFormating: numberFormating,
363 | whatType:whatType,
364 | moreBoxFit: moreBoxFit,
365 | textSlice: textSlice,
366 | }
--------------------------------------------------------------------------------
/pages/bookshelf/bookshelf.wxss:
--------------------------------------------------------------------------------
1 | /* pages/bookshelf/bookshelf.wxss */
2 | @import '../../template/template.wxss';
3 |
4 | .page-background{
5 | /*background-color:#ddd;*/
6 | background-color:#eee;
7 | width:100vw;
8 | height:100vh;
9 | position:fixed;
10 | top:0;
11 | left:0;
12 | z-index:0;
13 | }
14 |
15 | .navigationBar{
16 | width:100vw;
17 | height:60px;
18 | position:fixed;
19 | z-index:10;
20 | align-items:center;
21 | padding-top:20px;
22 | display:flex;
23 | /*background-color:#1c80ff;*/
24 | box-shadow:2px 0px 20px rgba(0,0,0,0.08);
25 | color:#fff;
26 | background:linear-gradient(to right, #1c80ff, #05AFF2);
27 | }
28 | .nav-title{
29 | height:32px;
30 | line-height:32px;
31 | font-size:16px;
32 | margin-left:15px;
33 | }
34 | .nav-button{
35 | height:20px;
36 | width:20px;
37 | padding:6px;
38 | margin-left:10px;
39 | /*background-color:#fff;*/
40 | border-radius:16px;
41 | }
42 |
43 |
44 | .bookshelf{
45 | padding-top:100px;
46 | padding-bottom:100px;
47 | overflow:hidden;
48 | }
49 |
50 | .books-infobar-container{
51 | position:relative;
52 | }
53 | .bookshelf-title-bar{
54 | height:30px;
55 | align-items:center;
56 | display:flex;
57 | padding-top:10px;
58 | }
59 | .bookshelf-title{
60 | margin-left:15px;
61 | font-size:14px;
62 | }
63 | .bookshelf-icon{
64 | position:absolute;
65 | width:30px;
66 | height:30px;
67 | right:15px;
68 | transition:all 0.5s;
69 | }
70 | .b-icon-fold{
71 | transform:rotate(90deg);
72 | }
73 |
74 |
75 | .books-infobar{
76 | background-color:#fff;
77 | height:50px;
78 | width:calc(100% - 30px);
79 | display:flex;
80 | align-items:center;
81 | padding: 5px 15px;
82 | }
83 | .books-image{
84 | width:31px;
85 | height:50px;
86 | }
87 | .book-info{
88 | display:block;
89 | padding-left:15px;
90 | }
91 | .books-title{
92 | font-size:17px;
93 | display:block;
94 | }
95 | .b-title-fold{
96 | border-bottom:1px solid #05AFF2;
97 | }
98 | .info-detail{
99 | display:flex;
100 | }
101 | .detail-icon{
102 | display:inline-block;
103 | width:15px;
104 | height:15px;
105 | margin:0 7.5px;
106 | }
107 | .books-icon{
108 | width:30px;
109 | height:30px;
110 | position:absolute;
111 | right:15px;
112 | }
113 | .books-last{
114 | font-size:10px;
115 | }
116 | .book-fold{
117 | position:relative;
118 | height:60px;
119 | transition:all 0.5s;
120 | margin-top:1px;
121 | }
122 | .book-empty-img{
123 | position:relative;
124 | height:60px;
125 | width:60px;
126 | left:calc((100% - 60px) / 2);
127 | }
128 |
129 |
130 | @keyframes fold{
131 | 0%{
132 |
133 | }
134 | 50%{
135 |
136 | }
137 | 100%{
138 | height:0px;
139 | }
140 | }
141 |
142 | .page-masking{
143 | position:fixed;
144 | top:0;
145 | left:0;
146 | width:100vw;
147 | height:100vh;
148 | display:none;
149 | background-color:rgba(0,0,0,0.32);
150 | }
151 | .masking-show{
152 | display:block;
153 | }
154 |
155 |
156 | .book-more-box{
157 | width:0;
158 | transform:scaleY(0);
159 | opacity:0;
160 |
161 | border-radius:5px;
162 | background-color:#fff;
163 | box-shadow:0 0 10px rgba(0,0,0,0.3);
164 |
165 | position:fixed;
166 | top:100px;
167 | /*right:40px;*/
168 | right:calc((100vw - 140px) / 2);
169 | overflow:hidden;
170 |
171 | transition:all 0.3s, top 0.1s;
172 | }
173 | .more-box-show{
174 | top:120px;
175 | width:140px;
176 | transform:scaleY(1);
177 | transform-origin: 0 0;
178 | opacity:1;
179 | }
180 | .book-title{
181 | height:32px;
182 | line-height:32px;
183 | text-align:center;
184 | font-size:14px;
185 | }
186 | .more-box-show-up{
187 | width:140px;
188 | transform:scaleY(1);
189 | transform-origin: 0 100%;
190 | opacity:1;
191 | }
192 | .book-more-item{
193 | height:32px;
194 | margin: 5px 10px;
195 | align-items:center;
196 | display:flex;
197 | }
198 | .item-unavailable{
199 | display:none;
200 | /*opacity:0.3;*/
201 | }
202 | .item-icon{
203 | width:20px;
204 | height:20px;
205 | padding:6px;
206 | }
207 | .item-title{
208 | height:30px;
209 | line-height:30px;
210 | font-size:14px;
211 | }
212 |
213 | .add-container{
214 |
215 | }
216 | .add-button-shadow{
217 | position:fixed;
218 | right:15px;
219 | bottom:15px;
220 | width:30px;
221 | height:30px;
222 | padding:15px;
223 | border-radius:30px;
224 | box-shadow:1px 1px 10px rgba(0,0,0,0.3);
225 | }
226 | .add-button{
227 | position:fixed;
228 | right:15px;
229 | bottom:15px;
230 | width:30px;
231 | height:30px;
232 | padding:15px;
233 | border-radius:30px;
234 | /*background-color:#ccf;*/
235 | background-color:#1c80ff;
236 | z-index:100;
237 | transition:all 0.5s ease-in-out;
238 | }
239 | .menu-button{
240 | position:fixed;
241 | right:15px;
242 | bottom:15px;
243 | width:60px;
244 | height:60px;
245 | z-index:90;
246 | transition:all 0.3s;
247 | opacity:0;
248 | }
249 | .menu-button-show{
250 | width:500px;
251 | }
252 | .menu-button-icon{
253 | position:absolute;
254 | right:0;
255 | bottom:0;
256 | width:30px;
257 | height:30px;
258 | padding:15px;
259 | border-radius:30px;
260 | box-shadow:1px 1px 10px rgba(0,0,0,0.3);
261 | background-color:#fff;
262 | }
263 | .menu-tip{
264 | position:absolute;
265 | right:70px;
266 | top:18px;
267 | height:24px;
268 | line-height:24px;
269 | font-size:14px;
270 | color:#fff;
271 | padding:0 10px;
272 | border-radius:7px;
273 | background-color:#333;
274 | box-shadow:1px 1px 10px rgba(0,0,0,0.3);
275 | }
276 |
277 | /**未使用*/
278 | .button-pop{
279 | animation:pop 0.6s;
280 | }
281 | @keyframes pop{
282 | 0%{
283 | transform:scale(0.9)
284 | }
285 | 50%{
286 | transform:scale(1.1)
287 | }
288 | 100%{
289 | transtorm:scale(0.9)
290 | }
291 | }
--------------------------------------------------------------------------------
/pages/logs/logs.js:
--------------------------------------------------------------------------------
1 | //logs.js
2 | const util = require('../../utils/util.js')
3 |
4 | Page({
5 | data: {
6 | logs: []
7 | },
8 | onLoad: function () {
9 | this.setData({
10 | logs: (wx.getStorageSync('logs') || []).map(log => {
11 | return util.formatTime(new Date(log))
12 | })
13 | })
14 | }
15 | })
16 |
--------------------------------------------------------------------------------
/pages/logs/logs.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "查看启动日志",
3 | "usingComponents": {}
4 | }
--------------------------------------------------------------------------------
/pages/logs/logs.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{index + 1}}. {{log}}
5 |
6 |
7 |
--------------------------------------------------------------------------------
/pages/logs/logs.wxss:
--------------------------------------------------------------------------------
1 | .log-list {
2 | display: flex;
3 | flex-direction: column;
4 | padding: 40rpx;
5 | }
6 | .log-item {
7 | margin: 10rpx;
8 | }
9 |
--------------------------------------------------------------------------------
/pages/me/me.js:
--------------------------------------------------------------------------------
1 | // pages/me/me.js
2 | var me; // 相当于onLoad 里的this
3 | var todo;
4 | var currentO = {}; // 记录当前操作对象的信息,格式{}
5 | var inputText; // 记录输入内容
6 |
7 | /**绘制使用情况的函数 */
8 | function drawLine(list = []){
9 | list = [5, 20, 29, 74, 42, 6, 42];
10 | console.log('drawLine')
11 | let imgLine = wx.createCanvasContext('use_info');
12 | let canvasW = 300; // canvas 宽
13 | let canvasH = 100; // canvas 高
14 |
15 | let step = canvasW / ( list.length + 1 )
16 | let d_X = step;
17 |
18 | imgLine.setLineWidth = 5;
19 | imgLine.setStrokeStyle('#1c80ff')
20 | imgLine.setTextAlign('center')
21 | let grd = imgLine.createLinearGradient(0, 0, 0, canvasH);
22 | grd.addColorStop(0, '#1c80ff') //rgba(28,128,255,0.6)
23 | grd.addColorStop(1, '#ffffff')
24 | imgLine.setFillStyle(grd)
25 |
26 |
27 | imgLine.moveTo(d_X,canvasH - list[0])
28 | for(let i =1; i< list.length; i++){
29 | d_X += step;
30 | imgLine.lineTo(d_X, canvasH - list[i]);
31 | }
32 | // imgLine.closePath()
33 | imgLine.fill()
34 | imgLine.stroke()
35 | imgLine.draw()
36 | }
37 |
38 | function todoClass(){
39 | this.todo = [];
40 | // 读取
41 | this.getD = function(){
42 | let todoD = wx.getStorageSync('todo');
43 | if (!todoD) {
44 | todoD = [
45 | '⛳可以在这里记下要做的事!',
46 | '👉比如每天阅读一小时 🎓',
47 | '💡记的坚持下去哦,✊加油!',
48 | '☁☕💡📝🔍❌❗',
49 | ]
50 | }
51 | this.todo = todoD
52 | this.setD()
53 | }
54 |
55 | // 编辑
56 | this.edit = function(index,text){
57 | console.log('todo edit',text)
58 | this.todo[index] = text
59 | // 为空则删除
60 | if(this.todo[index].match(/\s*/)[0]){
61 | this.todo.splice(index, 1)
62 | console.log('删除')
63 | }
64 | this.setD()
65 | }
66 |
67 | // 添加
68 | this.add = function(text){
69 | console.log('todo add')
70 | this.todo.push(text)
71 | this.setD()
72 | }
73 |
74 | // setData
75 | this.setD = function(){
76 | me.setData({
77 | todo:this.todo
78 | })
79 | // 储存
80 | wx.setStorageSync('todo',this.todo)
81 | }
82 | }
83 |
84 | Page({
85 |
86 | /**
87 | * 页面的初始数据
88 | */
89 | data: {
90 | todo:[],
91 | textareaValue:'',
92 | inputFocus:false,
93 | },
94 |
95 | /**
96 | * 生命周期函数--监听页面加载
97 | */
98 | onLoad: function (options) {
99 | me = this
100 | // drawLine()
101 | // wx.openSetting({})
102 |
103 | todo = new todoClass()
104 | todo.getD()
105 |
106 | },
107 |
108 | /**
109 | * 生命周期函数--监听页面初次渲染完成
110 | */
111 | onReady: function () {
112 |
113 | },
114 |
115 | /**
116 | * 生命周期函数--监听页面显示
117 | */
118 | onShow: function () {
119 |
120 | },
121 |
122 | /**
123 | * 生命周期函数--监听页面隐藏
124 | */
125 | onHide: function () {
126 |
127 | },
128 |
129 | /**
130 | * 生命周期函数--监听页面卸载
131 | */
132 | onUnload: function () {
133 | },
134 |
135 | /**
136 | * 页面相关事件处理函数--监听用户下拉动作
137 | */
138 | onPullDownRefresh: function () {
139 |
140 | },
141 |
142 | /**
143 | * 页面上拉触底事件的处理函数
144 | */
145 | onReachBottom: function () {
146 |
147 | },
148 |
149 | /**
150 | * 用户点击右上角分享
151 | */
152 | onShareAppMessage: function () {
153 |
154 | },
155 |
156 | tapTodo:function(e){
157 | let index = e.currentTarget.dataset.index;
158 |
159 | },
160 |
161 | eidtTodo:function(index){
162 | console.log('eidt todo',index)
163 | // 编辑
164 | this.setData({
165 | textareaValue:todo.todo[index],
166 | inputFocus:true,
167 | })
168 |
169 | // inputText赋值
170 | inputText = todo.todo[index]
171 |
172 | // 记录
173 | currentO = {
174 | who: 'todo',
175 | todo: 'edit',
176 | index:index
177 | }
178 | },
179 |
180 | // 记录输入
181 | input:function(e){
182 | inputText = e.detail.value;
183 | },
184 |
185 | newTodo:function(){
186 | currentO = {
187 | who:'todo',
188 | todo:'newTodo'
189 | }
190 | this.setData({
191 | inputFocus:true,
192 | })
193 | },
194 |
195 | inputDone:function(e){
196 | console.log('input', e)
197 | console.log('currentO,',currentO)
198 | console.log('inputText->',inputText)
199 | // input = e.detail.value;
200 | let inputTodo;
201 | if('todo' in currentO){
202 | if(currentO.todo == 'newTodo'){
203 | inputTodo = 'newTodo';
204 | } else if (currentO.todo == 'edit'){
205 | inputTodo = 'eidtTodo'
206 | }else{
207 | console.log('未定义inputDone行为 ->',currentO)
208 | console.log(currentO.todo, 'edit')
209 | }
210 | }
211 | // 为何输入
212 | if (inputTodo == 'newTodo'){
213 | console.log('add')
214 | todo.add(inputText)
215 | } else if (inputTodo == 'eidtTodo'){
216 | let index = currentO.index
217 | todo.edit(index, inputText)
218 | } else {
219 | console.log('未定义inputDone行为 ->', currentO)
220 | }
221 |
222 | // 清空上次输入记录
223 | inputText = ''
224 | currentO = {}
225 | this.setData({
226 | textareaValue:''
227 | })
228 | }
229 | })
--------------------------------------------------------------------------------
/pages/me/me.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {}
3 | }
--------------------------------------------------------------------------------
/pages/me/me.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
13 |
14 |
15 | TO DO
16 |
17 | {{item}}
18 |
19 | +
20 |
21 |
22 | 分享
23 |
24 |
25 |
26 |
27 | 意见反馈
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | 我们需要您的一些信息,以便给您提供更好的服务
38 |
39 |
40 |
41 |
42 |
43 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/pages/me/me.wxs:
--------------------------------------------------------------------------------
1 |
2 | /**todo输入,显示textarea */
3 | function inputTodo(e,owner){
4 | var textarea = owner.selectComponent('.text-edit');
5 | textarea.setStyle({
6 | display:'block'
7 | })
8 | var todo = e.currentTarget.dataset.todo;
9 | if(todo == 'edit'){
10 | var index = e.currentTarget.dataset.index.toString()
11 | if(! index) index = 0
12 | textarea.callMethod('eidtTodo',index)
13 | }else if(todo =="new"){
14 | textarea.callMethod('newTodo','')
15 | }
16 | }
17 |
18 | function inputDone(e, owner){
19 | var textarea = owner.selectComponent('.text-edit');
20 | textarea.setStyle({
21 | display: 'none'
22 | })
23 | textarea.callMethod('inputDone',e)
24 | }
25 |
26 |
27 | module.exports = {
28 | inputTodo: inputTodo,
29 | inputDone: inputDone
30 | }
--------------------------------------------------------------------------------
/pages/me/me.wxss:
--------------------------------------------------------------------------------
1 | /* pages/me/me.wxss */
2 | .me-container{
3 | position:fixed;
4 | top:0;
5 | left:0;
6 | width:100vw;
7 | height:80vw;
8 | }
9 | .me-bg{
10 | position:absolute;
11 | z-index:-10;
12 | width:100%;
13 | height:100%;
14 | background-color:#aaa;
15 | }
16 |
17 | .me-avatar{
18 | position:absolute;
19 | width:70px;
20 | height:70px;
21 | border-radius:50%;
22 | border:2px solid rgba(255,255,255,0.5);
23 | top:calc(80vw - 70px - 80px);
24 | left:calc((100vw - 70px) / 2 - 2px);
25 | overflow:hidden;
26 | }
27 | .me-nickname{
28 | position:absolute;
29 | width:100%;
30 | height:32px;
31 | line-height:32px;
32 | font-size:24px;
33 | top:calc(80vw - 70px);
34 | text-align:center;
35 | color:rgba(255,255,255,0.9);
36 | /*background:linear-gradient(90deg, rgba(0,0,0,0) 30%, #fff 50%, rgba(0,0,0,0) 70% );*/
37 | }
38 |
39 |
40 | .request-authorize{
41 | position:fixed;
42 | width:200px;
43 | height:100px;
44 | top:calc((100vh - 100px) / 2);
45 | left:calc((100vw - 200px) / 2);
46 | background-color:#fff;
47 | box-shadow:0 0 20px rgba(255,255,255,0.2);
48 | border-radius:5px;
49 | text-align:center;
50 | }
51 | .req-auth-tip{
52 | padding:20px 20px 10px 20px;
53 | font-size:11px;
54 | color:#333;
55 | }
56 |
57 | .item-box{
58 | position:absolute;
59 | top:calc(80vw - 30px);
60 | left:0;
61 | width:calc(100% - 40px);
62 | background-color:rgba(255,255,255,1);
63 | padding: 20px 20px 20px 20px;
64 | min-height:calc(100vh - 80vw - 30px);
65 | border-radius:20px 20px 0 0;
66 | }
67 | .bottom-fix{
68 | position:absolute;
69 | height:32px;
70 | width:100vw;
71 | bottom:-30px;
72 | left:0px;
73 | background-color:#fff;
74 | /*background-color:rgba(250,250,250,0.9);*/
75 | /*background:linear-gradient(180deg, rgba(255,255,255,0.8) 0%, rgba(255,255,255,1));*/
76 | }
77 | .item-use{
78 | font-size:14px;
79 | }
80 | .use-canvas{
81 | width:calc(100% -40px);
82 | height:120px;
83 | }
84 |
85 | .item-bar-title{
86 | margin:0 0 10px 0;
87 | }
88 | .todo-bar{
89 | width:100%;
90 | border-radius:100px;
91 | text-align:center;
92 | font-size:12px;
93 | color:#333;
94 | /*background-color:rgba(0,0,0,0.5);*/
95 | padding:6px 0;
96 | margin:10px 0;
97 | /*box-shadow:0 0 10px rgba(0,0,0,0.07);*/
98 | border:1px solid rgba(0,0,0,0.2);
99 | }
100 |
101 |
102 | .share-button{
103 | position:relative;
104 | width:100%;
105 | height:40px;
106 | margin: 20px 0;
107 | border-radius:20px;
108 | background-color:#fff;
109 | font-size:14px;
110 | color:#333;
111 | text-align:center;
112 | line-height:40px;
113 | /*box-shadow:0 0 20px rgba(0,0,0,0.2);*/
114 | border:1px solid rgba(0,0,0,0.2);
115 | }
116 | .share-button-button{
117 | position:absolute;
118 | top:0;
119 | width:100%;
120 | height:100%;
121 | opacity:0;
122 | }
123 |
124 | .feedback-button{
125 | position:relative;
126 | width:60px;
127 | height:32px;
128 | line-height:32px;
129 | color:#1c80ff;
130 | text-align:center;
131 | left:calc((100% - 60px) / 2);
132 | margin-top:30px;
133 | font-size:12px;
134 | }
135 | .feedback-button-button{
136 | position:absolute;
137 | top:0;
138 | width:100%;
139 | height:100%;
140 | opacity:0;
141 | }
142 |
143 |
144 | .text-edit{
145 | position:fixed;
146 | top:25vh;
147 | left:20px;
148 | width:calc(100% - 80px);
149 | padding:20px;
150 | background-color:#333;
151 | color:#fff;
152 | border-radius:40px;
153 | box-shadow: 0 0 10px rgba(0,0,0,0.3);
154 | opacity:0.8;
155 | transition:all 0.2s;
156 | display:none;
157 | }
158 |
159 |
160 |
--------------------------------------------------------------------------------
/pages/reading/reading.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {}
3 | }
--------------------------------------------------------------------------------
/pages/reading/reading.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | {{word}}
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | 加载中
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | {{word}}
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | 加载中
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | {{word}}
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | 加载中
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
91 |
92 |
93 |
94 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 | {{word}}
106 |
107 |
108 |
109 |
110 | {{word}}
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 | {{reading.capitalize(lookUp_result['word'])}}
123 |
124 |
125 |
126 | {{(lookUp_result['ukphone'] || lookUp_result['ukspeech'])?'英':''}} {{(lookUp_result['ukphone'])? lookUp_result['ukphone']:''}}
127 |
128 | {{(lookUp_result['usphone'] || lookUp_result['usspeech'])?'美':''}} {{(lookUp_result['usphone'])? lookUp_result['usphone']:''}}
129 |
130 |
131 | {{item}}
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 | 保存剪贴板内容:
146 |
147 | 取消
148 | 确定
149 |
150 |
151 | 请输入书签标题:
152 |
153 | 取消
154 | 确定
155 |
156 |
157 |
158 |
159 |
160 |
161 | {{title}}
162 |
163 | 书签
164 | 页码
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 | {{item['title']}}
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 | {{item + 1}}
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 | {{item[0]}}
204 | {{' ' + reading.textSlice(item[1],24)}}
205 |
206 |
207 |
208 | Hello
209 |
210 |
211 |
--------------------------------------------------------------------------------
/pages/reading/reading.wxs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | var sum_top = 0;
5 | var lastTop = 0;
6 | var navHeight = 120; // statusBarHeight + navHeight
7 | var topColumn;
8 |
9 |
10 | /**顶栏下滑显示,上滑隐藏
11 | * e.detail = {deltaX:0,deltaY:-1.22,scrollHeight:766,scrollLeft:0,scrollTop:1.22,scrollWidth:411}
12 | */
13 | function navScroll(e,s){
14 | // var topColumn = s.selectComponent('.top-column')
15 | // topColumn 在setNavData中赋值
16 | if (topColumn){
17 | var scrollTop = e.detail.scrollTop
18 | if (lastTop < scrollTop) {
19 | // 页面向上滑动,向下浏览,关闭,lastTop < scrollTop,sum_top变小
20 | if (sum_top <= -navHeight) {
21 | // 已完全隐藏
22 |
23 | } else {
24 | sum_top += scrollTop - lastTop
25 | if (sum_top > navHeight) sum_top = navHeight
26 | topColumn.setStyle({
27 | 'transform': 'translateY(' + sum_top + 'px)'
28 | })
29 | }
30 | } else {
31 | // 向下,返回查看上面的内容,显示, lastTop > scrollTop, sum_top变大
32 | if (sum_top <= 0) {
33 | // 已完全显示
34 |
35 | } else {
36 | sum_top += scrollTop - lastTop
37 | if (sum_top < 0) sum_top = 0
38 | topColumn.setStyle({
39 | 'transform': 'translateY(' + sum_top + 'px)'
40 | })
41 | }
42 | }
43 | // 记录本次的值,用于判断滑动方向
44 | lastTop = scrollTop
45 | }else{
46 | topColumn = s.selectComponent('.top-column')
47 | }
48 | }
49 |
50 | /** 根据不同机型设置top column高度
51 | * 将top column移动到下面后,这个可以不要
52 | */
53 | function setNavData(systemInfo, oldValue, ownerInstance, instance){
54 | var navBar = ownerInstance.selectComponent('.navigationBar')
55 | topColumn = ownerInstance.selectComponent('.top-column')
56 | var catalog = ownerInstance.selectComponent('.catalog-title')
57 | if(systemInfo){
58 | var statusBarHeight = systemInfo.statusBarHeight
59 | // if (isNaN(statusBarHeight)) statusBarHeight = 20
60 | if (systemInfo.system.substring(0, 2) == 'iOS') {
61 | // 记录topColumn总高, 46为operateBar的高度
62 | navHeight = 44 + statusBarHeight + 46
63 | // 适配
64 | navBar.setStyle({
65 | height: '44px',
66 | 'padding-top': statusBarHeight + 'px'
67 | })
68 | // 设置书签页标题栏高度
69 | catalog.setStyle({
70 | 'padding-top': statusBarHeight + 'px',
71 | height: '44px',
72 | })
73 | } else {
74 | // 记录topColumn总高, 46为operateBar的高度
75 | navHeight = 48 + statusBarHeight + 46
76 | // 适配
77 | navBar.setStyle({
78 | height: '48px',
79 | 'padding-top': statusBarHeight + 'px'
80 | })
81 | // 设置书签页标题栏高度
82 | catalog.setStyle({
83 | 'padding-top': statusBarHeight + 'px',
84 | height: '48px',
85 | })
86 | }
87 | }
88 | }
89 |
90 | // /**展示,隐藏顶栏 */
91 | // function sTouchMove(e, owner) {
92 | // console.log('sTouchMove')
93 | // var instance = s.selectComponent('.top-column')
94 | // var scrollTop = e.changedTouches[0].clientY
95 | // if (lastTop < scrollTop) {
96 | // // 页面向上滑动,向下浏览,关闭,lastTop < scrollTop,sum_top变小
97 | // if (sum_top < -110) {
98 | // // 已完全隐藏
99 |
100 | // } else {
101 | // sum_top += lastTop - scrollTop
102 | // if (sum_top < -110) sum_top = -110
103 | // instance.setStyle({
104 | // 'transform': 'translateY(' + sum_top + 'px)'
105 | // })
106 | // }
107 | // } else {
108 | // // 向下,返回查看上面的内容,显示, lastTop > scrollTop, sum_top变大
109 | // if (sum_top > 0) {
110 | // // 已完全显示
111 |
112 | // } else {
113 | // sum_top += lastTop - scrollTop
114 | // if (sum_top > 0) sum_top = 0
115 | // instance.setStyle({
116 | // 'transform': 'translateY(' + sum_top + 'px)'
117 | // })
118 | // }
119 | // }
120 |
121 | // // 记录本次的值,用于判断滑动方向
122 | // lastTop = scrollTop
123 | // }
124 |
125 | /**input输入框显示与否 bintdtap调用 */
126 | function inputShow(e,ownerInstance){
127 | // console.log('ownerInstance ->', ownerInstance,e)
128 | if (ownerInstance != undefined){
129 | var instance = ownerInstance.selectComponent('.input')
130 | var inputShow = instance.hasClass('input-show')
131 | if (inputShow) {
132 | instance.removeClass('input-show')
133 | } else {
134 | instance.addClass('input-show')
135 | }
136 | }
137 | }
138 | /**input输入框显示与否,change:porp调用*/
139 | function inputBox(newValue, oldValue, ownerInstance, instance){
140 | console.log('===================== ->',newValue)
141 | if(newValue != undefined){
142 | // console.log('call inputTitle()')
143 | inputShow('aaaaaaaaa', ownerInstance)
144 | }
145 | }
146 |
147 |
148 | /**catalog目录显示与否 */
149 | function catalogBox(e,ownerInstance,instance){
150 | var instance = ownerInstance.selectComponent('.catalog')
151 | var catalogShow = instance.hasClass('catalog-show')
152 | var bg = ownerInstance.selectComponent('.catalog-bg')
153 | if(catalogShow){
154 | instance.removeClass('catalog-show')
155 | bg.removeClass('catalog-bg-show')
156 | }else{
157 | instance.addClass('catalog-show')
158 | bg.addClass('catalog-bg-show')
159 | }
160 | wxsHover(e,ownerInstance) // 点击动画
161 | }
162 |
163 | /**目录点击效果 */
164 | function tapCatalog(e,ownerInstance){
165 | // var instance = ownerInstance.selectComponent('.')
166 | // var id = 'c-' + e.currentTarget.dataset.index
167 | // var instance = ownerInstance.selectComponent('#' + id)
168 | // instance.addClass('pageNum-hasread')
169 | }
170 |
171 | /**书签滑动删除效果 */
172 | var bookmark;
173 | var fX;
174 | var fY;
175 | var x;
176 | var y;
177 | var deleteIcon;
178 | function btouchStart(e,ownerInstance){
179 | // console.log('touchStart')
180 | var index = e.currentTarget.dataset.index
181 | bookmark = ownerInstance.selectComponent('#c-b-' + index)
182 | deleteIcon = ownerInstance.selectComponent('#b-d-' + index)
183 | fX = e.touches[0]['clientX']
184 | fY = e.touches[0]['clientY']
185 | }
186 | function btouchMove(e, ownerInstance){
187 | // console.log('touchMove')
188 | x = e.touches[0]['clientX'] - fX
189 | y = e.touches[0]['clientY'] - fY
190 | bookmark.setStyle({
191 | transform: 'translate(' + x + 'px, '+ y + 'px)'
192 | })
193 | bookmark.addClass('b-moving')
194 | if(x > 90 || x < -90){
195 | deleteIcon.addClass('b-delete')
196 | }else{
197 | deleteIcon.removeClass('b-delete')
198 | }
199 | }
200 | function btouchEnd(e){
201 | bookmark.setStyle({
202 | transform: 'translate( 0px, 0px)'
203 | })
204 | bookmark.removeClass('b-moving')
205 | if(x > 90 || x < -90){
206 | // 删除
207 | deleteIcon.removeClass('b-delete')
208 | bookmark.addClass('b-deleted')
209 | bookmark.callMethod('deleteBookmark',e)
210 | }
211 | x = 0
212 | y = 0
213 | fX = 0
214 | fY = 0
215 | }
216 | function refreshBookmark(newValue, oldValue, ownerInstance, instance){
217 | // 移除class b-deleted, 因为添加b-deleted只是动画删除,500ms后会真正删除,bookmarks会刷新,bookmarks index会变,导致被删除书签的下一个书签不显示
218 | var b = ownerInstance.selectAllComponents('.b-deleted')
219 | for(var i=0; i < b.length; i++){
220 | b[i].removeClass('b-deleted')
221 | }
222 | }
223 |
224 | /**目录切换页码-书签 */
225 | function switchToBookmark(e, ownerInstance){
226 | var button = ownerInstance.selectComponent('.button-select')
227 | var bkView = ownerInstance.selectComponent('.catalog-bookmarks')
228 | var pnView = ownerInstance.selectComponent('.catalog-page-number')
229 | button.setStyle({
230 | transform:'translateX(0px)'
231 | })
232 | bkView.removeClass('bookmarks-hidden')
233 | pnView.addClass('pageNum-hidden')
234 | }
235 | function switchToPageNum(e, ownerInstance){
236 | var button = ownerInstance.selectComponent('.button-select')
237 | var bkView = ownerInstance.selectComponent('.catalog-bookmarks')
238 | var pnView = ownerInstance.selectComponent('.catalog-page-number')
239 | button.setStyle({
240 | transform: 'translateX(115px)'
241 | })
242 | bkView.addClass('bookmarks-hidden')
243 | pnView.removeClass('pageNum-hidden')
244 | }
245 |
246 | /**废弃 - 正文内点击查词 */
247 | function lookupWord(e,ownerInstance){
248 | console.log('--------------------')
249 | var word_index = [e.currentTarget.dataset['sindex'], e.currentTarget.dataset['windex']]
250 | // var id = e.currentTarget.dataset['id']
251 | var word = ownerInstance.selectComponent('#w-' + word_index[0] + '-' + word_index[1])
252 | // var word = ownerInstance.selectComponent('#' + id)
253 | // var sentence = ownerInstance.selectComponent('#s-' + word_index[0])
254 | var loading = ownerInstance.selectComponent('.loading-an')
255 | // console.log('lookup word->', 'w-' + word_index[0] + '-' + word_index[1], 's-' + word_index[0])
256 | word.addClass('selectWord')
257 | // sentence.addClass('inSentence')
258 | loading.setStyle({
259 | top: e['changedTouches'][0]['clientY'] - 30 + 'px',
260 | left: e.changedTouches[0].clientX - 22 + 'px',
261 | display:'flex'
262 | })
263 | // triggerEvent('lookUpWord',e)
264 | word.callMethod('lookUpWord',e)
265 | word.callMethod('bindtest',e) // test
266 | ownerInstance.callMethod('setLogSindex', e.currentTarget.dataset['sindex'])
267 | // console.log('_relatedInfo ->', e._relatedInfo.anchorTargetText)
268 | }
269 |
270 | /**划词着色,显示加载动画 */
271 | function wordColour(newValue, oldValue, ownerInstance, instance){
272 | if (newValue['id']){
273 | var word = ownerInstance.selectComponent('#' + newValue['id'])
274 | var loading = ownerInstance.selectComponent('.loading-an')
275 | word.addClass('selectWord')
276 | loading.setStyle({
277 | top: newValue['touchY'] - 30 + 'px',
278 | left: newValue['touchX'] - 22 + 'px',
279 | display: 'flex'
280 | })
281 | var explainBox = ownerInstance.selectComponent('.explain-box')
282 | explainBox.setStyle({
283 | visibility: newValue['visibility']
284 | })
285 | }
286 | }
287 |
288 |
289 | /**隐藏explainbox划词释义框 */
290 | function hiddenExplainBox(e,ownerInstance){
291 | /**不能直接setStyle,因为wxs的优先级高,导致explainBox不显示 */
292 | var explainBox = ownerInstance.selectComponent('.explain-box')
293 | explainBox.setStyle({
294 | visibility:'hidden'
295 | })
296 | console.log('hiddenExplainBox')
297 | var word = ownerInstance.selectComponent('.selectWord')
298 | // ownerInstance.callMethod('hiddenExplain')
299 | if(word){
300 | word.removeClass('selectWord')
301 | word.addClass('selected-w')
302 | // sentence.removeClass('inSentence')
303 | }
304 | }
305 |
306 | function hiddenLoading(newValue, oldValue, ownerInstance, instance){
307 | console.log('hidden loading')
308 | var loading = ownerInstance.selectComponent('.loading-an')
309 | loading.setStyle({
310 | display: 'none'
311 | })
312 | }
313 |
314 | /**清除着色 */
315 | function clearColour(newValue, oldValue, ownerInstance, instance){
316 | console.log('clearCoulour')
317 | var slist = ownerInstance.selectAllComponents('.selected-s')
318 | var wlist = ownerInstance.selectAllComponents('.selected-w')
319 | for(var i = 0; i < slist.length; i++){
320 | slist[i].removeClass('selected-s')
321 | }
322 | for(var i = 0; i < wlist.length;i++){
323 | wlist[i].removeClass('selected-w')
324 | }
325 | var s = ownerInstance.selectComponent('.sentenceBackground')
326 | var w = ownerInstance.selectComponent('.selectWord')
327 | if(s){
328 | s.removeClass('sentenceBackground')
329 | }
330 | if (w) {
331 | w.removeClass('selectWord')
332 | }
333 | var ins = ownerInstance.selectComponent('.inSentence')
334 | if(ins){
335 | ins.removeClass('inSentence')
336 | }
337 | }
338 |
339 | var touchXY = []; // [[firstX,firstY],[lastX,lastY]]
340 | /**滑动翻译 */
341 | function touchStart(e, ownerInstance){
342 | var moveXY = [e.changedTouches[0].clientX, e.changedTouches[0].clientY]
343 | touchXY[0] = moveXY
344 | }
345 | function touchMove(e, ownerInstance){
346 | //console.log('operateClass.touchMove', e)
347 | var moveXY = [e.changedTouches[0].clientX, e.changedTouches[0].clientY]
348 | if (touchXY.length == 0) {
349 | touchXY[0] = moveXY
350 | } else {
351 | touchXY[1] = moveXY
352 | }
353 | }
354 | function touchEnd(e, ownerInstance){
355 | // console.log('operateClass.touchEnd', e)
356 | var sindex = e.target.dataset.sindex
357 | if (touchXY.length > 1) {
358 | /** 滑动 */
359 | var moveX = touchXY[1][0] - touchXY[0][0]
360 | var moveY = touchXY[1][1] - touchXY[0][1]
361 | if (Math.abs(moveX) / Math.abs(moveY) > 3 & Math.abs(moveX) > 10) {
362 | // 横向滑动 翻译整个句子
363 | // console.log('横向滑动 翻译', moveX, moveY)
364 | translate(sindex, ownerInstance)
365 | } else {
366 | // console.log('其他滑动 xy', moveX, moveY)
367 | }
368 | } else if (touchXY.length == 1) {
369 | /** 快速滑动 */
370 | // console.log('快速滑动 翻译', moveX, moveY)
371 | // translate(sindex, ownerInstance)
372 | }
373 | touchXY = [] // 清空
374 | ownerInstance.callMethod('setLogSindex', sindex)
375 | }
376 | var transBoxUp = false
377 | function translate(sindex,ownerInstance){
378 | var sentence = ownerInstance.selectComponent('#s-' + sindex)
379 | var transBox = ownerInstance.selectComponent('.trans-box')
380 | sentence.callMethod('querySentence_wxs', { 'index': sindex })
381 | sentence.addClass('selectSentence')
382 | // transBox.addClass('trans-box-up')'
383 | transBox.callMethod('transBoxUp',{'sindex':sindex})
384 | transBoxUp = true; // 要注意为true并不一定都在上面,也有可能用户手动滑下去
385 | }
386 | function transEnd(ownerInstance){
387 | var transBox = ownerInstance.selectComponent('.trans-box')
388 | transBox.removeClass('trans-box-up')
389 | var selectedS = ownerInstance.selectComponent('.selectSentence')
390 | if (selectedS){
391 | selectedS.removeClass('selectSentence')
392 | selectedS.addClass('selected-s')
393 | }
394 | transBox.callMethod('transBoxUp','down')
395 |
396 | }
397 |
398 | /**点击页面其他部分,隐藏弹窗 */
399 | function hiddenAll(e, ownerInstance){
400 | // 隐藏翻译框
401 | if (transBoxUp) {
402 | transEnd(ownerInstance)
403 | }
404 | hiddenExplainBox(null,ownerInstance)
405 | }
406 |
407 | /**返回text指定长度(l),多余的以‘...’显示 */
408 | function textSlice(text,l){
409 | if(text.length > l){
410 | return text.substring(0, l) + '...'
411 | }else{
412 | return text
413 | }
414 | }
415 |
416 | /**显示查词界面 */
417 | function showHiddenDict(e,owner){
418 | console.log('show hidden dict more')
419 | var dict = owner.selectComponent('.dict-more');
420 | if (dict.hasClass('dice-more-show')){
421 | console.log('remove')
422 | dict.removeClass('dice-more-show')
423 | dict.callMethod('findInputClear') // 清空输入框
424 | }else{
425 | console.log('add')
426 | dict.addClass('dice-more-show')
427 | hiddenAll('',owner) // 隐藏查词翻译弹窗
428 | dict.callMethod('inputFocus')
429 | }
430 | }
431 |
432 | /**hover 动画,hover-clsss只能用在view中,用此函数的标签需要有id
433 | * 调用data-mybind中的逻辑层函数,传入e
434 | * 播放data-play中的动画,需要注意的使,data-play只传入一个class,但是wxs里必须有一个副本class,后缀+1,两个循环播放
435 | */
436 | function hover(e,owner){
437 | console.log('hover id=>',e.currentTarget.id)
438 | var id = e.currentTarget.id
439 | var playclass = e.currentTarget.dataset.play
440 | var hover = owner.selectComponent('#'+id)
441 | if(hover.hasClass(playclass)){
442 | hover.removeClass(playclass)
443 | hover.addClass(playclass + '1')
444 | }else{
445 | hover.removeClass(playclass + '1')
446 | hover.addClass(playclass)
447 | }
448 | var bind = e.currentTarget.dataset.mybind //逻辑层
449 | if(bind){
450 | console.log('cal method ->',bind)
451 | hover.callMethod(bind,e)
452 | }else{
453 | console.log('bind false ->',bind)
454 | }
455 | }
456 |
457 | /**hover wxs函数调用版
458 | * tag需要有id,data-play
459 | */
460 | function wxsHover(e,owner){
461 | console.log('hover id=>', e.currentTarget.id)
462 | var id = e.currentTarget.id
463 | var playclass = e.currentTarget.dataset.play
464 | var hover = owner.selectComponent('#' + id)
465 | if(hover){
466 | if (hover.hasClass(playclass)) {
467 | hover.removeClass(playclass)
468 | hover.addClass(playclass + '1')
469 | } else {
470 | hover.removeClass(playclass + '1')
471 | hover.addClass(playclass)
472 | }
473 | }
474 | }
475 |
476 | /**首字母大写 */
477 | function capitalize(text){
478 | if(text){
479 | text = text.substring(0,1).toUpperCase() + text.substring(1,)
480 | return text
481 | }else{
482 | return ''
483 | }
484 | }
485 |
486 |
487 |
488 | module.exports = {
489 | navScroll: navScroll,
490 | inputShow: inputShow,
491 | inputBox:inputBox,
492 | catalogBox: catalogBox,
493 | // tapCatalog: tapCatalog,
494 | btouchStart: btouchStart,
495 | btouchMove:btouchMove,
496 | btouchEnd: btouchEnd,
497 | switchToBookmark: switchToBookmark,
498 | switchToPageNum: switchToPageNum,
499 | lookupWord: lookupWord,
500 | hiddenLoading: hiddenLoading,
501 | clearColour: clearColour,
502 | touchStart: touchStart,
503 | touchMove: touchMove,
504 | touchEnd: touchEnd,
505 | hiddenAll: hiddenAll,
506 | textSlice: textSlice,
507 | showHiddenDict: showHiddenDict,
508 | refreshBookmark: refreshBookmark,
509 | hover: hover,
510 | setNavData: setNavData,
511 | capitalize: capitalize,
512 | hiddenExplainBox: hiddenExplainBox,
513 | wordColour: wordColour
514 | }
515 |
516 |
--------------------------------------------------------------------------------
/pages/reading/reading.wxss:
--------------------------------------------------------------------------------
1 | @import '../../template/template.wxss';
2 |
3 |
4 | /**reading.wxss**/
5 | .reading-background{
6 | position:fixed;
7 | top:0;
8 | left:0;
9 | width:100vw;
10 | height:100vh;
11 | z-index:-100;
12 | }
13 |
14 | .swiper{
15 | position:fixed;
16 | top:0;
17 | left:0;
18 | width:100vw;
19 | height:calc(100vh + 20px);
20 | }
21 | .swiper-item{
22 | height:calc(100vh + 20px);
23 | /*margin-bottom:30px;*/
24 | /*box-shadow:0 0 20px rgba(0,0,0,0.3);*/
25 | }
26 | .swiper-border{
27 | position:absolute;
28 | bottom:0;
29 | height:20px;
30 | width:100%;
31 | background-color:#aaa;
32 | }
33 |
34 | .article-container-scroll{
35 | position:fixed;
36 | top:0;
37 | left:0;
38 | width:100vw;
39 | height:100vh;
40 | }
41 | .article-container{
42 | position:relative;
43 | top:0;
44 | left:0;
45 | padding:100px 20px 180px 20px;
46 | line-height:2em;
47 | font-family:serif;
48 | font-size:17px;
49 | }
50 | .sentence-container{
51 | display:inline;
52 | flex-wrap:wrap;
53 | word-wrap:break-word;
54 | border-radius:0.2em;
55 | }
56 | .word-container{
57 | height:1em;
58 | line-height:1em;
59 | }
60 |
61 |
62 | /**翻译过的句子*/
63 | .selected-s{
64 | /*border:1px dotted rgba(28,128,255,0.2);*/
65 | outline:1px dotted rgba(28,128,255,0.2);
66 | }
67 | /**查过的词 */
68 | .selected-w{
69 | /*background-color:#F2EBDE;*/
70 | background-color:rgba(28,128,255,0.2);
71 | border-radius:0.382em;
72 | }
73 | /** 选中样式*/
74 | .selectSentence{
75 | /*background-color:#ccf;*/
76 | /*border:1px dotted #aaf;*/
77 | /*background-color:#F2EBDE ;*/
78 | background-color:rgba(28,128,255,0.4);
79 | }
80 | .selectWord{
81 | /*background-color:#ccf;*/
82 | /*border:1px dotted #aaf;*/
83 | background-color:rgba(28,128,255,0.4);
84 | border-radius:0.382em;
85 | }
86 | .inSentence{
87 | /*background-color:#ececec;*/
88 | /*border:1px dotted rgba(28,128,255,0.4);*/
89 | outline:1px dotted rgba(28,128,255,0.4);
90 | }
91 |
92 |
93 | .explain-box{
94 | font-size:10px;
95 | width:20em;
96 | height:10em;
97 | position:fixed;
98 | /*border:1px solid #ededed;*/
99 | border-radius:8px;
100 | bottom:30px;
101 | left:30px;
102 | background-color:#fff;
103 | box-shadow:2px 2px 20px rgba(0,0,0,0.3);
104 | z-index:20;
105 | }
106 | .eb-word-container{
107 | display:flex;
108 | align-items:center;
109 | /*margin:0.8em 0 0 1.2em;*/
110 | margin:2px 0;
111 | height:1.2em;
112 | }
113 | .eb-word{
114 | /*background-color:#eee;*/
115 | position:relative;
116 | display:inline-block;
117 | font-size:12px;
118 | font-weight:700;
119 | }
120 | .eb-phone-container{
121 | /*margin:0.3em 1.2em 0.1em 1.2em;*/
122 | margin:2px 0;
123 | position:relative;
124 | display:flex;
125 | align-items:center;
126 | flex-wrap:wrap;
127 | line-height:1.3em;
128 | }
129 | .eb-usphone{
130 | /*background-color:#eee;*/
131 | display:block;
132 | }
133 | .eb-ukphone{
134 | /*background-color:#eee;*/
135 | display:block;
136 | }
137 | .eb-phone-icon{
138 | width:1em;
139 | height:1em;
140 | padding:0.2em 0.6em;
141 | vertical-align:middle;
142 | transform:scale(1.8);
143 | }
144 | .eb-explain-scroll{
145 | /*background-color:#eee;*/
146 | font-size:10px;
147 | padding:0.3em 1.2em;
148 | width:calc(100% - 2.4em);
149 | height:calc(100% - 0.6em);
150 | border-radius:8px;
151 | box-shadow:inset 0 0 5px #fff;
152 | }
153 | .eb-explain{
154 | display:block;
155 | }
156 | .eb-arrow{
157 | position:absolute;
158 | width:20px;
159 | height:20px;
160 | top:-18px;
161 | left:20px;
162 | }
163 | .explain-loading{
164 | padding:15px;
165 | }
166 | .e-l-ti{
167 | width:40px;
168 | height:1.2em;
169 | background-color:#ddd;
170 | margin:5px 0;
171 | }
172 | .e-l-te{
173 | width:100%;
174 | height:1.1em;
175 | background-color:#ddd;
176 | margin:5px 0;
177 | }
178 |
179 | .verticality-move{
180 | position:fixed;
181 | width:100vw;
182 | height:1px;
183 | top:100vh;
184 | left:0;
185 | }
186 |
187 | .trans-box{
188 | /*position:fixed;*/
189 | top:0;
190 | left:0;
191 | width:100vw;
192 | height:75vh;
193 | background-color: #fff;
194 | font-size:15px;
195 | box-shadow: 0 0 50px rgba(0,0,0,0.27);
196 | /*transition:transform 0.5s;*/
197 | border-radius:20px 20px 0 0;
198 | padding-bottom:20px;
199 | border:1px solid rgba(0,0,0,0.03);
200 | }
201 | .trans-box-up{
202 | transform:translateY(-25.5vh);
203 | }
204 | .trans-box-button-container{
205 | height:2em;
206 | display:flex;
207 | align-items:center;
208 | padding: 0 20px;
209 | }
210 | .brans-box-button{
211 | background-color:#aaf;
212 | box-shadow:0 0 5px #888;
213 | padding:0 0.5em;
214 | border-radius: 0.2em;
215 | }
216 | .trans-box-input{
217 | padding: 0px 20px 5px 20px;
218 | font-weight:700;
219 | }
220 | .t-i-text{
221 | vertical-align:middle;
222 | }
223 | .trans-box-tran{
224 | padding:5px 20px 20px 20px;
225 | }
226 |
227 |
228 |
229 |
230 |
231 | .top-column{
232 | width:100%;
233 | /*height:92px;*/
234 | /*padding-top:20px;*/
235 | position:fixed;
236 | bottom:0;
237 | left:0;
238 | /*background-color:#1c80ff;*/
239 | transition:transform 0.1s;
240 | /*box-shadow: 0px 0px 20px rgba(0,0,0,0.3);*/
241 | /*background:linear-gradient(to right, #1c80ff, #05AFF2);*/
242 | background-color:#555;
243 | outline:1px solid rgba(0,0,0,0.1);
244 | }
245 |
246 |
247 | /**页面转跳按钮样式-临时*/
248 | .navigation-bar{
249 | height:44px;
250 | width:100%;
251 | display:flex;
252 | align-items:center;
253 | }
254 | .nav-button{
255 | height:20px;
256 | width:20px;
257 | padding:6px;
258 | /*background-color:#fff;*/
259 | border-radius:16px;
260 | z-index:10px;
261 | margin:0 calc((100% - 32px * 4) / 8);
262 | }
263 | .operate-bar{
264 | height:32px;
265 | padding:2px 0;
266 | display:flex;
267 | background-color:#fff;
268 | }
269 |
270 | .button{
271 | width:60px;
272 | height:30px;
273 | background-color:#efefef;
274 | border-radius:15px;
275 | border:1px solid #aaa;
276 | font-size:12px;
277 | }
278 |
279 | .catalog{
280 | position:fixed;
281 | top:0;
282 | left:-260px;
283 | height:100vh;
284 | width:260px;
285 | transition:all 0.5s;
286 | background-color:#fff;
287 | }
288 | .catalog-show{
289 | top:0;
290 | left:0;
291 | box-shadow:0 0 15px #888;
292 | }
293 | .catalog-bg{
294 | position:absolute;
295 | width:1px;
296 | height:0px;
297 | transition:opacity 0.1s;
298 | z-index:-2;
299 | opacity:0;
300 | }
301 | .catalog-bg-show{
302 | position:absolute;
303 | height:100vh;
304 | width:100vw;
305 | }
306 | .catalog-title{
307 | display:block;
308 | height:44px;
309 | line-height:48px;
310 | text-align:center;
311 | padding-top:20px;
312 | /*background-color:#aaf;*/
313 | background:linear-gradient(to right, #1c80ff, #05AFF2);
314 | color:#fff;
315 | }
316 | .catalog-type{
317 | position:relative;
318 | display:flex;
319 | height:32px;
320 | line-height:32px;
321 | padding: 5px 15px;
322 | text-align:center;
323 | }
324 | .catalog-button{
325 | height:100%;
326 | width:50%;
327 | }
328 | .button-select{
329 | position:absolute;
330 | height:calc(100% - 10px);
331 | width:calc(50% - 15px);
332 | /*background-color:#aaf;*/
333 | background:linear-gradient(to right, #1c80ff, #05AFF2);
334 | border-radius:21px;
335 | transform: translateX(115px);
336 | transition:all 0.5s;
337 | z-index:-10;
338 | }
339 | .catalog-scroll-c{
340 | position:relative;
341 | width:100%;
342 | height:calc(100% - 104px);
343 | overflow:hidden;
344 | }
345 | .catalog-bookmarks{
346 | position:absolute;
347 | height:100%;
348 | left:0px;
349 | transition:all 0.5s;
350 | }
351 | .bookmarks-hidden{
352 | left:-260px;
353 | }
354 | .catalog-page-number{
355 | position:absolute;
356 | height:100%;
357 | left:0;
358 | transition:all 0.5s;
359 | }
360 | .pageNum-hidden{
361 | left:260px;
362 | }
363 | .catalog-item{
364 | height:32px;
365 | line-height:32px;
366 | align-items:center;
367 | display:flex;
368 | background-color:transparent;
369 | /*transition:all 0.1s;*/
370 | }
371 | .catalog-current{
372 | /*background-color:#aaf;*/
373 | background:linear-gradient(to right, #1c80ff, #05AFF2);
374 | color:#fff;
375 | }
376 | .none-bookmark-tip{
377 | width:260px;
378 | height:80px;
379 | }
380 | .item-icon{
381 | height:20px;
382 | width:20px;
383 | margin: 0 10px 0 15px;
384 | }
385 | .item-title{
386 | display:block;
387 | width:200px;
388 | }
389 | .b-delete-icon{
390 | position:absolute;
391 | width:20px;
392 | height:20px;
393 | padding:6px calc((100% - 20px) / 2) 6px calc((100% - 20px) / 2);
394 | opacity:0;
395 | transition: all 0.5s;
396 | }
397 | .b-delete{
398 | opacity:1;
399 | background-color:#f00;
400 | }
401 | .b-moving{
402 | opacity:0.6;
403 | z-index:1000;
404 | background-color:#ccc;
405 | }
406 | .b-deleted{
407 | opacity:0;
408 | height:0;
409 | overflow:hidden;
410 | }
411 |
412 |
413 | .loading-an{
414 | position:fixed;
415 | top:200px;
416 | left:60px;
417 | width:45px;
418 | height:0px;
419 | display:none;
420 | }
421 | .loading{
422 | position:relative;
423 | display:inline-block;
424 | width:10px;
425 | height:10px;
426 | border-radius:5px;
427 | background-color:#888;
428 | opacity:0.62;
429 | margin:0 2.5px;
430 | }
431 | #l-1{
432 | animation:loading3 1s infinite;
433 | }
434 | #l-2{
435 | animation:loading2 1s infinite;
436 | }
437 | #l-3{
438 | animation:loading 1s infinite;
439 | }
440 |
441 | @keyframes loading{
442 | 0%{
443 | transform:scale(0.6);
444 | }
445 | 20%{
446 | transform:scale(1);
447 | }
448 | 50%{
449 | transform:scale(1.6);
450 | }
451 | 80%{
452 | transform:scale(1);
453 | }
454 | 100%{
455 | transform:scale(0.6);
456 | }
457 | }
458 | @keyframes loading2{
459 | 0%{
460 | transform:scale(1);
461 | }
462 | 20%{
463 | transform:scale(1.6);
464 | }
465 | 50%{
466 | transform:scale(1);
467 | }
468 | 80%{
469 | transform:scale(0.6);
470 | }
471 | 100%{
472 | transform:scale(1);
473 | }
474 | }
475 | @keyframes loading3{
476 | 0%{
477 | transform:scale(1.6);
478 | }
479 | 20%{
480 | transform:scale(1);
481 | }
482 | 50%{
483 | transform:scale(0.6);
484 | }
485 | 80%{
486 | transform:scale(1);
487 | }
488 | 100%{
489 | transform:scale(1.6);
490 | }
491 | }
492 |
493 | .page-loading{
494 | position:fixed;
495 | top:39vh;
496 | left:calc(50vw - 22.5px);
497 | width:45px;
498 | height:0px;
499 | text-align:center;
500 | }
501 | .page-loading-tip{
502 | color:#888;
503 | font-size:12px;
504 | }
505 |
506 | .dict-more{
507 | position:fixed;
508 | top:0;
509 | left:0;
510 | width:100vw;
511 | height:100vh;
512 | background-color:#fff;
513 | opacity:0.9;
514 | display:none;
515 | }
516 | .dice-more-show{
517 | display:block;
518 | }
519 | .dict-topColumn{
520 | position:relative;
521 | margin:30px 0 10px 0;
522 | display:flex;
523 | }
524 | .dict-back{
525 | height:20px;
526 | width:20px;
527 | padding:6px;
528 | margin:0 5px;
529 | }
530 | .fillet-input{
531 | position:relative;
532 | height:32px;
533 | left:0px;
534 | width:200px;
535 | border-radius:16px;
536 | background-color:#eef;
537 | align-items:center;
538 | display:flex;
539 | transition:all 0.3s;
540 | }
541 | .fillet-input-clear{
542 | height:18px;
543 | width:18px;
544 | padding:10px;
545 | }
546 | .fillet-input-input{
547 | position:relative;
548 | height:30px;
549 | line-height:30px;
550 | width:calc(100% - 46px);
551 | margin-left:10px;
552 | font-size:12px;
553 | color:#555;
554 | }
555 | .dict-suggest{
556 | margin:5px 30px;
557 | font-size:0.8em;
558 | line-height:2em;
559 | }
560 | .suggest-item{
561 | height:30px;
562 | overflow:hidden;
563 | }
564 | .suggest-word{
565 | font-weight:700;
566 | font-size:1em;
567 | }
568 |
569 | /**点击动画*/
570 | .hover{
571 | animation: tap 0.3s;
572 | }
573 | .hover1{
574 | animation: taptap 0.3s;
575 | }
576 |
577 | @keyframes tap{
578 | 0%{
579 | transform:scale(1)
580 | }
581 | 10%{
582 | transform:scale(0.9)
583 | }
584 | 50%{
585 | transfrom:scale(1.1)
586 | }
587 | 90%{
588 | transform:scale(0.9)
589 | }
590 | 100%{
591 | transform:scale(1)
592 | }
593 | }
594 | @keyframes taptap{
595 | 0%{
596 | transform:scale(1)
597 | }
598 | 10%{
599 | transform:scale(0.9)
600 | }
601 | 50%{
602 | transfrom:scale(1.1)
603 | }
604 | 90%{
605 | transform:scale(0.9)
606 | }
607 | 100%{
608 | transform:scale(1)
609 | }
610 | }
611 | .audioPlay{
612 | animation: audioPlaying 0.5s 3;
613 | }
614 | .audioPlay1{
615 | animation: audioPlaying1 0.5s 3;
616 | }
617 | @keyframes audioPlaying{
618 | from{
619 | opacity:1;
620 | scale:1.1;
621 | }to{
622 | opacity:0.2;
623 | scale:0.9;
624 | }
625 | }
626 | @keyframes audioPlaying1{
627 | from{
628 | opacity:1;
629 | scale:1.1;
630 | }to{
631 | opacity:0.2;
632 | scale:0.9;
633 | }
634 | }
635 |
636 |
637 |
638 | /**书名输入框样式
639 | .input{
640 | position:fixed;
641 | top:80px;
642 | left:160px;
643 | width:0px;
644 | height:0px;
645 | overflow:hidden;
646 | opacity:0;
647 | transition:all 0.5s;
648 | z-index:-10;
649 | }
650 | .input-show{
651 | display:block;
652 | position:fixed;
653 | height:100px;
654 | width:220px;
655 | top:calc(25vh - 30px);
656 | left:calc((100vw - 260px) / 2);
657 | background-color:#fff;
658 | border-radius:10px;
659 | padding:20px;
660 | box-shadow:0 0 10px #888;
661 | opacity:1;
662 | z-index:50;
663 | }
664 | .input-prompt{
665 | font-size:1em;
666 | }
667 | .input-masking{
668 | position:fixed;
669 | top:0;
670 | left:0;
671 | width:100vw;
672 | height:100vh;
673 | opacity:0.6;
674 | background-color:#333;
675 | }
676 | .input-input{
677 | border-bottom:1px solid #aaf;
678 | height:30%;
679 | margin:10px 0 5px 0;
680 | }
681 | .input-button{
682 | display:inline-block;
683 | position:relative;
684 | font-size:0.8em;
685 | width:40px;
686 | height:25%;
687 | line-height:25px;
688 | text-align:center;
689 | transition:all 0.5s;
690 | }
691 | #input-cancel{
692 | margin-left:calc(100% - 80px);
693 | color:#555;
694 | }
695 | */
--------------------------------------------------------------------------------
/pages/store/store.js:
--------------------------------------------------------------------------------
1 | // pages/store/store.js
2 | const bookmgr = require('../../js/bookshelfMgr.js');
3 | var findInput = '' // 记录findInput的输入
4 |
5 | Page({
6 |
7 | /**
8 | * 页面的初始数据
9 | */
10 | data: {
11 | systemInfo:null,
12 | findInput:'',
13 | swiperBookList:[
14 | {
15 | 'image': 'cloud://release-bf6b22.7265-release-bf6b22/dev-test/gatsby-detail.png',
16 | 'shareLink': '我分享给你了一本《The Great Gatsby》,快用英语划词阅读打开吧!share://0ZyhlB&2019428-26.98w-WXZU&key/'
17 | },
18 | {
19 | 'image': 'cloud://release-bf6b22.7265-release-bf6b22/dev-test/shawshank-detail.png',
20 | 'shareLink': ''
21 | },
22 | {
23 | 'image': '',
24 | 'shareLink': ''
25 | }
26 | ]
27 | },
28 |
29 | /**
30 | * 生命周期函数--监听页面加载
31 | */
32 | onLoad: function (options) {
33 | this.setData({
34 | systemInfo:wx.getSystemInfoSync()
35 | })
36 | },
37 |
38 | /**
39 | * 生命周期函数--监听页面初次渲染完成
40 | */
41 | onReady: function () {
42 |
43 | },
44 |
45 | /**
46 | * 生命周期函数--监听页面显示
47 | */
48 | onShow: function () {
49 |
50 | },
51 |
52 | /**
53 | * 生命周期函数--监听页面隐藏
54 | */
55 | onHide: function () {
56 |
57 | },
58 |
59 | /**
60 | * 生命周期函数--监听页面卸载
61 | */
62 | onUnload: function () {
63 |
64 | },
65 |
66 | /**
67 | * 页面相关事件处理函数--监听用户下拉动作
68 | */
69 | onPullDownRefresh: function () {
70 |
71 | },
72 |
73 | /**
74 | * 页面上拉触底事件的处理函数
75 | */
76 | onReachBottom: function () {
77 |
78 | },
79 |
80 | /**
81 | * 用户点击右上角分享
82 | */
83 | onShareAppMessage: function () {
84 |
85 | },
86 |
87 | findInput:function(e){
88 | // console.log(e)
89 | findInput = e.detail.value
90 | this.setData({
91 | findInput: findInput
92 | })
93 | },
94 |
95 | findInputClear:function(e){
96 | this.setData({
97 | findInput: ''
98 | })
99 | },
100 |
101 | test_getShareBook:function(e){
102 | var input = e.detail.value
103 | var shareLinkPattern = /.+?&.+?&.+?/
104 | if (input.match(shareLinkPattern)){
105 | var bookMgr = new bookmgr.bookshelfClass()
106 | bookMgr.addBookByShare(input)
107 | }
108 | console.log(e)
109 |
110 | },
111 |
112 | tapSwiper:async function(e){
113 | let index = e.currentTarget.dataset.index
114 | let shareLink = this.data.swiperBookList[index].shareLink
115 | if(shareLink){
116 | let shareLinkExtract = /^[\s\S]*?\b(\w+?&.+?&\w+?)\b[\s\S]*$/
117 | shareLink = shareLink.replace(shareLinkExtract, '$1')
118 | const bookMgr = new bookmgr.bookshelfClass()
119 | wx.showLoading({
120 | title: '获取中...'
121 | })
122 | console.log('shareLink ->', shareLink)
123 | let stats = await bookMgr.addBookByShare(shareLink)
124 | if(stats.stats == 'ok'){
125 | let id = stats.id
126 | // 下载成功 转到阅读页面
127 | wx.navigateTo({
128 | url: '../../pages/reading/reading?bookId=' + id
129 | })
130 | }else{
131 | // 失败
132 | }
133 | wx.hideLoading()
134 |
135 | }
136 | },
137 |
138 | goStoreList:function(e){
139 | let type1 = e.currentTarget.dataset.type1;
140 | let type2 = e.currentTarget.dataset.type2;
141 | wx.navigateTo({
142 | url:`../../pages/storeList/storeList?type1=${type1}&type2=${type2}`
143 | })
144 | }
145 | })
--------------------------------------------------------------------------------
/pages/store/store.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {}
3 | }
--------------------------------------------------------------------------------
/pages/store/store.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | 发现
11 |
12 |
13 |
14 |
15 |
16 |
17 |
53 |
54 |
55 |
56 |
57 |
64 |
65 |
66 |
67 |
68 | 四级
69 |
70 |
71 | 阅读
72 |
73 |
74 |
75 | 听力
76 |
77 |
78 |
79 |
80 | 写作
81 |
82 |
83 |
84 | 翻译
85 |
86 |
90 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 | 六级
102 |
103 |
104 | 阅读
105 |
106 |
107 |
108 | 听力
109 |
110 |
111 |
112 |
113 | 写作
114 |
115 |
116 |
117 | 翻译
118 |
119 |
123 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 | 考研
135 |
136 |
137 | 阅读
138 |
139 |
143 |
144 |
145 | 写作
146 |
147 |
148 |
149 | 翻译
150 |
151 |
155 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
--------------------------------------------------------------------------------
/pages/store/store.wxs:
--------------------------------------------------------------------------------
1 |
2 | /**input发现一下获得焦点触发,输入框变宽 */
3 |
4 | function inputFocus(e, ownerInstance){
5 | console.log('input get focus')
6 | var instance = ownerInstance.selectComponent('.nav-input')
7 | instance.addClass('nav-input-focus ')
8 | // var title = ownerInstance.selectComponent('.nav-title')
9 | // title.setStyle({
10 | // opacity:'0'
11 | // })
12 | }
13 |
14 | function loseFocus(e,ownerInstance){
15 | console.log('input lose focus')
16 | var instance = ownerInstance.selectComponent('.nav-input')
17 | instance.removeClass('nav-input-focus')
18 | // var title = ownerInstance.selectComponent('.nav-title')
19 | // title.setStyle({
20 | // opacity: '1'
21 | // })
22 | // 失去焦点,考虑调用输入完成函数
23 |
24 | }
25 |
26 |
27 | // swiper位置 适配不同机型
28 | function setSwiperPos(systemInfo, oldValue, ownerInstance, instance){
29 | // console.log('set nav height--------------------------------')
30 | if (systemInfo) {
31 | // console.log('适应 nav bar 高度========')
32 | var detailSwiper = ownerInstance.selectAllComponents('.detail-swiper')
33 | var cardBottom;
34 | var system = systemInfo.system
35 | if (systemInfo.system.substring(0, 2) == 'iOS') {
36 | cardBottom = 'calc((' + '100vh - 44px - ' + systemInfo.statusBarHeight + 'px - 970rpx) / 2)'
37 | } else {
38 | cardBottom = 'calc((' + '100vh - 48px - ' + systemInfo.statusBarHeight + 'px - 970rpx) / 2)'
39 | }
40 | for (var i = 0; i < detailSwiper.length; i++){
41 | detailSwiper[i].setStyle({
42 | 'bottom': cardBottom
43 | })
44 | }
45 |
46 | }
47 | }
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | module.exports = {
59 | inputFocus: inputFocus,
60 | loseFocus: loseFocus,
61 | setSwiperPos: setSwiperPos
62 | }
--------------------------------------------------------------------------------
/pages/store/store.wxss:
--------------------------------------------------------------------------------
1 | /* pages/store/store.wxss */
2 |
3 | .store-bg{
4 | position:fixed;
5 | width:100vw;
6 | height:100vh;
7 | background-color:#eee;
8 | }
9 |
10 | .navigationBar{
11 | width:100vw;
12 | height:60px;
13 | position:fixed;
14 | z-index:10;
15 | align-items:center;
16 | padding-top:20px;
17 | display:flex;
18 | /*background-color:#1c80ff;*/
19 | box-shadow:2px 0px 5px #888;
20 | color:#fff;
21 | background:linear-gradient(to right, #1c80ff, #05AFF2);
22 | }
23 | .nav-title{
24 | height:32px;
25 | line-height:32px;
26 | font-size:16px;
27 | margin-left:15px;
28 | transition:all 0.5s;
29 | }
30 | .nav-input{
31 | position:relative;
32 | height:32px;
33 | left:0px;
34 | width:128px;
35 | border-radius:16px;
36 | background-color:#fff;
37 | margin-left:20px;
38 | align-items:center;
39 | display:flex;
40 | transition:all 0.3s;
41 | }
42 | .nav-input-focus{
43 | width:220px;
44 | left:0px;
45 | }
46 | .nav-input-icon{
47 | height:18px;
48 | width:18px;
49 | margin-left:10px;
50 | }
51 | .input-clear{
52 | height:18px;
53 | width:18px;
54 | padding:10px;
55 | }
56 | .input{
57 | position:relative;
58 | height:30px;
59 | line-height:30px;
60 | width:calc(100% - 74px);
61 | margin-left:10px;
62 | font-size:12px;
63 | color:#555;
64 | }
65 |
66 | /**主页面*/
67 | .store-page{
68 | /**navigation bar 占有高度*/
69 | padding-top:80px;
70 | }
71 | .store-swiper{
72 | width:100vw;
73 | height:calc(0.618 * 100vw);
74 | }
75 | .swiper-item{
76 | background-color:#fff;
77 | }
78 | .swiper-image{
79 | height:100%;
80 | width:100%;
81 | }
82 | .group-container{
83 | display:block;
84 | text-align:center;
85 | }
86 |
87 | .group-box{
88 | display:inline-block;
89 | position:relative;
90 | width:280rpx;
91 | height:170rpx;
92 | border-radius:5px;
93 | margin:20px 10px;
94 | overflow:hidden;
95 | box-shadow:0 0 5px rgba(0,0,0,0.3);
96 | }
97 | .group-box-bg{
98 | width:100%;
99 | height:100%;
100 | }
101 | .group-box-title{
102 | position:absolute;
103 | width:100%;
104 | height:32px;
105 | left:0;
106 | top:calc((100% - 32px) / 2);
107 | font-size:17px;
108 | }
109 |
110 |
111 | .book-detail-subpage{
112 | position:fixed;
113 | width:100vw;
114 | height:100vh;
115 | top:0;
116 | left:0;
117 | }
118 | .swiper{
119 | height:100%;
120 | width:100%;
121 | }
122 | .detail-swiper{
123 | position:absolute;
124 | height:970rpx;
125 | width:600rpx;
126 | margin:0 15rpx;
127 | background-color:#fff;
128 | bottom:50rpx;
129 | border-radius:5px;
130 | overflow:hidden;
131 | box-shadow:2px 2px 10px rgba(0,0,0,0.08);
132 | }
133 | .detail-image{
134 | position:absolute;
135 | width:100%;
136 | height:100%;
137 | }
138 |
139 |
140 | /** swiper card*/
141 | .card-title{
142 | position:relative;
143 | display:block;
144 | font-size:32px;
145 | padding:20px 0 5px 20px;
146 | }
147 | .card-list{
148 | position:relative;
149 | height:90px;
150 | margin:20px 20px;
151 | border-radius:10px;
152 | display:flex;
153 | align-items:center;
154 | }
155 |
156 | .card-item-bg{
157 | width:100%;
158 | height:100%;
159 | }
160 |
161 |
162 |
163 | .swiper-icon-view{
164 | display:inline-block;
165 | width:50px;
166 | height:70px;
167 | padding:10px;
168 | text-align:center;
169 | color:#333;
170 | font-size:12px;
171 | line-height:20px;
172 |
173 | margin:0 15px;
174 | }
175 | .swiper-icon-i{
176 | width:50px;
177 | height:50px;
178 | border-radius:25px;
179 | background-color:#eee;
180 | }
181 |
182 | .swiper-title{
183 | font-size:24px;
184 | margin-bottom:20px;
185 | }
186 |
187 | .icon-container{
188 | position:relative;
189 | display:block;
190 | top:100px;
191 | padding:20px;
192 | text-align:center;
193 | }
--------------------------------------------------------------------------------
/pages/storeList/storeList.js:
--------------------------------------------------------------------------------
1 | // pages/storeList/storeList.js
2 | const bookmgr = require('../../js/bookshelfMgr.js');
3 |
4 | /**解析onload中options携带的参数,确定用户需要的book / article 类型
5 | * 从数据库获取,并返回
6 | */
7 | async function getStoreDB(options){
8 | // console.log('options ->',options)
9 | let type1 = options.type1;
10 | let type2 = options.type2;
11 | // 验证type1,2是否合法
12 |
13 | // 数据库id
14 | if (type1 == "cet4") type1 = 'Find-cet4-4527254'
15 | if (type1 == "cet6") type1 = 'Find-cet6-1452524'
16 | if (type1 == "postgraduate") type1 = 'Find-postgraduate-183844'
17 | // if (type1 == "cet4") type1 = 'Find-cet4-4527254'
18 |
19 | // console.log('type ->', type1, type2)
20 | // 获取数据
21 | const db = wx.cloud.database()
22 | const _ = db.command
23 | let data = await new Promise((resolve,reject)=>{
24 | db.collection('store').doc(type1).field({
25 | [type2]: true
26 | }).get({
27 | success(res) {
28 | console.log('get db success->',res)
29 | resolve(res.data[type2])
30 | },
31 | fial(res) {
32 | console.log('get db fail->', res)
33 | reject()
34 | }
35 | })
36 | })
37 |
38 |
39 | console.log('data ->', data)
40 | return data
41 | }
42 |
43 | function setTitle(options){
44 | let type1 = options.type1;
45 | let type2 = options.type2;
46 |
47 | let title =''
48 |
49 | // 标题
50 | if (type1 == "cet4") title = '四级'
51 | if (type1 == "cet6") title = '六级'
52 | if (type1 == "postgraduate") title = '考研'
53 |
54 | // 副标题
55 | if(type2 == 'reading') title = title + '-阅读'
56 | if (type2 == 'writing') title = title + '-写作'
57 | if (type2 == 'listening') title = title + '-听力'
58 | if (type2 == 'translate') title = title + '-翻译'
59 |
60 | return title
61 | }
62 |
63 |
64 | Page({
65 |
66 | /**
67 | * 页面的初始数据
68 | */
69 | data: {
70 | systemInfo:null,
71 | listTitle:'',
72 | dataList:[], // 显示的list信息
73 | },
74 |
75 | /**
76 | * 生命周期函数--监听页面加载
77 | */
78 | onLoad: function (options) {
79 | // 导航栏高度适配
80 | this.setData({
81 | systemInfo:wx.getSystemInfoSync()
82 | })
83 | // 设置标题
84 | let title = setTitle(options)
85 | this.setData({
86 | listTitle:title
87 | })
88 |
89 | // 获取数据库数据
90 | this.getData(options)
91 | },
92 |
93 | /**
94 | * 生命周期函数--监听页面初次渲染完成
95 | */
96 | onReady: function () {
97 |
98 | },
99 |
100 | /**
101 | * 生命周期函数--监听页面显示
102 | */
103 | onShow: function () {
104 |
105 | },
106 |
107 | /**
108 | * 生命周期函数--监听页面隐藏
109 | */
110 | onHide: function () {
111 |
112 | },
113 |
114 | /**
115 | * 生命周期函数--监听页面卸载
116 | */
117 | onUnload: function () {
118 |
119 | },
120 |
121 | /**
122 | * 页面相关事件处理函数--监听用户下拉动作
123 | */
124 | onPullDownRefresh: function () {
125 |
126 | },
127 |
128 | /**
129 | * 页面上拉触底事件的处理函数
130 | */
131 | onReachBottom: function () {
132 |
133 | },
134 |
135 | /**
136 | * 用户点击右上角分享
137 | */
138 | onShareAppMessage: function () {
139 |
140 | },
141 |
142 | getData: async function (options){
143 | let dataList = await getStoreDB(options)
144 | this.setData({
145 | dataList: dataList
146 | })
147 | },
148 |
149 | navigateBack:function(){
150 | wx.navigateBack({
151 | })
152 | },
153 |
154 | test:function(e){
155 | console.log('tests->',e)
156 | },
157 |
158 | downloadBookAndGo: async function (e) {
159 | console.log('downloadBookAndGo->',e)
160 | let shareLink = e.currentTarget.dataset.sharelink
161 | if (shareLink) {
162 | let shareLinkExtract = /^[\s\S]*?\b(\w+?&.+?&\w+?)\b[\s\S]*$/
163 | shareLink = shareLink.replace(shareLinkExtract, '$1')
164 | const bookMgr = new bookmgr.bookshelfClass()
165 | wx.showLoading({
166 | title: '获取中...'
167 | })
168 | console.log('shareLink ->', shareLink)
169 | let stats = await bookMgr.addBookByShare(shareLink)
170 | if (stats.stats == 'ok') {
171 | let id = stats.id
172 | // 下载成功 转到阅读页面
173 | wx.navigateTo({
174 | url: '../../pages/reading/reading?bookId=' + id
175 | })
176 | } else {
177 | // 失败
178 | }
179 | wx.hideLoading()
180 |
181 | }
182 | },
183 | })
--------------------------------------------------------------------------------
/pages/storeList/storeList.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {}
3 | }
--------------------------------------------------------------------------------
/pages/storeList/storeList.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | {{listTitle}}
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | {{data['title']}}
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/pages/storeList/storeList.wxs:
--------------------------------------------------------------------------------
1 | // 点击后显示点击态
2 | function tapAction(e,owner){
3 | console.log('hover id=>', e.currentTarget.id)
4 | var id = e.currentTarget.id
5 | var playclass = e.currentTarget.dataset.play
6 | var hover = owner.selectComponent('#' + id)
7 | if (hover.hasClass(playclass)) {
8 | hover.removeClass(playclass)
9 | hover.addClass(playclass + '1')
10 | } else {
11 | hover.removeClass(playclass + '1')
12 | hover.addClass(playclass)
13 | }
14 | var bind = e.currentTarget.dataset.mybind //逻辑层
15 | if (bind) {
16 | console.log('cal method ->', bind)
17 | hover.callMethod(bind, e)
18 | } else {
19 | console.log('bind false ->', bind)
20 | }
21 | }
22 |
23 |
24 | module.exports = {
25 | tapAction: tapAction
26 | }
--------------------------------------------------------------------------------
/pages/storeList/storeList.wxss:
--------------------------------------------------------------------------------
1 | /* pages/storeList/storeList.wxss */
2 | .cover-image{
3 | position:fixed;
4 | width:100vw;
5 | height:80vw;
6 | top:0;
7 | left:0;
8 | background-color:#aaa;
9 | }
10 | .cover-image-image{
11 | position:relative;
12 | top:0;
13 | left:0;
14 | width:100%;
15 | height:100%;
16 | }
17 | .navigate-back{
18 | width:20px;
19 | height:20px;
20 | position:absolute;
21 | left:10px;
22 | top:7px;
23 | padding-top:26px 6px 6px 6px;
24 | z-index:10;
25 | transition: all 0.5s;
26 | }
27 |
28 | .item-box{
29 | position:relative;
30 | top:80vw;
31 | width:calc(100% - 40px);
32 | min-height:calc(100vh - 80vw);
33 | padding: 0 20px;
34 | color:#333;
35 | background-color:#fff;
36 | }
37 | .style-fix{
38 | position:absolute;
39 | top:-40px;
40 | left:0;
41 | width:100vw;
42 | height:40px;
43 | background:linear-gradient(180deg, rgba(255,255,255,0.8) 0%, rgba(255,255,255,1) 100% );
44 | border-radius:20px 20px 0 0;
45 | }
46 | .title-text{
47 | position:relative;
48 | font-size:24px;
49 | top:-10px;
50 | }
51 |
52 | .list-item{
53 | width:100%;
54 | height:60px;
55 | line-height:60px;
56 | align-items:center;
57 | display:flex;
58 | }
59 | .item-icon{
60 | width:40px;
61 | height:40px;
62 | margin-right:10px;
63 | }
64 | .item-title{
65 | width:calc(100% - 50px);
66 | height:100%;
67 | border-top:1px solid rgba(0,0,0,0.1);
68 | }
69 | .item-title-first{
70 | border-top:1px solid rgba(0,0,0,0);
71 | }
72 |
73 | /**点击动画*/
74 | .hover{
75 | animation: tap 0.3s;
76 | }
77 |
78 | @keyframes tap{
79 | 0%{
80 | transform:scale(1)
81 | }
82 | 10%{
83 | transform:scale(0.9)
84 | }
85 | 50%{
86 | transfrom:scale(1.1)
87 | }
88 | 90%{
89 | transform:scale(0.9)
90 | }
91 | 100%{
92 | transform:scale(1)
93 | }
94 | }
95 |
96 | .item-title-placeholder{
97 | width:calc(100% - 50px);
98 | height:25px;
99 | background-color:#eee;
100 | }
101 |
102 | .placeholder{
103 | background-color:#eee;
104 | }
105 |
106 |
107 |
--------------------------------------------------------------------------------
/pages/wordbook/wordbook.js:
--------------------------------------------------------------------------------
1 | // pages/wordbook/wordbook.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 | systemInfo:null,
9 | },
10 |
11 | /**
12 | * 生命周期函数--监听页面加载
13 | */
14 | onLoad: function (options) {
15 | this.setData({
16 | systemInfo:wx.getSystemInfoSync()
17 | })
18 | },
19 |
20 | /**
21 | * 生命周期函数--监听页面初次渲染完成
22 | */
23 | onReady: function () {
24 |
25 | },
26 |
27 | /**
28 | * 生命周期函数--监听页面显示
29 | */
30 | onShow: function () {
31 |
32 | },
33 |
34 | /**
35 | * 生命周期函数--监听页面隐藏
36 | */
37 | onHide: function () {
38 |
39 | },
40 |
41 | /**
42 | * 生命周期函数--监听页面卸载
43 | */
44 | onUnload: function () {
45 |
46 | },
47 |
48 | /**
49 | * 页面相关事件处理函数--监听用户下拉动作
50 | */
51 | onPullDownRefresh: function () {
52 |
53 | },
54 |
55 | /**
56 | * 页面上拉触底事件的处理函数
57 | */
58 | onReachBottom: function () {
59 |
60 | },
61 |
62 | /**
63 | * 用户点击右上角分享
64 | */
65 | onShareAppMessage: function () {
66 |
67 | },
68 |
69 | test:function(e){
70 | console.log('test ->',e)
71 | }
72 | })
--------------------------------------------------------------------------------
/pages/wordbook/wordbook.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {}
3 | }
--------------------------------------------------------------------------------
/pages/wordbook/wordbook.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 生词本
6 |
7 |
8 | 开发中...
9 |
10 |
18 |
--------------------------------------------------------------------------------
/pages/wordbook/wordbook.wxss:
--------------------------------------------------------------------------------
1 | /* pages/wordbook/wordbook.wxss */
2 | .navigationBar{
3 | width:100vw;
4 | height:60px;
5 | position:fixed;
6 | z-index:10;
7 | align-items:center;
8 | padding-top:20px;
9 | display:flex;
10 | /*background-color:#ccf;*/
11 | background:linear-gradient(to right, #1c80ff, #05AFF2);
12 | color:#fff;
13 | box-shadow:2px 0px 5px #888;
14 | }
15 | .nav-title{
16 | height:32px;
17 | line-height:32px;
18 | font-size:16px;
19 | margin-left:15px;
20 | }
--------------------------------------------------------------------------------
/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "项目配置文件",
3 | "packOptions": {
4 | "ignore": []
5 | },
6 | "setting": {
7 | "urlCheck": true,
8 | "es6": false,
9 | "postcss": true,
10 | "minified": true,
11 | "newFeature": true,
12 | "autoAudits": true,
13 | "uglifyFileName": true,
14 | "checkInvalidKey": true
15 | },
16 | "compileType": "miniprogram",
17 | "libVersion": "2.6.2",
18 | "appid": "wx16b955041265aaf5",
19 | "projectname": "%E5%88%92%E8%AF%8D%E9%98%85%E8%AF%BB",
20 | "debugOptions": {
21 | "hidedInDevtools": []
22 | },
23 | "isGameTourist": false,
24 | "cloudfunctionRoot": "cloudFunction/",
25 | "simulatorType": "wechat",
26 | "simulatorPluginLibVersion": {},
27 | "condition": {
28 | "search": {
29 | "current": -1,
30 | "list": []
31 | },
32 | "conversation": {
33 | "current": -1,
34 | "list": []
35 | },
36 | "game": {
37 | "currentL": -1,
38 | "list": []
39 | },
40 | "miniprogram": {
41 | "current": -1,
42 | "list": []
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/sitemap.json:
--------------------------------------------------------------------------------
1 | {
2 | "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
3 | "rules": [{
4 | "action": "allow",
5 | "page": "*"
6 | }]
7 | }
--------------------------------------------------------------------------------
/template/template.wxml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baotlake/WordReading/a05ee9264d7fc8d085b4d550bf2c51310e4eb8bd/template/template.wxml
--------------------------------------------------------------------------------
/template/template.wxss:
--------------------------------------------------------------------------------
1 | /**书名输入框样式*/
2 | .input{
3 | position:fixed;
4 | top:80px;
5 | left:160px;
6 | width:0px;
7 | height:0px;
8 | overflow:hidden;
9 | opacity:0;
10 | transition:all 0.5s;
11 | }
12 | .input-show{
13 | display:block;
14 | position:fixed;
15 | height:100px;
16 | width:220px;
17 | top:calc(25vh - 30px);
18 | left:calc((100vw - 260px) / 2);
19 | background-color:#fff;
20 | border-radius:10px;
21 | padding:20px;
22 | box-shadow:0 0 10px #888;
23 | opacity:1;
24 | z-index:50;
25 | }
26 | .input-prompt{
27 | font-size:1em;
28 | }
29 | .input-masking{
30 | position:fixed;
31 | top:0;
32 | left:0;
33 | width:100vw;
34 | height:100vh;
35 | opacity:0.6;
36 | background-color:#333;
37 | }
38 | .input-input{
39 | border-bottom:1px solid #aaf;
40 | height:30%;
41 | margin:10px 0 5px 0;
42 | }
43 | .input-button{
44 | display:inline-block;
45 | position:relative;
46 | font-size:0.8em;
47 | width:40px;
48 | height:25%;
49 | line-height:25px;
50 | text-align:center;
51 | transition:all 0.5s;
52 | }
53 | #input-cancel{
54 | margin-left:calc(100% - 80px);
55 | color:#555;
56 | }
57 |
--------------------------------------------------------------------------------
/utils/util.js:
--------------------------------------------------------------------------------
1 | const formatTime = date => {
2 | const year = date.getFullYear()
3 | const month = date.getMonth() + 1
4 | const day = date.getDate()
5 | const hour = date.getHours()
6 | const minute = date.getMinutes()
7 | const second = date.getSeconds()
8 |
9 | return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
10 | }
11 |
12 | const formatNumber = n => {
13 | n = n.toString()
14 | return n[1] ? n : '0' + n
15 | }
16 |
17 | module.exports = {
18 | formatTime: formatTime
19 | }
20 |
--------------------------------------------------------------------------------