default.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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 (app.globalData.IsIPad){
  24. that.setData({
  25. IsIPad: "_iPad",
  26. });
  27. if (app.globalData.systemInfo.windowHeight < app.globalData.systemInfo.windowWidth){
  28. that.setData({
  29. IsExit:true,
  30. });
  31. }
  32. }
  33. },
  34. onShow: function () {
  35. var that = this;
  36. wx.getSetting({
  37. success(res) {
  38. if (res.authSetting['scope.userInfo']) {
  39. if (!app.globalData.userInfo.IsMember && app.globalData.userInfo.IsShow == 1){
  40. if (app.globalData.userInfo.Subscribe == 1) {
  41. wx.navigateTo({
  42. url: '../other/userbook',
  43. });
  44. app.globalData.GotoUrl = "";
  45. }
  46. else{
  47. wx.redirectTo({
  48. url: '../other/newuser',
  49. });
  50. }
  51. }
  52. else if (app.globalData.userInfo.IsMember && app.globalData.userInfo.IsShow == 1){
  53. var productServiceTime = common.formatDateCHS(common.formatTime(new Date(app.globalData.userInfo.ProductServiceTime)));
  54. var today = common.formatDateCHS(common.formatTime(new Date()));
  55. if (productServiceTime < today) {
  56. wx.redirectTo({
  57. url: '../other/userbook',
  58. });
  59. }
  60. else if (app.globalData.userInfo.ClassDayNumber<0){
  61. wx.redirectTo({
  62. url: '../other/userbook',
  63. });
  64. }
  65. else if (app.globalData.GotoUrl) {
  66. //console.log(app.globalData.GotoUrl);
  67. wx.navigateTo({
  68. url: app.globalData.GotoUrl,
  69. });
  70. app.globalData.GotoUrl="";
  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. isNoSavedCard:function(){
  139. var that=this;
  140. //判断是否有未保存的卡
  141. if (wx.getStorageSync("TempCardNoSaved")) {
  142. that.setData({
  143. IsTempCardNoSaved: true,
  144. });
  145. wx.setNavigationBarColor({
  146. frontColor: "#ffffff",
  147. backgroundColor: "#0B8457",
  148. })
  149. }
  150. else{
  151. that.setData({
  152. IsTempCardNoSaved: false,
  153. });
  154. wx.setNavigationBarColor({
  155. frontColor: "#ffffff",
  156. backgroundColor: "#3157BA",
  157. });
  158. }
  159. },
  160. onOpenTempCard:function(){
  161. var card = wx.getStorageSync("TempCardNoSaved");
  162. app.globalData.CardList=[card];
  163. wx.navigateTo({
  164. url: './add?type=add2&id='+card.MiaoguoCardID,
  165. });
  166. },
  167. onGiveupTempCard:function(){
  168. var that=this;
  169. wx.removeStorageSync("TempCardNoSaved");
  170. that.isNoSavedCard();
  171. },
  172. onShareAppMessage: function () {
  173. return {
  174. title: app.globalData.ShareTitle,
  175. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  176. imageUrl: app.globalData.ShareImage,
  177. }
  178. },
  179. })