default.js 7.0 KB

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