default.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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 MemoryLevel = wx.getStorageSync("MemoryLevel");
  163. if (!MemoryLevel)
  164. MemoryLevel = 0;
  165. app.globalData.MemoryLevel = MemoryLevel;
  166. //选择建议
  167. var SecondConfigArray = wx.getStorageSync("SecondConfigArray");
  168. if (SecondConfigArray)
  169. app.globalData.SecondConfigArray = SecondConfigArray;
  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. }
  201. });
  202. });
  203. },
  204. isNoSavedCard: function () {
  205. var that = this;
  206. //判断是否有未保存的卡
  207. if (app.globalData.userInfo.IsMaintain == 1) {
  208. that.setData({
  209. IsMaintain: app.globalData.userInfo.IsMaintain,
  210. });
  211. wx.setNavigationBarColor({
  212. frontColor: "#ffffff",
  213. backgroundColor: "#0B8457",
  214. })
  215. }
  216. //判断是否有未保存的卡
  217. else if (wx.getStorageSync("TempCardNoSaved")) {
  218. that.setData({
  219. IsTempCardNoSaved: true,
  220. });
  221. wx.setNavigationBarColor({
  222. frontColor: "#ffffff",
  223. backgroundColor: "#0B8457",
  224. })
  225. }
  226. else {
  227. that.setData({
  228. IsTempCardNoSaved: false,
  229. });
  230. wx.setNavigationBarColor({
  231. frontColor: "#ffffff",
  232. backgroundColor: "#3157BA",
  233. });
  234. }
  235. },
  236. onOpenTempCard: function () {
  237. var card = wx.getStorageSync("TempCardNoSaved");
  238. app.globalData.CardList = [card];
  239. wx.navigateTo({
  240. url: './add?type=add2&id=' + card.MiaoguoCardID,
  241. });
  242. },
  243. onGiveupTempCard: function () {
  244. var that = this;
  245. wx.removeStorageSync("TempCardNoSaved");
  246. that.isNoSavedCard();
  247. },
  248. gotoSearchCard: function () {
  249. wx.reLaunch({
  250. url: './searchCard',
  251. });
  252. },
  253. closeMarketing: function () {
  254. this.setData({
  255. IsShowMarketing: 3,
  256. });
  257. wx.setStorageSync("IsShowMarketing", 3);
  258. wx.setStorageSync("IsShowMarketingTime", common.formatTime(common.addDate("d", 7, new Date())));
  259. },
  260. showUserID:function(){
  261. var that = this;
  262. if (app.globalData.userInfo.UserID == 1
  263. || app.globalData.userInfo.UserID == 2
  264. || app.globalData.userInfo.UserID == 3
  265. || app.globalData.userInfo.UserID == 4) {
  266. that.setData({
  267. IsShowUserID: true,
  268. ChangeuUserID:2,
  269. });
  270. }
  271. },
  272. onKeyInput: function (e) {
  273. var id = e.detail.value;
  274. var that = this;
  275. that.setData({
  276. ChangeuUserID: id,
  277. });
  278. },
  279. setSelectUser: function (e) {
  280. var that = this;
  281. if (app.globalData.userInfo.UserID == 1
  282. || app.globalData.userInfo.UserID == 2
  283. || app.globalData.userInfo.UserID == 3
  284. || app.globalData.userInfo.UserID == 4) {
  285. var userid = that.data.ChangeuUserID;
  286. wx.setStorageSync("UserID", userid);
  287. app.globalData.userInfo.UserID = userid;
  288. var url = "GetMiaoguoWXUserInfo?UserID=" + app.globalData.userInfo.UserID + "&FieldStr=NickName";
  289. main.getData(url, function (data) {
  290. if (data) {
  291. wx.setNavigationBarTitle({
  292. title: data.NickName
  293. });
  294. main.getUserConfig();
  295. }
  296. });
  297. that.setData({
  298. IsShowUserID: false,
  299. });
  300. that.onShow();
  301. }
  302. },
  303. onShareAppMessage: function () {
  304. return {
  305. title: app.globalData.ShareTitle,
  306. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  307. imageUrl: app.globalData.ShareImage,
  308. }
  309. },
  310. })