default.js 8.3 KB

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