default.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  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. IsMaintain: 0,
  12. IsIPhoneX: app.globalData.IsIPhoneX,
  13. ImagePath: app.globalData.uploadImageUrl,
  14. IsShowUserID: false,
  15. VersionID: app.globalData.Version,
  16. AwardDayNumber: 0,
  17. IsShowRemind: false,
  18. IsShowHelp: false,
  19. },
  20. onPullDownRefresh: function () {
  21. wx.redirectTo({
  22. url: '../main/default',
  23. })
  24. wx.stopPullDownRefresh();
  25. },
  26. onLoad: function (options) {
  27. var that = this;
  28. that.setData({
  29. Containnerheight: main.getWindowHeight(),
  30. });
  31. if (app.globalData.IsIPad) {
  32. that.setData({
  33. IsIPad: "_iPad",
  34. });
  35. }
  36. wx.showShareMenu({
  37. withShareTicket: true,
  38. menus: ['shareAppMessage', 'shareTimeline']
  39. });
  40. },
  41. onHide: function () {
  42. wx.hideLoading();
  43. },
  44. onShow: function () {
  45. var that = this;
  46. if (app.globalData.userInfo.IsNewUser && app.globalData.userInfo.IsNewUser == 1 && app.globalData.userInfo.IsShow == 1) {
  47. if (app.globalData.userInfo.Subscribe == 0) {
  48. wx.navigateTo({
  49. url: '../other/newuser',
  50. });
  51. }
  52. } else {
  53. wx.getSetting({
  54. success(res) {
  55. if (app.globalData.userInfo.NickName == "陌生用户" && app.globalData.userInfo.IsMember == 1 && app.globalData.userInfo.IsShow == 1) {
  56. wx.navigateTo({
  57. url: '../index/accredit',
  58. });
  59. } else {
  60. if (!app.globalData.userInfo.IsMember && app.globalData.userInfo.IsShow == 1) {
  61. if (app.globalData.userInfo.Subscribe == 1) {
  62. wx.navigateTo({
  63. url: '../other/userbook',
  64. });
  65. app.globalData.GotoUrl = "";
  66. } else {
  67. wx.redirectTo({
  68. url: '../other/newuser',
  69. });
  70. }
  71. } else if (app.globalData.userInfo.IsMember && app.globalData.userInfo.IsShow == 1) {
  72. if (app.globalData.GotoUrl.indexOf("../other/pay?PayType=6") >= 0) {
  73. wx.navigateTo({
  74. url: app.globalData.GotoUrl,
  75. });
  76. app.globalData.GotoUrl = "";
  77. } else {
  78. var productServiceTime = common.formatDateCHS(common.formatTime(new Date(app.globalData.userInfo.ProductServiceTime)));
  79. var today = common.formatDateCHS(common.formatTime(new Date()));
  80. if (productServiceTime < today) {
  81. wx.redirectTo({
  82. url: '../other/userbook',
  83. });
  84. } else if (app.globalData.userInfo.ClassDayNumber < 0) {
  85. wx.redirectTo({
  86. url: '../other/userbook',
  87. });
  88. } else if (app.globalData.GotoUrl) {
  89. //console.log(app.globalData.GotoUrl);
  90. wx.navigateTo({
  91. url: app.globalData.GotoUrl,
  92. });
  93. app.globalData.GotoUrl = "";
  94. }
  95. }
  96. } else if (app.globalData.userInfo.IsShow == 0) {
  97. main.buildInitData(function () {});
  98. }
  99. that.setData({
  100. IsAccredit: true,
  101. });
  102. that.init();
  103. that.getTaskTodayList();
  104. that.isNoSavedCard();
  105. if (res.authSetting['scope.record'] === true) {
  106. app.globalData.IsRecorderAccredit = 1;
  107. } else if (res.authSetting['scope.record'] === false) {
  108. app.globalData.IsRecorderAccredit = -1;
  109. }
  110. }
  111. }
  112. });
  113. }
  114. app.globalData.TempStr2 = null;
  115. wx.setNavigationBarColor({
  116. frontColor: "#ffffff",
  117. backgroundColor: "#3157BA",
  118. });
  119. if (wx.getStorageSync("IsHelpAddInfomation") == 1) {
  120. that.setData({
  121. IsShowHelp: true,
  122. });
  123. main.ShowHelp(that, "#btnAdd", "up", "点击下方“添加题卡”按钮");
  124. } else {
  125. that.setData({
  126. IsShowHelp: false,
  127. });
  128. }
  129. },
  130. init: function () {
  131. //显示练习模式
  132. var cardType = wx.getStorageSync("CardType");
  133. if (!cardType)
  134. cardType = 0;
  135. this.setData({
  136. CardType: cardType,
  137. });
  138. //题卡主题色
  139. var arrColorIndex = wx.getStorageSync("ColorIndexArr");
  140. if (!arrColorIndex) {
  141. app.globalData.ColorIndex = common.random(1, 4);
  142. } else {
  143. app.globalData.ColorIndex = arrColorIndex[common.random(0, arrColorIndex.length - 1)];
  144. }
  145. //显示答案操作方式
  146. var clickType = wx.getStorageSync("ClickType");
  147. if (!clickType)
  148. clickType = 0;
  149. app.globalData.ClickType = clickType;
  150. //选择建议
  151. var SecondConfigArray = wx.getStorageSync("SecondConfigArray");
  152. if (SecondConfigArray)
  153. app.globalData.SecondConfigArray = SecondConfigArray;
  154. //显示命名方式
  155. var MemoryLevel = wx.getStorageSync("MemoryLevel");
  156. if (!MemoryLevel)
  157. MemoryLevel = 0;
  158. app.globalData.MemoryLevel = MemoryLevel;
  159. },
  160. goto: function (e) {
  161. var url = e.currentTarget.dataset.url;
  162. wx.navigateTo({
  163. url: url,
  164. });
  165. if (url == "../../pages_agent/marketing/index") {
  166. this.setData({
  167. IsShowRemind: false,
  168. });
  169. wx.setStorageSync("IsShowMarketingTime", common.formatTime(common.addDate("d", 30, new Date())));
  170. }
  171. if (url == "../plan/studyplan" && this.data.DayNumber <= app.globalData.IsShowSettingRemind) {
  172. wx.setStorageSync('IsShowSettingRemind', this.data.DayNumber);
  173. }
  174. },
  175. //得到当天任务
  176. getTaskTodayList: function () {
  177. var that = this;
  178. main.UpdateMiaoguoCardTodayAll(true, function () {
  179. main.getTaskTodayList(function (data) {
  180. if (data.IsMaintain == 1) {
  181. that.setData({
  182. IsMaintain: 1,
  183. });
  184. } else {
  185. var TodayTaskNumber = data.ListNew.length + data.ListReview.length + data.ListHistory.length;
  186. that.setData({
  187. DayNumber: data.DayNumber,
  188. TodayTaskNumber: TodayTaskNumber,
  189. IsStart: data.IsStart,
  190. });
  191. //是否显示提示任务量设置
  192. if (that.data.DayNumber <= app.globalData.IsShowSettingRemind) {
  193. var IsShowSettingRemind = wx.getStorageSync("IsShowSettingRemind");
  194. if (!IsShowSettingRemind || IsShowSettingRemind < that.data.DayNumber) {
  195. that.setData({
  196. IsShowSettingRemind: 1,
  197. });
  198. } else {
  199. that.setData({
  200. IsShowSettingRemind: 0,
  201. });
  202. }
  203. }
  204. //判断是否出现推广广告
  205. common.getStorageValue(that, "IsShowMarketingTime", "2020-01-01 00:00:00", function () {
  206. if (that.data.IsShowMarketingTime < common.formatTime(new Date())) {
  207. main.getAwardData(function (data) {
  208. var award = data.Total - data.AwardDayNumber
  209. that.setData({
  210. IsShowRemind: true,
  211. AwardDayNumber: award,
  212. });
  213. });
  214. } else {
  215. if (app.globalData.MemoryLevel == 0 && data.DayNumber >= 8) {
  216. var IsShowPatternMenu = wx.getStorageSync("IsShowPatternMenu");
  217. if (!IsShowPatternMenu) {
  218. wx.navigateTo({
  219. url: '../other/menu?Type=1',
  220. });
  221. wx.setStorageSync('IsShowPatternMenu', 1);
  222. }
  223. }
  224. }
  225. });
  226. }
  227. });
  228. });
  229. },
  230. isNoSavedCard: function () {
  231. var that = this;
  232. //判断是否有系统故障
  233. if (app.globalData.userInfo.IsMaintain == 1) {
  234. that.setData({
  235. IsMaintain: app.globalData.userInfo.IsMaintain,
  236. });
  237. wx.setNavigationBarColor({
  238. frontColor: "#ffffff",
  239. backgroundColor: "#0B8457",
  240. })
  241. }
  242. //判断是否有未保存的卡
  243. else if (wx.getStorageSync("TempCardNoSaved")) {
  244. wx.navigateTo({
  245. url: '../other/recover',
  246. });
  247. } else {
  248. that.setData({
  249. IsTempCardNoSaved: false,
  250. });
  251. wx.setNavigationBarColor({
  252. frontColor: "#ffffff",
  253. backgroundColor: "#3157BA",
  254. });
  255. }
  256. },
  257. gotoReLaunch: function (e) {
  258. var url = e.currentTarget.dataset.url;
  259. wx.reLaunch({
  260. url: url,
  261. });
  262. },
  263. showUserID: function () {
  264. var that = this;
  265. if (app.globalData.userInfo.UserID == 1 ||
  266. app.globalData.userInfo.UserID == 3 ||
  267. app.globalData.userInfo.UserID == 4) {
  268. var userid = 2;
  269. if (app.globalData.userInfo.UserID >= 3)
  270. userid = app.globalData.userInfo.UserID;
  271. that.setData({
  272. IsShowUserID: true,
  273. ChangeUserID: userid,
  274. });
  275. }
  276. },
  277. onKeyInput: function (e) {
  278. var id = e.detail.value;
  279. var usertype = e.currentTarget.dataset.type;
  280. var that = this;
  281. if (usertype == "userid") {
  282. that.setData({
  283. ChangeUserID: id,
  284. });
  285. } else if (usertype == "newuserid") {
  286. that.setData({
  287. ChangeNewUserID: id,
  288. });
  289. } else if (usertype == "introduceruserid") {
  290. that.setData({
  291. ChangeIntroducerUserID: id,
  292. });
  293. } else if (usertype == "versionid") {
  294. that.setData({
  295. VersoinID: id,
  296. });
  297. } else if (usertype == "groupuserid") {
  298. that.setData({
  299. ChangeGroupUserID: id,
  300. });
  301. } else if (usertype == "refunduserid") {
  302. that.setData({
  303. RefundUserID: id,
  304. });
  305. } else if (usertype == "refundremark") {
  306. that.setData({
  307. RefundRemark: id,
  308. });
  309. }
  310. },
  311. setSelectUser: function (e) {
  312. var that = this;
  313. if (app.globalData.userInfo.UserID == 1 ||
  314. app.globalData.userInfo.UserID == 2 ||
  315. app.globalData.userInfo.UserID == 3 ||
  316. app.globalData.userInfo.UserID == 4) {
  317. var userid = that.data.ChangeUserID;
  318. wx.setStorageSync("UserID", userid);
  319. app.globalData.userInfo.UserID = userid;
  320. var fieldStr = "";
  321. that.getUserInfo(userid, fieldStr, function (data) {
  322. wx.setNavigationBarTitle({
  323. title: data.NickName
  324. });
  325. main.getUserConfig();
  326. app.globalData.userInfo.ProductServiceTime = data.ProductServiceTime;
  327. if (app.globalData.userInfo.UserID != 2) {
  328. app.globalData.userInfo.NickName = data.NickName;
  329. app.globalData.userInfo.AvatarUrl = data.AvatarUrl;
  330. }
  331. if (data.IsPromoter > 0) {
  332. app.globalData.userInfo.IsPromoter = data.IsPromoter;
  333. app.globalData.userInfo.PromotionLimitDays = data.PromotionLimitDays;
  334. app.globalData.userInfo.PromotionLimitTime = data.PromotionLimitTime;
  335. app.globalData.userInfo.WXServiceCharge = data.WXServiceCharge;
  336. app.globalData.userInfo.IndividualIncomeTax = data.IndividualIncomeTax;
  337. app.globalData.userInfo.WXAccount = data.WXAccount;
  338. app.globalData.userInfo.RealName = data.RealName;
  339. app.globalData.userInfo.IntroducerNickName = data.IntroducerNickName;
  340. app.globalData.userInfo.IntroducerAvatarUrl = data.IntroducerAvatarUrl;
  341. }
  342. });
  343. that.setData({
  344. IsShowUserID: false,
  345. });
  346. that.onShow();
  347. }
  348. },
  349. getUserInfoFunction: function (e) {
  350. var that = this;
  351. var userid = e.currentTarget.dataset.id;
  352. var type1 = e.currentTarget.dataset.type;
  353. var fieldStr = "&FieldStr=NickName,AvatarUrl";
  354. if (userid) {
  355. that.getUserInfo(userid, fieldStr, function (data) {
  356. if (type1 == 3) {
  357. that.setData({
  358. RefundUserAvatar: data.AvatarUrl,
  359. RefundUserNickName: data.NickName,
  360. });
  361. var url = "GetUserPayList?UserID=" + userid;
  362. main.getData(url, function (data) {
  363. if (data) {
  364. that.setData({
  365. PayList: data,
  366. });
  367. }
  368. });
  369. }
  370. });
  371. }
  372. },
  373. getUserInfo: function (userID, fieldStr, callback) {
  374. var url = "GetMiaoguoWXUserInfo?UserID=" + userID + fieldStr;
  375. main.getData(url, function (data) {
  376. if (data) {
  377. callback(data);
  378. }
  379. });
  380. },
  381. selectPayItem: function (e) {
  382. var that = this;
  383. var id = e.currentTarget.dataset.id;
  384. var list = that.data.PayList;
  385. for (var i = 0; i < list.length; i++) {
  386. if (list[i].TradeNo == id)
  387. list[i].IsSelected = "1";
  388. else
  389. list[i].IsSelected = "";
  390. }
  391. that.setData({
  392. PayList: list,
  393. });
  394. },
  395. setRefund: function () {
  396. var that = this;
  397. var str = "",
  398. TradeNo = "",
  399. Remark = "";
  400. var list = that.data.PayList;
  401. for (var i = 0; i < list.length; i++) {
  402. if (list[i].IsSelected == "1") {
  403. str = '确认给【' + that.data.RefundUserNickName + "】退款 ";
  404. str += list[i].Money + "元,";
  405. str += "交易编号:" + list[i].TradeNo;
  406. TradeNo = list[i].TradeNo;
  407. Remark = that.data.RefundRemark;
  408. break;
  409. }
  410. }
  411. if (!str) {
  412. wx.showToast({
  413. title: '请列表中选择',
  414. });
  415. } else if (!that.data.RefundRemark) {
  416. wx.showToast({
  417. title: '请输入退款备注',
  418. });
  419. } else {
  420. wx.showModal({
  421. title: '退款确认',
  422. showCancel: true,
  423. cancelText: "取消",
  424. content: str,
  425. confirmText: '确认',
  426. success(res) {
  427. if (res.confirm) {
  428. var url = "RefundUser?UserID=" + that.data.RefundUserID + "&TradeNo=" + TradeNo + "&Remark=" + Remark;
  429. main.getData(url, function (data) {
  430. wx.showToast({
  431. title: '退款完成',
  432. });
  433. });
  434. }
  435. }
  436. });
  437. }
  438. },
  439. closeRemind: function () {
  440. this.setData({
  441. IsShowRemind: false,
  442. });
  443. wx.setStorageSync("IsShowMarketingTime", common.formatTime(common.addDate("d", 30, new Date())));
  444. //判断每30天是否是高级模式
  445. wx.removeStorageSync('IsShowPatternMenu');
  446. },
  447. setVersionStart: function (e) {
  448. var flag = e.currentTarget.dataset.flag;
  449. var versionid = e.currentTarget.dataset.versionid;
  450. var url = "UpdateVersionStatus?ProgramID=166&Version=" + versionid + "&Flag=" + flag;
  451. main.getData(url, function (data) {
  452. wx.showToast({
  453. title: '修改成功!',
  454. })
  455. });
  456. },
  457. onShareTimeline: function () {
  458. return this.onShareAppMessage();
  459. },
  460. closeHelp: function () {
  461. this.setData({
  462. IsShowHelp: false,
  463. });
  464. wx.setStorageSync('IsHelpAddInfomation', 0);
  465. },
  466. onShareAppMessage: function () {
  467. if (wx.getStorageSync("IsHelpAddInfomation") == 1) {
  468. return {
  469. title: "题卡制作【加资料】教程",
  470. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID + "&type=helpAddInfomation",
  471. imageUrl: app.globalData.uploadImageUrl + "web/program_screenshot_lesson_a0204.png",
  472. }
  473. } else {
  474. return {
  475. title: app.globalData.ShareTitle,
  476. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  477. imageUrl: app.globalData.ShareImage,
  478. }
  479. }
  480. },
  481. })