default.js 9.7 KB

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