activity.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809
  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. if (currentUserCount.wxNum > summaryInfo.wxMaxNum && summaryInfo.reCountFlag
  342. && currentUserCount.wxNum > 1 && currentUserCount.wxNum - summaryInfo.wxMaxNum > 1) {
  343. 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' }]
  344. this.save({ saveFlag: false, url: '/package-basic-data/pages/activity/detail/detail?staffInfo=' + JSON.stringify(staffInfo) });
  345. } else {
  346. this.save({});
  347. }
  348. } else {
  349. // 判断数量是否超出续约授权
  350. if (currentUserCount.wxNum > summaryInfo.wxMaxNum || currentUserCount.webNum > summaryInfo.webMaxNum) {
  351. 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' }]
  352. this.save({ saveFlag: false, url: '/package-basic-data/pages/activity/detail/detail?staffInfo=' + JSON.stringify(staffInfo) });
  353. } else {
  354. this.save({});
  355. }
  356. }
  357. },
  358. /**
  359. * @desc : 改变用户授权数
  360. * @author : 周兴
  361. * @date : 2024/4/1
  362. */
  363. changeUserSTD(e) {
  364. let summaryInfo = this.data.summaryInfo
  365. summaryInfo.wxMaxNum = e.detail
  366. this.setData({
  367. summaryInfo: summaryInfo
  368. })
  369. wx.nextTick(() => {
  370. // 计算金额
  371. this.countSummaryAmountSTD();
  372. });
  373. },
  374. /**
  375. * @desc : 校验
  376. * @author : 周兴
  377. * @date : 2024/4/1
  378. */
  379. validData() {
  380. // 专业版校验
  381. if (this.data.gradeCode == Constants.gradeCode.PRO) {
  382. // if (!this.data.readFlag) {
  383. // util.showToast('请勾选阅读须知');
  384. // return false;
  385. // }
  386. let curentAdItem = this.data.curentAdItem;
  387. if (!curentAdItem) {
  388. util.showToast('请选择活动');
  389. return false
  390. }
  391. // 必须要选择一个授权
  392. let staffCount = this.data.staffCount
  393. if (!staffCount.maxNum && !staffCount.webMaxNum && !staffCount.wxMaxNum) {
  394. util.showToast('请选择一个授权');
  395. return false
  396. }
  397. } else {
  398. let curentAdItem = this.data.curentAdItem;
  399. if (!curentAdItem) {
  400. util.showToast('请选择活动');
  401. return false
  402. }
  403. }
  404. return true;
  405. },
  406. /**
  407. * @desc : 设置保存参数
  408. * @author : 周兴
  409. * @date : 2024/4/1
  410. */
  411. setParams(params) {
  412. let summaryInfo = this.data.summaryInfo
  413. let curentAdItem = this.data.curentAdItem
  414. let cpEndDate = this.data.cpEndDate
  415. if (!summaryInfo || !cpEndDate) return;
  416. params.endDate = summaryInfo.endDate
  417. params.userEndDate = summaryInfo.userEndDate
  418. params.gradeCode = this.data.gradeCode
  419. params.cpId = app.globalData.company.cpId
  420. params.tradeNo = this.generateRandomNo();
  421. params.wxUserId = app.globalData.user.userId
  422. params.tradeAmount = summaryInfo.amount
  423. params.buyBeginDate = summaryInfo.buyBeginDate;
  424. params.buyEndDate = summaryInfo.endDate
  425. params.extendDays = summaryInfo.extendDays;
  426. if (this.data.gradeCode == Constants.gradeCode.STD) {
  427. params.buyEndDate = summaryInfo.userEndDate
  428. params.endDate = app.globalData.company.endDate
  429. params.wxMaxNum = summaryInfo.wxMaxNum
  430. if (!summaryInfo.reCountFlag && summaryInfo.wxMaxNumSocial) {
  431. params.wxMaxNum = summaryInfo.wxMaxNum + summaryInfo.wxMaxNumSocial
  432. }
  433. let funPackage = app.globalData.company.funPackage ? [...app.globalData.company.funPackage] : []
  434. params.funPackage = funPackage
  435. // 选中的功能包的数据
  436. let activityIds = []
  437. let itemIds = []
  438. this.data.vipTable.forEach(it => {
  439. if (it.chooseVipFlag) {
  440. activityIds.push(it.activityId)
  441. itemIds.push(it.itemId)
  442. }
  443. })
  444. if (activityIds.length > 0) {
  445. params.activityIds = activityIds
  446. params.activityItemIds = itemIds
  447. }
  448. // 续费的时候需要传
  449. // 购买授权
  450. if (this.data.buyUser) {
  451. params.reNew = app.globalData.company.reNew
  452. } else {
  453. let funPackages = []
  454. this.data.vipTable.forEach(it => {
  455. if (it.chooseVipFlag) {
  456. funPackages.push({
  457. activityId: it.activityId,
  458. funUuids: it.funUuids
  459. })
  460. }
  461. })
  462. let renew = {
  463. "user_end_date": this.data.userEndDate,
  464. "wx_max_num": summaryInfo.wxMaxNum + 1,
  465. "fun_package": funPackages.length > 0 ? funPackages : null,
  466. }
  467. params.reNew = renew
  468. // 续费时候保持原来的 微信人数
  469. params.wxMaxNum = summaryInfo.wxMaxNumSocial
  470. }
  471. params.webMaxNum = 0
  472. params.remarks = summaryInfo.amountInfo
  473. // 交易类型-续费
  474. params.tradeType = '交易类型-续费'
  475. } else {
  476. params.webMaxNum = summaryInfo.webMaxNum
  477. params.wxMaxNum = summaryInfo.wxMaxNum
  478. }
  479. params.buyLong = curentAdItem.activityItemName
  480. return params;
  481. },
  482. /**
  483. * @desc : 保存数据
  484. * @author : 周兴
  485. * @date : 2024/5/17
  486. */
  487. saveData(params) {
  488. return this.excute(this.data.service, this.data.service.reNewCompany, this.data.params).then(res => {
  489. if (res.data.code == Constants.SUCESS_CODE) {
  490. // 成功后跳转支付
  491. this.toPay(res.data.data);
  492. }
  493. })
  494. },
  495. /**
  496. * @desc : 查询当前用户授权数
  497. * @author : 周兴
  498. * @date : 2024/4/1
  499. */
  500. getStaffCount() {
  501. let service = app.globalData['commonService']
  502. this.excute(service, service.selectUserCount, {}).then(res => {
  503. if (res.data.code == Constants.SUCESS_CODE) {
  504. if (res.data && res.data.data) {
  505. let currentUserCount = res.data.data;
  506. this.setData({
  507. currentUserCount: currentUserCount,
  508. //服务器的时间
  509. currentDate: new Date(currentUserCount.currentDate)
  510. })
  511. }
  512. }
  513. // 获取活动
  514. this.getActivity()
  515. this.setData({
  516. loadFlag: true
  517. })
  518. });
  519. },
  520. /**
  521. * @desc : 查询活动
  522. * @author : 周兴
  523. * @date : 2024/4/1
  524. */
  525. getActivity() {
  526. let params = {
  527. appCode: Constants.APP_CODE,
  528. activityStatus: Constants.kindCode.activityStatus,
  529. cpId: app.globalData.company.cpId,
  530. gradeCode: this.data.gradeCode
  531. }
  532. // 标准版
  533. if (this.data.gradeCode == Constants.gradeCode.STD) {
  534. if (this.data.buyUser) {
  535. params.activityTypeList = [Constants.kindCode.activityGrade];
  536. } else {
  537. params.activityTypeList = [Constants.kindCode.activityGrade, Constants.kindCode.activityFunc];
  538. }
  539. } else {
  540. params.activityTypeList = [Constants.kindCode.activityGrade, Constants.kindCode.activityVip];
  541. }
  542. let service = app.globalData['activityService']
  543. this.excute(service, service.selectActivityItems, params).then(res => {
  544. if (res.data.code == Constants.SUCESS_CODE) {
  545. if (res.data && res.data.data) {
  546. let activityTable = res.data.data;
  547. // 如果是标准版,需要进行截止日期的处理
  548. if (this.data.gradeCode == Constants.gradeCode.STD) {
  549. this.setData({
  550. activityTable: activityTable.filter(it => it.activityType == Constants.kindCode.activityGrade),
  551. vipTable: activityTable.filter(it => it.activityType == Constants.kindCode.activityFunc),
  552. })
  553. this.handleDataStd(activityTable);
  554. } else {
  555. this.setData({
  556. activityTable: activityTable
  557. })
  558. }
  559. }
  560. }
  561. });
  562. },
  563. /**
  564. * @desc : 标准版处理数据
  565. * @author : 周兴
  566. * @date : 2024/4/1
  567. */
  568. handleDataStd(activityTable) {
  569. if (activityTable && activityTable.length > 0) {
  570. let item = activityTable[0]
  571. this.setData({
  572. curentAdItem: item
  573. })
  574. let summaryInfo = this.data.summaryInfo
  575. let months = item.validLong + item.extraLong
  576. //服务器的时间
  577. let endDate = this.data.currentDate.addMonths(months).addDays(-1)
  578. let dayDiffs = null;
  579. if (summaryInfo.userEndDate) {
  580. dayDiffs = new Date(summaryInfo.userEndDate).dayDiff(this.data.currentDate)
  581. }
  582. // 如果截止日期是空,就取活动中的截止日期
  583. if (!summaryInfo.userEndDate || !dayDiffs || dayDiffs < 0) {
  584. summaryInfo.userEndDate = endDate.toDateStr();
  585. // 重新统计,到期续费或者第一次购买用户
  586. summaryInfo.reCountFlag = true;
  587. summaryInfo.wxMaxNum = summaryInfo.wxMaxNumSocial
  588. this.setData({
  589. showVip: true
  590. })
  591. } else {
  592. // 如果没有购买,需要显示
  593. if (!app.globalData.company.vip) {
  594. this.setData({
  595. showVip: true
  596. })
  597. }
  598. }
  599. summaryInfo.buyBeginDate = this.data.currentDate.toDateStr();
  600. this.setData({
  601. summaryInfo: summaryInfo
  602. })
  603. wx.nextTick(() => {
  604. // 计算金额
  605. this.countSummaryAmountSTD();
  606. });
  607. }
  608. },
  609. /**
  610. * 生命周期函数--监听页面加载
  611. */
  612. onLoad(options) {
  613. // 升级
  614. if (options && options.upgrade) {
  615. wx.setNavigationBarTitle({
  616. title: mixins.$t('updateSpecialized'),
  617. })
  618. this.setData({
  619. gradeCode: Constants.gradeCode.PRO,
  620. upgradeFlag: true
  621. })
  622. } else {
  623. // 购买授权 和续费
  624. if (options.buyUser) {
  625. wx.setNavigationBarTitle({
  626. title: mixins.$t('buyUser'),
  627. })
  628. } else {
  629. wx.setNavigationBarTitle({
  630. title: mixins.$t('reNew'),
  631. })
  632. }
  633. this.setData({
  634. gradeCode: app.globalData.company.gradeCode,
  635. buyUser: options.buyUser
  636. })
  637. }
  638. this.setData({
  639. companyName: app.globalData.company.cpName,
  640. cpManager: app.globalData.company.cpManager,
  641. cpPhone: app.globalData.company.cpPhone,
  642. cpEndDate: app.globalData.company.endDate,
  643. webMaxNum: app.globalData.company.webMaxNum,
  644. wxMaxNum: app.globalData.company.wxMaxNum,
  645. })
  646. // 如果是标准版,需要获取用户授权数(手机)
  647. let summaryInfo = {}
  648. if (app.globalData.company.gradeCode == Constants.gradeCode.STD && !options.buyUser) {
  649. summaryInfo.wxMaxNum = app.globalData.company.wxMaxNum
  650. summaryInfo.reCountFlag = true
  651. } else {
  652. summaryInfo.wxMaxNum = 1
  653. }
  654. summaryInfo.wxMaxNumSocial = this.data.wxMaxNum
  655. // 续费用户到期日期
  656. summaryInfo.userEndDate = app.globalData.company.userEndDate
  657. this.setData({
  658. summaryInfo: summaryInfo,
  659. })
  660. // 获取活动
  661. // this.getActivity();
  662. // 获取当前用户授权数
  663. this.getStaffCount();
  664. },
  665. /**
  666. * 六大功能的切换
  667. */
  668. funcClick(e) {
  669. let funcMenuFlg = !this.data.funcMenuFlg
  670. if (funcMenuFlg) {
  671. this.setData({
  672. funcMenu: [
  673. {
  674. title: '订单开单',
  675. icon: 'btn-account-receivable.png',
  676. },
  677. {
  678. title: '销售出库',
  679. icon: 'btn-shipped.png',
  680. },
  681. {
  682. title: '销售退货',
  683. icon: 'btn-stored.png',
  684. },
  685. {
  686. title: '销售跟踪',
  687. icon: 'btn-shipped-out.png',
  688. },
  689. {
  690. title: '采购订单',
  691. icon: 'btn-account-receivable.png',
  692. },
  693. {
  694. title: '采购入库',
  695. icon: 'btn-shipped.png',
  696. },
  697. {
  698. title: '采购退货',
  699. icon: 'btn-stored.png',
  700. },
  701. {
  702. title: '以销定采',
  703. icon: 'btn-shipped-out.png',
  704. },
  705. {
  706. title: '库存查询',
  707. icon: 'btn-account-receivable.png',
  708. },
  709. {
  710. title: '入库办理',
  711. icon: 'btn-shipped.png',
  712. },
  713. {
  714. title: '出库办理',
  715. icon: 'btn-stored.png',
  716. },
  717. {
  718. title: '库存盘点',
  719. icon: 'btn-shipped-out.png',
  720. },
  721. {
  722. title: '资金账户',
  723. icon: 'btn-account-receivable.png',
  724. },
  725. {
  726. title: '资金转账',
  727. icon: 'btn-shipped.png',
  728. },
  729. {
  730. title: '收款单',
  731. icon: 'btn-stored.png',
  732. },
  733. {
  734. title: '付款单',
  735. icon: 'btn-shipped-out.png',
  736. },
  737. {
  738. title: '日结对账',
  739. icon: 'btn-account-receivable.png',
  740. },
  741. {
  742. title: '资金日记账',
  743. icon: 'btn-shipped.png',
  744. },
  745. {
  746. title: '供应商往来',
  747. icon: 'btn-stored.png',
  748. },
  749. ],
  750. })
  751. } else {
  752. this.setData({
  753. funcMenu: [
  754. {
  755. title: '订单开单',
  756. icon: 'btn-account-receivable.png',
  757. },
  758. {
  759. title: '销售出库',
  760. icon: 'btn-shipped.png',
  761. },
  762. {
  763. title: '销售退货',
  764. icon: 'btn-stored.png',
  765. },
  766. {
  767. title: '销售跟踪',
  768. icon: 'btn-shipped-out.png',
  769. },
  770. {
  771. title: '采购订单',
  772. icon: 'btn-account-receivable.png',
  773. },
  774. {
  775. title: '采购入库',
  776. icon: 'btn-shipped.png',
  777. },
  778. {
  779. title: '采购退货',
  780. icon: 'btn-stored.png',
  781. },
  782. {
  783. title: '以销定采',
  784. icon: 'btn-shipped-out.png',
  785. },
  786. ],
  787. })
  788. }
  789. this.setData({
  790. funcMenuFlg
  791. })
  792. },
  793. })