index.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. });
  17. that.initMenu();
  18. // setTimeout(function(){
  19. // if (!app.globalData.IsProduction){
  20. // wx.navigateTo({
  21. // url: '../../packageReader/main/index',
  22. // })
  23. // }
  24. // },1000);
  25. if (app.globalData.goto){
  26. wx.navigateTo({
  27. url: app.globalData.goto,
  28. });
  29. }
  30. if (app.globalData.systemInfo.windowHeight>700){
  31. that.setData({
  32. CanScrollCSS: "panelTop1",
  33. });
  34. }
  35. that.getBaiduToken();
  36. that.initUserCollect();
  37. },
  38. onShow:function(){
  39. app.globalData.SelectedWords=[];
  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 ((
  61. app.globalData.userInfo.UserID==1 ||
  62. app.globalData.userInfo.UserID==244 ||
  63. app.globalData.userInfo.UserID==1874
  64. )
  65. && url=="../../packageReader/main/index"){
  66. wx.redirectTo({
  67. url: url,
  68. });
  69. }
  70. if (url=="wordsinput"){
  71. if (that.data.TodayCount>that.data.MaxCount){
  72. animation.toggleRemindWithAnimation(that);
  73. return ;
  74. }
  75. }
  76. if (url=="articlefine" || url=="../../packageProduct/main/product"){
  77. wx.redirectTo({
  78. url: url,
  79. });
  80. }
  81. else{
  82. wx.navigateTo({
  83. url: url,
  84. });
  85. }
  86. that.setData({
  87. IsShowRemind:false,
  88. })
  89. },
  90. getData:function(){
  91. let that=this;
  92. main.getData('GetYJBDCArticleList?UserID=' + app.globalData.userInfo.UserID+'&IsTodayCount=1', function (data) {
  93. if (data) {
  94. that.setData({
  95. TodayCount:data.TodayCount,
  96. MaxCount:data.MaxCount,
  97. UnReadCount:data.UnReadCount,
  98. });
  99. app.globalData.UnReadCount=data.UnReadCount;
  100. }
  101. });
  102. },
  103. showRemind:function(){
  104. animation.toggleRemindWithAnimation(this);
  105. },
  106. initGuide:function(){
  107. let that=this;
  108. that.setData({
  109. IsShowGuideContainer:true,
  110. });
  111. main.showGuideContainer(that,"#txtWordsInput",-5,60,"pic_ha01",196,126);
  112. wx.setStorageSync('IsShowGuideContainer', true);
  113. },
  114. initMenu:function(){
  115. let that = this;
  116. main.getData('GetYJBDCGenerateConfig?UserID=' + app.globalData.userInfo.UserID, function (data) {
  117. app.globalData.GenerateConfig=data;
  118. });
  119. },
  120. initUserCollect:function(){
  121. let that = this;
  122. main.getData('GetYJBDCUserCollect?UserID=' + app.globalData.userInfo.UserID, function (data) {
  123. app.globalData.UserCollect=data;
  124. });
  125. },
  126. catchTouchMove: main.catchTouchMove,
  127. getBaiduToken: function () {
  128. var that = this;
  129. wx.login({
  130. success: function (res0) {
  131. main.getData('GetBaiduToken?ProgramID=' + app.globalData.ProgramID+"&Code="+res0.code, function (data) {
  132. if (data) {
  133. app.globalData.BaiduToken=data;
  134. //console.log("BD:"+data);
  135. }
  136. });
  137. },
  138. });
  139. },
  140. onShareAppMessage: function () {
  141. return {
  142. title: app.globalData.ShareTitle,
  143. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  144. imageUrl: app.globalData.ShareImage,
  145. }
  146. },
  147. })