├── .gitignore
├── README.md
├── cloudfunctions
├── do_collect
│ ├── index.js
│ └── package.json
├── do_search
│ ├── index.js
│ └── package.json
├── do_star
│ ├── index.js
│ └── package.json
├── get_author_poems
│ ├── index.js
│ └── package.json
├── get_collect
│ ├── index.js
│ └── package.json
├── get_tag
│ ├── index.js
│ └── package.json
├── get_tag_poems
│ ├── index.js
│ └── package.json
├── is_collect
│ ├── index.js
│ └── package.json
├── login
│ └── index.js
└── recommend
│ ├── index.js
│ └── package.json
├── miniprogram
├── app.js
├── app.json
├── app.wxss
├── images
│ ├── icon_collect_checked.png
│ ├── icon_collect_nol.png
│ ├── icon_do_collect_checked.png
│ ├── icon_do_collect_nol.png
│ ├── icon_recommend_checked.png
│ ├── icon_recommend_nol.png
│ ├── icon_share.png
│ ├── icon_sort_checked.png
│ ├── icon_sort_nol.png
│ ├── icon_star_checked.png
│ └── icon_star_nol.png
├── lib
│ └── regenerator-runtime
│ │ ├── README.md
│ │ ├── package.json
│ │ ├── path.js
│ │ └── runtime.js
└── pages
│ ├── author
│ ├── author.js
│ ├── author.json
│ ├── author.wxml
│ └── author.wxss
│ ├── author_poem
│ ├── author_poem.js
│ ├── author_poem.json
│ ├── author_poem.wxml
│ └── author_poem.wxss
│ ├── authors
│ ├── authors.js
│ ├── authors.json
│ ├── authors.wxml
│ └── authors.wxss
│ ├── collect
│ ├── collect.js
│ ├── collect.json
│ ├── collect.wxml
│ └── collect.wxss
│ ├── poem
│ ├── poem.js
│ ├── poem.json
│ ├── poem.wxml
│ └── poem.wxss
│ ├── recommend
│ ├── recommend.js
│ ├── recommend.json
│ ├── recommend.wxml
│ └── recommend.wxss
│ ├── search
│ ├── search.js
│ ├── search.json
│ ├── search.wxml
│ └── search.wxss
│ ├── tag_poem
│ ├── tag_poem.js
│ ├── tag_poem.json
│ ├── tag_poem.wxml
│ └── tag_poem.wxss
│ └── tags
│ ├── all_poem
│ ├── all_poem.js
│ ├── all_poem.json
│ ├── all_poem.wxml
│ └── all_poem.wxss
│ ├── tags.js
│ ├── tags.json
│ ├── tags.wxml
│ └── tags.wxss
├── project.config.json
├── qrcode.jpg
└── 数据库.rar
/.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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 三号诗社
2 |
3 |
4 | 这是基于微信小程序云开发做的一款诗词类小程序
5 |
6 |
7 | 
8 |
--------------------------------------------------------------------------------
/cloudfunctions/do_collect/index.js:
--------------------------------------------------------------------------------
1 | // 云函数入口文件
2 | const cloud = require('wx-server-sdk')
3 |
4 | cloud.init()
5 | const db=cloud.database()
6 | const _=db.command
7 | // 云函数入口函数
8 | exports.main = async (event, context) => {
9 | var eventuser = event.userInfo.openId;
10 | var eventtype=event.type;
11 | var eventname=event.name;
12 | var eventid = event.id;
13 | var eventcontent = event.content;
14 | var dbName = eventtype=='01'?"poem_collect":"poet_collect";
15 | const isCollect = await db.collection(dbName).where({id:eventid,user:eventuser}).count();
16 | if (isCollect.total>0){//已收藏则取消收藏
17 | return await db.collection(dbName).where({ id: eventid }).remove();
18 | }else{
19 | return await db.collection(dbName).add({
20 | data: {
21 | id: eventid,
22 | user: eventuser,
23 | name: eventname,
24 | content: eventcontent,
25 | date: db.serverDate()
26 | }
27 | }).then(res =>{
28 | if (eventtype != '01'){//作者收藏时更新star字段
29 | return db.collection('poet').doc(eventid).update({data:{star:_.inc(1)}})
30 | }else{
31 | return db.collection('poetry').doc(eventid).update({ data: { collect: _.inc(1) } })
32 | }
33 | });
34 | }
35 | }
--------------------------------------------------------------------------------
/cloudfunctions/do_collect/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "do_collect",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "dependencies": {
12 | "wx-server-sdk": "latest"
13 | }
14 | }
--------------------------------------------------------------------------------
/cloudfunctions/do_search/index.js:
--------------------------------------------------------------------------------
1 | // 云函数入口文件
2 | const cloud = require('wx-server-sdk')
3 |
4 | cloud.init()
5 | const db=cloud.database();
6 | const _ = cloud.command;
7 | // 云函数入口函数
8 | exports.main = async (event, context) => {
9 | var value = event.value.trim();
10 | if (!value) {
11 | return { data: [], hasMore: false }
12 | }
13 | var data = [];
14 | await db.collection("poet").field({
15 | poetId: true,
16 | name: true,
17 | desc: true
18 | }).where({
19 | name: {
20 | $regex: '.*' + value,
21 | $options: 'i' //不区分大小写
22 | }
23 | }).get().then(res => {
24 | if (res.data) {
25 | for (var i = 0; i < res.data.length; i++) {
26 | data.push({
27 | id: res.data[i].poetId,
28 | type: "00",
29 | name: res.data[i].name,
30 | content: res.data[i].desc
31 | });
32 | }
33 | }
34 | });
35 | await db.collection("poetry").field({
36 | id:true,
37 | name:true,
38 | content:true
39 | }).where({
40 | name: {
41 | $regex: '.*' + value,
42 | $options: 'i' //不区分大小写
43 | }
44 | }).orderBy('star', 'desc').get().then(res =>{
45 | if (res.data) {
46 | for (var i = 0; i < res.data.length; i++) {
47 | if (data.findIndex(result=>{ return result.id==res.data[i]._id })==-1) {
48 | data.push({
49 | id: res.data[i]._id,
50 | type: "01",
51 | name: res.data[i].name,
52 | content: res.data[i].content
53 | });
54 | }
55 | }
56 | }
57 | });
58 | await db.collection("poetry").field({
59 | id: true,
60 | name: true,
61 | content: true
62 | }).where({
63 | content: {
64 | $regex: '.*' + value,
65 | $options: 'i' //不区分大小写
66 | }
67 | }).orderBy('star', 'desc').get().then(res => {
68 | if (res.data) {
69 | for (var i = 0; i < res.data.length; i++) {
70 | if (data.findIndex(result => { return result.id == res.data[i]._id }) == -1) {
71 | data.push({
72 | id: res.data[i]._id,
73 | type: "01",
74 | name: res.data[i].name,
75 | content: res.data[i].content
76 | });
77 | }
78 | }
79 | }
80 | });
81 | return data;
82 | }
--------------------------------------------------------------------------------
/cloudfunctions/do_search/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "do_search",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "dependencies": {
12 | "wx-server-sdk": "latest"
13 | }
14 | }
--------------------------------------------------------------------------------
/cloudfunctions/do_star/index.js:
--------------------------------------------------------------------------------
1 | // 云函数入口文件
2 | const cloud = require('wx-server-sdk')
3 |
4 | cloud.init()
5 | const db = cloud.database()
6 | const _=db.command
7 | // 云函数入口函数
8 | exports.main = async (event, context) => {
9 | var eventuser = event.userInfo.openId;
10 | var eventid = event.id;
11 | var eventname = event.name;
12 | await db.collection('poetry').where({_id:eventid}).update({
13 | data: {
14 | // 表示指示数据库将字段自增 10
15 | star: _.inc(1)
16 | }
17 | });
18 | return db.collection('poem_star').add({
19 | data:{
20 | id:eventid,
21 | name:eventname,
22 | user:eventuser,
23 | date: db.serverDate()
24 | }
25 | }).then(res => {
26 | return res;
27 | });
28 | }
--------------------------------------------------------------------------------
/cloudfunctions/do_star/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "do_star",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "dependencies": {
12 | "wx-server-sdk": "latest"
13 | }
14 | }
--------------------------------------------------------------------------------
/cloudfunctions/get_author_poems/index.js:
--------------------------------------------------------------------------------
1 | // 云函数入口文件
2 | const cloud = require('wx-server-sdk')
3 |
4 | cloud.init()
5 | const db = cloud.database()
6 | const _ = db.command
7 | // 云函数入口函数
8 | exports.main = async (event, context) => {
9 | var author = event.author;
10 | if(!author){
11 | return {data:[],hasMore:false}
12 | }
13 | var hasMore;
14 | var dbName = 'poetry';
15 | var field = {
16 | id: true,
17 | name: true,
18 | content:true
19 | };
20 | var pageIndex = event.pageIndex ? event.pageIndex : 1;
21 | var pageSize = event.pageSize ? event.pageSize : 10;
22 | var filter = {
23 | 'poet.id':parseInt(author)
24 | };
25 | const countResult = await db.collection(dbName).field(field).where(filter).count();
26 | const total = countResult.total;
27 | const totalPage = Math.ceil(total / pageSize);
28 | if (pageIndex > totalPage || pageIndex == totalPage) {
29 | hasMore = false;
30 | } else {
31 | hasMore = true;
32 | }
33 | return db.collection(dbName).field(field).where(filter).skip((pageIndex - 1) * pageSize).limit(pageSize).orderBy('star', 'desc').get().then(res => {
34 | res.hasMore = hasMore;
35 | return res;
36 | });
37 | }
--------------------------------------------------------------------------------
/cloudfunctions/get_author_poems/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "get_author_poems",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "dependencies": {
12 | "wx-server-sdk": "latest"
13 | }
14 | }
--------------------------------------------------------------------------------
/cloudfunctions/get_collect/index.js:
--------------------------------------------------------------------------------
1 | // 云函数入口文件
2 | const cloud = require('wx-server-sdk')
3 |
4 | cloud.init()
5 | const db = cloud.database()
6 | // 云函数入口函数
7 | exports.main = async (event, context) => {
8 | var eventuser = event.userInfo.openId;
9 | var eventtype = event.type;
10 | var dbName = eventtype == '01' ? "poem_collect" : "poet_collect";
11 |
12 | var pageIndex = event.pageIndex ? event.pageIndex : 1;
13 | var pageSize = event.pageSize ? event.pageSize : 10;
14 | var filter = {user: eventuser};
15 | const countResult = await db.collection(dbName).where(filter).count();
16 | const total = countResult.total;
17 | const totalPage = Math.ceil(total / pageSize);
18 | if (pageIndex > totalPage || pageIndex == totalPage) {
19 | hasMore = false;
20 | } else {
21 | hasMore = true;
22 | }
23 |
24 | return db.collection(dbName).where(filter).orderBy('date', 'desc')
25 | .skip((pageIndex - 1) * pageSize).limit(pageSize).get().then(res => {
26 | res.hasMore=hasMore;
27 | return res;
28 | });
29 | }
--------------------------------------------------------------------------------
/cloudfunctions/get_collect/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "get_collect",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "dependencies": {
12 | "wx-server-sdk": "latest"
13 | }
14 | }
--------------------------------------------------------------------------------
/cloudfunctions/get_tag/index.js:
--------------------------------------------------------------------------------
1 | // 云函数入口文件
2 | const cloud = require('wx-server-sdk')
3 |
4 | cloud.init()
5 | const testDB = cloud.database()
6 | // 云函数入口函数
7 | exports.main = async (event, context) => {
8 | //超过100条需要重写该函数
9 | return await testDB.collection('tag').get({
10 | success: function (res) {
11 | // console.info(res)
12 | return res
13 | },
14 | fail: function (info) {
15 | return info
16 | }
17 | })
18 | }
--------------------------------------------------------------------------------
/cloudfunctions/get_tag/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "get_tag",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "dependencies": {
12 | "wx-server-sdk": "latest"
13 | }
14 | }
--------------------------------------------------------------------------------
/cloudfunctions/get_tag_poems/index.js:
--------------------------------------------------------------------------------
1 | // 云函数入口文件
2 | const cloud = require('wx-server-sdk')
3 |
4 | cloud.init()
5 | const db=cloud.database()
6 | const _ = db.command
7 | // 云函数入口函数
8 | exports.main = async (event, context) => {
9 | var dbName=event.dbName;
10 | var tag=event.tag?event.tag:null;
11 | var field=event.field?event.field:null;
12 | var pageIndex = event.pageIndex ? event.pageIndex : 1;
13 | var pageSize = event.pageSize ? event.pageSize : 10;
14 | var filter = {
15 | tags: {
16 | $regex: '.*' + tag,
17 | $options: 'i' //不区分大小写
18 | }
19 | };
20 | const countResult = await db.collection(dbName).field(field).where(filter).count();
21 | const total=countResult.total;
22 | const totalPage=Math.ceil(total/pageSize);
23 | var hasMore;
24 | if(pageIndex>totalPage||pageIndex==totalPage){
25 | hasMore=false;
26 | }else{
27 | hasMore=true;
28 | }
29 | return db.collection(dbName).field(field).where(filter).skip((pageIndex - 1) * pageSize).limit(pageSize).orderBy('star', 'desc').get().then(res =>{
30 | res.hasMore=hasMore;
31 | return res;
32 | });
33 | }
--------------------------------------------------------------------------------
/cloudfunctions/get_tag_poems/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "get_tag_poems",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "dependencies": {
12 | "wx-server-sdk": "latest"
13 | }
14 | }
--------------------------------------------------------------------------------
/cloudfunctions/is_collect/index.js:
--------------------------------------------------------------------------------
1 | // 云函数入口文件
2 | const cloud = require('wx-server-sdk')
3 |
4 | cloud.init()
5 | const db = cloud.database()
6 | const _ = db.command
7 | // 云函数入口函数
8 | exports.main = async (event, context) => {
9 | var eventuser = event.userInfo.openId;
10 | var eventid = event.id;
11 | var eventtype = event.type;
12 | var dbName = eventtype == '01' ? "poem_collect" : "poet_collect";
13 | var result = await db.collection(dbName).where({ id: eventid ,user:eventuser}).count();
14 | return {message:result.total>0}
15 | }
--------------------------------------------------------------------------------
/cloudfunctions/is_collect/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "is_collect",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "dependencies": {
12 | "wx-server-sdk": "latest"
13 | }
14 | }
--------------------------------------------------------------------------------
/cloudfunctions/login/index.js:
--------------------------------------------------------------------------------
1 | // 云函数模板
2 | // 部署:在 cloud-functions/login 文件夹右击选择 “上传并部署”
3 |
4 | /**
5 | * 这个示例将经自动鉴权过的小程序用户 openid 返回给小程序端
6 | *
7 | * event 参数包含
8 | * - 小程序端调用传入的 data
9 | * - 经过微信鉴权直接可信的用户唯一标识 openid
10 | *
11 | */
12 | exports.main = (event, context) => {
13 | console.log(event)
14 | console.log(context)
15 |
16 | // 可执行其他自定义逻辑
17 | // console.log 的内容可以在云开发云函数调用日志查看
18 |
19 | return {
20 | openid: event.userInfo.openId,
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/cloudfunctions/recommend/index.js:
--------------------------------------------------------------------------------
1 | // 云函数入口文件
2 | const cloud = require('wx-server-sdk')
3 |
4 | cloud.init()
5 | const db = cloud.database()
6 | // 云函数入口函数
7 | exports.main = async(event, context) => {
8 | var eventuser = event.userInfo.openId;
9 | const seedPoet=1;
10 | const seedPoem=2;
11 | const seedStar=3;
12 | const seedMostStar=4;
13 | const seedAllRandom=5;
14 | var recommendID = '';
15 | var seeds=[1,4,4,1,5,1,4,1,4,2,3,4,5,4,1,4,3,4,2,4,3,4,4,4];
16 | var seed = parseInt((seeds.length-1) * Math.random());//产生随机数,决定从哪里选择推荐
17 | if(seeds[seed]==seedPoet){
18 | return await db.collection('poet_collect').where({ user: eventuser }).orderBy('date', 'desc').get()
19 | .then(res =>{
20 | if (res.errMsg.indexOf('ok') != -1 && res.data.length>0) {
21 | // collectPoets.concat(res.data);
22 | var poetIndex = parseInt((res.data.length - 1) * Math.random());//从收藏作者中随机抽取一位
23 | var poet = res.data[poetIndex];
24 | return db.collection('poetry').field({
25 | _id: true,
26 | id: true
27 | }).where({
28 | 'poet.name': poet.name
29 | }).get();
30 | }else{
31 | return {errMsg:'false'}
32 | }
33 | }).then(res => {
34 | if (res.errMsg.indexOf('ok') != -1 && res.data.length > 0) {
35 | // poetPoems.concat(res.data);
36 | recommendID = res.data[parseInt((res.data.length - 1) * Math.random())]._id;//从该作者诗文中随机抽取一篇推荐
37 | return db.collection('poetry').where({
38 | _id: recommendID
39 | }).get();
40 | } else {
41 | return db.collection('poetry').orderBy('star', 'desc').skip(parseInt(1000 * Math.random())).limit(1).get();
42 | }
43 |
44 | });
45 | } else if (seeds[seed] == seedPoem){
46 |
47 | return await db.collection('poem_collect').where({ user: eventuser }).orderBy('date', 'desc').get()
48 | .then(res => {
49 | if (res.errMsg.indexOf('ok') != -1 && res.data.length > 0) {
50 | // poetPoems.concat(res.data);
51 | recommendID = res.data[parseInt((res.data.length - 1) * Math.random())].id;//从该收藏诗文中随机抽取一篇推荐
52 | return db.collection('poetry').where({
53 | _id: recommendID
54 | }).get();
55 | } else {
56 | return db.collection('poetry').orderBy('star', 'desc').skip(parseInt(1000 * Math.random())).limit(1).get();
57 | }
58 |
59 | });
60 | } else if (seeds[seed] == seedStar) {
61 |
62 | return await db.collection('poem_star').where({ user: eventuser }).orderBy('date', 'desc').get()
63 | .then(res => {
64 | if (res.errMsg.indexOf('ok') != -1 && res.data.length > 0) {
65 | // poetPoems.concat(res.data);
66 | recommendID = res.data[parseInt((res.data.length - 1) * Math.random())].id;//从该点赞诗文中随机抽取一篇推荐
67 | return db.collection('poetry').where({
68 | _id: recommendID
69 | }).get();
70 | }else{
71 | return db.collection('poetry').orderBy('star', 'desc').skip(parseInt(1000 * Math.random())).limit(1).get();
72 | }
73 |
74 | });
75 | } else if (seeds[seed] == seedMostStar) {//点赞最多的1000条里读取一条
76 | return db.collection('poetry').orderBy('star', 'desc').skip(parseInt(1000 * Math.random())).limit(1).get();
77 |
78 | } else {
79 | var recommendIndex = parseInt(72417 * Math.random());//诗库里随机读取一首
80 | // console.info(recommendIndex)
81 | return await db.collection('poetry').where({
82 | id: recommendIndex
83 | }).get();
84 |
85 | }
86 |
87 | }
--------------------------------------------------------------------------------
/cloudfunctions/recommend/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "recommend",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "dependencies": {
12 | "wx-server-sdk": "latest"
13 | }
14 | }
--------------------------------------------------------------------------------
/miniprogram/app.js:
--------------------------------------------------------------------------------
1 | //app.js
2 | App({
3 | onLaunch: function () {
4 |
5 | if (!wx.cloud) {
6 | console.error('请使用 2.2.3 或以上的基础库以使用云能力')
7 | } else {
8 | wx.cloud.init({
9 | traceUser: true,
10 | })
11 | }
12 |
13 | this.globalData = {}
14 | }
15 | })
16 |
--------------------------------------------------------------------------------
/miniprogram/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": [
3 | "pages/recommend/recommend",
4 | "pages/collect/collect",
5 | "pages/tags/tags",
6 | "pages/search/search",
7 | "pages/tag_poem/tag_poem",
8 | "pages/poem/poem",
9 | "pages/author/author",
10 | "pages/author_poem/author_poem",
11 | "pages/authors/authors",
12 | "pages/tags/all_poem/all_poem"
13 | ],
14 | "window": {
15 | "backgroundColor": "#F6F6F6",
16 | "backgroundTextStyle": "light",
17 | "navigationBarBackgroundColor": "#F6F6F6",
18 | "navigationBarTitleText": "三号诗社",
19 | "navigationBarTextStyle": "black"
20 | },
21 | "tabBar": {
22 | "color": "#bfbfbf",
23 | "selectedColor": "#e6c7a1",
24 | "borderStyle": "#bfbfbf",
25 | "list": [
26 | {
27 | "selectedIconPath": "images/icon_recommend_checked.png",
28 | "iconPath": "images/icon_recommend_nol.png",
29 | "pagePath": "pages/recommend/recommend",
30 | "text": "推荐"
31 | },
32 | {
33 | "selectedIconPath": "images/icon_sort_checked.png",
34 | "iconPath": "images/icon_sort_nol.png",
35 | "pagePath": "pages/tags/tags",
36 | "text": "诗词"
37 | },
38 | {
39 | "selectedIconPath": "images/icon_collect_checked.png",
40 | "iconPath": "images/icon_collect_nol.png",
41 | "pagePath": "pages/collect/collect",
42 | "text": "收藏"
43 | }
44 | ]
45 | }
46 | }
--------------------------------------------------------------------------------
/miniprogram/app.wxss:
--------------------------------------------------------------------------------
1 | /**app.wxss**/
2 | .container {
3 | display: flex;
4 | flex-direction: column;
5 | align-items: center;
6 | box-sizing: border-box;
7 | }
8 |
--------------------------------------------------------------------------------
/miniprogram/images/icon_collect_checked.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s853562285/SanHaoPoem/b7690ab8e454d84e3dad3c8b21400016e36a2ad8/miniprogram/images/icon_collect_checked.png
--------------------------------------------------------------------------------
/miniprogram/images/icon_collect_nol.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s853562285/SanHaoPoem/b7690ab8e454d84e3dad3c8b21400016e36a2ad8/miniprogram/images/icon_collect_nol.png
--------------------------------------------------------------------------------
/miniprogram/images/icon_do_collect_checked.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s853562285/SanHaoPoem/b7690ab8e454d84e3dad3c8b21400016e36a2ad8/miniprogram/images/icon_do_collect_checked.png
--------------------------------------------------------------------------------
/miniprogram/images/icon_do_collect_nol.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s853562285/SanHaoPoem/b7690ab8e454d84e3dad3c8b21400016e36a2ad8/miniprogram/images/icon_do_collect_nol.png
--------------------------------------------------------------------------------
/miniprogram/images/icon_recommend_checked.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s853562285/SanHaoPoem/b7690ab8e454d84e3dad3c8b21400016e36a2ad8/miniprogram/images/icon_recommend_checked.png
--------------------------------------------------------------------------------
/miniprogram/images/icon_recommend_nol.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s853562285/SanHaoPoem/b7690ab8e454d84e3dad3c8b21400016e36a2ad8/miniprogram/images/icon_recommend_nol.png
--------------------------------------------------------------------------------
/miniprogram/images/icon_share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s853562285/SanHaoPoem/b7690ab8e454d84e3dad3c8b21400016e36a2ad8/miniprogram/images/icon_share.png
--------------------------------------------------------------------------------
/miniprogram/images/icon_sort_checked.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s853562285/SanHaoPoem/b7690ab8e454d84e3dad3c8b21400016e36a2ad8/miniprogram/images/icon_sort_checked.png
--------------------------------------------------------------------------------
/miniprogram/images/icon_sort_nol.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s853562285/SanHaoPoem/b7690ab8e454d84e3dad3c8b21400016e36a2ad8/miniprogram/images/icon_sort_nol.png
--------------------------------------------------------------------------------
/miniprogram/images/icon_star_checked.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s853562285/SanHaoPoem/b7690ab8e454d84e3dad3c8b21400016e36a2ad8/miniprogram/images/icon_star_checked.png
--------------------------------------------------------------------------------
/miniprogram/images/icon_star_nol.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s853562285/SanHaoPoem/b7690ab8e454d84e3dad3c8b21400016e36a2ad8/miniprogram/images/icon_star_nol.png
--------------------------------------------------------------------------------
/miniprogram/lib/regenerator-runtime/README.md:
--------------------------------------------------------------------------------
1 | # regenerator-runtime
2 |
3 | Standalone runtime for
4 | [Regenerator](https://github.com/facebook/regenerator)-compiled generator
5 | and `async` functions.
6 |
7 | To import the runtime as a module (recommended), either of the following
8 | import styles will work:
9 | ```js
10 | // CommonJS
11 | const regeneratorRuntime = require("regenerator-runtime");
12 |
13 | // ECMAScript 2015
14 | import regeneratorRuntime from "regenerator-runtime";
15 | ```
16 |
17 | To ensure that `regeneratorRuntime` is defined globally, either of the
18 | following styles will work:
19 | ```js
20 | // CommonJS
21 | require("regenerator-runtime/runtime");
22 |
23 | // ECMAScript 2015
24 | import "regenerator-runtime/runtime";
25 | ```
26 |
27 | To get the absolute file system path of `runtime.js`, evaluate the
28 | following expression:
29 | ```js
30 | require("regenerator-runtime/path").path
31 | ```
32 |
--------------------------------------------------------------------------------
/miniprogram/lib/regenerator-runtime/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "regenerator-runtime",
3 | "author": {
4 | "name": "Ben Newman",
5 | "email": "bn@cs.stanford.edu"
6 | },
7 | "description": "Runtime for Regenerator-compiled generator and async functions.",
8 | "version": "0.13.1",
9 | "main": "runtime.js",
10 | "keywords": [
11 | "regenerator",
12 | "runtime",
13 | "generator",
14 | "async"
15 | ],
16 | "repository": {
17 | "type": "git",
18 | "url": "https://github.com/facebook/regenerator/tree/master/packages/regenerator-runtime"
19 | },
20 | "license": "MIT",
21 | "_id": "regenerator-runtime@0.13.1",
22 | "_npmVersion": "6.4.1",
23 | "_nodeVersion": "8.11.4",
24 | "_npmUser": {
25 | "name": "benjamn",
26 | "email": "ben@benjamn.com"
27 | },
28 | "dist": {
29 | "integrity": "sha512-5KzMIyPLvfdPmvsdlYsHqITrDfK9k7bmvf97HvHSN4810i254ponbxCQ1NukpRWlu6en2MBWzAlhDExEKISwAA==",
30 | "shasum": "522ea2aafd9200a00eee143dc14219a35a0f3991",
31 | "tarball": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.1.tgz",
32 | "fileCount": 4,
33 | "unpackedSize": 24765,
34 | "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb7xFkCRA9TVsSAnZWagAAxQoQAJ3h/F9HulEQGRVwHJ6K\nJcKX7nFIlRWsmToc5/EKgqMYx/8EeTmdksMj8N8if4QhbMIVYJI67CbTgeVz\ntqHx4eJc+qlD2gYzUYQi4865WJD8ddClHQutueG5diLXLDHdjJO1BiEMBUyb\niYM2+VsT+YtoxpVUmCx6NXOG23PkVSLiKa+C9DEqWQAGUZbDA7MTAsv2nM9/\n9Yxn7FkQOTWlgtB8/2dx2rx5nMK295zZvzxOTyit6Eg2ekzxJkvsfejC8ygJ\n308G0ZxoUl0WWfGnbUBYr/iKhdMo/orxyQe5QNKA5kHMQ7mk2vX/pDyxHBh9\n8jHDfx95kEWFk6yGJAGhxMh4ZJsdTQy7y4xhNChI+m3OetHppvs/WHzqAUz1\njfV3MejgSAxe1uUG7dWpxdlFw28kvXq1eI4roxszjJcbq0sX8kUfxGO9Z63T\nKWn5nbjixkmlYvjCdsvHsAQlCQLePZqsAtVfJ5ajoITZIsCdNEUdSGvKooET\nJu2rbBGkYTl16CyLPu+oLAxDPXnacjrSP4sP4x7Wyy8xD6nol/Pr6ztCP/2E\nSq+alsinLPPVGd2M3sjW7PbOiyiz22DEGmlc12TOZA5/XdmIh+vji6fACIwc\n+8SMj3ujqsVbJLTA1xCxVbrPmWupF4/H34s+HG4/JrGgY/tFz+bxDXETDEtn\n3OET\r\n=GrDQ\r\n-----END PGP SIGNATURE-----\r\n"
35 | },
36 | "maintainers": [
37 | {
38 | "name": "benjamn",
39 | "email": "bn@cs.stanford.edu"
40 | }
41 | ],
42 | "directories": {},
43 | "_npmOperationalInternal": {
44 | "host": "s3://npm-registry-packages",
45 | "tmp": "tmp/regenerator-runtime_0.13.1_1542394212059_0.7211625959030727"
46 | },
47 | "_hasShrinkwrap": false,
48 | "_shasum": "522ea2aafd9200a00eee143dc14219a35a0f3991",
49 | "_resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.1.tgz",
50 | "_from": "regenerator-runtime@>=0.13.0 <0.14.0"
51 | }
52 |
--------------------------------------------------------------------------------
/miniprogram/lib/regenerator-runtime/path.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014-present, Facebook, Inc.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | exports.path = require("path").join(
9 | __dirname,
10 | "runtime.js"
11 | );
12 |
--------------------------------------------------------------------------------
/miniprogram/lib/regenerator-runtime/runtime.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014-present, Facebook, Inc.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | var regeneratorRuntime = (function (exports) {
9 | "use strict";
10 |
11 | var Op = Object.prototype;
12 | var hasOwn = Op.hasOwnProperty;
13 | var undefined; // More compressible than void 0.
14 | var $Symbol = typeof Symbol === "function" ? Symbol : {};
15 | var iteratorSymbol = $Symbol.iterator || "@@iterator";
16 | var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
17 | var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
18 |
19 | function wrap(innerFn, outerFn, self, tryLocsList) {
20 | // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
21 | var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
22 | var generator = Object.create(protoGenerator.prototype);
23 | var context = new Context(tryLocsList || []);
24 |
25 | // The ._invoke method unifies the implementations of the .next,
26 | // .throw, and .return methods.
27 | generator._invoke = makeInvokeMethod(innerFn, self, context);
28 |
29 | return generator;
30 | }
31 | exports.wrap = wrap;
32 |
33 | // Try/catch helper to minimize deoptimizations. Returns a completion
34 | // record like context.tryEntries[i].completion. This interface could
35 | // have been (and was previously) designed to take a closure to be
36 | // invoked without arguments, but in all the cases we care about we
37 | // already have an existing method we want to call, so there's no need
38 | // to create a new function object. We can even get away with assuming
39 | // the method takes exactly one argument, since that happens to be true
40 | // in every case, so we don't have to touch the arguments object. The
41 | // only additional allocation required is the completion record, which
42 | // has a stable shape and so hopefully should be cheap to allocate.
43 | function tryCatch(fn, obj, arg) {
44 | try {
45 | return { type: "normal", arg: fn.call(obj, arg) };
46 | } catch (err) {
47 | return { type: "throw", arg: err };
48 | }
49 | }
50 |
51 | var GenStateSuspendedStart = "suspendedStart";
52 | var GenStateSuspendedYield = "suspendedYield";
53 | var GenStateExecuting = "executing";
54 | var GenStateCompleted = "completed";
55 |
56 | // Returning this object from the innerFn has the same effect as
57 | // breaking out of the dispatch switch statement.
58 | var ContinueSentinel = {};
59 |
60 | // Dummy constructor functions that we use as the .constructor and
61 | // .constructor.prototype properties for functions that return Generator
62 | // objects. For full spec compliance, you may wish to configure your
63 | // minifier not to mangle the names of these two functions.
64 | function Generator() {}
65 | function GeneratorFunction() {}
66 | function GeneratorFunctionPrototype() {}
67 |
68 | // This is a polyfill for %IteratorPrototype% for environments that
69 | // don't natively support it.
70 | var IteratorPrototype = {};
71 | IteratorPrototype[iteratorSymbol] = function () {
72 | return this;
73 | };
74 |
75 | var getProto = Object.getPrototypeOf;
76 | var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
77 | if (NativeIteratorPrototype &&
78 | NativeIteratorPrototype !== Op &&
79 | hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
80 | // This environment has a native %IteratorPrototype%; use it instead
81 | // of the polyfill.
82 | IteratorPrototype = NativeIteratorPrototype;
83 | }
84 |
85 | var Gp = GeneratorFunctionPrototype.prototype =
86 | Generator.prototype = Object.create(IteratorPrototype);
87 | GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
88 | GeneratorFunctionPrototype.constructor = GeneratorFunction;
89 | GeneratorFunctionPrototype[toStringTagSymbol] =
90 | GeneratorFunction.displayName = "GeneratorFunction";
91 |
92 | // Helper for defining the .next, .throw, and .return methods of the
93 | // Iterator interface in terms of a single ._invoke method.
94 | function defineIteratorMethods(prototype) {
95 | ["next", "throw", "return"].forEach(function(method) {
96 | prototype[method] = function(arg) {
97 | return this._invoke(method, arg);
98 | };
99 | });
100 | }
101 |
102 | exports.isGeneratorFunction = function(genFun) {
103 | var ctor = typeof genFun === "function" && genFun.constructor;
104 | return ctor
105 | ? ctor === GeneratorFunction ||
106 | // For the native GeneratorFunction constructor, the best we can
107 | // do is to check its .name property.
108 | (ctor.displayName || ctor.name) === "GeneratorFunction"
109 | : false;
110 | };
111 |
112 | exports.mark = function(genFun) {
113 | if (Object.setPrototypeOf) {
114 | Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
115 | } else {
116 | genFun.__proto__ = GeneratorFunctionPrototype;
117 | if (!(toStringTagSymbol in genFun)) {
118 | genFun[toStringTagSymbol] = "GeneratorFunction";
119 | }
120 | }
121 | genFun.prototype = Object.create(Gp);
122 | return genFun;
123 | };
124 |
125 | // Within the body of any async function, `await x` is transformed to
126 | // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
127 | // `hasOwn.call(value, "__await")` to determine if the yielded value is
128 | // meant to be awaited.
129 | exports.awrap = function(arg) {
130 | return { __await: arg };
131 | };
132 |
133 | function AsyncIterator(generator) {
134 | function invoke(method, arg, resolve, reject) {
135 | var record = tryCatch(generator[method], generator, arg);
136 | if (record.type === "throw") {
137 | reject(record.arg);
138 | } else {
139 | var result = record.arg;
140 | var value = result.value;
141 | if (value &&
142 | typeof value === "object" &&
143 | hasOwn.call(value, "__await")) {
144 | return Promise.resolve(value.__await).then(function(value) {
145 | invoke("next", value, resolve, reject);
146 | }, function(err) {
147 | invoke("throw", err, resolve, reject);
148 | });
149 | }
150 |
151 | return Promise.resolve(value).then(function(unwrapped) {
152 | // When a yielded Promise is resolved, its final value becomes
153 | // the .value of the Promise<{value,done}> result for the
154 | // current iteration.
155 | result.value = unwrapped;
156 | resolve(result);
157 | }, function(error) {
158 | // If a rejected Promise was yielded, throw the rejection back
159 | // into the async generator function so it can be handled there.
160 | return invoke("throw", error, resolve, reject);
161 | });
162 | }
163 | }
164 |
165 | var previousPromise;
166 |
167 | function enqueue(method, arg) {
168 | function callInvokeWithMethodAndArg() {
169 | return new Promise(function(resolve, reject) {
170 | invoke(method, arg, resolve, reject);
171 | });
172 | }
173 |
174 | return previousPromise =
175 | // If enqueue has been called before, then we want to wait until
176 | // all previous Promises have been resolved before calling invoke,
177 | // so that results are always delivered in the correct order. If
178 | // enqueue has not been called before, then it is important to
179 | // call invoke immediately, without waiting on a callback to fire,
180 | // so that the async generator function has the opportunity to do
181 | // any necessary setup in a predictable way. This predictability
182 | // is why the Promise constructor synchronously invokes its
183 | // executor callback, and why async functions synchronously
184 | // execute code before the first await. Since we implement simple
185 | // async functions in terms of async generators, it is especially
186 | // important to get this right, even though it requires care.
187 | previousPromise ? previousPromise.then(
188 | callInvokeWithMethodAndArg,
189 | // Avoid propagating failures to Promises returned by later
190 | // invocations of the iterator.
191 | callInvokeWithMethodAndArg
192 | ) : callInvokeWithMethodAndArg();
193 | }
194 |
195 | // Define the unified helper method that is used to implement .next,
196 | // .throw, and .return (see defineIteratorMethods).
197 | this._invoke = enqueue;
198 | }
199 |
200 | defineIteratorMethods(AsyncIterator.prototype);
201 | AsyncIterator.prototype[asyncIteratorSymbol] = function () {
202 | return this;
203 | };
204 | exports.AsyncIterator = AsyncIterator;
205 |
206 | // Note that simple async functions are implemented on top of
207 | // AsyncIterator objects; they just return a Promise for the value of
208 | // the final result produced by the iterator.
209 | exports.async = function(innerFn, outerFn, self, tryLocsList) {
210 | var iter = new AsyncIterator(
211 | wrap(innerFn, outerFn, self, tryLocsList)
212 | );
213 |
214 | return exports.isGeneratorFunction(outerFn)
215 | ? iter // If outerFn is a generator, return the full iterator.
216 | : iter.next().then(function(result) {
217 | return result.done ? result.value : iter.next();
218 | });
219 | };
220 |
221 | function makeInvokeMethod(innerFn, self, context) {
222 | var state = GenStateSuspendedStart;
223 |
224 | return function invoke(method, arg) {
225 | if (state === GenStateExecuting) {
226 | throw new Error("Generator is already running");
227 | }
228 |
229 | if (state === GenStateCompleted) {
230 | if (method === "throw") {
231 | throw arg;
232 | }
233 |
234 | // Be forgiving, per 25.3.3.3.3 of the spec:
235 | // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
236 | return doneResult();
237 | }
238 |
239 | context.method = method;
240 | context.arg = arg;
241 |
242 | while (true) {
243 | var delegate = context.delegate;
244 | if (delegate) {
245 | var delegateResult = maybeInvokeDelegate(delegate, context);
246 | if (delegateResult) {
247 | if (delegateResult === ContinueSentinel) continue;
248 | return delegateResult;
249 | }
250 | }
251 |
252 | if (context.method === "next") {
253 | // Setting context._sent for legacy support of Babel's
254 | // function.sent implementation.
255 | context.sent = context._sent = context.arg;
256 |
257 | } else if (context.method === "throw") {
258 | if (state === GenStateSuspendedStart) {
259 | state = GenStateCompleted;
260 | throw context.arg;
261 | }
262 |
263 | context.dispatchException(context.arg);
264 |
265 | } else if (context.method === "return") {
266 | context.abrupt("return", context.arg);
267 | }
268 |
269 | state = GenStateExecuting;
270 |
271 | var record = tryCatch(innerFn, self, context);
272 | if (record.type === "normal") {
273 | // If an exception is thrown from innerFn, we leave state ===
274 | // GenStateExecuting and loop back for another invocation.
275 | state = context.done
276 | ? GenStateCompleted
277 | : GenStateSuspendedYield;
278 |
279 | if (record.arg === ContinueSentinel) {
280 | continue;
281 | }
282 |
283 | return {
284 | value: record.arg,
285 | done: context.done
286 | };
287 |
288 | } else if (record.type === "throw") {
289 | state = GenStateCompleted;
290 | // Dispatch the exception by looping back around to the
291 | // context.dispatchException(context.arg) call above.
292 | context.method = "throw";
293 | context.arg = record.arg;
294 | }
295 | }
296 | };
297 | }
298 |
299 | // Call delegate.iterator[context.method](context.arg) and handle the
300 | // result, either by returning a { value, done } result from the
301 | // delegate iterator, or by modifying context.method and context.arg,
302 | // setting context.delegate to null, and returning the ContinueSentinel.
303 | function maybeInvokeDelegate(delegate, context) {
304 | var method = delegate.iterator[context.method];
305 | if (method === undefined) {
306 | // A .throw or .return when the delegate iterator has no .throw
307 | // method always terminates the yield* loop.
308 | context.delegate = null;
309 |
310 | if (context.method === "throw") {
311 | // Note: ["return"] must be used for ES3 parsing compatibility.
312 | if (delegate.iterator["return"]) {
313 | // If the delegate iterator has a return method, give it a
314 | // chance to clean up.
315 | context.method = "return";
316 | context.arg = undefined;
317 | maybeInvokeDelegate(delegate, context);
318 |
319 | if (context.method === "throw") {
320 | // If maybeInvokeDelegate(context) changed context.method from
321 | // "return" to "throw", let that override the TypeError below.
322 | return ContinueSentinel;
323 | }
324 | }
325 |
326 | context.method = "throw";
327 | context.arg = new TypeError(
328 | "The iterator does not provide a 'throw' method");
329 | }
330 |
331 | return ContinueSentinel;
332 | }
333 |
334 | var record = tryCatch(method, delegate.iterator, context.arg);
335 |
336 | if (record.type === "throw") {
337 | context.method = "throw";
338 | context.arg = record.arg;
339 | context.delegate = null;
340 | return ContinueSentinel;
341 | }
342 |
343 | var info = record.arg;
344 |
345 | if (! info) {
346 | context.method = "throw";
347 | context.arg = new TypeError("iterator result is not an object");
348 | context.delegate = null;
349 | return ContinueSentinel;
350 | }
351 |
352 | if (info.done) {
353 | // Assign the result of the finished delegate to the temporary
354 | // variable specified by delegate.resultName (see delegateYield).
355 | context[delegate.resultName] = info.value;
356 |
357 | // Resume execution at the desired location (see delegateYield).
358 | context.next = delegate.nextLoc;
359 |
360 | // If context.method was "throw" but the delegate handled the
361 | // exception, let the outer generator proceed normally. If
362 | // context.method was "next", forget context.arg since it has been
363 | // "consumed" by the delegate iterator. If context.method was
364 | // "return", allow the original .return call to continue in the
365 | // outer generator.
366 | if (context.method !== "return") {
367 | context.method = "next";
368 | context.arg = undefined;
369 | }
370 |
371 | } else {
372 | // Re-yield the result returned by the delegate method.
373 | return info;
374 | }
375 |
376 | // The delegate iterator is finished, so forget it and continue with
377 | // the outer generator.
378 | context.delegate = null;
379 | return ContinueSentinel;
380 | }
381 |
382 | // Define Generator.prototype.{next,throw,return} in terms of the
383 | // unified ._invoke helper method.
384 | defineIteratorMethods(Gp);
385 |
386 | Gp[toStringTagSymbol] = "Generator";
387 |
388 | // A Generator should always return itself as the iterator object when the
389 | // @@iterator function is called on it. Some browsers' implementations of the
390 | // iterator prototype chain incorrectly implement this, causing the Generator
391 | // object to not be returned from this call. This ensures that doesn't happen.
392 | // See https://github.com/facebook/regenerator/issues/274 for more details.
393 | Gp[iteratorSymbol] = function() {
394 | return this;
395 | };
396 |
397 | Gp.toString = function() {
398 | return "[object Generator]";
399 | };
400 |
401 | function pushTryEntry(locs) {
402 | var entry = { tryLoc: locs[0] };
403 |
404 | if (1 in locs) {
405 | entry.catchLoc = locs[1];
406 | }
407 |
408 | if (2 in locs) {
409 | entry.finallyLoc = locs[2];
410 | entry.afterLoc = locs[3];
411 | }
412 |
413 | this.tryEntries.push(entry);
414 | }
415 |
416 | function resetTryEntry(entry) {
417 | var record = entry.completion || {};
418 | record.type = "normal";
419 | delete record.arg;
420 | entry.completion = record;
421 | }
422 |
423 | function Context(tryLocsList) {
424 | // The root entry object (effectively a try statement without a catch
425 | // or a finally block) gives us a place to store values thrown from
426 | // locations where there is no enclosing try statement.
427 | this.tryEntries = [{ tryLoc: "root" }];
428 | tryLocsList.forEach(pushTryEntry, this);
429 | this.reset(true);
430 | }
431 |
432 | exports.keys = function(object) {
433 | var keys = [];
434 | for (var key in object) {
435 | keys.push(key);
436 | }
437 | keys.reverse();
438 |
439 | // Rather than returning an object with a next method, we keep
440 | // things simple and return the next function itself.
441 | return function next() {
442 | while (keys.length) {
443 | var key = keys.pop();
444 | if (key in object) {
445 | next.value = key;
446 | next.done = false;
447 | return next;
448 | }
449 | }
450 |
451 | // To avoid creating an additional object, we just hang the .value
452 | // and .done properties off the next function object itself. This
453 | // also ensures that the minifier will not anonymize the function.
454 | next.done = true;
455 | return next;
456 | };
457 | };
458 |
459 | function values(iterable) {
460 | if (iterable) {
461 | var iteratorMethod = iterable[iteratorSymbol];
462 | if (iteratorMethod) {
463 | return iteratorMethod.call(iterable);
464 | }
465 |
466 | if (typeof iterable.next === "function") {
467 | return iterable;
468 | }
469 |
470 | if (!isNaN(iterable.length)) {
471 | var i = -1, next = function next() {
472 | while (++i < iterable.length) {
473 | if (hasOwn.call(iterable, i)) {
474 | next.value = iterable[i];
475 | next.done = false;
476 | return next;
477 | }
478 | }
479 |
480 | next.value = undefined;
481 | next.done = true;
482 |
483 | return next;
484 | };
485 |
486 | return next.next = next;
487 | }
488 | }
489 |
490 | // Return an iterator with no values.
491 | return { next: doneResult };
492 | }
493 | exports.values = values;
494 |
495 | function doneResult() {
496 | return { value: undefined, done: true };
497 | }
498 |
499 | Context.prototype = {
500 | constructor: Context,
501 |
502 | reset: function(skipTempReset) {
503 | this.prev = 0;
504 | this.next = 0;
505 | // Resetting context._sent for legacy support of Babel's
506 | // function.sent implementation.
507 | this.sent = this._sent = undefined;
508 | this.done = false;
509 | this.delegate = null;
510 |
511 | this.method = "next";
512 | this.arg = undefined;
513 |
514 | this.tryEntries.forEach(resetTryEntry);
515 |
516 | if (!skipTempReset) {
517 | for (var name in this) {
518 | // Not sure about the optimal order of these conditions:
519 | if (name.charAt(0) === "t" &&
520 | hasOwn.call(this, name) &&
521 | !isNaN(+name.slice(1))) {
522 | this[name] = undefined;
523 | }
524 | }
525 | }
526 | },
527 |
528 | stop: function() {
529 | this.done = true;
530 |
531 | var rootEntry = this.tryEntries[0];
532 | var rootRecord = rootEntry.completion;
533 | if (rootRecord.type === "throw") {
534 | throw rootRecord.arg;
535 | }
536 |
537 | return this.rval;
538 | },
539 |
540 | dispatchException: function(exception) {
541 | if (this.done) {
542 | throw exception;
543 | }
544 |
545 | var context = this;
546 | function handle(loc, caught) {
547 | record.type = "throw";
548 | record.arg = exception;
549 | context.next = loc;
550 |
551 | if (caught) {
552 | // If the dispatched exception was caught by a catch block,
553 | // then let that catch block handle the exception normally.
554 | context.method = "next";
555 | context.arg = undefined;
556 | }
557 |
558 | return !! caught;
559 | }
560 |
561 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
562 | var entry = this.tryEntries[i];
563 | var record = entry.completion;
564 |
565 | if (entry.tryLoc === "root") {
566 | // Exception thrown outside of any try block that could handle
567 | // it, so set the completion value of the entire function to
568 | // throw the exception.
569 | return handle("end");
570 | }
571 |
572 | if (entry.tryLoc <= this.prev) {
573 | var hasCatch = hasOwn.call(entry, "catchLoc");
574 | var hasFinally = hasOwn.call(entry, "finallyLoc");
575 |
576 | if (hasCatch && hasFinally) {
577 | if (this.prev < entry.catchLoc) {
578 | return handle(entry.catchLoc, true);
579 | } else if (this.prev < entry.finallyLoc) {
580 | return handle(entry.finallyLoc);
581 | }
582 |
583 | } else if (hasCatch) {
584 | if (this.prev < entry.catchLoc) {
585 | return handle(entry.catchLoc, true);
586 | }
587 |
588 | } else if (hasFinally) {
589 | if (this.prev < entry.finallyLoc) {
590 | return handle(entry.finallyLoc);
591 | }
592 |
593 | } else {
594 | throw new Error("try statement without catch or finally");
595 | }
596 | }
597 | }
598 | },
599 |
600 | abrupt: function(type, arg) {
601 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
602 | var entry = this.tryEntries[i];
603 | if (entry.tryLoc <= this.prev &&
604 | hasOwn.call(entry, "finallyLoc") &&
605 | this.prev < entry.finallyLoc) {
606 | var finallyEntry = entry;
607 | break;
608 | }
609 | }
610 |
611 | if (finallyEntry &&
612 | (type === "break" ||
613 | type === "continue") &&
614 | finallyEntry.tryLoc <= arg &&
615 | arg <= finallyEntry.finallyLoc) {
616 | // Ignore the finally entry if control is not jumping to a
617 | // location outside the try/catch block.
618 | finallyEntry = null;
619 | }
620 |
621 | var record = finallyEntry ? finallyEntry.completion : {};
622 | record.type = type;
623 | record.arg = arg;
624 |
625 | if (finallyEntry) {
626 | this.method = "next";
627 | this.next = finallyEntry.finallyLoc;
628 | return ContinueSentinel;
629 | }
630 |
631 | return this.complete(record);
632 | },
633 |
634 | complete: function(record, afterLoc) {
635 | if (record.type === "throw") {
636 | throw record.arg;
637 | }
638 |
639 | if (record.type === "break" ||
640 | record.type === "continue") {
641 | this.next = record.arg;
642 | } else if (record.type === "return") {
643 | this.rval = this.arg = record.arg;
644 | this.method = "return";
645 | this.next = "end";
646 | } else if (record.type === "normal" && afterLoc) {
647 | this.next = afterLoc;
648 | }
649 |
650 | return ContinueSentinel;
651 | },
652 |
653 | finish: function(finallyLoc) {
654 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
655 | var entry = this.tryEntries[i];
656 | if (entry.finallyLoc === finallyLoc) {
657 | this.complete(entry.completion, entry.afterLoc);
658 | resetTryEntry(entry);
659 | return ContinueSentinel;
660 | }
661 | }
662 | },
663 |
664 | "catch": function(tryLoc) {
665 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
666 | var entry = this.tryEntries[i];
667 | if (entry.tryLoc === tryLoc) {
668 | var record = entry.completion;
669 | if (record.type === "throw") {
670 | var thrown = record.arg;
671 | resetTryEntry(entry);
672 | }
673 | return thrown;
674 | }
675 | }
676 |
677 | // The context.catch method must only be called with a location
678 | // argument that corresponds to a known catch block.
679 | throw new Error("illegal catch attempt");
680 | },
681 |
682 | delegateYield: function(iterable, resultName, nextLoc) {
683 | this.delegate = {
684 | iterator: values(iterable),
685 | resultName: resultName,
686 | nextLoc: nextLoc
687 | };
688 |
689 | if (this.method === "next") {
690 | // Deliberately forget the last sent value so that we don't
691 | // accidentally pass it on to the delegate.
692 | this.arg = undefined;
693 | }
694 |
695 | return ContinueSentinel;
696 | }
697 | };
698 |
699 | // Regardless of whether this script is executing as a CommonJS module
700 | // or not, return the runtime object so that we can declare the variable
701 | // regeneratorRuntime in the outer scope, which allows this module to be
702 | // injected easily by `bin/regenerator --include-runtime script.js`.
703 | return exports;
704 |
705 | }(
706 | // If this script is executing as a CommonJS module, use module.exports
707 | // as the regeneratorRuntime namespace. Otherwise create a new empty
708 | // object. Either way, the resulting object will be used to initialize
709 | // the regeneratorRuntime variable at the top of this file.
710 | typeof module === "object" ? module.exports : {}
711 | ));
712 |
--------------------------------------------------------------------------------
/miniprogram/pages/author/author.js:
--------------------------------------------------------------------------------
1 | // miniprogram/pages/author/author.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 | loadingHidden: false,
9 | loadingFail:false,
10 | collect:false,
11 | author:{}
12 |
13 | },
14 |
15 | /**
16 | * 生命周期函数--监听页面加载
17 | */
18 | onLoad: function (options) {
19 | var authorID = options.author;
20 | var isYun = options.isYun ? true : false;
21 | this.loadAuthor(authorID, isYun);
22 | },
23 |
24 | loadAuthor: function (authorID,isYun) {
25 | var that = this;
26 | const db = wx.cloud.database();
27 | const _ = db.command
28 | console.info(authorID);
29 | var filter = isYun ? { _id: authorID } : { poetId: parseInt(authorID) }
30 | console.info(filter);
31 | db.collection('poet').where(filter).get({
32 | success: function (res) {
33 | // console.info(res);
34 | if (res.data&&res.data.length>0){
35 | that.setData({ author: res.data[0], loadingHidden: true });
36 | wx.setNavigationBarTitle({
37 | title: res.data[0].name//页面标题为路由参数
38 | })
39 | that.updateCollect(that);
40 | }else{
41 | that.setData({ loadingFail: true, loadingHidden: true });
42 | }
43 | },
44 | fail:function(info){
45 | that.setData({ loadingFail: true, loadingHidden:true});
46 | }
47 | });
48 | },
49 | doCollect: function () {
50 | var that = this;
51 | wx.cloud.callFunction({
52 | name: 'do_collect',
53 | data: {
54 | type: '00',
55 | name: that.data.author.name,
56 | id: that.data.author._id,
57 | content: that.data.author.desc,
58 | },
59 | complete: function (res) {
60 | console.info(res);
61 | that.setData({ collect: !that.data.collect });
62 | wx.showToast({
63 | title: that.data.collect ? '收藏成功~' : '取消收藏成功~',
64 | icon: 'success',
65 | duration: 1000,
66 | mask: true
67 | })
68 | },
69 | fail: function (res) {
70 | wx.showToast({
71 | title: '操作失败',
72 | icon: 'warn',
73 | duration: 1000,
74 | mask: true
75 | })
76 | }
77 | });
78 | },
79 |
80 | updateCollect: function (that) {
81 | wx.cloud.callFunction({
82 | name: 'is_collect',
83 | data: {
84 | id: that.data.author._id,
85 | type: '00'
86 | },
87 | complete: function (res) {
88 | console.info(res);
89 | if (res.errMsg.indexOf("ok") != -1) {
90 | that.setData({ collect: res.result.message });
91 | }
92 | },
93 | fail: function (res) {
94 | // console.info(res);
95 |
96 | }
97 | });
98 | },
99 | /**
100 | * 生命周期函数--监听页面初次渲染完成
101 | */
102 | onReady: function () {
103 |
104 | },
105 |
106 | /**
107 | * 生命周期函数--监听页面显示
108 | */
109 | onShow: function () {
110 |
111 | },
112 |
113 | /**
114 | * 生命周期函数--监听页面隐藏
115 | */
116 | onHide: function () {
117 |
118 | },
119 |
120 | /**
121 | * 生命周期函数--监听页面卸载
122 | */
123 | onUnload: function () {
124 |
125 | },
126 |
127 | /**
128 | * 页面相关事件处理函数--监听用户下拉动作
129 | */
130 | onPullDownRefresh: function () {
131 |
132 | },
133 |
134 | /**
135 | * 页面上拉触底事件的处理函数
136 | */
137 | onReachBottom: function () {
138 |
139 | },
140 |
141 | /**
142 | * 用户点击右上角分享
143 | */
144 | onShareAppMessage: function () {
145 |
146 | return {
147 | path: '/pages/recommend/recommend?author=' + this.data.author._id
148 | }
149 | }
150 | })
--------------------------------------------------------------------------------
/miniprogram/pages/author/author.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/miniprogram/pages/author/author.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{author.name}}\n
6 | {{author.desc}}
7 |
8 |
9 |
10 |
11 |
12 |
15 |
16 |
17 |
18 |
19 | 『作者诗文』
20 |
21 |
22 |
23 | {{author.content}}
24 |
25 |
26 |
27 |
28 | 加载中...
29 |
--------------------------------------------------------------------------------
/miniprogram/pages/author/author.wxss:
--------------------------------------------------------------------------------
1 | /* miniprogram/pages/author/author.wxss */
2 | .author_pic{
3 | height: 200px;
4 | margin-top: 10px
5 | }
6 | .author_name{
7 | font-size: 24px;
8 | font-weight: bold;
9 | }
10 | .author_introduce_container{
11 | margin: 10px;
12 | }
13 | .author_introduce{
14 | color: #C68739;
15 | margin: 5px;
16 | }
17 | .author_content{
18 | color: gray;
19 | margin: 5px;
20 | }
21 | .author_content_container{
22 | margin: 10px;
23 | }
24 | .author_poem{
25 | color: rgb(75, 134, 223);
26 | width: 100%;
27 | text-align: right;
28 | }
29 | .author_poem_container{
30 | width: 100%;
31 | padding: 5px;
32 | text-align: right;
33 | }
34 | .collect{
35 | width:30px;
36 | height: 30px;
37 | padding: 10px;
38 |
39 | }
40 |
41 | .collect_star{
42 | width: 50%;
43 | flex-direction:row;
44 | display: flex;
45 | justify-content:space-between;
46 | }
47 | .share{
48 | margin: 10px;
49 | padding: 0px;
50 | width: 30px;
51 | height: 30px;
52 | border: none;
53 | }
54 | .share[plain]{ border: none; }
55 | .share_pic{
56 | width:30px;
57 | height: 30px;
58 | margin-top: 0px;
59 | }
--------------------------------------------------------------------------------
/miniprogram/pages/author_poem/author_poem.js:
--------------------------------------------------------------------------------
1 | // miniprogram/pages/author_poem/author_poem.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 | loadingHidden: false,
9 | author: '',
10 | poems: [],
11 | hasMore: true,
12 | pageIndex: 1,
13 | pageSize: 10
14 | },
15 |
16 | /**
17 | * 生命周期函数--监听页面加载
18 | */
19 | onLoad: function (options) {
20 | this.setData({
21 | author: options.author,
22 | loadingHidden: false,
23 | })
24 | this.loadNextData(1);
25 | },
26 | onNextBtnClick: function () {
27 | this.loadNextData(this.data.pageIndex + 1);
28 | },
29 | onPreviousBtnClick: function () {
30 | this.loadNextData(this.data.pageIndex - 1);
31 | },
32 | loadNextData: function (index) {
33 | var that = this;
34 | var fields = {
35 | id: true,
36 | name: true,
37 | poet: true
38 | };
39 | wx.cloud.callFunction({
40 | name: 'get_author_poems',
41 | data: {
42 | pageIndex: index,
43 | pageSize: that.data.pageSize,
44 | author: [that.data.author],
45 | }
46 | }).then(res => {
47 | console.info(res);
48 | that.setData({
49 | loadingHidden: true,
50 | poems: res.result.data,
51 | hasMore: res.result.hasMore,
52 | pageIndex: index
53 | });
54 | }).catch(console.error);
55 | },
56 |
57 | /**
58 | * 生命周期函数--监听页面初次渲染完成
59 | */
60 | onReady: function () {
61 |
62 | },
63 |
64 | /**
65 | * 生命周期函数--监听页面显示
66 | */
67 | onShow: function () {
68 |
69 | },
70 |
71 | /**
72 | * 生命周期函数--监听页面隐藏
73 | */
74 | onHide: function () {
75 |
76 | },
77 |
78 | /**
79 | * 生命周期函数--监听页面卸载
80 | */
81 | onUnload: function () {
82 |
83 | },
84 |
85 | /**
86 | * 页面相关事件处理函数--监听用户下拉动作
87 | */
88 | onPullDownRefresh: function () {
89 |
90 | },
91 |
92 | /**
93 | * 页面上拉触底事件的处理函数
94 | */
95 | onReachBottom: function () {
96 |
97 | },
98 |
99 | /**
100 | * 用户点击右上角分享
101 | */
102 | onShareAppMessage: function () {
103 |
104 | }
105 | })
--------------------------------------------------------------------------------
/miniprogram/pages/author_poem/author_poem.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "诗人作品"
3 | }
--------------------------------------------------------------------------------
/miniprogram/pages/author_poem/author_poem.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{item.name}}
6 | {{item.content}}
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | 加载中...
17 |
--------------------------------------------------------------------------------
/miniprogram/pages/author_poem/author_poem.wxss:
--------------------------------------------------------------------------------
1 | /* miniprogram/pages/author_poem/author_poem.wxss */
2 | .poem_container{
3 | width: 100%;
4 | text-align: center;
5 | display: flex;
6 | flex-direction:column;
7 | justify-content: center;
8 | align-items: center;
9 | padding-top: 20px;
10 | padding-bottom: 20px;
11 | border-bottom:1px solid #e6c7a1;
12 | }
13 | .poem_name{
14 | color: #C68739;
15 | font-size: 16px;
16 | font-weight: bold
17 | }
18 | .poem_content{
19 | color: gray;
20 | font-size: 14px;
21 | overflow:hidden;/*只显示三行*/
22 | text-overflow:ellipsis;
23 | display:-webkit-box;
24 | -webkit-box-orient:vertical;
25 | -webkit-line-clamp:2;
26 | }
27 | navigator{
28 | width: 100%
29 | }
30 | .btn_container{
31 | flex-direction:row;
32 | display: flex;
33 | margin: 10px;
34 | }
35 | .btn_previous{
36 | margin-right: 60px
37 | }
--------------------------------------------------------------------------------
/miniprogram/pages/authors/authors.js:
--------------------------------------------------------------------------------
1 | // miniprogram/pages/authors/authors.js
2 |
3 | const regeneratorRuntime = require('../../lib/regenerator-runtime/runtime.js');
4 | Page({
5 | /**
6 | * 页面的初始数据
7 | */
8 | data: {
9 | winHeight: "",
10 | loadingHidden: false,
11 | searchLoading: false,
12 | poets: [],
13 | poetHasMore: true,
14 | poetPageIndex: 1,
15 | pageSize: 20
16 | },
17 |
18 | /**
19 | * 生命周期函数--监听页面加载
20 | */
21 | onLoad: function (options) {
22 | this.loadData(1);
23 | },
24 | async loadData(pageIndex) {
25 | const db = wx.cloud.database();
26 | const countResult = await db.collection('poet').count();
27 | const total = countResult.total;
28 | const totalPage = Math.ceil(total / this.data.pageSize);
29 | if (pageIndex > totalPage || pageIndex == totalPage) {
30 | this.setData({
31 | poetHasMore : false
32 | });
33 | } else {
34 | this.setData({
35 | poetHasMore: true
36 | });
37 | }
38 | console.info(totalPage);
39 | var that=this;
40 | db.collection('poet').field({name:true,_id:true,desc:true}).orderBy('star', 'desc')
41 | .skip((pageIndex - 1) * this.data.pageSize).limit(this.data.pageSize).get({
42 | success:function(res){
43 | console.info(res);
44 | if (res.data && res.data.length > 0) {
45 | var data = pageIndex > 1 ? that.data.poets.concat(res.data) : res.data;
46 | console.info(data);
47 | that.setData({
48 | poets: data,
49 | loadingHidden:true,
50 | searchLoading: false,
51 | poetPageIndex:pageIndex
52 | });
53 | }
54 | },
55 | fail:function(res){
56 | console.info(res);
57 | that.setData({
58 | loadingHidden: true,
59 | searchLoading: false
60 | });
61 | }
62 | });
63 | },
64 | loadMorePoet: function () {
65 | if (!this.data.poetHasMore || this.data.searchLoading) {
66 | return;
67 | }
68 | // console.info('loadMorePoet');
69 | this.setData({
70 | searchLoading: true
71 | });
72 | this.loadData(this.data.poetPageIndex + 1);
73 | },
74 | /**
75 | * 生命周期函数--监听页面初次渲染完成
76 | */
77 | onReady: function () {
78 |
79 | },
80 |
81 | /**
82 | * 生命周期函数--监听页面显示
83 | */
84 | onShow: function () {
85 |
86 | },
87 |
88 | /**
89 | * 生命周期函数--监听页面隐藏
90 | */
91 | onHide: function () {
92 |
93 | },
94 |
95 | /**
96 | * 生命周期函数--监听页面卸载
97 | */
98 | onUnload: function () {
99 |
100 | },
101 |
102 | /**
103 | * 页面相关事件处理函数--监听用户下拉动作
104 | */
105 | onPullDownRefresh: function () {
106 |
107 | },
108 |
109 | /**
110 | * 页面上拉触底事件的处理函数
111 | */
112 | onReachBottom: function () {
113 |
114 | },
115 |
116 | /**
117 | * 用户点击右上角分享
118 | */
119 | onShareAppMessage: function () {
120 |
121 | }
122 | })
--------------------------------------------------------------------------------
/miniprogram/pages/authors/authors.json:
--------------------------------------------------------------------------------
1 | {"navigationBarTitleText": "全部诗人"}
--------------------------------------------------------------------------------
/miniprogram/pages/authors/authors.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{item.name}}
5 | {{item.desc}}
6 |
7 |
8 | 正在载入更多...
9 | {{poets.length>0?'已加载全部':'暂无内容~'}}
10 |
11 |
12 | 加载中...
13 |
14 |
--------------------------------------------------------------------------------
/miniprogram/pages/authors/authors.wxss:
--------------------------------------------------------------------------------
1 | @import "/pages/collect/collect.wxss";
--------------------------------------------------------------------------------
/miniprogram/pages/collect/collect.js:
--------------------------------------------------------------------------------
1 | // miniprogram/pages/collect/collect.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 | winHeight:"",
9 | loadingHidden: false,
10 | searchLoading:false,
11 | currentTab:0,
12 | poems:[],
13 | poets: [],
14 | poetType:'00',
15 | poemType:'01',
16 | poemHasMore: true,
17 | poetHasMore: true,
18 | poemPageIndex: 1,
19 | poetPageIndex: 1,
20 | pageSize: 20
21 | },
22 |
23 | /**
24 | * 生命周期函数--监听页面加载
25 | */
26 | onLoad: function (options) {
27 | var that = this;
28 | // 高度自适应
29 | wx.getSystemInfo({
30 | success: function (res) {
31 | var clientHeight = res.windowHeight,
32 | clientWidth = res.windowWidth,
33 | rpxR = 750 / clientWidth;
34 | var calc = clientHeight * rpxR - 80;
35 | console.log(calc)
36 | that.setData({
37 | winHeight: calc
38 | });
39 | }
40 | });
41 | },
42 | loadData: function (loadType, index) {
43 | // console.info("loadData" + loadType);
44 | var that=this;
45 | wx.cloud.callFunction({
46 | name:'get_collect',
47 | data: {
48 | type: loadType,
49 | pageIndex:index,
50 | pageSize:that.data.pageSize
51 | },
52 | success: function (res) {
53 | console.info(res);
54 | if(res.errMsg.indexOf('ok')!=-1){
55 | if (loadType == that.data.poemType) {
56 | var data = index > 1 ? that.data.poems.concat(res.result.data) : res.result.data;
57 | that.setData({
58 | loadingHidden: true,
59 | searchLoading:false,
60 | poems: data,
61 | poemHasMore: res.result.hasMore,
62 | poemPageIndex: index
63 | });
64 | } else {
65 | var data = index > 1 ? that.data.poets.concat(res.result.data) : res.result.data;
66 | // console.info(loadType+"poets"+data);
67 | that.setData({
68 | loadingHidden: true,
69 | searchLoading: false,
70 | poets: data,
71 | poetHasMore: res.result.hasMore,
72 | poetPageIndex: index
73 | });
74 | }
75 | }
76 | },
77 | fail:function(res){
78 | that.setData({
79 | loadingHidden: true,
80 | searchLoading: false
81 | });
82 | console.info(res);
83 | }
84 | });
85 | },
86 | loadMorePoet:function(){
87 | if (!this.data.poetHasMore || this.data.searchLoading){
88 | return;
89 | }
90 | // console.info('loadMorePoet');
91 | this.setData({
92 | searchLoading:true
93 | });
94 | this.loadData(this.data.poetType,this.data.poetPageIndex+1);
95 | },
96 |
97 | loadMorePoem: function () {
98 | if (!this.data.poemHasMore || this.data.searchLoading) {
99 | return;
100 | }
101 | // console.info('loadMorePoem');
102 | this.setData({
103 | searchLoading: true
104 | });
105 | this.loadData(this.data.poemType, this.data.poemPageIndex + 1);
106 | },
107 | //滑动切换
108 | swiperTab: function (e) {
109 | var that = this;
110 | that.setData({
111 | currentTab: e.detail.current
112 | });
113 | },
114 | //点击切换
115 | clickTab: function (e) {
116 | var that = this;
117 | if (this.data.currentTab === e.target.dataset.current) {
118 | return false;
119 | } else {
120 | that.setData({
121 | currentTab: e.target.dataset.current
122 | })
123 | }
124 | },
125 | /**
126 | * 生命周期函数--监听页面初次渲染完成
127 | */
128 | onReady: function () {
129 |
130 | },
131 |
132 | /**
133 | * 生命周期函数--监听页面显示
134 | */
135 | onShow: function () {
136 | console.info('onShow')
137 | this.setData({
138 | loadingHidden: true,
139 | poemHasMore: true,
140 | poetHasMore: true,
141 | poemPageIndex: 1,
142 | poetPageIndex: 1,
143 | });
144 | this.loadData(this.data.poemType, this.data.poemPageIndex);
145 | this.loadData(this.data.poetType, this.data.poetPageIndex);
146 | },
147 |
148 | /**
149 | * 生命周期函数--监听页面隐藏
150 | */
151 | onHide: function () {
152 |
153 | },
154 |
155 | /**
156 | * 生命周期函数--监听页面卸载
157 | */
158 | onUnload: function () {
159 |
160 | },
161 |
162 | /**
163 | * 页面相关事件处理函数--监听用户下拉动作
164 | */
165 | onPullDownRefresh: function () {
166 |
167 | },
168 |
169 | /**
170 | * 页面上拉触底事件的处理函数
171 | */
172 | onReachBottom: function () {
173 |
174 | },
175 |
176 | /**
177 | * 用户点击右上角分享
178 | */
179 | onShareAppMessage: function () {
180 |
181 | }
182 | })
--------------------------------------------------------------------------------
/miniprogram/pages/collect/collect.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/miniprogram/pages/collect/collect.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 诗词
5 |
6 |
7 | 诗人
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | {{item.name}}
16 | {{item.content}}
17 |
18 |
19 | 正在载入更多...
20 | {{poems.length>0?'已加载全部':'暂无内容,快去收藏吧~'}}
21 |
22 |
23 |
24 |
25 |
26 |
27 | {{item.name}}
28 | {{item.content}}
29 |
30 |
31 | 正在载入更多...
32 | {{poets.length>0?'已加载全部':'快去收藏吧~'}}
33 |
34 |
35 |
36 |
37 | 加载中...
38 |
--------------------------------------------------------------------------------
/miniprogram/pages/collect/collect.wxss:
--------------------------------------------------------------------------------
1 | /* miniprogram/pages/collect/collect.wxss */
2 | .swiper-tab{
3 | width: 100%;
4 | border-bottom: 2rpx solid #ccc;
5 | text-align: center;
6 | height: 88rpx;
7 | line-height: 88rpx;
8 | display: flex;
9 | flex-flow: row;
10 | justify-content: space-between;
11 | }
12 | .swiper-tab-item{
13 | width: 50%;
14 | color:#434343;
15 | }
16 | .active{
17 | color:#C68739;
18 | border-bottom: 4rpx solid #C68739;
19 | }
20 | swiper{
21 | text-align: center;
22 | }
23 | .poem_container{
24 | width: 100%;
25 | text-align: center;
26 | display: flex;
27 | flex-direction:column;
28 | justify-content: center;
29 | align-items: center;
30 | padding-top: 20px;
31 | padding-bottom: 20px;
32 | border-bottom:1px solid #e6c7a1;
33 | }
34 | .poem_name{
35 | color: #C68739;
36 | font-size: 16px;
37 | font-weight: bold
38 | }
39 | .poem_content{
40 | color: gray;
41 | font-size: 14px;
42 | overflow:hidden;/*只显示三行*/
43 | text-overflow:ellipsis;
44 | display:-webkit-box;
45 | -webkit-box-orient:vertical;
46 | -webkit-line-clamp:2;
47 | }
48 | navigator{
49 | width: 100%
50 | }
51 | scroll-view{
52 | position: absolute;
53 | bottom: 0;
54 | left: 0;
55 | right: 0;
56 | top: 0;
57 | }
58 | .loading{
59 | color: gray;
60 | font-size: 14px;
61 | }
--------------------------------------------------------------------------------
/miniprogram/pages/poem/poem.js:
--------------------------------------------------------------------------------
1 | // miniprogram/pages/poem/poem.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 | loadingHidden: false,
9 | getNextHidden: true,
10 | star: false,
11 | collect: false,
12 | poem: {
13 | name: "",
14 | dynasty: "",
15 | content: "",
16 | poet: {
17 | name: ""
18 | }
19 | }
20 | },
21 |
22 | /**
23 | * 生命周期函数--监听页面加载
24 | */
25 | onLoad: function (options) {
26 | var poemID = options.poem;
27 | console.info(poemID);
28 | this.loadPoem(poemID);
29 | },
30 |
31 | loadPoem: function (id) {
32 | var that=this;
33 | var db = wx.cloud.database();
34 | db.collection('poetry').doc(id).get({
35 | success: function (res) {
36 | console.info(res);
37 | wx.setNavigationBarTitle({
38 | title: res.data.name//页面标题为路由参数
39 | })
40 | that.setData({ poem: res.data, loadingHidden: true })
41 | that.updateCollect(that)
42 | },
43 | fail:console.error
44 | });
45 | },
46 | doCollect: function () {
47 | var that = this;
48 | wx.cloud.callFunction({
49 | name: 'do_collect',
50 | data: {
51 | type: '01',
52 | name: that.data.poem.name,
53 | id: that.data.poem._id,
54 | content: that.data.poem.content,
55 | },
56 | complete: function (res) {
57 | console.info(res);
58 | that.setData({ collect: !that.data.collect });
59 | wx.showToast({
60 | title: that.data.collect ? '收藏成功~' : '取消收藏成功~',
61 | icon: 'success',
62 | duration: 1000,
63 | mask: true
64 | })
65 | },
66 | fail: function (res) {
67 | wx.showToast({
68 | title: '操作失败',
69 | icon: 'warn',
70 | duration: 1000,
71 | mask: true
72 | })
73 | }
74 | });
75 | },
76 | doStar: function () {
77 | // var recommend=require("/miniprogram/pages/recommend/recommend.js");
78 | // recommend.doStar();
79 | if (this.data.star) {
80 | return;
81 | }
82 | this.setData({ star: true, 'poem.star': this.data.poem.star + 1 });
83 | var that = this;
84 | wx.cloud.callFunction({
85 | name: 'do_star',
86 | data: {
87 | name: that.data.poem.name,
88 | id: that.data.poem._id,
89 | },
90 | complete: function (res) {
91 | // console.info(res);
92 | // that.setData({ star: true, 'poem.star': that.data.poem.star + 1 });
93 | },
94 | fail: function (res) {
95 | // console.info(res);
96 |
97 | }
98 | });
99 | },
100 | /**
101 | * 生命周期函数--监听页面初次渲染完成
102 | */
103 | onReady: function () {
104 |
105 | },
106 |
107 | /**
108 | * 生命周期函数--监听页面显示
109 | */
110 | onShow: function () {
111 |
112 | },
113 |
114 | updateCollect: function (that) {
115 | wx.cloud.callFunction({
116 | name: 'is_collect',
117 | data: {
118 | id: that.data.poem._id,
119 | type:'01'
120 | },
121 | complete: function (res) {
122 | console.info(res);
123 | if (res.errMsg.indexOf("ok") != -1) {
124 | that.setData({ collect: res.result.message });
125 | }
126 | },
127 | fail: function (res) {
128 | // console.info(res);
129 |
130 | }
131 | });
132 | },
133 |
134 | /**
135 | * 生命周期函数--监听页面隐藏
136 | */
137 | onHide: function () {
138 |
139 | },
140 |
141 | /**
142 | * 生命周期函数--监听页面卸载
143 | */
144 | onUnload: function () {
145 |
146 | },
147 |
148 | /**
149 | * 页面相关事件处理函数--监听用户下拉动作
150 | */
151 | onPullDownRefresh: function () {
152 |
153 | },
154 |
155 | /**
156 | * 页面上拉触底事件的处理函数
157 | */
158 | onReachBottom: function () {
159 |
160 | },
161 |
162 | /**
163 | * 用户点击右上角分享
164 | */
165 | onShareAppMessage: function () {
166 | return {
167 | path: '/pages/recommend/recommend?poem=' + this.data.poem._id
168 | }
169 | }
170 | })
--------------------------------------------------------------------------------
/miniprogram/pages/poem/poem.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/miniprogram/pages/poem/poem.wxml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/miniprogram/pages/poem/poem.wxss:
--------------------------------------------------------------------------------
1 | @import "/pages/recommend/recommend.wxss";
--------------------------------------------------------------------------------
/miniprogram/pages/recommend/recommend.js:
--------------------------------------------------------------------------------
1 | // miniprogram/pages/recommend.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 | loadingHidden: false,
9 | getNextHidden:false,
10 | star:false,
11 | collect:false,
12 | poem: {
13 | name:"",
14 | dynasty:"",
15 | content:"",
16 | poet:{
17 | name:""
18 | },
19 | star:0
20 | }
21 | },
22 |
23 | /**
24 | * 生命周期函数--监听页面加载
25 | */
26 | onLoad: function (options) {
27 | var poem=options.poem;
28 | var author = options.author;
29 | if(poem){
30 | wx.navigateTo({
31 | url: '/pages/poem/poem?poem=' + poem
32 | });
33 | } else if (author) {
34 | wx.navigateTo({
35 | url: '/pages/author/author?author=' + author +'&isYun=true'
36 | });
37 |
38 | }
39 | this.loadData();
40 | },
41 | loadData:function(){
42 | this.setData({
43 | loadingHidden: false,
44 | star: false,
45 | collect: false
46 | });
47 | var that = this;
48 | wx.cloud.callFunction({
49 | name: "recommend",
50 | complete: function (res) {
51 | console.info(res)
52 | if(res.result==null){
53 | that.setData({
54 | poem: {
55 | name: '推荐诗词加载失败,换一首吧~',
56 | dynasty: "",
57 | content: "",
58 | poet: {
59 | name: ""
60 | },
61 | star: 0
62 | } , loadingHidden: true,star:false})
63 | }else{
64 | that.setData({ poem: res.result.data[0], loadingHidden: true, star: false})
65 | that.updateCollect(that);
66 | }
67 | },
68 | fail: function(res){
69 | this.loadData()
70 | }
71 | })
72 | },
73 | doCollect:function(){
74 | var that=this;
75 | wx.cloud.callFunction({
76 | name:'do_collect',
77 | data:{
78 | type:'01',
79 | name: that.data.poem.name,
80 | id: that.data.poem._id,
81 | content: that.data.poem.content,
82 | },
83 | complete:function(res){
84 | console.info(res);
85 | that.setData({ collect: !that.data.collect});
86 | wx.showToast({
87 | title: that.data.collect?'收藏成功~':'取消收藏成功~',
88 | icon: 'success',
89 | duration: 1000,
90 | mask: true
91 | })
92 | },
93 | fail:function(res){
94 | wx.showToast({
95 | title: '操作失败',
96 | icon: 'warn',
97 | duration: 1000,
98 | mask: true
99 | })
100 | }
101 | });
102 | },
103 | doStar:function(){
104 | if(this.data.star){
105 | return;
106 | }
107 | this.setData({ star: true, 'poem.star': this.data.poem.star + 1 });
108 | var that = this;
109 | wx.cloud.callFunction({
110 | name: 'do_star',
111 | data: {
112 | name: that.data.poem.name,
113 | id: that.data.poem._id,
114 | },
115 | complete: function (res) {
116 | // console.info(that.data.poem.star + 1);
117 | // that.setData({ star: true,'poem.star':that.data.poem.star+1});
118 | },
119 | fail: function (res) {
120 | // console.info(res);
121 |
122 | }
123 | });
124 | },
125 | updateCollect:function(that){
126 | wx.cloud.callFunction({
127 | name: 'is_collect',
128 | data: {
129 | id: that.data.poem._id,
130 | type: '01'
131 | },
132 | complete: function (res) {
133 | console.info(res);
134 | if (res.errMsg.indexOf("ok") != -1) {
135 | that.setData({ collect: res.result.message });
136 | }
137 | },
138 | fail: function (res) {
139 | // console.info(res);
140 |
141 | }
142 | });
143 | },
144 |
145 | /**
146 | * 生命周期函数--监听页面初次渲染完成
147 | */
148 | onReady: function () {
149 |
150 | },
151 |
152 | /**
153 | * 生命周期函数--监听页面显示
154 | */
155 | onShow: function () {
156 | // this.updateCollect();
157 | if(this.data.poem.name){
158 | this.updateCollect(this)
159 | }
160 | },
161 | /**
162 | * 生命周期函数--监听页面隐藏
163 | */
164 | onHide: function () {
165 |
166 | },
167 |
168 | /**
169 | * 生命周期函数--监听页面卸载
170 | */
171 | onUnload: function () {
172 |
173 | },
174 |
175 | /**
176 | * 页面相关事件处理函数--监听用户下拉动作
177 | */
178 | onPullDownRefresh: function () {
179 |
180 | },
181 |
182 | /**
183 | * 页面上拉触底事件的处理函数
184 | */
185 | onReachBottom: function () {
186 |
187 | },
188 |
189 | /**
190 | * 用户点击右上角分享
191 | */
192 | onShareAppMessage: function () {
193 | return {
194 | path: '/pages/recommend/recommend?poem=' + this.data.poem._id
195 | }
196 | }
197 | })
--------------------------------------------------------------------------------
/miniprogram/pages/recommend/recommend.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/miniprogram/pages/recommend/recommend.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{poem.name+'\n'}}
5 | {{poem.dynasty+'|'+poem.poet.name+'\n'}}
6 | {{poem.content+'\n'}}
7 |
8 |
9 |
10 |
11 |
12 | {{poem.star}}
13 |
14 |
17 |
18 |
19 |
20 |
21 | {{poem.poet.name}}
22 | {{poem.poet.desc}}
23 |
24 |
25 | {{poem.fanyi}}
26 | {{poem.shangxi}}
27 | {{poem.about}}
28 |
29 |
30 | 加载中...
31 |
--------------------------------------------------------------------------------
/miniprogram/pages/recommend/recommend.wxss:
--------------------------------------------------------------------------------
1 | /* miniprogram/pages/recommend.wxss */
2 | .poem{
3 | width: 80%;
4 | margin-top: 20px;
5 | height: 100%;
6 | text-align:center;
7 | }
8 | text{
9 | display:inline/inline-block;
10 | text-align: left;
11 | line-height:40px
12 | }
13 | .dynasty{
14 | font-size: 14px;
15 | color: gray;
16 | }
17 | .refresh{
18 | font-size: 16px;
19 | width: 30%;
20 | margin: 20px;
21 | text-align: center;
22 | color: #e6c7a1
23 | }
24 | .author_nav{
25 |
26 | width: 90%;
27 | }
28 | .author{
29 | width: 100%;
30 | margin-top: 20px;
31 | border:1px solid #e6c7a1;
32 | text-align:left;
33 | margin-bottom: 20px
34 | }
35 | .author_name{
36 | padding: 5px;
37 | font-size: 16px;
38 | color: gray;
39 | line-height:20px
40 | }
41 | .author_desc{
42 | padding: 5px;
43 | font-size: 14px;
44 | color: gray;
45 | overflow:hidden;/*只显示三行*/
46 | text-overflow:ellipsis;
47 | display:-webkit-box;
48 | -webkit-box-orient:vertical;
49 | -webkit-line-clamp:3;
50 | line-height:20px
51 |
52 | }
53 | .fanyi{
54 | width: 90%;
55 | font-size: 16px;
56 | color: #C68739;
57 | line-height:20px
58 | }
59 | .shangxi{
60 | width: 90%;
61 | font-size: 16px;
62 | color: #DEB787;
63 | line-height:20px
64 | }
65 | .about{
66 | font-size: 16px;
67 | color: gray;
68 | width: 90%;
69 | line-height:20px
70 | }
71 | .collect_star{
72 | width: 50%;
73 | flex-direction:row;
74 | display: flex;
75 | justify-content:space-between;
76 | }
77 | .collect{
78 | width:30px;
79 | height: 30px;
80 | padding: 10px;
81 | }
82 | .star{
83 | flex-direction:row;
84 | display: flex;
85 | padding: 10px;
86 | justify-content:center;
87 | }
88 | .star_icon{
89 | width: 30px;
90 | height: 30px;
91 | }
92 | .stat_num{
93 | color: #dbdbdb;
94 | font-size: 14px;
95 | }
96 | .share{
97 | margin: 10px;
98 | padding: 0px;
99 | width: 30px;
100 | height: 30px;
101 | border: none;
102 | }
103 | .share[plain]{ border: none; }
--------------------------------------------------------------------------------
/miniprogram/pages/search/search.js:
--------------------------------------------------------------------------------
1 | // miniprogram/pages/search/search.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 | loadingHidden: false,
9 | loadingFail: false,
10 | searchs:[]
11 | },
12 |
13 | /**
14 | * 生命周期函数--监听页面加载
15 | */
16 | onLoad: function (options) {
17 | var that=this;
18 | var values=options.value;
19 | wx.cloud.callFunction({
20 | name:'do_search',
21 | data:{
22 | value: values
23 | },
24 | complete:function(res){
25 | if (res.result && res.result.length > 0) {
26 | console.info(res.result);
27 | that.setData({ searchs: res.result, loadingHidden: true })
28 | } else {
29 | that.setData({ loadingFail: true, loadingHidden: true });
30 | }
31 | },
32 | fail:function(res){
33 | that.setData({ loadingFail: true, loadingHidden: true });
34 | }
35 | });
36 | },
37 | itemClick:function(event){
38 | console.info(event.currentTarget.id);
39 | var data = this.data.searchs[parseInt(event.currentTarget.id)];
40 | console.info(data);
41 | var ntUrl="";
42 | if (data.type == "01") {
43 | ntUrl = '/pages/poem/poem?poem=' + data.id;
44 | }else{
45 | ntUrl = '/pages/author/author?author=' + data.id;
46 | }
47 | console.info(ntUrl);
48 | wx.navigateTo({
49 | url: ntUrl,
50 | success: function(res) {},
51 | fail: function(res) {},
52 | complete: function(res) {},
53 | })
54 | },
55 | /**
56 | * 生命周期函数--监听页面初次渲染完成
57 | */
58 | onReady: function () {
59 |
60 | },
61 |
62 | /**
63 | * 生命周期函数--监听页面显示
64 | */
65 | onShow: function () {
66 |
67 | },
68 |
69 | /**
70 | * 生命周期函数--监听页面隐藏
71 | */
72 | onHide: function () {
73 |
74 | },
75 |
76 | /**
77 | * 生命周期函数--监听页面卸载
78 | */
79 | onUnload: function () {
80 |
81 | },
82 |
83 | /**
84 | * 页面相关事件处理函数--监听用户下拉动作
85 | */
86 | onPullDownRefresh: function () {
87 |
88 | },
89 |
90 | /**
91 | * 页面上拉触底事件的处理函数
92 | */
93 | onReachBottom: function () {
94 |
95 | },
96 |
97 | /**
98 | * 用户点击右上角分享
99 | */
100 | onShareAppMessage: function () {
101 |
102 | }
103 | })
--------------------------------------------------------------------------------
/miniprogram/pages/search/search.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "诗文搜索"
3 | }
--------------------------------------------------------------------------------
/miniprogram/pages/search/search.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{item.name}}
5 | {{item.content}}
6 |
7 |
8 |
9 |
10 | 加载中...
11 |
--------------------------------------------------------------------------------
/miniprogram/pages/search/search.wxss:
--------------------------------------------------------------------------------
1 | /* miniprogram/pages/search/search.wxss */
2 | .container{
3 | width: 100%;
4 | text-align: center;
5 | display: flex;
6 | flex-direction:column;
7 | justify-content: center;
8 | align-items: center;
9 | padding-top: 20px;
10 | padding-bottom: 20px;
11 | border-bottom:1px solid #e6c7a1;
12 | }
13 | .poem_name{
14 | color: #C68739;
15 | font-size: 16px;
16 | font-weight: bold
17 | }
18 | .poem_content{
19 | color: gray;
20 | font-size: 14px;
21 | overflow:hidden;/*只显示三行*/
22 | text-overflow:ellipsis;
23 | display:-webkit-box;
24 | -webkit-box-orient:vertical;
25 | -webkit-line-clamp:3;
26 | }
27 | navigator{
28 | width: 100%
29 | }
30 | .tips{
31 | margin: 20px;
32 | width: 100%;
33 | color: gray;
34 | font-size: 12px;
35 | text-align: right
36 | }
--------------------------------------------------------------------------------
/miniprogram/pages/tag_poem/tag_poem.js:
--------------------------------------------------------------------------------
1 | // miniprogram/pages/tag_poem/tag_poem.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 | loadingHidden:false,
9 | tag:'',
10 | poems: [],
11 | hasMore: true,
12 | pageIndex: 1,
13 | pageSize: 10
14 | },
15 |
16 | /**
17 | * 生命周期函数--监听页面加载
18 | */
19 | onLoad: function (options) {
20 | this.setData({
21 | tag: options.tag,
22 | loadingHidden:false,
23 | })
24 |
25 | wx.setNavigationBarTitle({
26 | title: this.data.tag//页面标题为路由参数
27 | })
28 | this.loadNextData(1);
29 | },
30 | onNextBtnClick:function(){
31 | this.loadNextData(this.data.pageIndex+1);
32 | },
33 | onPreviousBtnClick: function () {
34 | this.loadNextData(this.data.pageIndex - 1);
35 | },
36 | loadNextData:function(index){
37 | var that=this;
38 | var fields = {
39 | id: true,
40 | name: true,
41 | poet: true,
42 | content:true
43 | };
44 | wx.cloud.callFunction({
45 | name: 'get_tag_poems',
46 | data: {
47 | dbName: 'poetry',
48 | pageIndex: index,
49 | pageSize: that.data.pageSize,
50 | tag: [that.data.tag],
51 | field: fields
52 | }
53 | }).then(res => {
54 | console.info(res);
55 | that.setData({
56 | loadingHidden: true,
57 | poems: res.result.data,
58 | hasMore: res.result.hasMore,
59 | pageIndex: index
60 | });
61 | }).catch(console.error);
62 | },
63 | /**
64 | * 生命周期函数--监听页面初次渲染完成
65 | */
66 | onReady: function () {
67 |
68 | },
69 |
70 | /**
71 | * 生命周期函数--监听页面显示
72 | */
73 | onShow: function () {
74 |
75 | },
76 |
77 | /**
78 | * 生命周期函数--监听页面隐藏
79 | */
80 | onHide: function () {
81 |
82 | },
83 |
84 | /**
85 | * 生命周期函数--监听页面卸载
86 | */
87 | onUnload: function () {
88 |
89 | },
90 |
91 | /**
92 | * 页面相关事件处理函数--监听用户下拉动作
93 | */
94 | onPullDownRefresh: function () {
95 |
96 | },
97 |
98 | /**
99 | * 页面上拉触底事件的处理函数
100 | */
101 | onReachBottom: function () {
102 |
103 | },
104 |
105 | /**
106 | * 用户点击右上角分享
107 | */
108 | onShareAppMessage: function () {
109 |
110 | }
111 | })
--------------------------------------------------------------------------------
/miniprogram/pages/tag_poem/tag_poem.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/miniprogram/pages/tag_poem/tag_poem.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 《{{item.name}}》{{item.poet.name}}
6 | {{item.content}}
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | 加载中...
17 |
--------------------------------------------------------------------------------
/miniprogram/pages/tag_poem/tag_poem.wxss:
--------------------------------------------------------------------------------
1 | /* miniprogram/pages/tag_poem/tag_poem.wxss */
2 | @import "/pages/collect/collect.wxss";
3 | .btn_container{
4 | flex-direction:row;
5 | display: flex;
6 | margin: 10px;
7 | }
8 | .btn_previous{
9 | margin-right: 60px
10 | }
--------------------------------------------------------------------------------
/miniprogram/pages/tags/all_poem/all_poem.js:
--------------------------------------------------------------------------------
1 |
2 | const regeneratorRuntime = require('../../../lib/regenerator-runtime/runtime.js');
3 | Page({
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 | winHeight: "",
9 | loadingHidden: false,
10 | searchLoading: false,
11 | poems: [],
12 | poemHasMore: true,
13 | poemPageIndex: 1,
14 | pageSize: 20
15 | },
16 |
17 | /**
18 | * 生命周期函数--监听页面加载
19 | */
20 | onLoad: function (options) {
21 | this.loadData(1);
22 | },
23 | async loadData(pageIndex) {
24 | const db = wx.cloud.database();
25 | const countResult = await db.collection('poetry').count();
26 | const total = countResult.total;
27 | const totalPage = Math.ceil(total / this.data.pageSize);
28 | if (pageIndex > totalPage || pageIndex == totalPage) {
29 | this.setData({
30 | poemHasMore: false
31 | });
32 | } else {
33 | this.setData({
34 | poemHasMore: true
35 | });
36 | }
37 | console.info(totalPage);
38 | var that = this;
39 | db.collection('poetry').field({ name: true, _id: true, content: true,poet:true }).orderBy('star', 'desc')
40 | .skip((pageIndex - 1) * this.data.pageSize).limit(this.data.pageSize).get({
41 | success: function (res) {
42 | console.info(res);
43 | if (res.data && res.data.length > 0) {
44 | var data = pageIndex > 1 ? that.data.poems.concat(res.data) : res.data;
45 | console.info(data);
46 | that.setData({
47 | poems: data,
48 | loadingHidden: true,
49 | searchLoading: false,
50 | poemPageIndex: pageIndex
51 | });
52 | }
53 | },
54 | fail: function (res) {
55 | console.info(res);
56 | that.setData({
57 | loadingHidden: true,
58 | searchLoading: false
59 | });
60 | }
61 | });
62 | },
63 | loadMorePoem: function () {
64 | if (!this.data.poemHasMore || this.data.searchLoading) {
65 | return;
66 | }
67 | // console.info('loadMorepoem');
68 | this.setData({
69 | searchLoading: true
70 | });
71 | this.loadData(this.data.poemPageIndex + 1);
72 | },
73 | /**
74 | * 生命周期函数--监听页面初次渲染完成
75 | */
76 | onReady: function () {
77 |
78 | },
79 |
80 | /**
81 | * 生命周期函数--监听页面显示
82 | */
83 | onShow: function () {
84 |
85 | },
86 |
87 | /**
88 | * 生命周期函数--监听页面隐藏
89 | */
90 | onHide: function () {
91 |
92 | },
93 |
94 | /**
95 | * 生命周期函数--监听页面卸载
96 | */
97 | onUnload: function () {
98 |
99 | },
100 |
101 | /**
102 | * 页面相关事件处理函数--监听用户下拉动作
103 | */
104 | onPullDownRefresh: function () {
105 |
106 | },
107 |
108 | /**
109 | * 页面上拉触底事件的处理函数
110 | */
111 | onReachBottom: function () {
112 |
113 | },
114 |
115 | /**
116 | * 用户点击右上角分享
117 | */
118 | onShareAppMessage: function () {
119 |
120 | }
121 | })
--------------------------------------------------------------------------------
/miniprogram/pages/tags/all_poem/all_poem.json:
--------------------------------------------------------------------------------
1 | {"navigationBarTitleText": "全部诗词"}
--------------------------------------------------------------------------------
/miniprogram/pages/tags/all_poem/all_poem.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 《{{item.name}}》{{item.poet.name}}
6 | {{item.content}}
7 |
8 |
9 | 正在载入更多...
10 | {{poems.length>0?'已加载全部':'暂无内容~'}}
11 |
12 |
13 | 加载中...
14 |
15 |
--------------------------------------------------------------------------------
/miniprogram/pages/tags/all_poem/all_poem.wxss:
--------------------------------------------------------------------------------
1 | /* miniprogram/pages/tags/all_poem/all_poem.wxss */
2 | @import "/pages/authors/authors.wxss"
--------------------------------------------------------------------------------
/miniprogram/pages/tags/tags.js:
--------------------------------------------------------------------------------
1 | // miniprogram/pages/sort/sort.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 | loadingHidden: false,
9 | tags:[],
10 | search:""
11 | },
12 |
13 | /**
14 | * 生命周期函数--监听页面加载
15 | */
16 | onLoad: function (options) {
17 | var that = this;
18 | wx.cloud.callFunction({
19 | name: "get_tag",
20 | complete: function (res) {
21 | console.info(res)
22 | that.setData({ tags: res.result.data, loadingHidden: true})
23 | },
24 | fail: function (res) {
25 | console.info(res)
26 | that.setData({loadingHidden: true});
27 | }
28 | })
29 | },
30 | onCancelBtnClcik: function(){
31 | this.setData({
32 | search:""
33 | });
34 | },
35 | onSearchConfirm:function(value){
36 | // console.info(typeof(value))
37 | this.setData({
38 | search:value.detail.value
39 | });
40 | if (value.detail.value !== null && value.detail.value !== ''){
41 | wx.navigateTo({
42 | url: '/pages/search/search?value=' + this.data.search,
43 | success: function (res) { },
44 | fail: function (res) { },
45 | complete: function (res) { },
46 | });
47 | }
48 | },
49 | /**
50 | * 生命周期函数--监听页面初次渲染完成
51 | */
52 | onReady: function () {
53 |
54 | },
55 |
56 | /**
57 | * 生命周期函数--监听页面显示
58 | */
59 | onShow: function () {
60 |
61 | },
62 |
63 | /**
64 | * 生命周期函数--监听页面隐藏
65 | */
66 | onHide: function () {
67 |
68 | },
69 |
70 | /**
71 | * 生命周期函数--监听页面卸载
72 | */
73 | onUnload: function () {
74 |
75 | },
76 |
77 | /**
78 | * 页面相关事件处理函数--监听用户下拉动作
79 | */
80 | onPullDownRefresh: function () {
81 |
82 | },
83 |
84 | /**
85 | * 页面上拉触底事件的处理函数
86 | */
87 | onReachBottom: function () {
88 |
89 | },
90 |
91 | /**
92 | * 用户点击右上角分享
93 | */
94 | onShareAppMessage: function () {
95 |
96 | }
97 | })
--------------------------------------------------------------------------------
/miniprogram/pages/tags/tags.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/miniprogram/pages/tags/tags.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 取消
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | 加载中...
15 |
--------------------------------------------------------------------------------
/miniprogram/pages/tags/tags.wxss:
--------------------------------------------------------------------------------
1 | /* miniprogram/pages/sort/sort.wxss */
2 | .search_container{
3 | flex-direction:row;
4 | display: flex;
5 | margin-top: 20px;
6 | margin: 10px;
7 | }
8 | input{
9 | width: 80%;
10 | font-size: 14px
11 | }
12 | .search_cancel{
13 | color: #C68739
14 | }
15 | .tag_container{
16 | flex-direction:row;
17 | display: flex;
18 | flex-wrap:wrap;
19 | justify-content: center;
20 | margin-top: 20px;
21 | }
22 | .tag_item{
23 | margin: 10px;
24 | }
--------------------------------------------------------------------------------
/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "miniprogramRoot": "miniprogram/",
3 | "cloudfunctionRoot": "cloudfunctions/",
4 | "setting": {
5 | "urlCheck": true,
6 | "es6": true,
7 | "postcss": true,
8 | "minified": true,
9 | "newFeature": true,
10 | "nodeModules": true
11 | },
12 | "appid": "wx896d0093c2a9d848",
13 | "projectname": "sanhaopoem",
14 | "libVersion": "2.4.0",
15 | "condition": {
16 | "search": {
17 | "current": -1,
18 | "list": []
19 | },
20 | "conversation": {
21 | "current": -1,
22 | "list": []
23 | },
24 | "plugin": {
25 | "current": -1,
26 | "list": []
27 | },
28 | "game": {
29 | "list": []
30 | },
31 | "miniprogram": {
32 | "current": 0,
33 | "list": [
34 | {
35 | "id": -1,
36 | "name": "db guide",
37 | "pathName": "pages/databaseGuide/databaseGuide"
38 | }
39 | ]
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/qrcode.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s853562285/SanHaoPoem/b7690ab8e454d84e3dad3c8b21400016e36a2ad8/qrcode.jpg
--------------------------------------------------------------------------------
/数据库.rar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s853562285/SanHaoPoem/b7690ab8e454d84e3dad3c8b21400016e36a2ad8/数据库.rar
--------------------------------------------------------------------------------