default.js 3.7 KB

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