default.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. if (!app.globalData.userInfo.IsMember && app.globalData.userInfo.IsShow == 1) {
  38. if (app.globalData.userInfo.Subscribe == 0) {
  39. wx.redirectTo({
  40. url: '../other/newuser',
  41. });
  42. }
  43. }
  44. else {
  45. wx.getSetting({
  46. success(res) {
  47. if (res.authSetting['scope.userInfo'] || app.globalData.userInfo.IsShow == 0) {
  48. if (!app.globalData.userInfo.IsMember && app.globalData.userInfo.IsShow == 1) {
  49. if (app.globalData.userInfo.Subscribe == 1) {
  50. wx.navigateTo({
  51. url: '../other/userbook',
  52. });
  53. app.globalData.GotoUrl = "";
  54. }
  55. }
  56. else if (app.globalData.userInfo.IsMember && app.globalData.userInfo.IsShow == 1) {
  57. var productServiceTime = common.formatDateCHS(common.formatTime(new Date(app.globalData.userInfo.ProductServiceTime)));
  58. var today = common.formatDateCHS(common.formatTime(new Date()));
  59. if (productServiceTime < today) {
  60. wx.redirectTo({
  61. url: '../other/userbook',
  62. });
  63. }
  64. else if (app.globalData.userInfo.ClassDayNumber < 0) {
  65. wx.redirectTo({
  66. url: '../other/userbook',
  67. });
  68. }
  69. else if (app.globalData.GotoUrl) {
  70. //console.log(app.globalData.GotoUrl);
  71. wx.navigateTo({
  72. url: app.globalData.GotoUrl,
  73. });
  74. app.globalData.GotoUrl = "";
  75. }
  76. }
  77. else if (app.globalData.userInfo.IsShow == 0) {
  78. main.buildInitData(function () { });
  79. }
  80. that.setData({
  81. IsAccredit: true,
  82. });
  83. common.getStorageValue(that, "UserName", "秒过", function () {
  84. wx.setNavigationBarTitle({
  85. title: that.data.UserName
  86. });
  87. });
  88. //判断是否出现推广广告
  89. common.getStorageValue(that, "IsShowMarketing", app.globalData.userInfo.HasIntroducer, function () {
  90. if (app.globalData.userInfo.HasIntroducer == 0 && that.data.IsShowMarketing == 3) {
  91. var isShowMarketingTime = wx.getStorageSync("IsShowMarketingTime");
  92. if (common.formatTime(new Date()) >= isShowMarketingTime) {
  93. wx.removeStorageSync("IsShowMarketing");
  94. wx.removeStorageSync("IsShowMarketingTime");
  95. that.setData({
  96. IsShowMarketing: 0,
  97. });
  98. }
  99. }
  100. });
  101. that.init();
  102. that.getTaskTodayList();
  103. that.isNoSavedCard();
  104. }
  105. else {
  106. wx.navigateTo({
  107. url: '../index/accredit',
  108. });
  109. }
  110. if (res.authSetting['scope.record'] === true) {
  111. app.globalData.IsRecorderAccredit = 1;
  112. }
  113. else if (res.authSetting['scope.record'] === false) {
  114. app.globalData.IsRecorderAccredit = -1;
  115. }
  116. }
  117. });
  118. }
  119. wx.setNavigationBarColor({
  120. frontColor: "#ffffff",
  121. backgroundColor: "#3157BA",
  122. });
  123. },
  124. init:function(){
  125. //题卡主题色
  126. var arrColorIndex = wx.getStorageSync("ColorIndexArr");
  127. if (!arrColorIndex) {
  128. app.globalData.ColorIndex = common.random(1,4);
  129. }
  130. else {
  131. app.globalData.ColorIndex = arrColorIndex[common.random(0, arrColorIndex.length - 1)];
  132. }
  133. //显示答案操作方式
  134. var clickType = wx.getStorageSync("ClickType");
  135. if (!clickType)
  136. clickType = 0;
  137. app.globalData.ClickType=clickType;
  138. //显示命名方式
  139. var MemoryLevel = wx.getStorageSync("MemoryLevel");
  140. if (!MemoryLevel)
  141. MemoryLevel = 0;
  142. app.globalData.MemoryLevel = MemoryLevel;
  143. //选择建议
  144. var SecondConfigArray = wx.getStorageSync("SecondConfigArray");
  145. if (SecondConfigArray)
  146. app.globalData.SecondConfigArray = SecondConfigArray;
  147. },
  148. goto: function (e) {
  149. var url = e.currentTarget.dataset.url;
  150. wx.navigateTo({
  151. url: url,
  152. });
  153. if (url =="../../marketing/main/index"){
  154. this.setData({
  155. IsShowMarketing: 2,
  156. });
  157. wx.setStorageSync("IsShowMarketing", 2);
  158. }
  159. },
  160. //得到当天任务
  161. getTaskTodayList: function () {
  162. var that=this;
  163. main.UpdateMiaoguoCardTodayAll(true, function () {
  164. main.getTaskTodayList(function (data) {
  165. var TodayTaskNumber = data.ListNew.length + data.ListReview.length + data.ListHistory.length;
  166. that.setData({
  167. DayNumber: data.DayNumber,
  168. TodayTaskNumber: TodayTaskNumber,
  169. IsStart: data.IsStart,
  170. });
  171. });
  172. });
  173. },
  174. isNoSavedCard:function(){
  175. var that=this;
  176. //判断是否有未保存的卡
  177. if (wx.getStorageSync("TempCardNoSaved")) {
  178. that.setData({
  179. IsTempCardNoSaved: true,
  180. });
  181. wx.setNavigationBarColor({
  182. frontColor: "#ffffff",
  183. backgroundColor: "#0B8457",
  184. })
  185. }
  186. else{
  187. that.setData({
  188. IsTempCardNoSaved: false,
  189. });
  190. wx.setNavigationBarColor({
  191. frontColor: "#ffffff",
  192. backgroundColor: "#3157BA",
  193. });
  194. }
  195. },
  196. onOpenTempCard:function(){
  197. var card = wx.getStorageSync("TempCardNoSaved");
  198. app.globalData.CardList=[card];
  199. wx.navigateTo({
  200. url: './add?type=add2&id='+card.MiaoguoCardID,
  201. });
  202. },
  203. onGiveupTempCard:function(){
  204. var that=this;
  205. wx.removeStorageSync("TempCardNoSaved");
  206. that.isNoSavedCard();
  207. },
  208. gotoSearchCard:function(){
  209. wx.reLaunch({
  210. url: './searchCard',
  211. });
  212. },
  213. closeMarketing:function(){
  214. this.setData({
  215. IsShowMarketing:3,
  216. });
  217. wx.setStorageSync("IsShowMarketing", 3);
  218. wx.setStorageSync("IsShowMarketingTime", common.formatTime(common.addDate("d",7,new Date())));
  219. },
  220. onShareAppMessage: function () {
  221. return {
  222. title: app.globalData.ShareTitle,
  223. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  224. imageUrl: app.globalData.ShareImage,
  225. }
  226. },
  227. })