default.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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: '../index/notice',
  39. });
  40. }
  41. that.setData({
  42. IsAccredit: true,
  43. });
  44. common.getStorageValue(that, "UserName", "秒过", function () {
  45. wx.setNavigationBarTitle({
  46. title: that.data.UserName
  47. });
  48. });
  49. that.init();
  50. that.getTaskTodayList();
  51. that.isNoSavedCard();
  52. }
  53. else {
  54. wx.navigateTo({
  55. url: '../index/accredit',
  56. });
  57. }
  58. }
  59. });
  60. },
  61. init:function(){
  62. //题卡主题色
  63. var arrColorIndex = wx.getStorageSync("ColorIndexArr");
  64. if (!arrColorIndex) {
  65. app.globalData.ColorIndex = common.random(1,4);
  66. }
  67. else {
  68. app.globalData.ColorIndex = arrColorIndex[common.random(0, arrColorIndex.length - 1)];
  69. }
  70. //显示答案操作方式
  71. var clickType = wx.getStorageSync("ClickType");
  72. if (!clickType)
  73. clickType = 0;
  74. app.globalData.ClickType=clickType;
  75. //选择建议
  76. var SecondConfigArray = wx.getStorageSync("SecondConfigArray");
  77. if (SecondConfigArray)
  78. app.globalData.SecondConfigArray = SecondConfigArray;
  79. },
  80. goto: function (e) {
  81. var url = e.currentTarget.dataset.url;
  82. wx.navigateTo({
  83. url: './' + url,
  84. })
  85. },
  86. //得到当天任务
  87. getTaskTodayList: function () {
  88. var that=this;
  89. main.getTaskTodayList(function(data){
  90. var TodayTaskNumber = data.ListNew.length + data.ListReview.length + data.ListHistory.length;
  91. that.setData({
  92. List: data,
  93. DayNumber: data.DayNumber,
  94. TodayTaskNumber: TodayTaskNumber,
  95. IsStart: data.IsStart,
  96. });
  97. });
  98. },
  99. gotoCard: function () {
  100. wx.redirectTo({
  101. url: './searchCard',
  102. })
  103. },
  104. isNoSavedCard:function(){
  105. var that=this;
  106. //判断是否有未保存的卡
  107. if (wx.getStorageSync("TempCardNoSaved")) {
  108. that.setData({
  109. IsTempCardNoSaved: true,
  110. });
  111. wx.setNavigationBarColor({
  112. frontColor: "#ffffff",
  113. backgroundColor: "#0B8457",
  114. })
  115. }
  116. else{
  117. that.setData({
  118. IsTempCardNoSaved: false,
  119. });
  120. wx.setNavigationBarColor({
  121. frontColor: "#ffffff",
  122. backgroundColor: "#3157BA",
  123. });
  124. }
  125. },
  126. onOpenTempCard:function(){
  127. var card = wx.getStorageSync("TempCardNoSaved");
  128. app.globalData.CardList=[card];
  129. wx.navigateTo({
  130. url: './add?type=add2&id='+card.MiaoguoCardID,
  131. });
  132. },
  133. onGiveupTempCard:function(){
  134. var that=this;
  135. wx.removeStorageSync("TempCardNoSaved");
  136. that.isNoSavedCard();
  137. },
  138. onShareAppMessage: function () {
  139. return {
  140. title: app.globalData.ShareTitle,
  141. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  142. imageUrl: app.globalData.ShareImage,
  143. }
  144. },
  145. })