default.js 5.2 KB

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