activity.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900
  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. integral: 0,
  95. viewHeight: 205,
  96. couponList: [],
  97. couponUse: {},
  98. // 策略
  99. integralTacticItem: {},
  100. },
  101. /**
  102. * @desc : 选择活动明细
  103. * @author : 周兴
  104. * @date : 2024/4/1
  105. */
  106. chooseAdItem(e) {
  107. let item = e.currentTarget.dataset.item;
  108. let summaryInfo = this.data.summaryInfo
  109. // 计算截止日期
  110. let months = item.validLong + item.extraLong
  111. let endDate = app.globalData.company.endDate
  112. // 升级需要从当天开始算
  113. if (this.data.upgradeFlag) {
  114. endDate = new Date()
  115. }
  116. endDate = new Date(endDate).addMonths(months).addDays(-1)
  117. summaryInfo.endDate = endDate.toDateStr();
  118. this.setData({
  119. curentAdItem: item,
  120. summaryInfo: summaryInfo
  121. })
  122. // 计算金额
  123. this.countSummaryAmount(item);
  124. },
  125. /**
  126. * @desc : 选择VIP报表明细
  127. * @author : 周兴
  128. * @date : 2024/4/1
  129. */
  130. chooseVipItem(e) {
  131. let item = e.currentTarget.dataset.item
  132. let index = e.currentTarget.dataset.index
  133. let vipTable = this.data.vipTable
  134. item.chooseVipFlag = !item.chooseVipFlag
  135. vipTable[index] = item
  136. this.setData({
  137. chooseVipFlag: !this.data.chooseVipFlag,
  138. vipTable,
  139. })
  140. // 计算金额
  141. this.countSummaryAmountSTD();
  142. },
  143. /**
  144. * @desc : 勾选已阅读表示
  145. * @author : 周兴
  146. * @date : 2024/5/17
  147. */
  148. handleChangeCheckbox(e) {
  149. this.setData({
  150. readFlag: e.detail
  151. })
  152. },
  153. /**
  154. * @desc : 计算金额
  155. * @author : 周兴
  156. * @date : 2024/4/1
  157. */
  158. countSummaryAmount() {
  159. let item = this.data.curentAdItem;
  160. if (!item) return;
  161. let staffCount = this.data.staffCount;
  162. let summaryInfo = this.data.summaryInfo
  163. let amount = 0;
  164. // 先清空
  165. summaryInfo.amountInfo = '';
  166. // 共通用户
  167. if (staffCount.maxNum) {
  168. summaryInfo.amountInfo = item.stdPrice + '(打包价格)*' + staffCount.maxNum
  169. amount += item.stdPrice * staffCount.maxNum
  170. }
  171. // 手机端用户
  172. if (staffCount.wxMaxNum) {
  173. if (summaryInfo.amountInfo) {
  174. summaryInfo.amountInfo += ' + '
  175. }
  176. summaryInfo.amountInfo += item.wxPrice + '(手机端价格)*' + staffCount.wxMaxNum
  177. amount += item.wxPrice * staffCount.wxMaxNum
  178. }
  179. // 电脑端用户
  180. if (staffCount.webMaxNum) {
  181. if (summaryInfo.amountInfo) {
  182. summaryInfo.amountInfo += ' + '
  183. }
  184. summaryInfo.amountInfo += item.webPrice + '(电脑端价格)*' + staffCount.webMaxNum
  185. amount += item.webPrice * staffCount.webMaxNum
  186. }
  187. if (summaryInfo.amountInfo) {
  188. summaryInfo.amountInfo += ' = ' + amount + '(元)'
  189. summaryInfo.amount = amount;
  190. }
  191. this.setData({
  192. summaryInfo: summaryInfo
  193. })
  194. // 统计两端用户数
  195. this.countStaffInfo();
  196. },
  197. /**
  198. * @desc : 获取标准版的价格显示
  199. * @author : 周兴
  200. * @date : 2024/4/1
  201. */
  202. countSummaryAmountSTD() {
  203. let _this = this
  204. let item = this.data.curentAdItem;
  205. let vipTable = this.data.vipTable
  206. let summaryInfo = this.data.summaryInfo
  207. let amount = 0;
  208. // 先清空
  209. summaryInfo.amountInfo = '';
  210. let extendDays = null;
  211. // 服务器的时间
  212. let nowDate = new Date(this.data.currentDate.toDateStr());
  213. extendDays = new Date(summaryInfo.userEndDate).dayDiff(nowDate) + 1;
  214. if (summaryInfo.wxMaxNum >= 0) {
  215. // 购买授权
  216. if (this.data.buyUser) {
  217. summaryInfo.amountInfo += item.wxPrice + '(元) '
  218. } else {
  219. summaryInfo.amountInfo += item.wxPrice + '(元) ' +
  220. ' * 1(年) * ' + summaryInfo.wxMaxNum + '(个)'
  221. }
  222. amount += item.wxPrice * summaryInfo.wxMaxNum
  223. }
  224. // vip报表
  225. if (vipTable && vipTable.length > 0) {
  226. vipTable.forEach(vipItem => {
  227. if (vipItem.chooseVipFlag) {
  228. summaryInfo.amountInfo += ' + ' + vipItem.wxPrice + '(元/' + vipItem.activityItemDescribe + ') ';
  229. summaryInfo.amountInfo = '( ' + summaryInfo.amountInfo + ' ) ';
  230. amount += vipItem.wxPrice;
  231. }
  232. })
  233. }
  234. // 购买授权
  235. if (this.data.buyUser) {
  236. summaryInfo.amountInfo += ' / 365(天) * ' + extendDays + '(天) * ' + summaryInfo.wxMaxNum + '(个)'
  237. if (summaryInfo.amountInfo) {
  238. amount = (amount / 365 * extendDays).toFixed(2);
  239. summaryInfo.amountInfo += ' = ' + amount + '(元)'
  240. summaryInfo.amount = amount;
  241. }
  242. this.setData({
  243. userEndDate: summaryInfo.userEndDate
  244. })
  245. } else {
  246. // 续费
  247. if (summaryInfo.amountInfo) {
  248. amount = (amount).toFixed(2);
  249. summaryInfo.amountInfo += ' = ' + amount + '(元)'
  250. summaryInfo.amount = amount;
  251. }
  252. let userEndDate = new Date(summaryInfo.userEndDate).addMonths(12).addDays(-1)
  253. this.setData({
  254. userEndDate: userEndDate.toDateStr()
  255. })
  256. }
  257. // 积分转成现金
  258. let integralRateVal = Number((_this.data.integral / _this.data.integralTacticItem.exchangeRate).toFixed(2))
  259. // 折扣--数据库的值不能超过10
  260. let discount = _this.data.couponUse.discount ? _this.data.couponUse.discount / 10 : 1
  261. if (_this.data.integral > Math.ceil(_this.data.integralTacticItem.exchangeRate * summaryInfo.amount)) {
  262. _this.setData({
  263. integral: Math.ceil(_this.data.integralTacticItem.exchangeRate * summaryInfo.amount)
  264. })
  265. summaryInfo.amount = 0.00
  266. } else {
  267. summaryInfo.amount = Number((summaryInfo.amount - integralRateVal) * discount.toFixed(2))
  268. }
  269. // 计算一授权一天的单价
  270. if (summaryInfo.userEndDate) {
  271. let price = (summaryInfo.amount / summaryInfo.wxMaxNum / extendDays).toFixed(2);
  272. summaryInfo.priceInfo = price
  273. summaryInfo.extendDays = extendDays
  274. }
  275. this.setData({
  276. summaryInfo: summaryInfo
  277. })
  278. },
  279. /**
  280. * @desc : 统计电脑端和手机端的用户数
  281. * @author : 周兴
  282. * @date : 2024/4/1
  283. */
  284. countStaffInfo() {
  285. let summaryInfo = this.data.summaryInfo;
  286. let staffCount = this.data.staffCount;
  287. if (!staffCount) {
  288. return;
  289. }
  290. let webNum = staffCount.webMaxNum + staffCount.maxNum
  291. let wxNum = staffCount.wxMaxNum + staffCount.maxNum
  292. summaryInfo.staffInfo = '可配置手机端授权' + wxNum + '个;电脑端授权' + webNum + '个(包含当前用户)'
  293. summaryInfo.webMaxNum = webNum
  294. summaryInfo.wxMaxNum = wxNum
  295. // 升级从当天算
  296. if (this.data.upgradeFlag) {
  297. summaryInfo.buyBeginDate = new Date().addDays(1).toDateStr();
  298. summaryInfo.extendDays = new Date(summaryInfo.endDate).dayDiff(new Date().addDays(1));
  299. } else {
  300. summaryInfo.buyBeginDate = new Date(this.data.cpEndDate).addDays(1).toDateStr();
  301. summaryInfo.extendDays = new Date(summaryInfo.endDate).dayDiff(new Date(this.data.cpEndDate).addDays(1));
  302. }
  303. // 计算一授权一天的单价
  304. let price = (summaryInfo.amount / (webNum + wxNum) / summaryInfo.extendDays).toFixed(2);
  305. summaryInfo.priceInfo = price
  306. this.setData({
  307. summaryInfo: summaryInfo
  308. })
  309. },
  310. /**
  311. * @desc : 修改用户数
  312. * @author : 周兴
  313. * @date : 2024/4/1
  314. */
  315. changeStaffCount(e) {
  316. let staffCount = this.data.staffCount
  317. let ds = e.currentTarget.dataset
  318. if (ds.type == 'wx') {
  319. staffCount.wxMaxNum = e.detail
  320. } else if (ds.type == 'web') {
  321. staffCount.webMaxNum = e.detail
  322. } else {
  323. staffCount.maxNum = e.detail
  324. }
  325. this.setData({
  326. staffCount: staffCount
  327. })
  328. // 计算金额
  329. this.countSummaryAmount();
  330. },
  331. /**
  332. * @desc : 保存
  333. * @author : 周兴
  334. * @date : 2024/4/1
  335. */
  336. handleSave() {
  337. let summaryInfo = this.data.summaryInfo;
  338. let currentUserCount = this.data.currentUserCount
  339. if (!currentUserCount) {
  340. return;
  341. }
  342. if (this.data.gradeCode == Constants.gradeCode.STD) {
  343. // 必须要选择一个授权
  344. if (Number(summaryInfo.wxMaxNum) <= 0 && this.data.buyUser) {
  345. util.showToast('请选择一个授权');
  346. return false
  347. }
  348. // 功能包
  349. let chooseVipFlag = false
  350. this.data.vipTable.forEach(it => {
  351. if (it.chooseVipFlag) {
  352. chooseVipFlag = true
  353. return
  354. }
  355. })
  356. if (Number(summaryInfo.wxMaxNum) <= 0 && !this.data.buyUser && !chooseVipFlag) {
  357. util.showToast('请选择一个授权或功能包');
  358. return false
  359. }
  360. // 判断数量是否超出续约授权
  361. if (currentUserCount.wxNum > summaryInfo.wxMaxNum && summaryInfo.reCountFlag
  362. && currentUserCount.wxNum > 1 && currentUserCount.wxNum - summaryInfo.wxMaxNum > 1) {
  363. 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' }]
  364. this.save({ saveFlag: false, url: '/package-basic-data/pages/activity/detail/detail?staffInfo=' + JSON.stringify(staffInfo) });
  365. } else {
  366. this.save({});
  367. }
  368. } else {
  369. // 判断数量是否超出续约授权
  370. if (currentUserCount.wxNum > summaryInfo.wxMaxNum || currentUserCount.webNum > summaryInfo.webMaxNum) {
  371. 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' }]
  372. this.save({ saveFlag: false, url: '/package-basic-data/pages/activity/detail/detail?staffInfo=' + JSON.stringify(staffInfo) });
  373. } else {
  374. this.save({});
  375. }
  376. }
  377. },
  378. /**
  379. * @desc : 改变用户授权数
  380. * @author : 周兴
  381. * @date : 2024/4/1
  382. */
  383. changeUserSTD(e) {
  384. let summaryInfo = this.data.summaryInfo
  385. summaryInfo.wxMaxNum = e.detail
  386. this.setData({
  387. summaryInfo: summaryInfo
  388. })
  389. wx.nextTick(() => {
  390. // 计算金额
  391. this.countSummaryAmountSTD();
  392. });
  393. },
  394. /**
  395. * @desc : 校验
  396. * @author : 周兴
  397. * @date : 2024/4/1
  398. */
  399. validData() {
  400. // 专业版校验
  401. if (this.data.gradeCode == Constants.gradeCode.PRO) {
  402. // if (!this.data.readFlag) {
  403. // util.showToast('请勾选阅读须知');
  404. // return false;
  405. // }
  406. let curentAdItem = this.data.curentAdItem;
  407. if (!curentAdItem) {
  408. util.showToast('请选择活动');
  409. return false
  410. }
  411. // 必须要选择一个授权
  412. let staffCount = this.data.staffCount
  413. if (!staffCount.maxNum && !staffCount.webMaxNum && !staffCount.wxMaxNum) {
  414. util.showToast('请选择一个授权');
  415. return false
  416. }
  417. } else {
  418. let curentAdItem = this.data.curentAdItem;
  419. if (!curentAdItem) {
  420. util.showToast('请选择活动');
  421. return false
  422. }
  423. }
  424. return true;
  425. },
  426. /**
  427. * @desc : 设置保存参数
  428. * @author : 周兴
  429. * @date : 2024/4/1
  430. */
  431. setParams(params) {
  432. let summaryInfo = this.data.summaryInfo
  433. let curentAdItem = this.data.curentAdItem
  434. let cpEndDate = this.data.cpEndDate
  435. if (!summaryInfo || !cpEndDate) return;
  436. params.endDate = summaryInfo.endDate
  437. params.userEndDate = summaryInfo.userEndDate
  438. params.gradeCode = this.data.gradeCode
  439. params.cpId = app.globalData.company.cpId
  440. params.tradeNo = this.generateRandomNo();
  441. params.wxUserId = app.globalData.user.userId
  442. params.tradeAmount = summaryInfo.amount
  443. params.buyBeginDate = summaryInfo.buyBeginDate;
  444. params.buyEndDate = summaryInfo.endDate
  445. params.extendDays = summaryInfo.extendDays;
  446. if (this.data.gradeCode == Constants.gradeCode.STD) {
  447. params.buyEndDate = summaryInfo.userEndDate
  448. params.endDate = app.globalData.company.endDate
  449. params.wxMaxNum = summaryInfo.wxMaxNum
  450. if (!summaryInfo.reCountFlag && summaryInfo.wxMaxNumSocial) {
  451. params.wxMaxNum = summaryInfo.wxMaxNum + summaryInfo.wxMaxNumSocial
  452. }
  453. let funPackage = app.globalData.company.funPackage ? [...app.globalData.company.funPackage] : []
  454. params.funPackage = funPackage
  455. // 选中的功能包的数据
  456. let activityIds = []
  457. let itemIds = []
  458. this.data.vipTable.forEach(it => {
  459. if (it.chooseVipFlag) {
  460. activityIds.push(it.activityId)
  461. itemIds.push(it.itemId)
  462. }
  463. })
  464. if (activityIds.length > 0) {
  465. params.activityIds = activityIds
  466. params.activityItemIds = itemIds
  467. }
  468. // 续费的时候需要传
  469. // 购买授权
  470. if (this.data.buyUser) {
  471. params.reNew = app.globalData.company.reNew
  472. } else {
  473. let funPackages = []
  474. this.data.vipTable.forEach(it => {
  475. if (it.chooseVipFlag) {
  476. funPackages.push({
  477. activityId: it.activityId,
  478. funUuids: it.funUuids
  479. })
  480. }
  481. })
  482. let renew = {
  483. "user_end_date": this.data.userEndDate,
  484. "wx_max_num": summaryInfo.wxMaxNum + 1,
  485. "fun_package": funPackages.length > 0 ? funPackages : null,
  486. }
  487. params.reNew = renew
  488. // 续费时候保持原来的 微信人数
  489. params.wxMaxNum = summaryInfo.wxMaxNumSocial
  490. }
  491. params.webMaxNum = 0
  492. params.remarks = summaryInfo.amountInfo
  493. // 交易类型-续费
  494. params.tradeType = '交易类型-续费'
  495. } else {
  496. params.webMaxNum = summaryInfo.webMaxNum
  497. params.wxMaxNum = summaryInfo.wxMaxNum
  498. }
  499. params.buyLong = curentAdItem.activityItemName
  500. // 操作员
  501. params.staffNameFrom = app.globalData.user.staffName
  502. // 优惠券使用id 金额大于0
  503. params.couponUseId = this.data.couponUse.useId && Number(summaryInfo.amount) > 0
  504. ? this.data.couponUse.useId : null
  505. params.integral = this.data.integral
  506. return params;
  507. },
  508. /**
  509. * @desc : 保存数据
  510. * @author : 周兴
  511. * @date : 2024/5/17
  512. */
  513. saveData(params) {
  514. return this.excute(this.data.service, this.data.service.reNewCompany, this.data.params).then(res => {
  515. if (res.data.code == Constants.SUCESS_CODE && Number(this.data.summaryInfo.amount) > 0) {
  516. // 成功后跳转支付
  517. this.toPay(res.data.data);
  518. }
  519. })
  520. },
  521. /**
  522. * @desc : 查询当前用户授权数
  523. * @author : 周兴
  524. * @date : 2024/4/1
  525. */
  526. getStaffCount() {
  527. let service = app.globalData['commonService']
  528. this.excute(service, service.selectUserCount, {}).then(res => {
  529. if (res.data.code == Constants.SUCESS_CODE) {
  530. if (res.data && res.data.data) {
  531. let currentUserCount = res.data.data;
  532. this.setData({
  533. currentUserCount: currentUserCount,
  534. //服务器的时间
  535. currentDate: new Date(currentUserCount.currentDate)
  536. })
  537. }
  538. }
  539. this.setData({
  540. loadFlag: true
  541. })
  542. });
  543. },
  544. /**
  545. * @desc : 关闭所有的tip
  546. * @date : 2024/5/24 15:49
  547. * @author : 王英杰
  548. */
  549. closeAllTips() {
  550. this.closeTips(['tipIntegral'])
  551. },
  552. /**
  553. * @desc : 优惠劵数量获取 积分策略 积分
  554. * @author : 刘尧
  555. * @date : 2024/7/29 15:54
  556. */
  557. getCouponUse() {
  558. let _this = this
  559. this.setData({
  560. loading: true
  561. })
  562. let params = {
  563. couponStatus: Constants.couponStatus.unused,
  564. flgValid: true,
  565. cpId: app.globalData.company.cpId,
  566. }
  567. let service = app.globalData['couponUseService']
  568. this.excute(service, service.listByCondUse, params).then(res => {
  569. if (res.data && res.data.data) {
  570. // 优惠劵数量获取
  571. if (res.data.data.list && res.data.data.list.length > 0) {
  572. this.setData({
  573. couponList: res.data.data.list,
  574. couponUse: res.data.data.list[0],
  575. viewHeight: this.data.viewHeight + 45
  576. })
  577. }
  578. // 积分
  579. if (res.data.data.integral) {
  580. this.setData({
  581. integral: res.data.data.integral,
  582. viewHeight: this.data.viewHeight + 45
  583. })
  584. }
  585. // 积分策略
  586. if (res.data.data.listIntegralTactic && res.data.data.listIntegralTactic.length > 0) {
  587. this.setData({
  588. integralTacticItem: res.data.data.listIntegralTactic[0],
  589. })
  590. }
  591. }
  592. // 获取活动
  593. _this.getActivity()
  594. });
  595. },
  596. /**
  597. * @desc : 查询活动
  598. * @author : 周兴
  599. * @date : 2024/4/1
  600. */
  601. getActivity() {
  602. let params = {
  603. appCode: Constants.APP_CODE,
  604. activityStatus: Constants.kindCode.activityStatus,
  605. cpId: app.globalData.company.cpId,
  606. gradeCode: this.data.gradeCode
  607. }
  608. // 标准版
  609. if (this.data.gradeCode == Constants.gradeCode.STD) {
  610. if (this.data.buyUser) {
  611. params.activityTypeList = [Constants.kindCode.activityGrade];
  612. } else {
  613. params.activityTypeList = [Constants.kindCode.activityGrade, Constants.kindCode.activityFunc];
  614. }
  615. } else {
  616. params.activityTypeList = [Constants.kindCode.activityGrade, Constants.kindCode.activityVip];
  617. }
  618. let service = app.globalData['activityService']
  619. this.excute(service, service.selectActivityItems, params).then(res => {
  620. if (res.data.code == Constants.SUCESS_CODE) {
  621. if (res.data && res.data.data) {
  622. let activityTable = res.data.data;
  623. // 如果是标准版,需要进行截止日期的处理
  624. if (this.data.gradeCode == Constants.gradeCode.STD) {
  625. this.setData({
  626. activityTable: activityTable.filter(it => it.activityType == Constants.kindCode.activityGrade),
  627. vipTable: activityTable.filter(it => it.activityType == Constants.kindCode.activityFunc),
  628. })
  629. this.handleDataStd(activityTable);
  630. } else {
  631. this.setData({
  632. activityTable: activityTable
  633. })
  634. }
  635. }
  636. }
  637. this.setData({
  638. loading: false
  639. })
  640. });
  641. },
  642. /**
  643. * @desc : 标准版处理数据
  644. * @author : 周兴
  645. * @date : 2024/4/1
  646. */
  647. handleDataStd(activityTable) {
  648. if (activityTable && activityTable.length > 0) {
  649. let item = activityTable[0]
  650. this.setData({
  651. curentAdItem: item
  652. })
  653. let summaryInfo = this.data.summaryInfo
  654. let months = item.validLong + item.extraLong
  655. //服务器的时间
  656. let endDate = this.data.currentDate.addMonths(months).addDays(-1)
  657. let dayDiffs = null;
  658. if (summaryInfo.userEndDate) {
  659. dayDiffs = new Date(summaryInfo.userEndDate).dayDiff(this.data.currentDate)
  660. }
  661. // 如果截止日期是空,就取活动中的截止日期
  662. if (!summaryInfo.userEndDate || !dayDiffs || dayDiffs < 0) {
  663. summaryInfo.userEndDate = endDate.toDateStr();
  664. // 重新统计,到期续费或者第一次购买用户
  665. summaryInfo.reCountFlag = true;
  666. summaryInfo.wxMaxNum = summaryInfo.wxMaxNumSocial
  667. this.setData({
  668. showVip: true
  669. })
  670. } else {
  671. // 如果没有购买,需要显示
  672. if (!app.globalData.company.vip) {
  673. this.setData({
  674. showVip: true
  675. })
  676. }
  677. }
  678. summaryInfo.buyBeginDate = this.data.currentDate.toDateStr();
  679. this.setData({
  680. summaryInfo: summaryInfo
  681. })
  682. wx.nextTick(() => {
  683. // 计算金额
  684. this.countSummaryAmountSTD();
  685. });
  686. }
  687. },
  688. /**
  689. * 生命周期函数--监听页面加载
  690. */
  691. onLoad(options) {
  692. // 升级
  693. if (options && options.upgrade) {
  694. wx.setNavigationBarTitle({
  695. title: mixins.$t('updateSpecialized'),
  696. })
  697. this.setData({
  698. gradeCode: Constants.gradeCode.PRO,
  699. upgradeFlag: true
  700. })
  701. } else {
  702. // 购买授权 和续费
  703. if (options.buyUser) {
  704. wx.setNavigationBarTitle({
  705. title: mixins.$t('buyUser'),
  706. })
  707. } else {
  708. wx.setNavigationBarTitle({
  709. title: mixins.$t('reNew'),
  710. })
  711. }
  712. this.setData({
  713. gradeCode: app.globalData.company.gradeCode,
  714. buyUser: options.buyUser
  715. })
  716. }
  717. this.setData({
  718. companyName: app.globalData.company.cpName,
  719. cpManager: app.globalData.company.cpManager,
  720. cpPhone: app.globalData.company.cpPhone,
  721. cpEndDate: app.globalData.company.endDate,
  722. webMaxNum: app.globalData.company.webMaxNum,
  723. wxMaxNum: app.globalData.company.wxMaxNum,
  724. })
  725. // 如果是标准版,需要获取用户授权数(手机)
  726. let summaryInfo = {}
  727. if (app.globalData.company.gradeCode == Constants.gradeCode.STD && !options.buyUser) {
  728. summaryInfo.wxMaxNum = app.globalData.company.wxMaxNum
  729. summaryInfo.reCountFlag = true
  730. } else {
  731. summaryInfo.wxMaxNum = 1
  732. }
  733. summaryInfo.wxMaxNumSocial = this.data.wxMaxNum
  734. // 续费用户到期日期
  735. summaryInfo.userEndDate = app.globalData.company.userEndDate
  736. this.setData({
  737. summaryInfo: summaryInfo,
  738. })
  739. // 获取活动
  740. // this.getActivity();
  741. // 获取当前用户授权数
  742. this.getStaffCount();
  743. // 优惠劵数量获取 积分策略 积分
  744. this.getCouponUse()
  745. },
  746. /**
  747. * 六大功能的切换
  748. */
  749. funcClick(e) {
  750. let funcMenuFlg = !this.data.funcMenuFlg
  751. if (funcMenuFlg) {
  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. title: '库存查询',
  788. icon: 'btn-account-receivable.png',
  789. },
  790. {
  791. title: '入库办理',
  792. icon: 'btn-shipped.png',
  793. },
  794. {
  795. title: '出库办理',
  796. icon: 'btn-stored.png',
  797. },
  798. {
  799. title: '库存盘点',
  800. icon: 'btn-shipped-out.png',
  801. },
  802. {
  803. title: '资金账户',
  804. icon: 'btn-account-receivable.png',
  805. },
  806. {
  807. title: '资金转账',
  808. icon: 'btn-shipped.png',
  809. },
  810. {
  811. title: '收款单',
  812. icon: 'btn-stored.png',
  813. },
  814. {
  815. title: '付款单',
  816. icon: 'btn-shipped-out.png',
  817. },
  818. {
  819. title: '日结对账',
  820. icon: 'btn-account-receivable.png',
  821. },
  822. {
  823. title: '资金日记账',
  824. icon: 'btn-shipped.png',
  825. },
  826. {
  827. title: '供应商往来',
  828. icon: 'btn-stored.png',
  829. },
  830. ],
  831. })
  832. } else {
  833. this.setData({
  834. funcMenu: [
  835. {
  836. title: '订单开单',
  837. icon: 'btn-account-receivable.png',
  838. },
  839. {
  840. title: '销售出库',
  841. icon: 'btn-shipped.png',
  842. },
  843. {
  844. title: '销售退货',
  845. icon: 'btn-stored.png',
  846. },
  847. {
  848. title: '销售跟踪',
  849. icon: 'btn-shipped-out.png',
  850. },
  851. {
  852. title: '采购订单',
  853. icon: 'btn-account-receivable.png',
  854. },
  855. {
  856. title: '采购入库',
  857. icon: 'btn-shipped.png',
  858. },
  859. {
  860. title: '采购退货',
  861. icon: 'btn-stored.png',
  862. },
  863. {
  864. title: '以销定采',
  865. icon: 'btn-shipped-out.png',
  866. },
  867. ],
  868. })
  869. }
  870. this.setData({
  871. funcMenuFlg
  872. })
  873. },
  874. })