default.js 7.5 KB

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