index.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. IsIPhoneX:app.globalData.IsIPhoneX,
  11. },
  12. onLoad: function (options) {
  13. let that = this;
  14. that.setData({
  15. Containnerheight: main.getWindowHeight(),
  16. Version:app.globalData.Version,
  17. });
  18. that.initMenu();
  19. // setTimeout(function(){
  20. // if (!app.globalData.IsProduction){
  21. // wx.navigateTo({
  22. // url: 'articlefine',
  23. // })
  24. // }
  25. // },1000);
  26. if (app.globalData.goto){
  27. wx.navigateTo({
  28. url: app.globalData.goto,
  29. });
  30. }
  31. if (app.globalData.systemInfo.windowHeight>700){
  32. that.setData({
  33. CanScrollCSS: "panelTop1",
  34. });
  35. }
  36. that.getBaiduToken();
  37. that.initUserCollect();
  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. app.globalData.UnReadCount=data.UnReadCount;
  90. }
  91. });
  92. },
  93. showRemind:function(){
  94. animation.toggleRemindWithAnimation(this);
  95. },
  96. initGuide:function(){
  97. let that=this;
  98. that.setData({
  99. IsShowGuideContainer:true,
  100. });
  101. main.showGuideContainer(that,"#txtWordsInput",-5,60,"pic_ha01",196,126);
  102. wx.setStorageSync('IsShowGuideContainer', true);
  103. },
  104. initMenu:function(){
  105. let that = this;
  106. main.getData('GetYJBDCGenerateConfig?UserID=' + app.globalData.userInfo.UserID, function (data) {
  107. app.globalData.GenerateConfig=data;
  108. });
  109. },
  110. initUserCollect:function(){
  111. let that = this;
  112. main.getData('GetYJBDCUserCollect?UserID=' + app.globalData.userInfo.UserID, function (data) {
  113. app.globalData.UserCollect=data;
  114. });
  115. },
  116. catchTouchMove: main.catchTouchMove,
  117. getBaiduToken: function () {
  118. var that = this;
  119. wx.login({
  120. success: function (res0) {
  121. main.getData('GetBaiduToken?ProgramID=' + app.globalData.ProgramID+"&Code="+res0.code, function (data) {
  122. if (data) {
  123. app.globalData.BaiduToken=data;
  124. //console.log("BD:"+data);
  125. }
  126. });
  127. },
  128. });
  129. },
  130. onShareAppMessage: function () {
  131. return {
  132. title: app.globalData.ShareTitle,
  133. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  134. imageUrl: app.globalData.ShareImage,
  135. }
  136. },
  137. })