default.js 17 KB

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