article.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. import animation from '../../utils/animation';
  4. import commonBehavior from '../behaviors/commonBehavior';
  5. const Theme=[{
  6. "Name":"DarkColor",
  7. "backgroundColor": "#004433",
  8. "color":"#C1E1C1",
  9. "frontColor": '#ffffff',
  10. },{
  11. "Name":"LightColor",
  12. "backgroundColor": "#D0ECD3",
  13. "color":"#151815",
  14. "frontColor": '#000000',
  15. }
  16. ];
  17. const app = getApp();
  18. Page({
  19. behaviors: [commonBehavior],
  20. data: {
  21. Words:"",
  22. IsShowFirstOpen:true,
  23. IsBuilding:false,
  24. IsBuildError:false,
  25. IsShowLightColor:false,
  26. IsShowKeyword:true,//显示关键词
  27. IsShowQuestion:false,
  28. IsShowTranslate:false,
  29. IsShowSetting:false,
  30. IsShowWordTranslate:false,
  31. IsBuildQueue:false,
  32. TranslateHeight:100,//翻译单词框的高度
  33. CurrentQuestionIndex:0,
  34. swiperHeight: "526rpx",
  35. lastTapTime: 0, // 记录上一次点击的时间,用于检测双击
  36. CountDown:30,//倒计时秒数
  37. },
  38. onLoad: function (options) {
  39. let that = this;
  40. let words=app.globalData.SelectedWords.join(",");
  41. let wordsStr=app.globalData.SelectedWords.join(" ");
  42. const IsShowFirstOpen2=wx.getStorageSync('IsShowFirstOpen2');
  43. const IsShowGuideContainer=wx.getStorageSync('IsShowGuideContainer');
  44. if (!IsShowGuideContainer && !IsShowFirstOpen2){
  45. that.setData({
  46. IsShowFirstOpen2:1,
  47. });
  48. }
  49. else if (IsShowGuideContainer){
  50. that.setData({
  51. IsShowGuideContainer:true,
  52. IsShowFirstOpen2:false,
  53. });
  54. main.showGuideContainer(that,"#btnQAndA",-61,-195,"pic_ha07",240,0);
  55. }
  56. let IsShowKeyword=wx.getStorageSync('IsShowKeyword');
  57. if (IsShowKeyword===""){
  58. IsShowKeyword=true;
  59. wx.setStorageSync('IsShowKeyword', true);
  60. }
  61. let IsShowLightColor=wx.getStorageSync('IsShowLightColor');
  62. if (!IsShowLightColor){
  63. IsShowLightColor=false;
  64. }
  65. that.setData({
  66. Containnerheight: main.getWindowHeight(),
  67. Words:words,
  68. WordsStr:wordsStr,
  69. Level:options.Level,
  70. ArticleStyle:options.ArticleStyle,
  71. AIVersion:options.AIVersion,
  72. OpenType:options.Type,//打开的类型,可能是新用户引导
  73. IsShowLightColor:IsShowLightColor,
  74. IsShowKeyword:IsShowKeyword,
  75. IsBuildError:false,
  76. IsBuilding:false,
  77. IsCollect:false,
  78. });
  79. if (options.ID)
  80. that.getArticleByID(options.ID);
  81. else
  82. that.init(options);
  83. that.setTheme();
  84. // //测试
  85. // that.setData({
  86. // IsBuilding:true,
  87. // });
  88. // that.getChoicenessArticle();
  89. main.checkGenerating();
  90. this.audioCtx = wx.createAudioContext('myAudio');
  91. },
  92. onShow:function(){
  93. main.getPageInfo();
  94. },
  95. getArticleByID:function(id){
  96. let that=this;
  97. main.getData('GetYJBDCArticleList?UserID=' + app.globalData.userInfo.UserID+'&ID='+id, function (data) {
  98. if (data) {
  99. data=data[0];
  100. that.setData({
  101. Words:data.Words,
  102. Level:data.Level,
  103. ArticleStyle:data.ArticleStyle,
  104. CreateTime:data.CreateTime,
  105. ID:id,
  106. });
  107. let content=data.JSONString;
  108. that.updateData(content);
  109. that.updateReadCount(that.data.ID);
  110. }
  111. });
  112. },
  113. init:function(options){
  114. let that=this;
  115. let interval=0;
  116. that.data.CountDown=options.BuildSecond;
  117. that.setData({
  118. CountDown:that.data.CountDown,
  119. });
  120. interval = setInterval(function(){
  121. that.setData({
  122. CountDown:--that.data.CountDown,
  123. });
  124. if (that.data.CountDown<=0)
  125. clearInterval(interval);
  126. },1200);
  127. that.setData({
  128. IsBuilding:true,
  129. IsNew:true,
  130. });
  131. app.globalData.Generating=true;
  132. let words=app.globalData.SelectedWords.join(",");
  133. main.postData('QueuedGenerateArticle?UserID='+app.globalData.userInfo.UserID, {
  134. Words:words,
  135. Level:that.data.Level,
  136. ArticleStyle:that.data.ArticleStyle,
  137. AIVersion:that.data.AIVersion
  138. }, function (data) {
  139. app.globalData.Generating=false;
  140. app.globalData.GeneratingStart=false;
  141. if (data){
  142. console.log("请求生成数据:"+JSON.stringify(data));
  143. if (data=="-1"){
  144. that.setData({
  145. IsBuilding:false,
  146. IsBuildError:true,
  147. IsBuildQueue:false,
  148. });
  149. }
  150. else if (data=="-2"){
  151. that.setData({
  152. IsBuilding:false,
  153. IsBuildError:false,
  154. IsBuildQueue:true,
  155. });
  156. }
  157. else{
  158. console.log("生成1");
  159. if (that.data.IsNew){
  160. console.log("生成2");
  161. that.updateData(data.Content);
  162. that.updateReadCount(that.data.ID);
  163. }
  164. that.setData({
  165. IsBuilding:false,
  166. ID:data.ID,
  167. CreateTime:common.formatDateCHS(common.formatTime(new Date()),true),
  168. });
  169. }
  170. clearInterval(interval);
  171. }
  172. });
  173. that.getChoicenessArticle();
  174. },
  175. updateReadCount:function(id){
  176. if (id!="MAX")
  177. main.getData('UpdateYJBDCArticleReadCount?UserID=' + app.globalData.userInfo.UserID+'&ID='+id, function (data) {});
  178. },
  179. //得到精选文章
  180. getChoicenessArticle:function(){
  181. let that=this;
  182. main.getData('GetYJBDCArticleList?IsFine=1', function (data) {
  183. if (data) {
  184. that.setData({
  185. ChoicenessList:data,
  186. });
  187. }
  188. });
  189. },
  190. updateData:function(content){
  191. let that=this;
  192. //console.log(content);
  193. // 添加检查,确保 content 不是 undefined
  194. if (!content) {
  195. console.error('Content is undefined in updateData');
  196. return;
  197. }
  198. if (typeof content === 'string') {
  199. content = JSON.parse(content);
  200. }
  201. if (typeof content === 'string') {
  202. content = JSON.parse(content);
  203. }
  204. let hl = that.data.IsShowKeyword ? "highlight" : "nonelight";
  205. // 初始化ArticleEnglishArr数组
  206. content.ArticleEnglishArr = [];
  207. for(let i=0; i<content.ArticleEnglish.length; i++){
  208. // 确保每个句子末尾有空格,避免和下一句紧挨着
  209. let sentence = content.ArticleEnglish[i] + " ";
  210. // 替换所有单引号为双引号,包括对话中的单引号和句尾的单引号
  211. sentence = sentence.replace(/(^|[,.;:!?\s])'([^']+)'([,.;:!?]|\s|$)/g, '$1"$2"$3');
  212. // 处理常见的带点缩写,将其中的点替换为特殊标记,以防止被分割
  213. // 1. 称谓缩写
  214. sentence = sentence.replace(/\b(Dr|Mr|Mrs|Ms|Prof)\./g, '$1@DOT@');
  215. // 2. 时间缩写
  216. sentence = sentence.replace(/\b([ap])\.m\./gi, '$1@DOT@m@DOT@');
  217. // 3. 学位缩写
  218. sentence = sentence.replace(/\b(B|M|Ph)\.([A-Z])\./gi, '$1@DOT@$2@DOT@');
  219. // 4. 公司名称缩写
  220. sentence = sentence.replace(/\b(Inc|Ltd|Co|Corp)\./g, '$1@DOT@');
  221. // 5. 拉丁缩写
  222. sentence = sentence.replace(/\b(e\.g|i\.e|etc|et al|vs)\./g, '$1@DOT@');
  223. // 6. 军衔缩写
  224. sentence = sentence.replace(/\b(Lt|Col|Gen|Sgt|Capt)\./g, '$1@DOT@');
  225. // 7. 地理缩写
  226. sentence = sentence.replace(/\b(St|Ave|Rd|Blvd)\./g, '$1@DOT@');
  227. // 8. 其他常见缩写
  228. sentence = sentence.replace(/\b(U\.S|U\.K|U\.N)\./g, '$1@DOT@');
  229. // 先处理破折号,在破折号前后添加空格,使其成为独立元素
  230. sentence = sentence.replace(/([^\s])([—\-–—])([^\s])/g, '$1 $2 $3');
  231. // 将句子按空格分割成单词数组
  232. let words = sentence.trim().split(/\s+/);
  233. let wordObjects = [];
  234. // 处理每个单词,检查是否需要高亮
  235. for(let j=0; j<words.length; j++){
  236. let word = words[j];
  237. // 检查是否是单独的破折号
  238. let isDash = /^[—\-–—]$/.test(word);
  239. let originalWord = word.replace(/[.,!?;:"'()—\-–—_]/g, ''); // 去除标点符号和特殊字符(包括各种破折号)
  240. let isHighlighted = false;
  241. // 检查单词是否在需要高亮的列表中
  242. for(let k=0; k<content.FormsOfWords.length; k++){
  243. if(originalWord.toLowerCase() === content.FormsOfWords[k].toLowerCase()){
  244. isHighlighted = true;
  245. break;
  246. }
  247. }
  248. // 添加单词对象到数组
  249. wordObjects.push({
  250. Sentence: word,
  251. CSS: isHighlighted ? hl : "",
  252. OriginalWord: originalWord
  253. });
  254. }
  255. // 将单词数组添加到ArticleEnglishArr
  256. content.ArticleEnglishArr.push(wordObjects);
  257. }
  258. for(let i=0;i<content.Question.length;i++){
  259. //console.log("i:"+i);
  260. for(let j=0;j<content.Question[i].OptionsEnglish.length;j++){
  261. content.Question[i].OptionsEnglish[j] = content.Question[i].OptionsEnglish[j].replace(/(^|[,.]\s+)'([^']+)'/g, '$1"$2"');
  262. if (j<4){//选项不能超过4个
  263. let str=content.Question[i].OptionsChinese[j];
  264. content.Question[i].OptionsChinese[j]=str.substr(2);
  265. }
  266. }
  267. let char = content.Question[i].Answer;
  268. let asciiCode = char.charCodeAt(0);
  269. content.Question[i].AnswerNumber=asciiCode-65;
  270. content.Question[i].IsShowAnswer=false;
  271. }
  272. // 在设置数据前,确保所有@DOT@都被替换回.
  273. that.replaceAllDOTMarkers(content);
  274. that.setData({
  275. Content:content,
  276. });
  277. },
  278. setTheme:function(){
  279. let that=this;
  280. const css=Theme[that.data.IsShowLightColor?1:0];
  281. wx.setNavigationBarColor({
  282. frontColor: css.frontColor,
  283. backgroundColor: css.backgroundColor,
  284. });
  285. wx.setBackgroundColor({
  286. backgroundColor: css.backgroundColor,
  287. backgroundColorTop:css.backgroundColor,
  288. backgroundColorBottom:css.backgroundColor,
  289. });
  290. that.setData({
  291. ThemeCSS:css.Name,
  292. });
  293. wx.setStorageSync('IsShowLightColor', that.data.IsShowLightColor);
  294. },
  295. selectedAnswer:function(e){
  296. let that=this;
  297. const question=e.currentTarget.dataset.question;
  298. const index=e.currentTarget.dataset.index;
  299. if (that.data.Content.Question[question].UserAnswer==index)
  300. that.data.Content.Question[question].UserAnswer=-1;
  301. else
  302. that.data.Content.Question[question].UserAnswer=index;
  303. that.setData({
  304. Content:that.data.Content,
  305. });
  306. },
  307. showData:function(e){
  308. let that=this;
  309. let name=e.currentTarget.dataset.name;
  310. this.data[name] = !this.data[name];
  311. this.setData(this.data);
  312. if (name=="IsShowKeyword"){
  313. that.setShowKeyword();
  314. }
  315. else if (name=="IsShowLightColor"){
  316. that.setTheme();
  317. }
  318. else if (name=="IsShowAnswer"){
  319. let index=e.currentTarget.dataset.index;
  320. let content=that.data.Content;
  321. content.Question[index].IsShowAnswer=!content.Question[index].IsShowAnswer;
  322. that.setData({
  323. Content:content,
  324. });
  325. }
  326. else if (name=="IsShowQuestion"){
  327. main.showGuideContainer(that,"#panelArticle",38,30,"pic_ha08",196,279);
  328. }
  329. },
  330. setShowKeyword:function(){
  331. let that=this;
  332. let content=that.data.Content;
  333. let source="highlight",target="nonelight";
  334. if (that.data["IsShowKeyword"]){
  335. source="nonelight";
  336. target="highlight";
  337. }
  338. for(let i=0;i<content.ArticleEnglishArr.length;i++){
  339. let obj=content.ArticleEnglishArr[i];
  340. let arr=[];
  341. for(let j=0;j<obj.length;j++){
  342. if (obj[j].CSS==source)
  343. obj[j].CSS=target;
  344. }
  345. }
  346. for(let i=0;i<content.ArticleEnglish.length;i++){
  347. content.ArticleEnglish[i]=common.ReplaceAllString(content.ArticleEnglish[i],source,target);
  348. }
  349. that.setData({
  350. Content:content,
  351. });
  352. wx.setStorageSync('IsShowKeyword', that.data.IsShowKeyword);
  353. },
  354. nextQuestion:function(e){
  355. if (this.data.CurrentQuestionIndex+1<this.data.Content.Question.length){
  356. this.data.CurrentQuestionIndex=this.data.CurrentQuestionIndex+1;
  357. this.setData({
  358. CurrentQuestionIndex:this.data.CurrentQuestionIndex,
  359. });
  360. }
  361. },
  362. updateQuestionIndex:function(e){
  363. this.setData({
  364. CurrentQuestionIndex:e.detail.current,
  365. });
  366. console.log(e.detail.current);
  367. },
  368. //生成PDF文件
  369. //访问服务器的GeneratePDF接口,提交this.data.Content数据,获得一个生成好的pdf文件,服务端的代码已经生成好
  370. generatePDF: function(e) {
  371. let that = this;
  372. //debugger;
  373. that.data.Content.Words=that.data.Words;
  374. that.data.Content.Level=that.data.Level;
  375. that.data.Content.ArticleStyle=that.data.ArticleStyle;
  376. that.data.Content.CreateTime=that.data.CreateTime;
  377. let url = common.Encrypt("GeneratePDF");
  378. url =app.globalData.serverUrl + url;
  379. wx.request({
  380. url: url,
  381. method: "POST",
  382. data: {
  383. Content: that.data.Content,
  384. },
  385. responseType: 'arraybuffer', // 确保响应类型为arraybuffer
  386. success: function(res) {
  387. // 将arraybuffer转为临时文件
  388. const fsm = wx.getFileSystemManager();
  389. let time=common.formatTime(new Date(),"-");
  390. time=common.ReplaceAllString(time,"-","");
  391. time=common.ReplaceAllString(time,":","");
  392. time=common.ReplaceAllString(time," ","_");
  393. time=time.substring(2,time.length-2);
  394. const tempFilePath = `${wx.env.USER_DATA_PATH}/语境背单词_${time}.pdf`;
  395. try {
  396. fsm.writeFileSync(
  397. tempFilePath,
  398. res.data,
  399. 'binary'
  400. );
  401. // 直接使用临时文件路径,不再尝试永久保存
  402. console.log('文件已生成:', tempFilePath);
  403. // 打开PDF文件预览
  404. wx.openDocument({
  405. filePath: tempFilePath,
  406. fileType: 'pdf',
  407. showMenu: true, // 显示右上角菜单,可以分享
  408. success: function() {
  409. },
  410. fail: function(error) {
  411. console.error('打开文档失败:', error);
  412. wx.showToast({
  413. title: '打开文件失败',
  414. icon: 'none'
  415. });
  416. }
  417. });
  418. } catch (error) {
  419. console.error('写入文件失败:', error);
  420. wx.showToast({
  421. title: '写入文件失败',
  422. icon: 'none'
  423. });
  424. }
  425. },
  426. fail: function(err) {
  427. console.error('请求GeneratePDF接口失败:', err);
  428. wx.showToast({
  429. title: '网络错误,请稍候重试',
  430. icon: 'none'
  431. });
  432. }
  433. });
  434. },
  435. // 处理导航栏返回按钮点击事件
  436. onUnload: function() {
  437. if (this.data.IsNew || this.data.OpenType=="Guide"){
  438. wx.removeStorageSync('IsShowGuideContainer');
  439. app.globalData.SelectedWords=[];
  440. wx.navigateBack({
  441. delta: 1,
  442. });
  443. //判断用户是否离开
  444. this.setData({
  445. IsNew:false,
  446. });
  447. }
  448. this.setData({
  449. IsBuildQueue:false,
  450. });
  451. },
  452. onLongPress: function(e) {
  453. let that = this;
  454. let strType=e.currentTarget.dataset.strtype;
  455. let selectedIndex=e.currentTarget.dataset.index;
  456. let selectedIndex2=e.currentTarget.dataset.index2;
  457. let engSentence,chnSentence;
  458. if (strType=="article"){
  459. //console.log("选中的句子索引:", selectedIndex);
  460. //console.log("选中的句子:", that.data.Content.ArticleEnglish[selectedIndex]);
  461. engSentence=that.data.Content.ArticleEnglish[selectedIndex];
  462. chnSentence=that.data.Content.ArticleChinese[selectedIndex];
  463. }
  464. else if (strType=="question"){
  465. engSentence=that.data.Content.Question[selectedIndex].QuestionEnglish;
  466. chnSentence=that.data.Content.Question[selectedIndex].QuestionChinese;
  467. }
  468. else if (strType=="option"){
  469. engSentence=that.data.Content.Question[selectedIndex].OptionsEnglish[selectedIndex2];
  470. chnSentence=that.data.Content.Question[selectedIndex].OptionsChinese[selectedIndex2];
  471. }
  472. this.setData({
  473. EnglishSentence:engSentence,
  474. ChineseSentence:chnSentence,
  475. IsShowWordTranslate:true,
  476. TranslateHeight:240,
  477. });
  478. },
  479. selectWord:function(e){
  480. let that=this;
  481. let css=e.currentTarget.dataset.css;
  482. let word=e.currentTarget.dataset.word;
  483. let originalWord=e.currentTarget.dataset.originalWord || word;
  484. console.log("点击的单词:", originalWord);
  485. that.playAudio(originalWord);
  486. let b=false;
  487. if (css){
  488. let list=that.data.Content.FormsOfWords;
  489. for(let i=0;i<list.length;i++){
  490. if(list[i].toLowerCase() == originalWord.toLowerCase() && that.data.Content.FormsOfWordsChinese && that.data.Content.FormsOfWordsChinese[i]){
  491. let wordChinese=that.data.Content.FormsOfWordsChinese[i];
  492. // 直接更新翻译内容,不改变IsShowWordTranslate状态(如果已经是true)
  493. let updateData = {
  494. EnglishSentence: originalWord,
  495. ChineseSentence: wordChinese,
  496. };
  497. //debugger;
  498. // 只有当当前不显示翻译时,才设置IsShowWordTranslate为true
  499. if (!that.data.IsShowWordTranslate) {
  500. updateData.IsShowWordTranslate = true;
  501. }
  502. updateData.TranslateHeight=100;
  503. that.setData(updateData);
  504. b=true;
  505. break;
  506. }
  507. }
  508. }
  509. if (!b){
  510. that.getWordChinese(originalWord,function(wordTarget){
  511. // 准备更新数据
  512. let updateData = {};
  513. updateData.TranslateHeight=100;
  514. if (wordTarget){
  515. updateData.EnglishSentence = wordTarget.Word;
  516. updateData.ChineseSentence = wordTarget.Translate;
  517. }
  518. else{
  519. updateData.EnglishSentence = originalWord;
  520. updateData.ChineseSentence = "";
  521. }
  522. // 只有当当前不显示翻译时,才设置IsShowWordTranslate为true
  523. if (!that.data.IsShowWordTranslate) {
  524. updateData.IsShowWordTranslate = true;
  525. }
  526. that.setData(updateData);
  527. });
  528. }
  529. that.setData({
  530. IsCollect:false,
  531. });
  532. app.globalData.UserCollect.filter(function (item) {
  533. if (item.Word==originalWord){
  534. that.setData({
  535. IsCollect:true,
  536. });
  537. }
  538. });
  539. },
  540. getWordChinese:function(word,callback){
  541. let that=this;
  542. main.getData('GetWordChinese?UserID=' + app.globalData.userInfo.UserID+'&Word='+word+'&Level='+that.data.Level, function (data) {
  543. if (data) {
  544. callback(data);
  545. }
  546. else
  547. callback();
  548. });
  549. },
  550. saveUserCollect:function(e){
  551. let that=this;
  552. let word=e.currentTarget.dataset.word;
  553. main.getData('AddOrDeleteYJBDCUserCollect?UserID='+app.globalData.userInfo.UserID+'&Word='+word, function (data) {
  554. that.setData({
  555. IsCollect:!that.data.IsCollect,
  556. });
  557. app.globalData.UserCollect=data;
  558. });
  559. },
  560. playAudio: function (word) {
  561. var url = app.globalData.audioUrlBaidu;
  562. url = url.replace("[token]", app.globalData.BaiduToken);
  563. url = url.replace("[word]", word);
  564. this.audioCtx.setSrc(url);
  565. this.audioCtx.play();
  566. },
  567. hideWordTranslate: function() {
  568. console.log("IsShowWordTranslate:false");
  569. // 点击空白处时隐藏单词翻译
  570. this.setData({
  571. IsShowWordTranslate: false
  572. });
  573. },
  574. goto: function (e) {
  575. let that=this;
  576. var url=e.currentTarget.dataset.url;
  577. wx.navigateTo({
  578. url: url,
  579. });
  580. },
  581. // 替换Content对象中所有的@DOT@标记为.
  582. replaceAllDOTMarkers: function(obj) {
  583. if (!obj) return;
  584. // 如果是字符串,直接替换
  585. if (typeof obj === 'string') {
  586. return obj.replace(/@DOT@/g, '.');
  587. }
  588. // 如果是数组,递归处理每个元素
  589. if (Array.isArray(obj)) {
  590. for (let i = 0; i < obj.length; i++) {
  591. if (typeof obj[i] === 'string') {
  592. obj[i] = obj[i].replace(/@DOT@/g, '.');
  593. } else if (typeof obj[i] === 'object' && obj[i] !== null) {
  594. this.replaceAllDOTMarkers(obj[i]);
  595. }
  596. }
  597. return;
  598. }
  599. // 如果是对象,递归处理每个属性
  600. if (typeof obj === 'object') {
  601. for (let key in obj) {
  602. if (obj.hasOwnProperty(key)) {
  603. if (typeof obj[key] === 'string') {
  604. obj[key] = obj[key].replace(/@DOT@/g, '.');
  605. } else if (typeof obj[key] === 'object' && obj[key] !== null) {
  606. this.replaceAllDOTMarkers(obj[key]);
  607. }
  608. }
  609. }
  610. }
  611. },
  612. catchTouchMove: main.catchTouchMove,
  613. onShareAppMessage: function () {
  614. return {
  615. title: app.globalData.ShareTitle,
  616. path: app.globalData.SharePath + '?goto=article&ID='+this.data.ID+'&UserID=' + app.globalData.userInfo.UserID,
  617. }
  618. },
  619. })