default.js 7.5 KB

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