Skip to content

Commit 699e84e

Browse files
committed
更新 miniapp code
1 parent 6a3ac82 commit 699e84e

File tree

2 files changed

+145
-211
lines changed

2 files changed

+145
-211
lines changed

passjava-miniApp/passJava-Rest/miniprogram/pages/javaQuestionDetail/javaQuestionDetail.js

Lines changed: 2 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,7 @@ Page({
2020
* 生命周期函数--监听页面加载
2121
*/
2222
onLoad: function (options) {
23-
//let javaQuestionId = decodeURIComponent(options.id)
24-
let answerUrl = decodeURIComponent(options.answerUrl)
25-
//this.getJavaQuestionAnswerById2(javaQuestionId) // 通过rest api获取
26-
this.getJavaAnswerByAnswerUrl(answerUrl)
27-
},
28-
29-
getJavaAnswerByAnswerUrl: function(answerUrl) {
30-
this.getMarkdownFile(answerUrl)
23+
this.getJavaQuestionAnswerById(1) // 通过rest api获取
3124
},
3225

3326
onShow:function(options) {
@@ -37,12 +30,7 @@ Page({
3730
onUnload: function () {
3831
},
3932

40-
getJavaQuestionAnswerById2: function (javaQuestionId) {
41-
let that = this
42-
let params = {
43-
id: javaQuestionId
44-
}
45-
33+
getJavaQuestionAnswerById: function (javaQuestionId) {
4634
restService.get(config.service.getJavaQuestionAnswerById + '/' + javaQuestionId).then((res) => {
4735
if (res && res.statusCode == 200) {
4836
const data = JSON.parse(res.data)
@@ -59,60 +47,6 @@ Page({
5947
})
6048
},
6149

62-
getJavaQuestionAnswerById: function (javaQuestionId) {
63-
wx.cloud.callFunction({
64-
// 云函数名称
65-
name: 'getJavaQuestionDetail',
66-
data: {
67-
id: javaQuestionId
68-
}
69-
}).then(res => {
70-
let answerHtml = res.result.answer
71-
//answerHtml = cssUtil.addStyle(answerHtml);
72-
answerHtml = cssUtil.convertToMarkdown(answerHtml)
73-
this.setData({
74-
isLoading: false,
75-
detail: answerHtml
76-
})
77-
78-
//this.getMarkdownFile(answerUrl)
79-
}).catch(console.error)
80-
},
81-
82-
getMarkdownFile(answerUrl) {
83-
wx.cloud.downloadFile({
84-
fileID: answerUrl,
85-
success: res => {
86-
// get temp file path
87-
let tempFilePath = res.tempFilePath
88-
console.log('downloadFile', tempFilePath)
89-
//let index = tempFilePath.indexOf("?")
90-
//tempFilePath = tempFilePath.substring(0, index)
91-
//console.log('index', index)
92-
console.log('tempFilePath', tempFilePath)
93-
try {
94-
let savedFile = wx.getFileSystemManager().saveFileSync(tempFilePath, wx.env.USER_DATA_PATH + "/local.md")
95-
console.log('savedFile',savedFile);
96-
let fileContent = wx.getFileSystemManager().readFileSync(savedFile, "utf-8", 0)
97-
console.log('savedFile',fileContent);
98-
let markdownContent = this.convertToMarkdown(fileContent)
99-
this.setData({
100-
article: markdownContent,
101-
isLoading: false,
102-
detail: fileContent
103-
})
104-
105-
} catch (error) {
106-
console.log(error);
107-
}
108-
109-
},
110-
fail: err => {
111-
console.log(err);
112-
}
113-
})
114-
},
115-
11650
convertToMarkdown: function(answerHtml) {
11751
let result = app.towxml(answerHtml,'markdown',{
11852
theme:'light', // 主题,默认`light`
Lines changed: 143 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,145 @@
11
{
2-
"description": "项目配置文件",
3-
"packOptions": {
4-
"ignore": []
5-
},
6-
"setting": {
7-
"urlCheck": true,
8-
"es6": true,
9-
"enhance": false,
10-
"postcss": true,
11-
"preloadBackgroundData": false,
12-
"minified": true,
13-
"newFeature": true,
14-
"coverView": true,
15-
"nodeModules": false,
16-
"autoAudits": false,
17-
"showShadowRootInWxmlPanel": true,
18-
"scopeDataCheck": false,
19-
"uglifyFileName": false,
20-
"checkInvalidKey": true,
21-
"checkSiteMap": true,
22-
"uploadWithSourceMap": true,
23-
"compileHotReLoad": false,
24-
"useMultiFrameRuntime": true,
25-
"useApiHook": true,
26-
"useApiHostProcess": false,
27-
"babelSetting": {
28-
"ignore": [],
29-
"disablePlugins": [],
30-
"outputPath": ""
31-
},
32-
"enableEngineNative": false,
33-
"bundle": false,
34-
"useIsolateContext": true,
35-
"useCompilerModule": true,
36-
"userConfirmedUseCompilerModuleSwitch": false,
37-
"userConfirmedBundleSwitch": false,
38-
"packNpmManually": false,
39-
"packNpmRelationList": [],
40-
"minifyWXSS": true
41-
},
42-
"compileType": "miniprogram",
43-
"libVersion": "2.10.3",
44-
"appid": "wx08bacac66e424d72",
45-
"projectname": "passJavaCloud",
46-
"miniprogramRoot": "miniprogram/",
47-
"cloudfunctionRoot": "cloudfunctions/",
48-
"cloudfunctionTemplateRoot": "cloudfunctionTemplate",
49-
"debugOptions": {
50-
"hidedInDevtools": []
51-
},
52-
"scripts": {},
53-
"simulatorType": "wechat",
54-
"simulatorPluginLibVersion": {},
55-
"condition": {
56-
"search": {
57-
"list": []
58-
},
59-
"conversation": {
60-
"list": []
61-
},
62-
"plugin": {
63-
"list": []
64-
},
65-
"game": {
66-
"list": []
67-
},
68-
"gamePlugin": {
69-
"list": []
70-
},
71-
"miniprogram": {
72-
"list": [
73-
{
74-
"id": -1,
75-
"name": "db guide",
76-
"pathName": "pages/databaseGuide/databaseGuide",
77-
"query": ""
78-
},
79-
{
80-
"id": 1,
81-
"name": "exam",
82-
"pathName": "pages/exam/exam",
83-
"query": "type=daily&value=20190531",
84-
"scene": null
85-
},
86-
{
87-
"id": -1,
88-
"name": "answer",
89-
"pathName": "pages/answer/answer",
90-
"query": "",
91-
"scene": null
92-
},
93-
{
94-
"id": 3,
95-
"name": "exam5",
96-
"pathName": "pages/exam/exam",
97-
"query": "type=simulated&value=5&title=模拟试题5",
98-
"scene": null
99-
},
100-
{
101-
"id": -1,
102-
"name": "我的",
103-
"pathName": "pages/profile/profile",
104-
"query": "",
105-
"scene": null
106-
},
107-
{
108-
"id": -1,
109-
"name": "专题秘籍",
110-
"pathName": "pages/topic/topic",
111-
"query": "",
112-
"scene": null
113-
},
114-
{
115-
"id": -1,
116-
"name": "答题排行",
117-
"pathName": "pages/range/range",
118-
"query": "",
119-
"scene": null
120-
},
121-
{
122-
"id": -1,
123-
"name": "问题列表",
124-
"pathName": "pages/javaQuestionList/javaQuestionList",
125-
"query": "type=java&title=Java基础",
126-
"scene": null
127-
},
128-
{
129-
"id": 8,
130-
"name": "pages/javaQuestionDetail/javaQuestionDetail",
131-
"pathName": "pages/javaQuestionDetail/javaQuestionDetail",
132-
"query": "id=1&answerUrl=cloud://test-0jlva.7465-test-0jlva-1254012214/markdown/javaBasic/20200307.md",
133-
"scene": null
134-
},
135-
{
136-
"id": -1,
137-
"name": "pages/index/index",
138-
"pathName": "pages/index/index",
139-
"query": "",
140-
"scene": 1011
141-
}
142-
]
143-
}
144-
}
2+
"description": "项目配置文件",
3+
"packOptions": {
4+
"ignore": []
5+
},
6+
"setting": {
7+
"urlCheck": false,
8+
"es6": true,
9+
"enhance": false,
10+
"postcss": true,
11+
"preloadBackgroundData": false,
12+
"minified": true,
13+
"newFeature": true,
14+
"coverView": true,
15+
"nodeModules": false,
16+
"autoAudits": false,
17+
"showShadowRootInWxmlPanel": true,
18+
"scopeDataCheck": false,
19+
"uglifyFileName": false,
20+
"checkInvalidKey": true,
21+
"checkSiteMap": true,
22+
"uploadWithSourceMap": true,
23+
"compileHotReLoad": false,
24+
"babelSetting": {
25+
"ignore": [],
26+
"disablePlugins": [],
27+
"outputPath": ""
28+
},
29+
"bundle": false,
30+
"useIsolateContext": true,
31+
"useCompilerModule": true,
32+
"userConfirmedUseCompilerModuleSwitch": false,
33+
"useMultiFrameRuntime": true,
34+
"useApiHook": true,
35+
"useApiHostProcess": false,
36+
"enableEngineNative": false,
37+
"userConfirmedBundleSwitch": false,
38+
"packNpmManually": false,
39+
"packNpmRelationList": [],
40+
"minifyWXSS": true
41+
},
42+
"compileType": "miniprogram",
43+
"libVersion": "2.10.3",
44+
"appid": "wx08bacac66e424d72",
45+
"projectname": "passJavaCloud",
46+
"miniprogramRoot": "miniprogram/",
47+
"cloudfunctionRoot": "cloudfunctions/",
48+
"cloudfunctionTemplateRoot": "cloudfunctionTemplate",
49+
"debugOptions": {
50+
"hidedInDevtools": []
51+
},
52+
"scripts": {},
53+
"simulatorType": "wechat",
54+
"simulatorPluginLibVersion": {},
55+
"condition": {
56+
"search": {
57+
"list": []
58+
},
59+
"conversation": {
60+
"list": []
61+
},
62+
"plugin": {
63+
"list": []
64+
},
65+
"game": {
66+
"list": []
67+
},
68+
"gamePlugin": {
69+
"list": []
70+
},
71+
"miniprogram": {
72+
"list": [
73+
{
74+
"id": -1,
75+
"name": "db guide",
76+
"pathName": "pages/databaseGuide/databaseGuide",
77+
"query": ""
78+
},
79+
{
80+
"id": 1,
81+
"name": "exam",
82+
"pathName": "pages/exam/exam",
83+
"query": "type=daily&value=20190531",
84+
"scene": null
85+
},
86+
{
87+
"id": -1,
88+
"name": "answer",
89+
"pathName": "pages/answer/answer",
90+
"query": "",
91+
"scene": null
92+
},
93+
{
94+
"id": 3,
95+
"name": "exam5",
96+
"pathName": "pages/exam/exam",
97+
"query": "type=simulated&value=5&title=模拟试题5",
98+
"scene": null
99+
},
100+
{
101+
"id": -1,
102+
"name": "我的",
103+
"pathName": "pages/profile/profile",
104+
"query": "",
105+
"scene": null
106+
},
107+
{
108+
"id": -1,
109+
"name": "专题秘籍",
110+
"pathName": "pages/topic/topic",
111+
"query": "",
112+
"scene": null
113+
},
114+
{
115+
"id": -1,
116+
"name": "答题排行",
117+
"pathName": "pages/range/range",
118+
"query": "",
119+
"scene": null
120+
},
121+
{
122+
"id": -1,
123+
"name": "问题列表",
124+
"pathName": "pages/javaQuestionList/javaQuestionList",
125+
"query": "type=java&title=Java基础",
126+
"scene": null
127+
},
128+
{
129+
"id": 8,
130+
"name": "pages/javaQuestionDetail/javaQuestionDetail",
131+
"pathName": "pages/javaQuestionDetail/javaQuestionDetail",
132+
"query": "id=1&answerUrl=cloud://test-0jlva.7465-test-0jlva-1254012214/markdown/javaBasic/20200307.md",
133+
"scene": null
134+
},
135+
{
136+
"id": -1,
137+
"name": "pages/index/index",
138+
"pathName": "pages/index/index",
139+
"query": "",
140+
"scene": 1011
141+
}
142+
]
143+
}
144+
}
145145
}

0 commit comments

Comments
 (0)