|
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+import moment from 'moment';
|
|
|
2
|
+import dataUpdateStatus from '../../model/dataUpdateStatus.js';
|
|
|
3
|
+import pinyin from '../../model/pinyin.js';
|
|
|
4
|
+import config from '../../config/index.js';
|
|
|
5
|
+import _ from 'lodash';
|
|
|
6
|
+import axios from 'axios';
|
|
|
7
|
+import { Encrypt, Decrypt } from '../../util/crypto/index.js';
|
|
|
8
|
+import { stringUtils } from '../../util/stringClass.js';
|
|
|
9
|
+import WXBizDataCrypt from '../../util/WXBizDataCrypt.js';
|
|
|
10
|
+import { globalCache } from '../../util/GlobalCache.js';
|
|
|
11
|
+
|
|
|
12
|
+export async function PinyinLogin(ctx) {
|
|
|
13
|
+ let param = ctx.request.body;
|
|
|
14
|
+ if (param.param) {
|
|
|
15
|
+ const paramStr = Decrypt(param.param, config.urlSecrets.aes_key, config.urlSecrets.aes_iv);
|
|
|
16
|
+ //console.log("paramStr:"+paramStr);
|
|
|
17
|
+ param = JSON.parse(paramStr);
|
|
|
18
|
+ }
|
|
|
19
|
+ const code = param.Code;
|
|
|
20
|
+ //console.log("code:"+code);
|
|
|
21
|
+ const url = `https://api.weixin.qq.com/sns/jscode2session?appid=${config.wx.pinyin_appid}&secret=${config.wx.pinyin_appsecret}&js_code=${code}&grant_type=authorization_code`;
|
|
|
22
|
+
|
|
|
23
|
+ let result = await axios.get(url)
|
|
|
24
|
+ .then(res => {
|
|
|
25
|
+ const json = res.data;
|
|
|
26
|
+ //console.log("json:"+json);
|
|
|
27
|
+ if (json && json.openid) {
|
|
|
28
|
+ param.OpenID = json.openid;
|
|
|
29
|
+ param.sessionKey = json.session_key;
|
|
|
30
|
+ if (json.unionid)
|
|
|
31
|
+ param.UnionID = json.unionid;
|
|
|
32
|
+ return {errcode: 10000};
|
|
|
33
|
+ }
|
|
|
34
|
+ else {
|
|
|
35
|
+ return json;
|
|
|
36
|
+ }
|
|
|
37
|
+ })
|
|
|
38
|
+ .catch(err => {
|
|
|
39
|
+ return {errcode: 101, errStr: err};
|
|
|
40
|
+ });
|
|
|
41
|
+
|
|
|
42
|
+ if (result.errcode == 10000) {
|
|
|
43
|
+ delete param.Code;
|
|
|
44
|
+ if (param.sessionKey && param.iv && param.encryptedData){
|
|
|
45
|
+ //console.log("param.sessionKey:"+param.sessionKey);
|
|
|
46
|
+ const pc = new WXBizDataCrypt(config.wx.phonics_appid, param.sessionKey);
|
|
|
47
|
+ const dataUnionID = pc.decryptData(param.encryptedData , param.iv);
|
|
|
48
|
+ //console.log(dataUnionID);
|
|
|
49
|
+ param.UnionID = dataUnionID.unionId;
|
|
|
50
|
+ }
|
|
|
51
|
+
|
|
|
52
|
+ delete param.sessionKey;
|
|
|
53
|
+ delete param.iv;
|
|
|
54
|
+ delete param.encryptedData;
|
|
|
55
|
+
|
|
|
56
|
+ //todo
|
|
|
57
|
+ //param.OpenID="o4UHq4gaNlHfdTWxgl3fTgC1mFsI";
|
|
|
58
|
+
|
|
|
59
|
+ let userList = await pinyin.GetUsersInfo(param);
|
|
|
60
|
+ if (userList.length > 0) {
|
|
|
61
|
+ param.LastLoginTime = new Date();
|
|
|
62
|
+ const time1 = moment(userList[0].ProductServiceTime).format('YYYY-MM-DD HH:mm:ss');
|
|
|
63
|
+ const time3 = moment().format('YYYY-MM-DD HH:mm:ss');
|
|
|
64
|
+ if (time1 < time3)
|
|
|
65
|
+ param.IsMember = 0;
|
|
|
66
|
+
|
|
|
67
|
+ delete param.Introducer;
|
|
|
68
|
+ delete param.UserSource;
|
|
|
69
|
+ delete param.SourceID;
|
|
|
70
|
+ //console.log(param.NickName);
|
|
|
71
|
+ if (param.NickName == "陌生用户") {
|
|
|
72
|
+ delete param.NickName;
|
|
|
73
|
+ delete param.AvatarUrl;
|
|
|
74
|
+ delete param.Language;
|
|
|
75
|
+ delete param.Gender;
|
|
|
76
|
+ delete param.City;
|
|
|
77
|
+ delete param.Province;
|
|
|
78
|
+ delete param.Country;
|
|
|
79
|
+ }
|
|
|
80
|
+
|
|
|
81
|
+ await pinyin.UpdateUsers(param);
|
|
|
82
|
+ userList = await pinyin.GetUsersInfo(param);
|
|
|
83
|
+ }
|
|
|
84
|
+ else {
|
|
|
85
|
+ param.NickName = "陌生用户";
|
|
|
86
|
+ param.AvatarUrl = "../images/userface_default.png";
|
|
|
87
|
+ param.CreateTime = new Date();
|
|
|
88
|
+ param.LastLoginTime = param.CreateTime;
|
|
|
89
|
+ param.ProductServiceTime = param.CreateTime;
|
|
|
90
|
+ const inseredID = await pinyin.AddUsers(param);
|
|
|
91
|
+ userList = await pinyin.GetUsersInfo(param);
|
|
|
92
|
+ }
|
|
|
93
|
+
|
|
|
94
|
+ delete userList[0].OpenID;
|
|
|
95
|
+ delete userList[0].UnionID;
|
|
|
96
|
+
|
|
|
97
|
+ result = {errcode: 10000, result: userList[0]};
|
|
|
98
|
+ }
|
|
|
99
|
+
|
|
|
100
|
+ ctx.body = result;
|
|
|
101
|
+}
|
|
|
102
|
+
|
|
|
103
|
+//新增拼音记录
|
|
|
104
|
+export async function AddPinyinRecord(ctx) {
|
|
|
105
|
+ const param = ctx.request.body;
|
|
|
106
|
+ const inseredID = await pinyin.AddPinyinRecord(param);
|
|
|
107
|
+
|
|
|
108
|
+ ctx.body = {errcode: 10000, result: inseredID};
|
|
|
109
|
+}
|
|
|
110
|
+
|
|
|
111
|
+//更新拼音记录
|
|
|
112
|
+export async function UpdatePinyinRecord(ctx) {
|
|
|
113
|
+ const param = ctx.request.body;
|
|
|
114
|
+ await pinyin.UpdatePinyinRecord(param);
|
|
|
115
|
+ ctx.body = {errcode: 10000};
|
|
|
116
|
+}
|
|
|
117
|
+
|
|
|
118
|
+//得到用户记录
|
|
|
119
|
+export async function GetPinyinRecordData(ctx) {
|
|
|
120
|
+ const param = {
|
|
|
121
|
+ UserID: ctx.query.UserID || 0,
|
|
|
122
|
+ Version: ctx.query.Version || "1.0.0",
|
|
|
123
|
+ };
|
|
|
124
|
+ if (param.UserID === "undefined")
|
|
|
125
|
+ param.UserID = 0;
|
|
|
126
|
+
|
|
|
127
|
+ const result = await pinyin.GetPinyinRecordData(param);
|
|
|
128
|
+
|
|
|
129
|
+ if (param.UserID > 0 && result && result.length > 0) {
|
|
|
130
|
+ const userList = await pinyin.GetUsersInfoByUserID(param);
|
|
|
131
|
+
|
|
|
132
|
+ //是否是首日
|
|
|
133
|
+ const timeCreateTime = moment(userList[0].CreateTime).format('YYYYMMDD');
|
|
|
134
|
+ const timeToday = moment().format('YYYYMMDD');
|
|
|
135
|
+ if (timeCreateTime === timeToday)
|
|
|
136
|
+ result[0].IsFirstDay = true;
|
|
|
137
|
+ else
|
|
|
138
|
+ result[0].IsFirstDay = false;
|
|
|
139
|
+
|
|
|
140
|
+ const a = moment(userList[0].CreateTime);
|
|
|
141
|
+ const b = moment();
|
|
|
142
|
+ result[0].DayNumber = b.diff(a, 'days') + 1;
|
|
|
143
|
+
|
|
|
144
|
+ //得到分享新增用户数
|
|
|
145
|
+ let productServiceTime = moment(userList[0].ProductServiceTime).format('YYYYMMDD');
|
|
|
146
|
+ if (productServiceTime === "20991231") {
|
|
|
147
|
+ result[0].NewUserNumber = 999999;
|
|
|
148
|
+ }
|
|
|
149
|
+ else {
|
|
|
150
|
+ const newUserNumber = await pinyin.GetNewUserByUserID(param);
|
|
|
151
|
+ if (newUserNumber) {
|
|
|
152
|
+ result[0].NewUserNumber = newUserNumber.length;
|
|
|
153
|
+ //console.log("userList[0].ActivityTime:"+userList[0].ActivityTime);
|
|
|
154
|
+
|
|
|
155
|
+ productServiceTime = moment(userList[0].ProductServiceTime).format('YYYYMMDD');
|
|
|
156
|
+ const currentTime = moment().format('YYYYMMDD');
|
|
|
157
|
+
|
|
|
158
|
+ //如果推荐用户数超过6个,就改为增加3个月
|
|
|
159
|
+ if (newUserNumber.length >= 6 && !userList[0].ActivityTime && productServiceTime >= currentTime) {
|
|
|
160
|
+ const obj = {
|
|
|
161
|
+ ActivityTime: moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
162
|
+ ProductServiceTime: moment(userList[0].ProductServiceTime).add(1, 'months').format('YYYY-MM-DD HH:mm:ss'),
|
|
|
163
|
+ OpenID: userList[0].OpenID,
|
|
|
164
|
+ }
|
|
|
165
|
+ await pinyin.UpdateUsers(obj);
|
|
|
166
|
+ result[0].NewUserNumber = 999999;
|
|
|
167
|
+ }
|
|
|
168
|
+ }
|
|
|
169
|
+ }
|
|
|
170
|
+
|
|
|
171
|
+ result[0].IsMember = userList[0].IsMember;
|
|
|
172
|
+ if (productServiceTime < timeToday)
|
|
|
173
|
+ result[0].IsMember = 0;
|
|
|
174
|
+
|
|
|
175
|
+ const result2 = await pinyin.GetPinyinFinishedDataCount(param);
|
|
|
176
|
+
|
|
|
177
|
+ if (result2)
|
|
|
178
|
+ result[0].FinishedCount = result2[0].count;
|
|
|
179
|
+
|
|
|
180
|
+ const param2 = {
|
|
|
181
|
+ ProgramID: 98,
|
|
|
182
|
+ Version: param.Version,
|
|
|
183
|
+ };
|
|
|
184
|
+ const result3 = await dataUpdateStatus.GetProductVersionList(param2);
|
|
|
185
|
+ if (result3) {
|
|
|
186
|
+ if ((param.Version === result3[0].Version && result3[0].IsShowPay <= 0)
|
|
|
187
|
+ || param.Version > result3[0].Version) {
|
|
|
188
|
+ result[0].IsShow = result3[0].IsShowPay;
|
|
|
189
|
+ }
|
|
|
190
|
+ else {
|
|
|
191
|
+ result[0].IsShow = 1;
|
|
|
192
|
+ }
|
|
|
193
|
+
|
|
|
194
|
+ //针对iphone测试用户,永远是无支付状态
|
|
|
195
|
+ if (userList[0].Brand === 'iPhone' && userList[0].WXLanguage === 'en-US'
|
|
|
196
|
+ && userList[0].UserSource === '1001' && userList[0].IsPay === 0) {
|
|
|
197
|
+ result[0].IsShow = 0;
|
|
|
198
|
+ }
|
|
|
199
|
+ }
|
|
|
200
|
+
|
|
|
201
|
+ ctx.body = {"errcode": 10000, result: result[0]};
|
|
|
202
|
+ }
|
|
|
203
|
+ else
|
|
|
204
|
+ ctx.body = {"errcode": 10000};
|
|
|
205
|
+}
|
|
|
206
|
+
|
|
|
207
|
+//新增或删除拼音完成结果
|
|
|
208
|
+export async function UpdatePinyinFinished(ctx) {
|
|
|
209
|
+ const param = ctx.request.body;
|
|
|
210
|
+ if (param.Style === "undefined")
|
|
|
211
|
+ param.Style = "";
|
|
|
212
|
+ if (param.IsFinished) {
|
|
|
213
|
+ delete param.IsFinished;
|
|
|
214
|
+ if (param.UserID) {
|
|
|
215
|
+ await pinyin.AddPinyinFinished(param);
|
|
|
216
|
+ }
|
|
|
217
|
+ }
|
|
|
218
|
+ else {
|
|
|
219
|
+ delete param.IsFinished;
|
|
|
220
|
+ if (param.UserID) {
|
|
|
221
|
+ await pinyin.DeletePinyinFinished(param);
|
|
|
222
|
+ }
|
|
|
223
|
+ }
|
|
|
224
|
+ ctx.body = {errcode: 10000};
|
|
|
225
|
+}
|
|
|
226
|
+
|
|
|
227
|
+//得到用户完成记录
|
|
|
228
|
+export async function GetPinyinFinishedData(ctx) {
|
|
|
229
|
+ const param = {
|
|
|
230
|
+ UserID: ctx.query.UserID || 0,
|
|
|
231
|
+ Category: ctx.query.Category || 0,
|
|
|
232
|
+ };
|
|
|
233
|
+ if (param.UserID === "undefined")
|
|
|
234
|
+ param.UserID = 0;
|
|
|
235
|
+
|
|
|
236
|
+ const result = await pinyin.GetPinyinFinishedData(param);
|
|
|
237
|
+ if (result && result.length > 0)
|
|
|
238
|
+ ctx.body = {"errcode": 10000, result: result};
|
|
|
239
|
+ else
|
|
|
240
|
+ ctx.body = {"errcode": 10000};
|
|
|
241
|
+}
|
|
|
242
|
+
|
|
|
243
|
+//帮助用户使用兑换卡
|
|
|
244
|
+export async function SetPinyinUserExchange(ctx) {
|
|
|
245
|
+ const param = {
|
|
|
246
|
+ ExchangeUserID: ctx.query.UserID || 0,
|
|
|
247
|
+ ID: ctx.query.ProductPayInfoID || 0,
|
|
|
248
|
+ ExchangeTime: new Date(),
|
|
|
249
|
+ };
|
|
|
250
|
+ if (param.ID === "undefined")
|
|
|
251
|
+ param.ID = 0;
|
|
|
252
|
+
|
|
|
253
|
+ const ProductPayInfo = await pinyin.GetPinyinUserExchange(param);
|
|
|
254
|
+ if (ProductPayInfo && ProductPayInfo.length) {
|
|
|
255
|
+ if (ProductPayInfo[0].ExchangeUserID === 0) {
|
|
|
256
|
+ await pinyin.SetPinyinUserExchange(param);
|
|
|
257
|
+ const param2 = {};
|
|
|
258
|
+ param2.UserID = param.ExchangeUserID;
|
|
|
259
|
+ const userList = await pinyin.GetUsersInfoByUserID(param2);
|
|
|
260
|
+ if (userList && userList.length) {
|
|
|
261
|
+ const time1 = moment().format('YYYYMMDD');
|
|
|
262
|
+ const time2 = moment(userList[0].ProductServiceTime).format('YYYYMMDD');
|
|
|
263
|
+ if (time1 < time2) {
|
|
|
264
|
+ param2.ProductServiceTime = moment(userList[0].ProductServiceTime).add(6, 'months').format('YYYY-MM-DD HH:mm:ss');
|
|
|
265
|
+ }
|
|
|
266
|
+ else {
|
|
|
267
|
+ param2.ProductServiceTime = moment().add(6, 'months').format('YYYY-MM-DD HH:mm:ss');
|
|
|
268
|
+ }
|
|
|
269
|
+ param2.IsMember = 1;
|
|
|
270
|
+
|
|
|
271
|
+ await pinyin.UpdateUsersByUserID(param2);
|
|
|
272
|
+ }
|
|
|
273
|
+ ctx.body = {"errcode": 10000, result: true};
|
|
|
274
|
+ }
|
|
|
275
|
+ else
|
|
|
276
|
+ ctx.body = {"errcode": 10000, result: false};
|
|
|
277
|
+ }
|
|
|
278
|
+ else
|
|
|
279
|
+ ctx.body = {"errcode": 10000, result: false};
|
|
|
280
|
+}
|
|
|
281
|
+
|
|
|
282
|
+//得到拼音单元数据
|
|
|
283
|
+export async function GetPinyinUnitWords(ctx) {
|
|
|
284
|
+ const param = {
|
|
|
285
|
+ BookID: ctx.query.BookID || 44,
|
|
|
286
|
+ UnitID: ctx.query.UnitID || 431,
|
|
|
287
|
+ Word: ctx.query.Word || "b",
|
|
|
288
|
+ TestType: ctx.query.TestType || "read",
|
|
|
289
|
+ };
|
|
|
290
|
+
|
|
|
291
|
+ let result = globalCache.get("GetPinyinUnitWords?TestType=" + param.TestType + "&BookID=" + param.BookID + "&UnitID=" + param.UnitID + "&Word=" + param.Word);
|
|
|
292
|
+ if (result === 0) {
|
|
|
293
|
+ result = [];
|
|
|
294
|
+
|
|
|
295
|
+ if (param.BookID === 44) {
|
|
|
296
|
+ let arrExclude = [];
|
|
|
297
|
+ const arrPinyinBasic = constantClass.getPinyinBasic();
|
|
|
298
|
+ for (let k = 0; k < arrPinyinBasic.length; k++) {
|
|
|
299
|
+ for (let i = 0; i < arrPinyinBasic[k].List.length; i++) {
|
|
|
300
|
+ if (arrPinyinBasic[k].List[i].Name === param.Word) {
|
|
|
301
|
+ arrExclude = arrPinyinBasic[k].List[i].Exclude;
|
|
|
302
|
+ break;
|
|
|
303
|
+ }
|
|
|
304
|
+ }
|
|
|
305
|
+
|
|
|
306
|
+ if (arrExclude.length > 0)
|
|
|
307
|
+ break;
|
|
|
308
|
+ }
|
|
|
309
|
+
|
|
|
310
|
+ const pinyinArr = constantClass.getPinyinArray();
|
|
|
311
|
+
|
|
|
312
|
+ const arr = [];
|
|
|
313
|
+ for (let i = 0; i < pinyinArr.length; i++) {
|
|
|
314
|
+ let word = param.Word;
|
|
|
315
|
+ const item = pinyinArr[i];
|
|
|
316
|
+ if (word === "un") {
|
|
|
317
|
+ if (item[0].substr(0, 1) === "j"
|
|
|
318
|
+ || item[0].substr(0, 1) === "q"
|
|
|
319
|
+ || item[0].substr(0, 1) === "x"
|
|
|
320
|
+ || item[0].substr(0, 1) === "y"
|
|
|
321
|
+ ) {
|
|
|
322
|
+ continue;
|
|
|
323
|
+ }
|
|
|
324
|
+ }
|
|
|
325
|
+ if (word.indexOf("ü") >= 0) {
|
|
|
326
|
+ if (item[0].substr(0, 1) === "j"
|
|
|
327
|
+ || item[0].substr(0, 1) === "q"
|
|
|
328
|
+ || item[0].substr(0, 1) === "x"
|
|
|
329
|
+ || item[0].substr(0, 1) === "y"
|
|
|
330
|
+ ) {
|
|
|
331
|
+ word = word.replace("ü", "u");
|
|
|
332
|
+ }
|
|
|
333
|
+ else {
|
|
|
334
|
+ word = word.replace("ü", "v");
|
|
|
335
|
+ }
|
|
|
336
|
+ }
|
|
|
337
|
+
|
|
|
338
|
+ if (item[0].length > word.length &&
|
|
|
339
|
+ ((item[0].indexOf(word) === 0 && item[0].indexOf("5") < 0)
|
|
|
340
|
+ || item[0].lastIndexOf(word + "1") === (item[0].length - word.length - 1)
|
|
|
341
|
+ || item[0].lastIndexOf(word + "2") === (item[0].length - word.length - 1)
|
|
|
342
|
+ || item[0].lastIndexOf(word + "3") === (item[0].length - word.length - 1)
|
|
|
343
|
+ || item[0].lastIndexOf(word + "4") === (item[0].length - word.length - 1)
|
|
|
344
|
+ )
|
|
|
345
|
+ ) {
|
|
|
346
|
+ let b = true;
|
|
|
347
|
+ for (let j = 0; j < arrExclude.length; j++) {
|
|
|
348
|
+ if (item[0].indexOf(arrExclude[j]) >= 0) {
|
|
|
349
|
+ b = false;
|
|
|
350
|
+ break;
|
|
|
351
|
+ }
|
|
|
352
|
+ }
|
|
|
353
|
+ if (b) {
|
|
|
354
|
+ if (item[0].indexOf(word) >= 0 && !(item[2].length === 1 && item[2] === "")) {
|
|
|
355
|
+ arr.push(item)
|
|
|
356
|
+ }
|
|
|
357
|
+ }
|
|
|
358
|
+ }
|
|
|
359
|
+ }
|
|
|
360
|
+ //console.log(arr);
|
|
|
361
|
+ for (let i = 0; i < arr.length; i++) {
|
|
|
362
|
+ const obj = {};
|
|
|
363
|
+ obj.ID = i + 1;
|
|
|
364
|
+ let qustion, answer, tags;
|
|
|
365
|
+ const ReadString = "https://pinyin-1253256735.file.myqcloud.com/sounds/" + arr[i][0] + ".m4a";
|
|
|
366
|
+ qustion = arr[i][1];
|
|
|
367
|
+
|
|
|
368
|
+ //console.log(JSON.stringify(json.CHN));
|
|
|
369
|
+
|
|
|
370
|
+ answer = "[读 src='" + ReadString + "']" + qustion + "[/读]\n\n";
|
|
|
371
|
+
|
|
|
372
|
+ answer += arr[i][2].join(",");
|
|
|
373
|
+
|
|
|
374
|
+ tags = "拼音怎么念";
|
|
|
375
|
+
|
|
|
376
|
+ obj.Word = qustion;
|
|
|
377
|
+ obj.ReadString = ReadString;
|
|
|
378
|
+ obj.Content = [];
|
|
|
379
|
+ obj.Content.push({ContentType: 0, Content: tags});
|
|
|
380
|
+ obj.Content.push({ContentType: 1, Content: qustion});
|
|
|
381
|
+ obj.Content.push({ContentType: 2, Content: answer});
|
|
|
382
|
+ obj.Content.push({ContentType: 3, Content: ""});
|
|
|
383
|
+ result.push(obj);
|
|
|
384
|
+ }
|
|
|
385
|
+ }
|
|
|
386
|
+ else {
|
|
|
387
|
+ let arr = "";
|
|
|
388
|
+ switch (Number(param.UnitID)) {
|
|
|
389
|
+ case 431:
|
|
|
390
|
+ arr = "b,p,m,f,d,t,n,l";
|
|
|
391
|
+ break;
|
|
|
392
|
+ case 432:
|
|
|
393
|
+ arr = "g,k,h,j,q,x";
|
|
|
394
|
+ break;
|
|
|
395
|
+ case 433:
|
|
|
396
|
+ arr = "zh,ch,sh,r,z,c,s,y,w";
|
|
|
397
|
+ break;
|
|
|
398
|
+ case 434:
|
|
|
399
|
+ arr = "a,o,e,i,u,ü";
|
|
|
400
|
+ break;
|
|
|
401
|
+ case 435:
|
|
|
402
|
+ arr = "ai,ei,ui,ao,ou,iu,ie,üe,er";
|
|
|
403
|
+ break;
|
|
|
404
|
+ case 436:
|
|
|
405
|
+ arr = "an,en,in,un,ün,ang,eng,ing,ong";
|
|
|
406
|
+ break;
|
|
|
407
|
+ case 437:
|
|
|
408
|
+ arr = "zhi,chi,shi,ri,zi,ci,si,yi,wu";
|
|
|
409
|
+ break;
|
|
|
410
|
+ case 438:
|
|
|
411
|
+ arr = "yu,ye,yue,yin,yun,yuan,ying";
|
|
|
412
|
+ break;
|
|
|
413
|
+ }
|
|
|
414
|
+ arr = arr.split(",");
|
|
|
415
|
+ for (let i = 0; i < arr.length; i++) {
|
|
|
416
|
+ const obj = {};
|
|
|
417
|
+ obj.ID = i + 1;
|
|
|
418
|
+ let qustion, answer, tags;
|
|
|
419
|
+ let sound = arr[i];
|
|
|
420
|
+ sound = sound.replace("ü", "v");
|
|
|
421
|
+ const ReadString = "https://pinyin-1253256735.file.myqcloud.com/basic/" + sound + ".m4a";
|
|
|
422
|
+
|
|
|
423
|
+ if (param.TestType === "read") {
|
|
|
424
|
+ qustion = arr[i];
|
|
|
425
|
+ //console.log(JSON.stringify(json.CHN));
|
|
|
426
|
+ answer = "[读 src='" + ReadString + "']" + qustion + "[/读]\n\n";
|
|
|
427
|
+ tags = "拼音怎么念";
|
|
|
428
|
+ }
|
|
|
429
|
+ else {
|
|
|
430
|
+ //console.log(result[i].Word);
|
|
|
431
|
+ qustion = "[读 src='" + ReadString + "']拼音[/读]\n";
|
|
|
432
|
+
|
|
|
433
|
+ answer = arr[i] + "\n\n";
|
|
|
434
|
+ for (let j = 0; j < arr[i].length; j++) {
|
|
|
435
|
+ let str = arr[i][j];
|
|
|
436
|
+ if (str === "ü")
|
|
|
437
|
+ str = "v1"
|
|
|
438
|
+ answer += "[图 w='650' h='650']https://miaguo-1253256735.file.myqcloud.com/letter/s" + str + ".gif[/图]\n";
|
|
|
439
|
+ }
|
|
|
440
|
+
|
|
|
441
|
+ tags = "拼音怎么写";
|
|
|
442
|
+ }
|
|
|
443
|
+
|
|
|
444
|
+ obj.Word = arr[i];
|
|
|
445
|
+ obj.ReadString = ReadString;
|
|
|
446
|
+ obj.Content = [];
|
|
|
447
|
+ obj.Content.push({ContentType: 0, Content: tags});
|
|
|
448
|
+ obj.Content.push({ContentType: 1, Content: qustion});
|
|
|
449
|
+ obj.Content.push({ContentType: 2, Content: answer});
|
|
|
450
|
+ obj.Content.push({ContentType: 3, Content: ""});
|
|
|
451
|
+ result.push(obj);
|
|
|
452
|
+ }
|
|
|
453
|
+ }
|
|
|
454
|
+
|
|
|
455
|
+ globalCache.set("GetPinyinUnitWords?TestType=" + param.TestType + "&BookID=" + param.BookID + "&UnitID=" + param.UnitID + "&Word=" + param.Word, result, config.BufferMemoryTimeHigh);
|
|
|
456
|
+ }
|
|
|
457
|
+
|
|
|
458
|
+ ctx.body = {"errcode": 10000, result: result};
|
|
|
459
|
+}
|