default.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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. IsMaintain:0,
  13. IsIPhoneX: app.globalData.IsIPhoneX,
  14. ImagePath: app.globalData.uploadImageUrl,
  15. },
  16. onPullDownRefresh: function () {
  17. wx.redirectTo({
  18. url: '../main/default',
  19. })
  20. wx.stopPullDownRefresh();
  21. },
  22. onLoad: function (options) {
  23. var that = this;
  24. that.setData({
  25. Containnerheight: main.getWindowHeight(),
  26. });
  27. if (app.globalData.IsIPad){
  28. that.setData({
  29. IsIPad: "_iPad",
  30. });
  31. if (app.globalData.systemInfo.windowHeight < app.globalData.systemInfo.windowWidth){
  32. that.setData({
  33. IsExit:true,
  34. });
  35. }
  36. }
  37. this.checkMemory();
  38. },
  39. onHide:function(){
  40. wx.hideLoading();
  41. },
  42. onShow: function () {
  43. var that = this;
  44. if (app.globalData.userInfo.IsNewUser && app.globalData.userInfo.IsNewUser==1 && app.globalData.userInfo.IsShow == 1) {
  45. if (app.globalData.userInfo.Subscribe == 0) {
  46. wx.redirectTo({
  47. url: '../other/newuser',
  48. });
  49. }
  50. }
  51. else {
  52. wx.getSetting({
  53. success(res) {
  54. if (res.authSetting['scope.userInfo'] || app.globalData.userInfo.IsShow == 0) {
  55. if (!app.globalData.userInfo.IsMember && app.globalData.userInfo.IsShow == 1) {
  56. if (app.globalData.userInfo.Subscribe == 1) {
  57. wx.navigateTo({
  58. url: '../other/userbook',
  59. });
  60. app.globalData.GotoUrl = "";
  61. }
  62. else{
  63. wx.redirectTo({
  64. url: '../other/newuser',
  65. });
  66. }
  67. }
  68. else if (app.globalData.userInfo.IsMember && app.globalData.userInfo.IsShow == 1) {
  69. if (app.globalData.GotoUrl.indexOf("../other/pay?PayType=6")>=0){
  70. wx.navigateTo({
  71. url: app.globalData.GotoUrl,
  72. });
  73. app.globalData.GotoUrl = "";
  74. }
  75. else{
  76. var productServiceTime = common.formatDateCHS(common.formatTime(new Date(app.globalData.userInfo.ProductServiceTime)));
  77. var today = common.formatDateCHS(common.formatTime(new Date()));
  78. if (productServiceTime < today) {
  79. wx.redirectTo({
  80. url: '../other/userbook',
  81. });
  82. }
  83. else if (app.globalData.userInfo.ClassDayNumber < 0) {
  84. wx.redirectTo({
  85. url: '../other/userbook',
  86. });
  87. }
  88. else if (app.globalData.GotoUrl) {
  89. //console.log(app.globalData.GotoUrl);
  90. wx.navigateTo({
  91. url: app.globalData.GotoUrl,
  92. });
  93. app.globalData.GotoUrl = "";
  94. }
  95. }
  96. }
  97. else if (app.globalData.userInfo.IsShow == 0) {
  98. main.buildInitData(function () { });
  99. }
  100. that.setData({
  101. IsAccredit: true,
  102. });
  103. common.getStorageValue(that, "UserName", "秒过", function () {
  104. wx.setNavigationBarTitle({
  105. title: that.data.UserName
  106. });
  107. });
  108. //判断是否出现推广广告
  109. common.getStorageValue(that, "IsShowMarketing", app.globalData.userInfo.HasIntroducer, function () {
  110. if (app.globalData.userInfo.HasIntroducer == 0 && that.data.IsShowMarketing == 3) {
  111. var isShowMarketingTime = wx.getStorageSync("IsShowMarketingTime");
  112. if (common.formatTime(new Date()) >= isShowMarketingTime) {
  113. wx.removeStorageSync("IsShowMarketing");
  114. wx.removeStorageSync("IsShowMarketingTime");
  115. that.setData({
  116. IsShowMarketing: 0,
  117. });
  118. }
  119. }
  120. });
  121. that.init();
  122. that.getTaskTodayList();
  123. that.isNoSavedCard();
  124. }
  125. else {
  126. wx.navigateTo({
  127. url: '../index/accredit',
  128. });
  129. }
  130. if (res.authSetting['scope.record'] === true) {
  131. app.globalData.IsRecorderAccredit = 1;
  132. }
  133. else if (res.authSetting['scope.record'] === false) {
  134. app.globalData.IsRecorderAccredit = -1;
  135. }
  136. }
  137. });
  138. }
  139. wx.setNavigationBarColor({
  140. frontColor: "#ffffff",
  141. backgroundColor: "#3157BA",
  142. });
  143. },
  144. init:function(){
  145. //显示学习方案
  146. var cardType = wx.getStorageSync("CardType");
  147. if (!cardType)
  148. cardType = 0;
  149. this.setData({
  150. CardType:cardType,
  151. });
  152. //题卡主题色
  153. var arrColorIndex = wx.getStorageSync("ColorIndexArr");
  154. if (!arrColorIndex) {
  155. app.globalData.ColorIndex = common.random(1,4);
  156. }
  157. else {
  158. app.globalData.ColorIndex = arrColorIndex[common.random(0, arrColorIndex.length - 1)];
  159. }
  160. //显示答案操作方式
  161. var clickType = wx.getStorageSync("ClickType");
  162. if (!clickType)
  163. clickType = 0;
  164. app.globalData.ClickType=clickType;
  165. //显示命名方式
  166. var MemoryLevel = wx.getStorageSync("MemoryLevel");
  167. if (!MemoryLevel)
  168. MemoryLevel = 0;
  169. app.globalData.MemoryLevel = MemoryLevel;
  170. //选择建议
  171. var SecondConfigArray = wx.getStorageSync("SecondConfigArray");
  172. if (SecondConfigArray)
  173. app.globalData.SecondConfigArray = SecondConfigArray;
  174. },
  175. goto: function (e) {
  176. var url = e.currentTarget.dataset.url;
  177. wx.navigateTo({
  178. url: url,
  179. });
  180. if (url =="../marketing/index"){
  181. this.setData({
  182. IsShowMarketing: 2,
  183. });
  184. wx.setStorageSync("IsShowMarketing", 2);
  185. }
  186. },
  187. //得到当天任务
  188. getTaskTodayList: function () {
  189. var that=this;
  190. main.UpdateMiaoguoCardTodayAll(true, function () {
  191. main.getTaskTodayList(function (data) {
  192. if (data.IsMaintain==1){
  193. that.setData({
  194. IsMaintain:1,
  195. });
  196. }
  197. else{
  198. var TodayTaskNumber = data.ListNew.length + data.ListReview.length + data.ListHistory.length;
  199. that.setData({
  200. DayNumber: data.DayNumber,
  201. TodayTaskNumber: TodayTaskNumber,
  202. IsStart: data.IsStart,
  203. });
  204. }
  205. });
  206. });
  207. },
  208. isNoSavedCard:function(){
  209. var that=this;
  210. //判断是否有未保存的卡
  211. if (app.globalData.userInfo.IsMaintain==1) {
  212. that.setData({
  213. IsMaintain: app.globalData.userInfo.IsMaintain,
  214. });
  215. wx.setNavigationBarColor({
  216. frontColor: "#ffffff",
  217. backgroundColor: "#0B8457",
  218. })
  219. }
  220. //判断是否有未保存的卡
  221. else if (wx.getStorageSync("TempCardNoSaved")) {
  222. that.setData({
  223. IsTempCardNoSaved: true,
  224. });
  225. wx.setNavigationBarColor({
  226. frontColor: "#ffffff",
  227. backgroundColor: "#0B8457",
  228. })
  229. }
  230. else{
  231. that.setData({
  232. IsTempCardNoSaved: false,
  233. });
  234. wx.setNavigationBarColor({
  235. frontColor: "#ffffff",
  236. backgroundColor: "#3157BA",
  237. });
  238. }
  239. },
  240. onOpenTempCard:function(){
  241. var card = wx.getStorageSync("TempCardNoSaved");
  242. app.globalData.CardList=[card];
  243. wx.navigateTo({
  244. url: './add?type=add2&id='+card.MiaoguoCardID,
  245. });
  246. },
  247. onGiveupTempCard:function(){
  248. var that=this;
  249. wx.removeStorageSync("TempCardNoSaved");
  250. that.isNoSavedCard();
  251. },
  252. gotoSearchCard:function(){
  253. wx.reLaunch({
  254. url: './searchCard',
  255. });
  256. },
  257. closeMarketing:function(){
  258. this.setData({
  259. IsShowMarketing:3,
  260. });
  261. wx.setStorageSync("IsShowMarketing", 3);
  262. wx.setStorageSync("IsShowMarketingTime", common.formatTime(common.addDate("d",7,new Date())));
  263. },
  264. checkMemory: function () {
  265. wx.onMemoryWarning(function () {
  266. // wx.showModal({
  267. // title: '手机内存不足',
  268. // content: '请先清理内存再用秒过。内存不足会导致小程序异常或被迫退出。',
  269. // showCancel: false,
  270. // confirmText: '知道了',
  271. // success: function (res) {
  272. // }
  273. // });
  274. });
  275. },
  276. onShareAppMessage: function () {
  277. return {
  278. title: app.globalData.ShareTitle,
  279. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  280. imageUrl: app.globalData.ShareImage,
  281. }
  282. },
  283. })