default.js 7.5 KB

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