default.js 17 KB

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