default.js 5.6 KB

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