default.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. Page({
  5. data: {
  6. IsTempCardNoSaved:false,
  7. IsExit:false,
  8. DayNumber: 0,
  9. TodayTaskNumber: 1,
  10. IsStart: 1,
  11. },
  12. onPullDownRefresh: function () {
  13. wx.redirectTo({
  14. url: '../main/default',
  15. })
  16. wx.stopPullDownRefresh();
  17. },
  18. onLoad: function (options) {
  19. var that = this;
  20. that.setData({
  21. Containnerheight: main.getWindowHeight(),
  22. });
  23. if (options.Share==1){
  24. var id = options.MiaoguoCardID;
  25. wx.navigateTo({
  26. url: './preview?type=share&id=' + id,
  27. });
  28. }
  29. if (app.globalData.IsIPad){
  30. that.setData({
  31. IsIPad: "_iPad",
  32. });
  33. if (app.globalData.systemInfo.windowHeight < app.globalData.systemInfo.windowWidth){
  34. that.setData({
  35. IsExit:true,
  36. });
  37. }
  38. }
  39. },
  40. onShow: function () {
  41. var that = this;
  42. wx.getSetting({
  43. success(res) {
  44. if (res.authSetting['scope.userInfo']) {
  45. if (!app.globalData.userInfo.IsMember && app.globalData.userInfo.IsShow == 1){
  46. wx.redirectTo({
  47. url: '../other/pay?paypanel=0&payindex=1',
  48. });
  49. }
  50. else if (app.globalData.userInfo.IsMember && app.globalData.userInfo.IsShow == 1){
  51. var productServiceTime = common.formatDateCHS(common.formatTime(new Date(app.globalData.userInfo.ProductServiceTime)));
  52. var today = common.formatDateCHS(common.formatTime(new Date()));
  53. if (productServiceTime < today) {
  54. wx.redirectTo({
  55. url: '../other/pay?paypanel=3&payindex=4',
  56. });
  57. }
  58. }
  59. if (app.globalData.userInfo.IsMember && app.globalData.Homework == 1) {
  60. wx.navigateTo({
  61. url: '../other/homework',
  62. });
  63. }
  64. if (app.globalData.userInfo.IsMember && app.globalData.LessonID && app.globalData.LessonID>0) {
  65. wx.navigateTo({
  66. url: '../other/lesson?LessonID=' + app.globalData.LessonID +'&LessonPage='+app.globalData.LessonPage,
  67. });
  68. }
  69. that.setData({
  70. IsAccredit: true,
  71. });
  72. common.getStorageValue(that, "UserName", "秒过", function () {
  73. wx.setNavigationBarTitle({
  74. title: that.data.UserName
  75. });
  76. });
  77. that.init();
  78. that.getTaskTodayList();
  79. that.isNoSavedCard();
  80. }
  81. else {
  82. wx.navigateTo({
  83. url: '../index/accredit',
  84. });
  85. }
  86. }
  87. });
  88. },
  89. init:function(){
  90. //题卡主题色
  91. var arrColorIndex = wx.getStorageSync("ColorIndexArr");
  92. if (!arrColorIndex) {
  93. app.globalData.ColorIndex = common.random(1,4);
  94. }
  95. else {
  96. app.globalData.ColorIndex = arrColorIndex[common.random(0, arrColorIndex.length - 1)];
  97. }
  98. //显示答案操作方式
  99. var clickType = wx.getStorageSync("ClickType");
  100. if (!clickType)
  101. clickType = 0;
  102. app.globalData.ClickType=clickType;
  103. //选择建议
  104. var SecondConfigArray = wx.getStorageSync("SecondConfigArray");
  105. if (SecondConfigArray)
  106. app.globalData.SecondConfigArray = SecondConfigArray;
  107. },
  108. goto: function (e) {
  109. var url = e.currentTarget.dataset.url;
  110. wx.navigateTo({
  111. url: './' + url,
  112. })
  113. },
  114. //得到当天任务
  115. getTaskTodayList: function () {
  116. var that=this;
  117. main.UpdateMiaoguoCardTodayAll(true, function () {
  118. main.getTaskTodayList(function (data) {
  119. var TodayTaskNumber = data.ListNew.length + data.ListReview.length + data.ListHistory.length;
  120. that.setData({
  121. DayNumber: data.DayNumber,
  122. TodayTaskNumber: TodayTaskNumber,
  123. IsStart: data.IsStart,
  124. });
  125. });
  126. });
  127. },
  128. gotoCard: function () {
  129. wx.redirectTo({
  130. url: './searchCard',
  131. })
  132. },
  133. isNoSavedCard:function(){
  134. var that=this;
  135. //判断是否有未保存的卡
  136. if (wx.getStorageSync("TempCardNoSaved")) {
  137. that.setData({
  138. IsTempCardNoSaved: true,
  139. });
  140. wx.setNavigationBarColor({
  141. frontColor: "#ffffff",
  142. backgroundColor: "#0B8457",
  143. })
  144. }
  145. else{
  146. that.setData({
  147. IsTempCardNoSaved: false,
  148. });
  149. wx.setNavigationBarColor({
  150. frontColor: "#ffffff",
  151. backgroundColor: "#3157BA",
  152. });
  153. }
  154. },
  155. onOpenTempCard:function(){
  156. var card = wx.getStorageSync("TempCardNoSaved");
  157. app.globalData.CardList=[card];
  158. wx.navigateTo({
  159. url: './add?type=add2&id='+card.MiaoguoCardID,
  160. });
  161. },
  162. onGiveupTempCard:function(){
  163. var that=this;
  164. wx.removeStorageSync("TempCardNoSaved");
  165. that.isNoSavedCard();
  166. },
  167. onShareAppMessage: function () {
  168. return {
  169. title: app.globalData.ShareTitle,
  170. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  171. imageUrl: app.globalData.ShareImage,
  172. }
  173. },
  174. })