activity.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801
  1. /*******************************************************************************
  2. * Copyright(c) 2022 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:活动(用于续费、注册)
  5. * 编辑履历:
  6. * 作者 日期 版本 修改内容
  7. * 周兴 2024-5-15 1.00 新建
  8. *******************************************************************************/
  9. const Constants = require('@/utils/Constants.js');
  10. const util = require('@/utils/util.js')
  11. const mixins = require('@/mixins/index.js');
  12. const config = require('@/config/config.js');
  13. const app = getApp()
  14. Page({
  15. mixins: [mixins],
  16. /**
  17. * 页面的初始数据
  18. */
  19. data: {
  20. imageUrl: config.image_url + '/static/img/',
  21. // 是否加载完毕
  22. loadFlag: false,
  23. // 是否显示vip
  24. showVip: false,
  25. // 升级标识
  26. upgradeFlag: false,
  27. gradeCode: null,
  28. freeFlag: false,
  29. // 企业名称
  30. companyName: null,
  31. cpManager: null,
  32. cpPhone: null,
  33. webMaxNum: null,
  34. wxMaxNum: null,
  35. cpEndDate: null,
  36. activityTable: null,
  37. vipTable: [],
  38. readFlag: false,
  39. staffCount: {
  40. maxNum: 1,
  41. webMaxNum: 0,
  42. wxMaxNum: 0
  43. },
  44. curentAdItem: null,
  45. // 选择的vip报表
  46. chooseVipFlag: false,
  47. summaryInfo: {},
  48. routeObjName: 'company',
  49. pageFlag: false,
  50. // 当前用户授权数
  51. currentUserCount: null,
  52. //按钮
  53. buttonSaveList: [
  54. { code: 'save', title: mixins.$t('save'), width: '120rpx' }
  55. ],
  56. noticeInfo: Constants.noticeInfo,
  57. funcMenu: [
  58. {
  59. title: '订单开单',
  60. icon: 'btn-account-receivable.png',
  61. },
  62. {
  63. title: '销售出库',
  64. icon: 'btn-shipped.png',
  65. },
  66. {
  67. title: '销售退货',
  68. icon: 'btn-stored.png',
  69. },
  70. {
  71. title: '销售跟踪',
  72. icon: 'btn-shipped-out.png',
  73. },
  74. {
  75. title: '采购订单',
  76. icon: 'btn-account-receivable.png',
  77. },
  78. {
  79. title: '采购入库',
  80. icon: 'btn-shipped.png',
  81. },
  82. {
  83. title: '采购退货',
  84. icon: 'btn-stored.png',
  85. },
  86. {
  87. title: '以销定采',
  88. icon: 'btn-shipped-out.png',
  89. },
  90. ],
  91. funcMenuFlg: false,
  92. userEndDate: null,
  93. },
  94. /**
  95. * @desc : 选择活动明细
  96. * @author : 周兴
  97. * @date : 2024/4/1
  98. */
  99. chooseAdItem(e) {
  100. let item = e.currentTarget.dataset.item;
  101. let summaryInfo = this.data.summaryInfo
  102. // 计算截止日期
  103. let months = item.validLong + item.extraLong
  104. let endDate = app.globalData.company.endDate
  105. // 升级需要从当天开始算
  106. if (this.data.upgradeFlag) {
  107. endDate = new Date()
  108. }
  109. endDate = new Date(endDate).addMonths(months).addDays(-1)
  110. summaryInfo.endDate = endDate.toDateStr();
  111. this.setData({
  112. curentAdItem: item,
  113. summaryInfo: summaryInfo
  114. })
  115. // 计算金额
  116. this.countSummaryAmount(item);
  117. },
  118. /**
  119. * @desc : 选择VIP报表明细
  120. * @author : 周兴
  121. * @date : 2024/4/1
  122. */
  123. chooseVipItem(e) {
  124. let item = e.currentTarget.dataset.item
  125. let index = e.currentTarget.dataset.index
  126. let vipTable = this.data.vipTable
  127. item.chooseVipFlag = !item.chooseVipFlag
  128. vipTable[index] = item
  129. this.setData({
  130. chooseVipFlag: !this.data.chooseVipFlag,
  131. vipTable,
  132. })
  133. // 计算金额
  134. this.countSummaryAmountSTD();
  135. },
  136. /**
  137. * @desc : 勾选已阅读表示
  138. * @author : 周兴
  139. * @date : 2024/5/17
  140. */
  141. handleChangeCheckbox(e) {
  142. this.setData({
  143. readFlag: e.detail
  144. })
  145. },
  146. /**
  147. * @desc : 计算金额
  148. * @author : 周兴
  149. * @date : 2024/4/1
  150. */
  151. countSummaryAmount() {
  152. let item = this.data.curentAdItem;
  153. if (!item) return;
  154. let staffCount = this.data.staffCount;
  155. let summaryInfo = this.data.summaryInfo
  156. let amount = 0;
  157. // 先清空
  158. summaryInfo.amountInfo = '';
  159. // 共通用户
  160. if (staffCount.maxNum) {
  161. summaryInfo.amountInfo = item.stdPrice + '(打包价格)*' + staffCount.maxNum
  162. amount += item.stdPrice * staffCount.maxNum
  163. }
  164. // 手机端用户
  165. if (staffCount.wxMaxNum) {
  166. if (summaryInfo.amountInfo) {
  167. summaryInfo.amountInfo += ' + '
  168. }
  169. summaryInfo.amountInfo += item.wxPrice + '(手机端价格)*' + staffCount.wxMaxNum
  170. amount += item.wxPrice * staffCount.wxMaxNum
  171. }
  172. // 电脑端用户
  173. if (staffCount.webMaxNum) {
  174. if (summaryInfo.amountInfo) {
  175. summaryInfo.amountInfo += ' + '
  176. }
  177. summaryInfo.amountInfo += item.webPrice + '(电脑端价格)*' + staffCount.webMaxNum
  178. amount += item.webPrice * staffCount.webMaxNum
  179. }
  180. if (summaryInfo.amountInfo) {
  181. summaryInfo.amountInfo += ' = ' + amount + '(元)'
  182. summaryInfo.amount = amount;
  183. }
  184. this.setData({
  185. summaryInfo: summaryInfo
  186. })
  187. // 统计两端用户数
  188. this.countStaffInfo();
  189. },
  190. /**
  191. * @desc : 获取标准版的价格显示
  192. * @author : 周兴
  193. * @date : 2024/4/1
  194. */
  195. countSummaryAmountSTD() {
  196. let item = this.data.curentAdItem;
  197. let vipTable = this.data.vipTable
  198. let summaryInfo = this.data.summaryInfo
  199. let amount = 0;
  200. // 先清空
  201. summaryInfo.amountInfo = '';
  202. let extendDays = null;
  203. // 服务器的时间
  204. let nowDate = new Date(this.data.currentDate.toDateStr());
  205. extendDays = new Date(summaryInfo.userEndDate).dayDiff(nowDate) + 1;
  206. if (summaryInfo.wxMaxNum >= 0) {
  207. // 购买授权
  208. if (this.data.buyUser) {
  209. summaryInfo.amountInfo += item.wxPrice + '(元) '
  210. } else {
  211. summaryInfo.amountInfo += item.wxPrice + '(元) ' +
  212. ' * 1(年) * ' + summaryInfo.wxMaxNum + '(个)'
  213. }
  214. amount += item.wxPrice * summaryInfo.wxMaxNum
  215. }
  216. // vip报表
  217. if (vipTable && vipTable.length > 0) {
  218. vipTable.forEach(vipItem => {
  219. if (vipItem.chooseVipFlag) {
  220. summaryInfo.amountInfo += ' + ' + vipItem.wxPrice + '(元/' + vipItem.activityItemDescribe + ') ';
  221. summaryInfo.amountInfo = '( ' + summaryInfo.amountInfo + ' ) ';
  222. amount += vipItem.wxPrice;
  223. }
  224. })
  225. }
  226. // 购买授权
  227. if (this.data.buyUser) {
  228. summaryInfo.amountInfo += ' / 365(天) * ' + extendDays + '(天) * ' + summaryInfo.wxMaxNum + '(个)'
  229. if (summaryInfo.amountInfo) {
  230. amount = (amount / 365 * extendDays).toFixed(2);
  231. summaryInfo.amountInfo += ' = ' + amount + '(元)'
  232. summaryInfo.amount = amount;
  233. }
  234. this.setData({
  235. userEndDate: summaryInfo.userEndDate
  236. })
  237. } else {
  238. // 续费
  239. if (summaryInfo.amountInfo) {
  240. amount = (amount).toFixed(2);
  241. summaryInfo.amountInfo += ' = ' + amount + '(元)'
  242. summaryInfo.amount = amount;
  243. }
  244. let userEndDate = new Date(summaryInfo.userEndDate).addMonths(12).addDays(-1)
  245. this.setData({
  246. userEndDate: userEndDate.toDateStr()
  247. })
  248. }
  249. // 计算一授权一天的单价
  250. if (summaryInfo.userEndDate) {
  251. let price = (summaryInfo.amount / summaryInfo.wxMaxNum / extendDays).toFixed(2);
  252. summaryInfo.priceInfo = price
  253. summaryInfo.extendDays = extendDays
  254. }
  255. this.setData({
  256. summaryInfo: summaryInfo
  257. })
  258. },
  259. /**
  260. * @desc : 统计电脑端和手机端的用户数
  261. * @author : 周兴
  262. * @date : 2024/4/1
  263. */
  264. countStaffInfo() {
  265. let summaryInfo = this.data.summaryInfo;
  266. let staffCount = this.data.staffCount;
  267. if (!staffCount) {
  268. return;
  269. }
  270. let webNum = staffCount.webMaxNum + staffCount.maxNum
  271. let wxNum = staffCount.wxMaxNum + staffCount.maxNum
  272. summaryInfo.staffInfo = '可配置手机端授权' + wxNum + '个;电脑端授权' + webNum + '个(包含当前用户)'
  273. summaryInfo.webMaxNum = webNum
  274. summaryInfo.wxMaxNum = wxNum
  275. // 升级从当天算
  276. if (this.data.upgradeFlag) {
  277. summaryInfo.buyBeginDate = new Date().addDays(1).toDateStr();
  278. summaryInfo.extendDays = new Date(summaryInfo.endDate).dayDiff(new Date().addDays(1));
  279. } else {
  280. summaryInfo.buyBeginDate = new Date(this.data.cpEndDate).addDays(1).toDateStr();
  281. summaryInfo.extendDays = new Date(summaryInfo.endDate).dayDiff(new Date(this.data.cpEndDate).addDays(1));
  282. }
  283. // 计算一授权一天的单价
  284. let price = (summaryInfo.amount / (webNum + wxNum) / summaryInfo.extendDays).toFixed(2);
  285. summaryInfo.priceInfo = price
  286. this.setData({
  287. summaryInfo: summaryInfo
  288. })
  289. },
  290. /**
  291. * @desc : 修改用户数
  292. * @author : 周兴
  293. * @date : 2024/4/1
  294. */
  295. changeStaffCount(e) {
  296. let staffCount = this.data.staffCount
  297. let ds = e.currentTarget.dataset
  298. if (ds.type == 'wx') {
  299. staffCount.wxMaxNum = e.detail
  300. } else if (ds.type == 'web') {
  301. staffCount.webMaxNum = e.detail
  302. } else {
  303. staffCount.maxNum = e.detail
  304. }
  305. this.setData({
  306. staffCount: staffCount
  307. })
  308. // 计算金额
  309. this.countSummaryAmount();
  310. },
  311. /**
  312. * @desc : 保存
  313. * @author : 周兴
  314. * @date : 2024/4/1
  315. */
  316. handleSave() {
  317. let summaryInfo = this.data.summaryInfo;
  318. let currentUserCount = this.data.currentUserCount
  319. if (!currentUserCount) {
  320. return;
  321. }
  322. if (this.data.gradeCode == Constants.gradeCode.STD) {
  323. // 必须要选择一个授权
  324. if (Number(summaryInfo.wxMaxNum) <= 0 && this.data.buyUser) {
  325. util.showToast('请选择一个授权');
  326. return false
  327. }
  328. // 功能包
  329. let chooseVipFlag = false
  330. this.data.vipTable.forEach(it => {
  331. if (it.chooseVipFlag) {
  332. chooseVipFlag = true
  333. return
  334. }
  335. })
  336. if (Number(summaryInfo.wxMaxNum) <= 0 && !this.data.buyUser && !chooseVipFlag) {
  337. util.showToast('请选择一个授权或功能包');
  338. return false
  339. }
  340. // 判断数量是否超出续约授权
  341. console.log(currentUserCount.wxNum - summaryInfo.wxMaxNum);
  342. if (currentUserCount.wxNum > summaryInfo.wxMaxNum && summaryInfo.reCountFlag
  343. && currentUserCount.wxNum > 1 && currentUserCount.wxNum - summaryInfo.wxMaxNum > 1) {
  344. let staffInfo = [{ wxMaxNum: Number(this.data.wxMaxNum) + 1, title: '当前授权', wxTitle: '手机授权', code: 'current', userTitle: '当前用户' }, { wxMaxNum: summaryInfo.wxMaxNum, title: '续费授权', wxTitle: '手机授权', code: 'renew' }]
  345. this.save({ saveFlag: false, url: '/package-basic-data/pages/activity/detail/detail?staffInfo=' + JSON.stringify(staffInfo) });
  346. } else {
  347. this.save({});
  348. }
  349. } else {
  350. // 判断数量是否超出续约授权
  351. if (currentUserCount.wxNum > summaryInfo.wxMaxNum || currentUserCount.webNum > summaryInfo.webMaxNum) {
  352. let staffInfo = [{ wxMaxNum: this.data.wxMaxNum, webMaxNum: this.data.webMaxNum, title: '当前授权', wxTitle: '手机授权', webTitle: (app.globalData.company.gradeCode == Constants.gradeCode.STD) ? '' : '电脑授权', code: 'current', userTitle: '当前用户' }, { wxMaxNum: summaryInfo.wxMaxNum, webMaxNum: summaryInfo.webMaxNum, title: '续费授权', wxTitle: '手机授权', webTitle: '电脑授权', code: 'renew' }]
  353. this.save({ saveFlag: false, url: '/package-basic-data/pages/activity/detail/detail?staffInfo=' + JSON.stringify(staffInfo) });
  354. } else {
  355. this.save({});
  356. }
  357. }
  358. },
  359. /**
  360. * @desc : 改变用户授权数
  361. * @author : 周兴
  362. * @date : 2024/4/1
  363. */
  364. changeUserSTD(e) {
  365. let summaryInfo = this.data.summaryInfo
  366. summaryInfo.wxMaxNum = e.detail
  367. this.setData({
  368. summaryInfo: summaryInfo
  369. })
  370. wx.nextTick(() => {
  371. // 计算金额
  372. this.countSummaryAmountSTD();
  373. });
  374. },
  375. /**
  376. * @desc : 校验
  377. * @author : 周兴
  378. * @date : 2024/4/1
  379. */
  380. validData() {
  381. // 专业版校验
  382. if (this.data.gradeCode == Constants.gradeCode.PRO) {
  383. // if (!this.data.readFlag) {
  384. // util.showToast('请勾选阅读须知');
  385. // return false;
  386. // }
  387. let curentAdItem = this.data.curentAdItem;
  388. if (!curentAdItem) {
  389. util.showToast('请选择活动');
  390. return false
  391. }
  392. // 必须要选择一个授权
  393. let staffCount = this.data.staffCount
  394. if (!staffCount.maxNum && !staffCount.webMaxNum && !staffCount.wxMaxNum) {
  395. util.showToast('请选择一个授权');
  396. return false
  397. }
  398. } else {
  399. let curentAdItem = this.data.curentAdItem;
  400. if (!curentAdItem) {
  401. util.showToast('请选择活动');
  402. return false
  403. }
  404. }
  405. return true;
  406. },
  407. /**
  408. * @desc : 设置保存参数
  409. * @author : 周兴
  410. * @date : 2024/4/1
  411. */
  412. setParams(params) {
  413. let summaryInfo = this.data.summaryInfo
  414. let curentAdItem = this.data.curentAdItem
  415. let cpEndDate = this.data.cpEndDate
  416. if (!summaryInfo || !cpEndDate) return;
  417. params.endDate = summaryInfo.endDate
  418. params.userEndDate = summaryInfo.userEndDate
  419. params.gradeCode = this.data.gradeCode
  420. params.cpId = app.globalData.company.cpId
  421. params.tradeNo = this.generateRandomNo();
  422. params.wxUserId = app.globalData.user.userId
  423. params.tradeAmount = summaryInfo.amount
  424. params.buyBeginDate = summaryInfo.buyBeginDate;
  425. params.buyEndDate = summaryInfo.endDate
  426. params.extendDays = summaryInfo.extendDays;
  427. if (this.data.gradeCode == Constants.gradeCode.STD) {
  428. params.buyEndDate = summaryInfo.userEndDate
  429. params.endDate = app.globalData.company.endDate
  430. params.wxMaxNum = summaryInfo.wxMaxNum
  431. if (!summaryInfo.reCountFlag && summaryInfo.wxMaxNumSocial) {
  432. params.wxMaxNum = summaryInfo.wxMaxNum + summaryInfo.wxMaxNumSocial
  433. }
  434. let funPackage = app.globalData.company.funPackage ? [...app.globalData.company.funPackage] : []
  435. params.funPackage = funPackage
  436. // 续费的时候需要传
  437. // 购买授权
  438. if (this.data.buyUser) {
  439. params.reNew = app.globalData.company.reNew
  440. } else {
  441. let renew = {
  442. "user_end_date": this.data.userEndDate,
  443. "wx_max_num": summaryInfo.wxMaxNum,
  444. }
  445. params.reNew = renew
  446. // 续费时候保持原来的 微信人数
  447. params.wxMaxNum = summaryInfo.wxMaxNumSocial
  448. }
  449. params.webMaxNum = 0
  450. params.remarks = summaryInfo.amountInfo
  451. // 选中的功能包的数据
  452. let activityIds = []
  453. let itemIds = []
  454. this.data.vipTable.forEach(it=>{
  455. if (it.chooseVipFlag) {
  456. activityIds.push(it.activityId)
  457. itemIds.push(it.itemId)
  458. }
  459. })
  460. if (activityIds.length > 0){
  461. params.activityIds = activityIds
  462. params.activityItemIds = itemIds
  463. }
  464. // 交易类型-续费
  465. params.tradeType = '交易类型-续费'
  466. } else {
  467. params.webMaxNum = summaryInfo.webMaxNum
  468. params.wxMaxNum = summaryInfo.wxMaxNum
  469. }
  470. params.buyLong = curentAdItem.activityItemName
  471. return params;
  472. },
  473. /**
  474. * @desc : 保存数据
  475. * @author : 周兴
  476. * @date : 2024/5/17
  477. */
  478. saveData(params) {
  479. return this.excute(this.data.service, this.data.service.reNewCompany, this.data.params).then(res => {
  480. if (res.data.code == Constants.SUCESS_CODE) {
  481. // 成功后跳转支付
  482. this.toPay(res.data.data);
  483. }
  484. })
  485. },
  486. /**
  487. * @desc : 查询当前用户授权数
  488. * @author : 周兴
  489. * @date : 2024/4/1
  490. */
  491. getStaffCount() {
  492. let service = app.globalData['commonService']
  493. this.excute(service, service.selectUserCount, {}).then(res => {
  494. if (res.data.code == Constants.SUCESS_CODE) {
  495. if (res.data && res.data.data) {
  496. let currentUserCount = res.data.data;
  497. this.setData({
  498. currentUserCount: currentUserCount,
  499. //服务器的时间
  500. currentDate: new Date(currentUserCount.currentDate)
  501. })
  502. }
  503. }
  504. // 获取活动
  505. this.getActivity()
  506. this.setData({
  507. loadFlag: true
  508. })
  509. });
  510. },
  511. /**
  512. * @desc : 查询活动
  513. * @author : 周兴
  514. * @date : 2024/4/1
  515. */
  516. getActivity() {
  517. let params = {
  518. appCode: Constants.APP_CODE,
  519. activityStatus: Constants.kindCode.activityStatus,
  520. cpId: app.globalData.company.cpId,
  521. gradeCode: this.data.gradeCode
  522. }
  523. // 标准版
  524. if (this.data.gradeCode == Constants.gradeCode.STD) {
  525. if (this.data.buyUser) {
  526. params.activityTypeList = [Constants.kindCode.activityGrade];
  527. } else {
  528. params.activityTypeList = [Constants.kindCode.activityGrade, Constants.kindCode.activityFunc];
  529. }
  530. } else {
  531. params.activityTypeList = [Constants.kindCode.activityGrade, Constants.kindCode.activityVip];
  532. }
  533. let service = app.globalData['activityService']
  534. this.excute(service, service.selectActivityItems, params).then(res => {
  535. if (res.data.code == Constants.SUCESS_CODE) {
  536. if (res.data && res.data.data) {
  537. let activityTable = res.data.data;
  538. // 如果是标准版,需要进行截止日期的处理
  539. if (this.data.gradeCode == Constants.gradeCode.STD) {
  540. this.setData({
  541. activityTable: activityTable.filter(it => it.activityType == Constants.kindCode.activityGrade),
  542. vipTable: activityTable.filter(it => it.activityType == Constants.kindCode.activityFunc),
  543. })
  544. this.handleDataStd(activityTable);
  545. } else {
  546. this.setData({
  547. activityTable: activityTable
  548. })
  549. }
  550. }
  551. }
  552. });
  553. },
  554. /**
  555. * @desc : 标准版处理数据
  556. * @author : 周兴
  557. * @date : 2024/4/1
  558. */
  559. handleDataStd(activityTable) {
  560. if (activityTable && activityTable.length > 0) {
  561. let item = activityTable[0]
  562. this.setData({
  563. curentAdItem: item
  564. })
  565. let summaryInfo = this.data.summaryInfo
  566. let months = item.validLong + item.extraLong
  567. //服务器的时间
  568. let endDate = this.data.currentDate.addMonths(months).addDays(-1)
  569. let dayDiffs = null;
  570. if (summaryInfo.userEndDate) {
  571. dayDiffs = new Date(summaryInfo.userEndDate).dayDiff(this.data.currentDate)
  572. }
  573. // 如果截止日期是空,就取活动中的截止日期
  574. if (!summaryInfo.userEndDate || !dayDiffs || dayDiffs < 0) {
  575. summaryInfo.userEndDate = endDate.toDateStr();
  576. // 重新统计,到期续费或者第一次购买用户
  577. summaryInfo.reCountFlag = true;
  578. summaryInfo.wxMaxNum = summaryInfo.wxMaxNumSocial
  579. this.setData({
  580. showVip: true
  581. })
  582. } else {
  583. // 如果没有购买,需要显示
  584. if (!app.globalData.company.vip) {
  585. this.setData({
  586. showVip: true
  587. })
  588. }
  589. }
  590. summaryInfo.buyBeginDate = this.data.currentDate.toDateStr();
  591. this.setData({
  592. summaryInfo: summaryInfo
  593. })
  594. wx.nextTick(() => {
  595. // 计算金额
  596. this.countSummaryAmountSTD();
  597. });
  598. }
  599. },
  600. /**
  601. * 生命周期函数--监听页面加载
  602. */
  603. onLoad(options) {
  604. console.log(options, "onLoad");
  605. // 升级
  606. if (options && options.upgrade) {
  607. wx.setNavigationBarTitle({
  608. title: mixins.$t('updateSpecialized'),
  609. })
  610. this.setData({
  611. gradeCode: Constants.gradeCode.PRO,
  612. upgradeFlag: true
  613. })
  614. } else {
  615. // 购买授权 和续费
  616. if (options.buyUser) {
  617. wx.setNavigationBarTitle({
  618. title: mixins.$t('buyUser'),
  619. })
  620. } else {
  621. wx.setNavigationBarTitle({
  622. title: mixins.$t('reNew'),
  623. })
  624. }
  625. this.setData({
  626. gradeCode: app.globalData.company.gradeCode,
  627. buyUser: options.buyUser
  628. })
  629. }
  630. this.setData({
  631. companyName: app.globalData.company.cpName,
  632. cpManager: app.globalData.company.cpManager,
  633. cpPhone: app.globalData.company.cpPhone,
  634. cpEndDate: app.globalData.company.endDate,
  635. webMaxNum: app.globalData.company.webMaxNum,
  636. wxMaxNum: app.globalData.company.wxMaxNum,
  637. })
  638. // 如果是标准版,需要获取用户授权数(手机)
  639. let summaryInfo = {}
  640. if (app.globalData.company.gradeCode == Constants.gradeCode.STD && !options.buyUser) {
  641. summaryInfo.wxMaxNum = app.globalData.company.wxMaxNum
  642. summaryInfo.reCountFlag = true
  643. } else {
  644. summaryInfo.wxMaxNum = 1
  645. }
  646. summaryInfo.wxMaxNumSocial = this.data.wxMaxNum
  647. // 续费用户到期日期
  648. summaryInfo.userEndDate = app.globalData.company.userEndDate
  649. this.setData({
  650. summaryInfo: summaryInfo,
  651. })
  652. // 获取活动
  653. // this.getActivity();
  654. // 获取当前用户授权数
  655. this.getStaffCount();
  656. },
  657. /**
  658. * 六大功能的切换
  659. */
  660. funcClick(e) {
  661. let funcMenuFlg = !this.data.funcMenuFlg
  662. if (funcMenuFlg) {
  663. this.setData({
  664. funcMenu: [
  665. {
  666. title: '订单开单',
  667. icon: 'btn-account-receivable.png',
  668. },
  669. {
  670. title: '销售出库',
  671. icon: 'btn-shipped.png',
  672. },
  673. {
  674. title: '销售退货',
  675. icon: 'btn-stored.png',
  676. },
  677. {
  678. title: '销售跟踪',
  679. icon: 'btn-shipped-out.png',
  680. },
  681. {
  682. title: '采购订单',
  683. icon: 'btn-account-receivable.png',
  684. },
  685. {
  686. title: '采购入库',
  687. icon: 'btn-shipped.png',
  688. },
  689. {
  690. title: '采购退货',
  691. icon: 'btn-stored.png',
  692. },
  693. {
  694. title: '以销定采',
  695. icon: 'btn-shipped-out.png',
  696. },
  697. {
  698. title: '库存查询',
  699. icon: 'btn-account-receivable.png',
  700. },
  701. {
  702. title: '入库办理',
  703. icon: 'btn-shipped.png',
  704. },
  705. {
  706. title: '出库办理',
  707. icon: 'btn-stored.png',
  708. },
  709. {
  710. title: '库存盘点',
  711. icon: 'btn-shipped-out.png',
  712. },
  713. {
  714. title: '资金账户',
  715. icon: 'btn-account-receivable.png',
  716. },
  717. {
  718. title: '资金转账',
  719. icon: 'btn-shipped.png',
  720. },
  721. {
  722. title: '收款单',
  723. icon: 'btn-stored.png',
  724. },
  725. {
  726. title: '付款单',
  727. icon: 'btn-shipped-out.png',
  728. },
  729. {
  730. title: '日结对账',
  731. icon: 'btn-account-receivable.png',
  732. },
  733. {
  734. title: '资金日记账',
  735. icon: 'btn-shipped.png',
  736. },
  737. {
  738. title: '供应商往来',
  739. icon: 'btn-stored.png',
  740. },
  741. ],
  742. })
  743. } else {
  744. this.setData({
  745. funcMenu: [
  746. {
  747. title: '订单开单',
  748. icon: 'btn-account-receivable.png',
  749. },
  750. {
  751. title: '销售出库',
  752. icon: 'btn-shipped.png',
  753. },
  754. {
  755. title: '销售退货',
  756. icon: 'btn-stored.png',
  757. },
  758. {
  759. title: '销售跟踪',
  760. icon: 'btn-shipped-out.png',
  761. },
  762. {
  763. title: '采购订单',
  764. icon: 'btn-account-receivable.png',
  765. },
  766. {
  767. title: '采购入库',
  768. icon: 'btn-shipped.png',
  769. },
  770. {
  771. title: '采购退货',
  772. icon: 'btn-stored.png',
  773. },
  774. {
  775. title: '以销定采',
  776. icon: 'btn-shipped-out.png',
  777. },
  778. ],
  779. })
  780. }
  781. this.setData({
  782. funcMenuFlg
  783. })
  784. },
  785. })