default.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. },
  9. onLoad: function (options) {
  10. var that = this;
  11. that.setData({
  12. Containnerheight: main.getWindowHeight(),
  13. });
  14. if (options.Share==1){
  15. var id = options.MiaoguoCardID;
  16. wx.navigateTo({
  17. url: './preview?type=share&id=' + id,
  18. });
  19. }
  20. if (app.globalData.IsIPad){
  21. that.setData({
  22. IsIPad: "_iPad",
  23. });
  24. if (app.globalData.systemInfo.windowHeight < app.globalData.systemInfo.windowWidth){
  25. that.setData({
  26. IsExit:true,
  27. });
  28. }
  29. }
  30. },
  31. onShow: function () {
  32. var that = this;
  33. wx.getSetting({
  34. success(res) {
  35. if (res.authSetting['scope.userInfo']) {
  36. if (!app.globalData.userInfo.IsMember && app.globalData.userInfo.IsShow == 1){
  37. wx.navigateTo({
  38. url: '../other/payinfo',
  39. });
  40. }
  41. if (app.globalData.userInfo.IsMember && app.globalData.LessonID && app.globalData.LessonID>0) {
  42. wx.navigateTo({
  43. url: '../other/lesson?id=' + app.globalData.LessonID,
  44. });
  45. }
  46. that.setData({
  47. IsAccredit: true,
  48. });
  49. common.getStorageValue(that, "UserName", "秒过", function () {
  50. wx.setNavigationBarTitle({
  51. title: that.data.UserName
  52. });
  53. });
  54. that.init();
  55. that.getTaskTodayList();
  56. that.isNoSavedCard();
  57. }
  58. else {
  59. wx.navigateTo({
  60. url: '../index/accredit',
  61. });
  62. }
  63. }
  64. });
  65. },
  66. init:function(){
  67. //题卡主题色
  68. var arrColorIndex = wx.getStorageSync("ColorIndexArr");
  69. if (!arrColorIndex) {
  70. app.globalData.ColorIndex = common.random(1,4);
  71. }
  72. else {
  73. app.globalData.ColorIndex = arrColorIndex[common.random(0, arrColorIndex.length - 1)];
  74. }
  75. //显示答案操作方式
  76. var clickType = wx.getStorageSync("ClickType");
  77. if (!clickType)
  78. clickType = 0;
  79. app.globalData.ClickType=clickType;
  80. //选择建议
  81. var SecondConfigArray = wx.getStorageSync("SecondConfigArray");
  82. if (SecondConfigArray)
  83. app.globalData.SecondConfigArray = SecondConfigArray;
  84. },
  85. goto: function (e) {
  86. var url = e.currentTarget.dataset.url;
  87. wx.navigateTo({
  88. url: './' + url,
  89. })
  90. },
  91. //得到当天任务
  92. getTaskTodayList: function () {
  93. var that=this;
  94. main.getTaskTodayList(function(data){
  95. var TodayTaskNumber = data.ListNew.length + data.ListReview.length + data.ListHistory.length;
  96. that.setData({
  97. List: data,
  98. DayNumber: data.DayNumber,
  99. TodayTaskNumber: TodayTaskNumber,
  100. IsStart: data.IsStart,
  101. });
  102. });
  103. },
  104. gotoCard: function () {
  105. wx.redirectTo({
  106. url: './searchCard',
  107. })
  108. },
  109. isNoSavedCard:function(){
  110. var that=this;
  111. //判断是否有未保存的卡
  112. if (wx.getStorageSync("TempCardNoSaved")) {
  113. that.setData({
  114. IsTempCardNoSaved: true,
  115. });
  116. wx.setNavigationBarColor({
  117. frontColor: "#ffffff",
  118. backgroundColor: "#0B8457",
  119. })
  120. }
  121. else{
  122. that.setData({
  123. IsTempCardNoSaved: false,
  124. });
  125. wx.setNavigationBarColor({
  126. frontColor: "#ffffff",
  127. backgroundColor: "#3157BA",
  128. });
  129. }
  130. },
  131. onOpenTempCard:function(){
  132. var card = wx.getStorageSync("TempCardNoSaved");
  133. app.globalData.CardList=[card];
  134. wx.navigateTo({
  135. url: './add?type=add2&id='+card.MiaoguoCardID,
  136. });
  137. },
  138. onGiveupTempCard:function(){
  139. var that=this;
  140. wx.removeStorageSync("TempCardNoSaved");
  141. that.isNoSavedCard();
  142. },
  143. onShareAppMessage: function () {
  144. return {
  145. title: app.globalData.ShareTitle,
  146. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  147. imageUrl: app.globalData.ShareImage,
  148. }
  149. },
  150. })