Skip to content

Commit db32bb3

Browse files
committed
feat: complete learn module
1 parent 5a9a858 commit db32bb3

File tree

16 files changed

+1312
-151
lines changed

16 files changed

+1312
-151
lines changed

miniprogram/app.less

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,23 @@ page {
7171
content: '\E07C';
7272
}
7373
}
74+
75+
&--page {
76+
font-family: 't';
77+
text-decoration: underline;
78+
79+
&:before {
80+
content: '\E058';
81+
}
82+
}
83+
84+
&--quote {
85+
display: block;
86+
padding: 12rpx;
87+
font-size: 28rpx;
88+
color: #0052d9;
89+
background-color: #e6eefb;
90+
opacity: .7;
91+
border-radius: 8rpx;
92+
}
7493
}

miniprogram/data.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2695,7 +2695,7 @@ export default [
26952695
"冰块",
26962696
[
26972697
{
2698-
"type": "link",
2698+
"type": "page",
26992699
"text": "蔗糖糖浆",
27002700
"href": "../../condiment/蔗糖糖浆/蔗糖糖浆.md"
27012701
},
@@ -3069,7 +3069,7 @@ export default [
30693069
"苏打气泡水",
30703070
"柠檬",
30713071
{
3072-
"type": "link",
3072+
"type": "page",
30733073
"text": "蔗糖糖浆",
30743074
"href": "../../condiment/蔗糖糖浆/蔗糖糖浆.md"
30753075
},
@@ -4398,7 +4398,7 @@ export default [
43984398
[
43994399
"然后进行腌肉,加入生抽,淀粉,油,均匀搅拌,静止 30 分钟。腌肉方法也可参考",
44004400
{
4401-
"type": "link",
4401+
"type": "page",
44024402
"text": "学习腌",
44034403
"href": "../../tips/learn/学习腌.md"
44044404
}
@@ -6581,7 +6581,7 @@ export default [
65816581
[
65826582
"建议在此之前查看炒",
65836583
{
6584-
"type": "link",
6584+
"type": "page",
65856585
"text": "糖色",
65866586
"href": "./../../condiment/糖色.md"
65876587
},
@@ -6654,7 +6654,7 @@ export default [
66546654
[
66556655
"炒",
66566656
{
6657-
"type": "link",
6657+
"type": "page",
66586658
"text": "糖色",
66596659
"href": "./../../condiment/糖色.md"
66606660
},
@@ -7203,7 +7203,7 @@ export default [
72037203
[
72047204
"油热,将锅关至小火,如果你不明白为何要这样做,请查看",
72057205
{
7206-
"type": "link",
7206+
"type": "page",
72077207
"text": "学习炒与煎",
72087208
"href": "../../tips/learn/学习炒与煎.md"
72097209
},
@@ -8298,7 +8298,7 @@ export default [
82988298
[
82998299
"用砂锅/铝锅炖肉时,水开后转中小火/小火,使用高压锅见",
83008300
{
8301-
"type": "link",
8301+
"type": "page",
83028302
"text": "学习使用压力锅",
83038303
"href": "./../../../tips/learn/高压力锅.md"
83048304
}
@@ -8777,15 +8777,15 @@ export default [
87778777
[
87788778
"煎",
87798779
{
8780-
"type": "link",
8780+
"type": "page",
87818781
"text": "溏心蛋",
87828782
"href": "../../breakfast/溏心蛋.md"
87838783
}
87848784
],
87858785
[
87868786
"将",
87878787
{
8788-
"type": "link",
8788+
"type": "page",
87898789
"text": "米饭",
87908790
"href": "../../staple/米饭/米饭.md"
87918791
},
@@ -9272,7 +9272,7 @@ export default [
92729272
[
92739273
"胡萝卜洗净,切成丝,将胡萝卜丝",
92749274
{
9275-
"type": "link",
9275+
"type": "page",
92769276
"text": "焯水",
92779277
"href": "../../tips/learn/学习焯水.md"
92789278
},
@@ -10480,7 +10480,7 @@ export default [
1048010480
[
1048110481
"出锅后也可以加入水煮荷包蛋(",
1048210482
{
10483-
"type": "link",
10483+
"type": "page",
1048410484
"text": "太阳蛋",
1048510485
"href": "../../dishes/breakfast/太阳蛋.md"
1048610486
},
@@ -10496,7 +10496,7 @@ export default [
1049610496
[
1049710497
"馄饨是一种起源于中国的一种民间传统面食,",
1049810498
{
10499-
"type": "link",
10499+
"type": "page",
1050010500
"text": "饺子",
1050110501
"href": "./速冻水饺.md"
1050210502
},
@@ -11750,7 +11750,7 @@ export default [
1175011750
[
1175111751
"煎蛋或",
1175211752
{
11753-
"type": "link",
11753+
"type": "page",
1175411754
"text": "太阳蛋",
1175511755
"href": "../../breakfast/太阳蛋.md"
1175611756
}
@@ -11880,7 +11880,7 @@ export default [
1188011880
[
1188111881
"冷藏的咖喱每次取出需要吃的份量,加热后盖在",
1188211882
{
11883-
"type": "link",
11883+
"type": "page",
1188411884
"text": "米饭",
1188511885
"href": "../米饭/米饭.md"
1188611886
},
@@ -12289,7 +12289,7 @@ export default [
1228912289
[
1229012290
"白菜(或其他菜)切丝,",
1229112291
{
12292-
"type": "link",
12292+
"type": "page",
1229312293
"text": "焯水",
1229412294
"href": "../../tips/learn/学习焯水.md"
1229512295
},
@@ -12367,7 +12367,7 @@ export default [
1236712367
[
1236812368
"离醒面完成时间还有 10 分钟时,请查看",
1236912369
{
12370-
"type": "link",
12370+
"type": "page",
1237112371
"text": "小技巧",
1237212372
"href": "../../condiment/油酥.md"
1237312373
},
@@ -12886,7 +12886,7 @@ export default [
1288612886
[
1288712887
"准备时,米饭可以参考",
1288812888
{
12889-
"type": "link",
12889+
"type": "page",
1289012890
"text": "米饭的做法",
1289112891
"href": "./米饭/米饭.md"
1289212892
},

miniprogram/pages/detail/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import infos from '../../data'
2+
import tips from '../learn/data'
23
import Toast from 'tdesign-miniprogram/toast/index';
34
import Message from 'tdesign-miniprogram/message/index';
45

@@ -192,6 +193,13 @@ Page({
192193
url: './index?id=' + cookbook.id
193194
})
194195
}
196+
197+
const tip = tips.find(item => item.name.includes(match[1]))
198+
if (tip) {
199+
wx.navigateTo({
200+
url: '/pages/learn/detail?no=' + tip.no
201+
})
202+
}
195203
}
196204
}
197205
},

miniprogram/pages/index/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import config from '../../config/index.js'
55
Page({
66
data: {
77
list: [],
8-
value: 'home',
8+
value: 'index',
99
tabbars: [{
1010
text: '首页',
11-
value: 'home',
11+
value: 'index',
1212
icon: 'home'
1313
},{
1414
text: '学习',

miniprogram/pages/index/index.wxml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
wx:key="name"
88
bind:click="handleTap"
99
list="{{item.list}}" />
10-
<t-tab-bar
11-
value="{{value}}"
12-
bindchange="handleTabbarChange"
13-
>
14-
<t-tab-bar-item wx:for="{{tabbars}}" wx:key="index" value="{{item.value}}" icon="{{item.icon}}">
15-
{{item.text}}
16-
</t-tab-bar-item>
17-
</t-tab-bar>
1810
</view>
11+
12+
<include src="/templates/tabbar.wxml" />

miniprogram/pages/learn/data.js

Lines changed: 1092 additions & 1 deletion
Large diffs are not rendered by default.

miniprogram/pages/learn/detail.js

Lines changed: 66 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,81 @@
11
const info = require('./data.js').default
2+
const cookbooks = require('../../data').default
3+
// import Toast from 'tdesign-miniprogram/toast/index';
4+
import Message from 'tdesign-miniprogram/message/index';
25

36
Page({
4-
5-
/**
6-
* 页面的初始数据
7-
*/
87
data: {
98
info: []
109
},
1110

12-
/**
13-
* 生命周期函数--监听页面加载
14-
*/
1511
onLoad: function (options) {
16-
const { index = 0 } = options;
17-
const target = info[index];
18-
19-
this.setData({
20-
info: target.content
21-
})
22-
wx.setNavigationBarTitle({
23-
title: target.title
24-
})
25-
},
26-
27-
/**
28-
* 生命周期函数--监听页面初次渲染完成
29-
*/
30-
onReady: function () {
31-
32-
},
33-
34-
/**
35-
* 生命周期函数--监听页面显示
36-
*/
37-
onShow: function () {
38-
12+
const { no = 0 } = options;
13+
const target = info.find(item => item.no == no);
14+
15+
if (target) {
16+
this.setData({
17+
info: target.content
18+
})
19+
wx.setNavigationBarTitle({
20+
title: target.name
21+
})
22+
}
3923
},
4024

41-
/**
42-
* 生命周期函数--监听页面隐藏
43-
*/
44-
onHide: function () {
45-
46-
},
47-
48-
/**
49-
* 生命周期函数--监听页面卸载
50-
*/
51-
onUnload: function () {
52-
53-
},
54-
55-
/**
56-
* 页面相关事件处理函数--监听用户下拉动作
57-
*/
58-
onPullDownRefresh: function () {
59-
25+
handlePreview({ target }) {
26+
const { src } = target.dataset;
27+
28+
wx.previewImage({
29+
urls: [src],
30+
success() {
31+
console.log('success');
32+
},
33+
fail(e) {
34+
console.log(e);
35+
}
36+
})
6037
},
6138

62-
/**
63-
* 页面上拉触底事件的处理函数
64-
*/
65-
onReachBottom: function () {
66-
39+
handleLink({ target }) {
40+
41+
const { src } = target.dataset;
42+
43+
if (src.startsWith('http')) {
44+
wx.setClipboardData({
45+
data: src,
46+
}).then(() => {
47+
Message.info({
48+
offset: [20, 32],
49+
duration: 5000,
50+
content: '链接已复制,暂不支持直接打开网页',
51+
});
52+
}).catch(() => {
53+
Message.info({
54+
offset: [20, 32],
55+
duration: 5000,
56+
content: '链接无法复制,请稍后重试',
57+
});
58+
})
59+
} else {
60+
const match = /\/([^\/]+)\.md/.exec(src);
61+
62+
if (match[1]) {
63+
const cookbook = cookbooks.find(item => item.name.includes(match[1]))
64+
65+
if (cookbook) {
66+
wx.navigateTo({
67+
url: '/pages/detail/index?id=' + cookbook.id
68+
})
69+
}
70+
71+
const tips = info.find(item => item.name.includes(match[1]))
72+
if (tips) {
73+
wx.navigateTo({
74+
url: '/pages/learn/detail?no=' + tips.no
75+
})
76+
}
77+
}
78+
}
6779
},
6880

6981
/**

0 commit comments

Comments
 (0)