default.js 17 KB

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