default.js 5.3 KB

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