default.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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) {
  69. var url = '';
  70. if (app.globalData.LessonID==="all"){
  71. url = '../other/lessonlist';
  72. }
  73. else if (app.globalData.LessonID > 0){
  74. url='../other/lesson?LessonID=' + app.globalData.LessonID + '&LessonPage=' + app.globalData.LessonPage
  75. }
  76. wx.navigateTo({
  77. url: url,
  78. });
  79. }
  80. if (app.globalData.userInfo.IsMember && app.globalData.Marketing==1) {
  81. var url = '../../marketing/main/index';
  82. wx.navigateTo({
  83. url: url,
  84. });
  85. }
  86. that.setData({
  87. IsAccredit: true,
  88. });
  89. common.getStorageValue(that, "UserName", "秒过", function () {
  90. wx.setNavigationBarTitle({
  91. title: that.data.UserName
  92. });
  93. });
  94. that.init();
  95. that.getTaskTodayList();
  96. that.isNoSavedCard();
  97. }
  98. else {
  99. wx.navigateTo({
  100. url: '../index/accredit',
  101. });
  102. }
  103. if (res.authSetting['scope.record'] === true) {
  104. app.globalData.IsRecorderAccredit = 1;
  105. }
  106. else if (res.authSetting['scope.record'] === false) {
  107. app.globalData.IsRecorderAccredit = -1;
  108. }
  109. }
  110. });
  111. },
  112. init:function(){
  113. //题卡主题色
  114. var arrColorIndex = wx.getStorageSync("ColorIndexArr");
  115. if (!arrColorIndex) {
  116. app.globalData.ColorIndex = common.random(1,4);
  117. }
  118. else {
  119. app.globalData.ColorIndex = arrColorIndex[common.random(0, arrColorIndex.length - 1)];
  120. }
  121. //显示答案操作方式
  122. var clickType = wx.getStorageSync("ClickType");
  123. if (!clickType)
  124. clickType = 0;
  125. app.globalData.ClickType=clickType;
  126. //选择建议
  127. var SecondConfigArray = wx.getStorageSync("SecondConfigArray");
  128. if (SecondConfigArray)
  129. app.globalData.SecondConfigArray = SecondConfigArray;
  130. },
  131. goto: function (e) {
  132. var url = e.currentTarget.dataset.url;
  133. wx.navigateTo({
  134. url: url,
  135. })
  136. },
  137. //得到当天任务
  138. getTaskTodayList: function () {
  139. var that=this;
  140. main.UpdateMiaoguoCardTodayAll(true, function () {
  141. main.getTaskTodayList(function (data) {
  142. var TodayTaskNumber = data.ListNew.length + data.ListReview.length + data.ListHistory.length;
  143. that.setData({
  144. DayNumber: data.DayNumber,
  145. TodayTaskNumber: TodayTaskNumber,
  146. IsStart: data.IsStart,
  147. });
  148. });
  149. });
  150. },
  151. isNoSavedCard:function(){
  152. var that=this;
  153. //判断是否有未保存的卡
  154. if (wx.getStorageSync("TempCardNoSaved")) {
  155. that.setData({
  156. IsTempCardNoSaved: true,
  157. });
  158. wx.setNavigationBarColor({
  159. frontColor: "#ffffff",
  160. backgroundColor: "#0B8457",
  161. })
  162. }
  163. else{
  164. that.setData({
  165. IsTempCardNoSaved: false,
  166. });
  167. wx.setNavigationBarColor({
  168. frontColor: "#ffffff",
  169. backgroundColor: "#3157BA",
  170. });
  171. }
  172. },
  173. onOpenTempCard:function(){
  174. var card = wx.getStorageSync("TempCardNoSaved");
  175. app.globalData.CardList=[card];
  176. wx.navigateTo({
  177. url: './add?type=add2&id='+card.MiaoguoCardID,
  178. });
  179. },
  180. onGiveupTempCard:function(){
  181. var that=this;
  182. wx.removeStorageSync("TempCardNoSaved");
  183. that.isNoSavedCard();
  184. },
  185. onShareAppMessage: function () {
  186. return {
  187. title: app.globalData.ShareTitle,
  188. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  189. imageUrl: app.globalData.ShareImage,
  190. }
  191. },
  192. })