default.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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==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 arrColorIndex = wx.getStorageSync("ColorIndexArr");
  147. if (!arrColorIndex) {
  148. app.globalData.ColorIndex = common.random(1,4);
  149. }
  150. else {
  151. app.globalData.ColorIndex = arrColorIndex[common.random(0, arrColorIndex.length - 1)];
  152. }
  153. //显示答案操作方式
  154. var clickType = wx.getStorageSync("ClickType");
  155. if (!clickType)
  156. clickType = 0;
  157. app.globalData.ClickType=clickType;
  158. //显示命名方式
  159. var MemoryLevel = wx.getStorageSync("MemoryLevel");
  160. if (!MemoryLevel)
  161. MemoryLevel = 0;
  162. app.globalData.MemoryLevel = MemoryLevel;
  163. //选择建议
  164. var SecondConfigArray = wx.getStorageSync("SecondConfigArray");
  165. if (SecondConfigArray)
  166. app.globalData.SecondConfigArray = SecondConfigArray;
  167. },
  168. goto: function (e) {
  169. var url = e.currentTarget.dataset.url;
  170. wx.navigateTo({
  171. url: url,
  172. });
  173. if (url =="../marketing/index"){
  174. this.setData({
  175. IsShowMarketing: 2,
  176. });
  177. wx.setStorageSync("IsShowMarketing", 2);
  178. }
  179. },
  180. //得到当天任务
  181. getTaskTodayList: function () {
  182. var that=this;
  183. main.UpdateMiaoguoCardTodayAll(true, function () {
  184. main.getTaskTodayList(function (data) {
  185. if (data.IsMaintain==1){
  186. that.setData({
  187. IsMaintain:1,
  188. });
  189. }
  190. else{
  191. var TodayTaskNumber = data.ListNew.length + data.ListReview.length + data.ListHistory.length;
  192. that.setData({
  193. DayNumber: data.DayNumber,
  194. TodayTaskNumber: TodayTaskNumber,
  195. IsStart: data.IsStart,
  196. });
  197. }
  198. });
  199. });
  200. },
  201. isNoSavedCard:function(){
  202. var that=this;
  203. //判断是否有未保存的卡
  204. if (app.globalData.userInfo.IsMaintain==1) {
  205. that.setData({
  206. IsMaintain: app.globalData.userInfo.IsMaintain,
  207. });
  208. wx.setNavigationBarColor({
  209. frontColor: "#ffffff",
  210. backgroundColor: "#0B8457",
  211. })
  212. }
  213. //判断是否有未保存的卡
  214. else if (wx.getStorageSync("TempCardNoSaved")) {
  215. that.setData({
  216. IsTempCardNoSaved: true,
  217. });
  218. wx.setNavigationBarColor({
  219. frontColor: "#ffffff",
  220. backgroundColor: "#0B8457",
  221. })
  222. }
  223. else{
  224. that.setData({
  225. IsTempCardNoSaved: false,
  226. });
  227. wx.setNavigationBarColor({
  228. frontColor: "#ffffff",
  229. backgroundColor: "#3157BA",
  230. });
  231. }
  232. },
  233. onOpenTempCard:function(){
  234. var card = wx.getStorageSync("TempCardNoSaved");
  235. app.globalData.CardList=[card];
  236. wx.navigateTo({
  237. url: './add?type=add2&id='+card.MiaoguoCardID,
  238. });
  239. },
  240. onGiveupTempCard:function(){
  241. var that=this;
  242. wx.removeStorageSync("TempCardNoSaved");
  243. that.isNoSavedCard();
  244. },
  245. gotoSearchCard:function(){
  246. wx.reLaunch({
  247. url: './searchCard',
  248. });
  249. },
  250. closeMarketing:function(){
  251. this.setData({
  252. IsShowMarketing:3,
  253. });
  254. wx.setStorageSync("IsShowMarketing", 3);
  255. wx.setStorageSync("IsShowMarketingTime", common.formatTime(common.addDate("d",7,new Date())));
  256. },
  257. checkMemory: function () {
  258. wx.onMemoryWarning(function () {
  259. // wx.showModal({
  260. // title: '手机内存不足',
  261. // content: '请先清理内存再用秒过。内存不足会导致小程序异常或被迫退出。',
  262. // showCancel: false,
  263. // confirmText: '知道了',
  264. // success: function (res) {
  265. // }
  266. // });
  267. });
  268. },
  269. onShareAppMessage: function () {
  270. return {
  271. title: app.globalData.ShareTitle,
  272. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  273. imageUrl: app.globalData.ShareImage,
  274. }
  275. },
  276. })