default.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. //判断是否出现推广广告
  86. common.getStorageValue(that, "IsShowMarketing", app.globalData.userInfo.HasIntroducer, function () {
  87. if (app.globalData.userInfo.HasIntroducer==0 && that.data.IsShowMarketing==3){
  88. var isShowMarketingTime = wx.getStorageSync("IsShowMarketingTime");
  89. if (common.formatTime(new Date()) >= isShowMarketingTime) {
  90. wx.removeStorageSync("IsShowMarketing");
  91. wx.removeStorageSync("IsShowMarketingTime");
  92. that.setData({
  93. IsShowMarketing:0,
  94. });
  95. }
  96. }
  97. });
  98. that.init();
  99. that.getTaskTodayList();
  100. that.isNoSavedCard();
  101. }
  102. else {
  103. wx.navigateTo({
  104. url: '../index/accredit',
  105. });
  106. }
  107. if (res.authSetting['scope.record'] === true) {
  108. app.globalData.IsRecorderAccredit = 1;
  109. }
  110. else if (res.authSetting['scope.record'] === false) {
  111. app.globalData.IsRecorderAccredit = -1;
  112. }
  113. }
  114. });
  115. wx.setNavigationBarColor({
  116. frontColor: "#ffffff",
  117. backgroundColor: "#3157BA",
  118. });
  119. },
  120. init:function(){
  121. //题卡主题色
  122. var arrColorIndex = wx.getStorageSync("ColorIndexArr");
  123. if (!arrColorIndex) {
  124. app.globalData.ColorIndex = common.random(1,4);
  125. }
  126. else {
  127. app.globalData.ColorIndex = arrColorIndex[common.random(0, arrColorIndex.length - 1)];
  128. }
  129. //显示答案操作方式
  130. var clickType = wx.getStorageSync("ClickType");
  131. if (!clickType)
  132. clickType = 0;
  133. app.globalData.ClickType=clickType;
  134. //显示命名方式
  135. var MemoryLevel = wx.getStorageSync("MemoryLevel");
  136. if (!MemoryLevel)
  137. MemoryLevel = 0;
  138. app.globalData.MemoryLevel = MemoryLevel;
  139. //选择建议
  140. var SecondConfigArray = wx.getStorageSync("SecondConfigArray");
  141. if (SecondConfigArray)
  142. app.globalData.SecondConfigArray = SecondConfigArray;
  143. },
  144. goto: function (e) {
  145. var url = e.currentTarget.dataset.url;
  146. wx.navigateTo({
  147. url: url,
  148. });
  149. if (url =="../../marketing/main/index"){
  150. this.setData({
  151. IsShowMarketing: 2,
  152. });
  153. wx.setStorageSync("IsShowMarketing", 2);
  154. }
  155. },
  156. //得到当天任务
  157. getTaskTodayList: function () {
  158. var that=this;
  159. main.UpdateMiaoguoCardTodayAll(true, function () {
  160. main.getTaskTodayList(function (data) {
  161. var TodayTaskNumber = data.ListNew.length + data.ListReview.length + data.ListHistory.length;
  162. that.setData({
  163. DayNumber: data.DayNumber,
  164. TodayTaskNumber: TodayTaskNumber,
  165. IsStart: data.IsStart,
  166. });
  167. });
  168. });
  169. },
  170. isNoSavedCard:function(){
  171. var that=this;
  172. //判断是否有未保存的卡
  173. if (wx.getStorageSync("TempCardNoSaved")) {
  174. that.setData({
  175. IsTempCardNoSaved: true,
  176. });
  177. wx.setNavigationBarColor({
  178. frontColor: "#ffffff",
  179. backgroundColor: "#0B8457",
  180. })
  181. }
  182. else{
  183. that.setData({
  184. IsTempCardNoSaved: false,
  185. });
  186. wx.setNavigationBarColor({
  187. frontColor: "#ffffff",
  188. backgroundColor: "#3157BA",
  189. });
  190. }
  191. },
  192. onOpenTempCard:function(){
  193. var card = wx.getStorageSync("TempCardNoSaved");
  194. app.globalData.CardList=[card];
  195. wx.navigateTo({
  196. url: './add?type=add2&id='+card.MiaoguoCardID,
  197. });
  198. },
  199. onGiveupTempCard:function(){
  200. var that=this;
  201. wx.removeStorageSync("TempCardNoSaved");
  202. that.isNoSavedCard();
  203. },
  204. gotoSearchCard:function(){
  205. wx.reLaunch({
  206. url: './searchCard',
  207. });
  208. },
  209. closeMarketing:function(){
  210. this.setData({
  211. IsShowMarketing:3,
  212. });
  213. wx.setStorageSync("IsShowMarketing", 3);
  214. wx.setStorageSync("IsShowMarketingTime", common.formatTime(common.addDate("d",7,new Date())));
  215. },
  216. onShareAppMessage: function () {
  217. return {
  218. title: app.globalData.ShareTitle,
  219. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  220. imageUrl: app.globalData.ShareImage,
  221. }
  222. },
  223. })