activity.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811
  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('buyNow'), 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), title: '当前授权', wxTitle: '手机授权', code: 'current', userTitle: '当前用户' }, { wxMaxNum: this.data.buyUser ? summaryInfo.wxMaxNum : summaryInfo.wxMaxNum + 1, 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. let activityIds = []
  438. let itemIds = []
  439. this.data.vipTable.forEach(it => {
  440. if (it.chooseVipFlag) {
  441. activityIds.push(it.activityId)
  442. itemIds.push(it.itemId)
  443. }
  444. })
  445. if (activityIds.length > 0) {
  446. params.activityIds = activityIds
  447. params.activityItemIds = itemIds
  448. }
  449. // 续费的时候需要传
  450. // 购买授权
  451. if (this.data.buyUser) {
  452. params.reNew = app.globalData.company.reNew
  453. } else {
  454. let funPackages = []
  455. this.data.vipTable.forEach(it => {
  456. if (it.chooseVipFlag) {
  457. funPackages.push({
  458. activityId: it.activityId,
  459. funUuids: it.funUuids
  460. })
  461. }
  462. })
  463. let renew = {
  464. "user_end_date": this.data.userEndDate,
  465. "wx_max_num": summaryInfo.wxMaxNum + 1,
  466. "fun_package": funPackages.length > 0 ? funPackages : null,
  467. }
  468. params.reNew = renew
  469. // 续费时候保持原来的 微信人数
  470. params.wxMaxNum = summaryInfo.wxMaxNumSocial
  471. }
  472. params.webMaxNum = 0
  473. params.remarks = summaryInfo.amountInfo
  474. // 交易类型-续费
  475. params.tradeType = '交易类型-续费'
  476. } else {
  477. params.webMaxNum = summaryInfo.webMaxNum
  478. params.wxMaxNum = summaryInfo.wxMaxNum
  479. }
  480. params.buyLong = curentAdItem.activityItemName
  481. return params;
  482. },
  483. /**
  484. * @desc : 保存数据
  485. * @author : 周兴
  486. * @date : 2024/5/17
  487. */
  488. saveData(params) {
  489. return this.excute(this.data.service, this.data.service.reNewCompany, this.data.params).then(res => {
  490. if (res.data.code == Constants.SUCESS_CODE) {
  491. // 成功后跳转支付
  492. this.toPay(res.data.data);
  493. }
  494. })
  495. },
  496. /**
  497. * @desc : 查询当前用户授权数
  498. * @author : 周兴
  499. * @date : 2024/4/1
  500. */
  501. getStaffCount() {
  502. let service = app.globalData['commonService']
  503. this.excute(service, service.selectUserCount, {}).then(res => {
  504. if (res.data.code == Constants.SUCESS_CODE) {
  505. if (res.data && res.data.data) {
  506. let currentUserCount = res.data.data;
  507. this.setData({
  508. currentUserCount: currentUserCount,
  509. //服务器的时间
  510. currentDate: new Date(currentUserCount.currentDate)
  511. })
  512. }
  513. }
  514. // 获取活动
  515. this.getActivity()
  516. this.setData({
  517. loadFlag: true
  518. })
  519. });
  520. },
  521. /**
  522. * @desc : 查询活动
  523. * @author : 周兴
  524. * @date : 2024/4/1
  525. */
  526. getActivity() {
  527. let params = {
  528. appCode: Constants.APP_CODE,
  529. activityStatus: Constants.kindCode.activityStatus,
  530. cpId: app.globalData.company.cpId,
  531. gradeCode: this.data.gradeCode
  532. }
  533. // 标准版
  534. if (this.data.gradeCode == Constants.gradeCode.STD) {
  535. if (this.data.buyUser) {
  536. params.activityTypeList = [Constants.kindCode.activityGrade];
  537. } else {
  538. params.activityTypeList = [Constants.kindCode.activityGrade, Constants.kindCode.activityFunc];
  539. }
  540. } else {
  541. params.activityTypeList = [Constants.kindCode.activityGrade, Constants.kindCode.activityVip];
  542. }
  543. let service = app.globalData['activityService']
  544. this.excute(service, service.selectActivityItems, params).then(res => {
  545. if (res.data.code == Constants.SUCESS_CODE) {
  546. if (res.data && res.data.data) {
  547. let activityTable = res.data.data;
  548. // 如果是标准版,需要进行截止日期的处理
  549. if (this.data.gradeCode == Constants.gradeCode.STD) {
  550. this.setData({
  551. activityTable: activityTable.filter(it => it.activityType == Constants.kindCode.activityGrade),
  552. vipTable: activityTable.filter(it => it.activityType == Constants.kindCode.activityFunc),
  553. })
  554. this.handleDataStd(activityTable);
  555. } else {
  556. this.setData({
  557. activityTable: activityTable
  558. })
  559. }
  560. }
  561. }
  562. });
  563. },
  564. /**
  565. * @desc : 标准版处理数据
  566. * @author : 周兴
  567. * @date : 2024/4/1
  568. */
  569. handleDataStd(activityTable) {
  570. if (activityTable && activityTable.length > 0) {
  571. let item = activityTable[0]
  572. this.setData({
  573. curentAdItem: item
  574. })
  575. let summaryInfo = this.data.summaryInfo
  576. let months = item.validLong + item.extraLong
  577. //服务器的时间
  578. let endDate = this.data.currentDate.addMonths(months).addDays(-1)
  579. let dayDiffs = null;
  580. if (summaryInfo.userEndDate) {
  581. dayDiffs = new Date(summaryInfo.userEndDate).dayDiff(this.data.currentDate)
  582. }
  583. // 如果截止日期是空,就取活动中的截止日期
  584. if (!summaryInfo.userEndDate || !dayDiffs || dayDiffs < 0) {
  585. summaryInfo.userEndDate = endDate.toDateStr();
  586. // 重新统计,到期续费或者第一次购买用户
  587. summaryInfo.reCountFlag = true;
  588. summaryInfo.wxMaxNum = summaryInfo.wxMaxNumSocial
  589. this.setData({
  590. showVip: true
  591. })
  592. } else {
  593. // 如果没有购买,需要显示
  594. if (!app.globalData.company.vip) {
  595. this.setData({
  596. showVip: true
  597. })
  598. }
  599. }
  600. summaryInfo.buyBeginDate = this.data.currentDate.toDateStr();
  601. this.setData({
  602. summaryInfo: summaryInfo
  603. })
  604. wx.nextTick(() => {
  605. // 计算金额
  606. this.countSummaryAmountSTD();
  607. });
  608. }
  609. },
  610. /**
  611. * 生命周期函数--监听页面加载
  612. */
  613. onLoad(options) {
  614. console.log(options, "onLoad");
  615. // 升级
  616. if (options && options.upgrade) {
  617. wx.setNavigationBarTitle({
  618. title: mixins.$t('updateSpecialized'),
  619. })
  620. this.setData({
  621. gradeCode: Constants.gradeCode.PRO,
  622. upgradeFlag: true
  623. })
  624. } else {
  625. // 购买授权 和续费
  626. if (options.buyUser) {
  627. wx.setNavigationBarTitle({
  628. title: mixins.$t('buyUser'),
  629. })
  630. } else {
  631. wx.setNavigationBarTitle({
  632. title: mixins.$t('reNew'),
  633. })
  634. }
  635. this.setData({
  636. gradeCode: app.globalData.company.gradeCode,
  637. buyUser: options.buyUser
  638. })
  639. }
  640. this.setData({
  641. companyName: app.globalData.company.cpName,
  642. cpManager: app.globalData.company.cpManager,
  643. cpPhone: app.globalData.company.cpPhone,
  644. cpEndDate: app.globalData.company.endDate,
  645. webMaxNum: app.globalData.company.webMaxNum,
  646. wxMaxNum: app.globalData.company.wxMaxNum,
  647. })
  648. // 如果是标准版,需要获取用户授权数(手机)
  649. let summaryInfo = {}
  650. if (app.globalData.company.gradeCode == Constants.gradeCode.STD && !options.buyUser) {
  651. summaryInfo.wxMaxNum = app.globalData.company.wxMaxNum
  652. summaryInfo.reCountFlag = true
  653. } else {
  654. summaryInfo.wxMaxNum = 1
  655. }
  656. summaryInfo.wxMaxNumSocial = this.data.wxMaxNum
  657. // 续费用户到期日期
  658. summaryInfo.userEndDate = app.globalData.company.userEndDate
  659. this.setData({
  660. summaryInfo: summaryInfo,
  661. })
  662. // 获取活动
  663. // this.getActivity();
  664. // 获取当前用户授权数
  665. this.getStaffCount();
  666. },
  667. /**
  668. * 六大功能的切换
  669. */
  670. funcClick(e) {
  671. let funcMenuFlg = !this.data.funcMenuFlg
  672. if (funcMenuFlg) {
  673. this.setData({
  674. funcMenu: [
  675. {
  676. title: '订单开单',
  677. icon: 'btn-account-receivable.png',
  678. },
  679. {
  680. title: '销售出库',
  681. icon: 'btn-shipped.png',
  682. },
  683. {
  684. title: '销售退货',
  685. icon: 'btn-stored.png',
  686. },
  687. {
  688. title: '销售跟踪',
  689. icon: 'btn-shipped-out.png',
  690. },
  691. {
  692. title: '采购订单',
  693. icon: 'btn-account-receivable.png',
  694. },
  695. {
  696. title: '采购入库',
  697. icon: 'btn-shipped.png',
  698. },
  699. {
  700. title: '采购退货',
  701. icon: 'btn-stored.png',
  702. },
  703. {
  704. title: '以销定采',
  705. icon: 'btn-shipped-out.png',
  706. },
  707. {
  708. title: '库存查询',
  709. icon: 'btn-account-receivable.png',
  710. },
  711. {
  712. title: '入库办理',
  713. icon: 'btn-shipped.png',
  714. },
  715. {
  716. title: '出库办理',
  717. icon: 'btn-stored.png',
  718. },
  719. {
  720. title: '库存盘点',
  721. icon: 'btn-shipped-out.png',
  722. },
  723. {
  724. title: '资金账户',
  725. icon: 'btn-account-receivable.png',
  726. },
  727. {
  728. title: '资金转账',
  729. icon: 'btn-shipped.png',
  730. },
  731. {
  732. title: '收款单',
  733. icon: 'btn-stored.png',
  734. },
  735. {
  736. title: '付款单',
  737. icon: 'btn-shipped-out.png',
  738. },
  739. {
  740. title: '日结对账',
  741. icon: 'btn-account-receivable.png',
  742. },
  743. {
  744. title: '资金日记账',
  745. icon: 'btn-shipped.png',
  746. },
  747. {
  748. title: '供应商往来',
  749. icon: 'btn-stored.png',
  750. },
  751. ],
  752. })
  753. } else {
  754. this.setData({
  755. funcMenu: [
  756. {
  757. title: '订单开单',
  758. icon: 'btn-account-receivable.png',
  759. },
  760. {
  761. title: '销售出库',
  762. icon: 'btn-shipped.png',
  763. },
  764. {
  765. title: '销售退货',
  766. icon: 'btn-stored.png',
  767. },
  768. {
  769. title: '销售跟踪',
  770. icon: 'btn-shipped-out.png',
  771. },
  772. {
  773. title: '采购订单',
  774. icon: 'btn-account-receivable.png',
  775. },
  776. {
  777. title: '采购入库',
  778. icon: 'btn-shipped.png',
  779. },
  780. {
  781. title: '采购退货',
  782. icon: 'btn-stored.png',
  783. },
  784. {
  785. title: '以销定采',
  786. icon: 'btn-shipped-out.png',
  787. },
  788. ],
  789. })
  790. }
  791. this.setData({
  792. funcMenuFlg
  793. })
  794. },
  795. })