index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 app = getApp();
  6. Page({
  7. behaviors: [commonBehavior],
  8. data: {
  9. IsShowRemind:false,
  10. remindAnimation: "",
  11. IsIPhoneX:app.globalData.IsIPhoneX,
  12. },
  13. onLoad: function (options) {
  14. let that = this;
  15. that.setData({
  16. Containnerheight: main.getWindowHeight(),
  17. Version:app.globalData.Version,
  18. });
  19. that.initMenu();
  20. // setTimeout(function(){
  21. // if (!app.globalData.IsProduction){
  22. // wx.navigateTo({
  23. // url: 'articlefine',
  24. // })
  25. // }
  26. // },1000);
  27. if (app.globalData.goto){
  28. wx.navigateTo({
  29. url: app.globalData.goto,
  30. });
  31. }
  32. if (app.globalData.systemInfo.windowHeight>700){
  33. that.setData({
  34. CanScrollCSS: "panelTop1",
  35. });
  36. }
  37. that.getBaiduToken();
  38. },
  39. onShow:function(){
  40. this.getData();
  41. main.checkGenerating();
  42. if (wx.getStorageSync('IsShowGuideContainer')){
  43. this.initGuide();
  44. }
  45. else{
  46. this.setData({
  47. IsShowGuideContainer:false,
  48. })
  49. }
  50. if (app.globalData.goto){
  51. app.globalData.goto="";
  52. }
  53. else{
  54. app.globalData.OCRWords=[];
  55. }
  56. },
  57. goto: function (e) {
  58. let that=this;
  59. var url=e.currentTarget.dataset.url;
  60. if (url=="wordsinput"){
  61. if (that.data.TodayCount>that.data.MaxCount){
  62. animation.toggleRemindWithAnimation(that);
  63. return ;
  64. }
  65. }
  66. if (url=="articlefine"){
  67. wx.redirectTo({
  68. url: url,
  69. });
  70. }
  71. else{
  72. wx.navigateTo({
  73. url: url,
  74. });
  75. }
  76. that.setData({
  77. IsShowRemind:false,
  78. })
  79. },
  80. getData:function(){
  81. let that=this;
  82. main.getData('GetYJBDCArticleList?UserID=' + app.globalData.userInfo.UserID+'&IsTodayCount=1', function (data) {
  83. if (data) {
  84. that.setData({
  85. TodayCount:data.TodayCount,
  86. MaxCount:data.MaxCount,
  87. UnReadCount:data.UnReadCount,
  88. });
  89. }
  90. });
  91. },
  92. showRemind:function(){
  93. animation.toggleRemindWithAnimation(this);
  94. },
  95. initGuide:function(){
  96. let that=this;
  97. that.setData({
  98. IsShowGuideContainer:true,
  99. });
  100. main.showGuideContainer(that,"#txtWordsInput",-5,60,"pic_ha01",196,126);
  101. wx.setStorageSync('IsShowGuideContainer', true);
  102. },
  103. initMenu:function(){
  104. let that = this;
  105. main.getData('GetYJBDCGenerateConfig?UserID=' + app.globalData.userInfo.UserID, function (data) {
  106. app.globalData.GenerateConfig=data;
  107. });
  108. },
  109. catchTouchMove: main.catchTouchMove,
  110. getBaiduToken: function () {
  111. var that = this;
  112. wx.login({
  113. success: function (res0) {
  114. main.getData('GetBaiduToken?ProgramID=' + app.globalData.ProgramID+"&Code="+res0.code, function (data) {
  115. if (data) {
  116. app.globalData.BaiduToken=data;
  117. //console.log("BD:"+data);
  118. }
  119. });
  120. },
  121. });
  122. },
  123. onShareAppMessage: function () {
  124. return {
  125. title: app.globalData.ShareTitle,
  126. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  127. imageUrl: app.globalData.ShareImage,
  128. }
  129. },
  130. })