activity.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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 app = getApp()
  13. Page({
  14. mixins: [mixins],
  15. /**
  16. * 页面的初始数据
  17. */
  18. data: {
  19. // 企业名称
  20. companyName: null,
  21. staffName: null,
  22. staffPhone: null,
  23. webMaxNum: app.globalData.company.webMaxNum,
  24. wxMaxNum: app.globalData.company.wxMaxNum,
  25. cpEndDate: null,
  26. activityTable: null,
  27. readFlag: false,
  28. staffCount: {
  29. maxNum: 1,
  30. webMaxNum: 0,
  31. wxMaxNum: 0
  32. },
  33. curentAdItem: null,
  34. summaryInfo: {},
  35. routeObjName: 'company',
  36. pageFlag: false,
  37. //按钮
  38. buttonSaveList: [
  39. { code: 'save', title: mixins.$t('save'), width: '120rpx' }
  40. ],
  41. noticeInfo: {
  42. title: '注册须知:',
  43. cpName: '用于登录系统时显示公司信息。',
  44. contact: '负责人和联系电话:用于开通系统电话确认核实信息。',
  45. cpSize: '公司规模及门店规模:用于开通系统配置基础档案。'
  46. }
  47. },
  48. /**
  49. * @desc : 选择活动明细
  50. * @author : 周兴
  51. * @date : 2024/4/1
  52. */
  53. chooseAdItem(e) {
  54. let item = e.currentTarget.dataset.item;
  55. let summaryInfo = this.data.summaryInfo
  56. // 计算截止日期
  57. let months = item.validLong + item.extraLong
  58. let endDate = app.globalData.company.endDate
  59. endDate = new Date(endDate).addMonths(months)
  60. summaryInfo.endDate = endDate.toDateStr();
  61. this.setData({
  62. curentAdItem: item,
  63. summaryInfo: summaryInfo
  64. })
  65. // 计算金额
  66. this.countSummaryAmount(item);
  67. },
  68. /**
  69. * @desc : 勾选已阅读表示
  70. * @author : 周兴
  71. * @date : 2024/5/17
  72. */
  73. handleChangeCheckbox(e) {
  74. console.log('ee', e);
  75. this.setData({
  76. readFlag: e.detail
  77. })
  78. },
  79. /**
  80. * @desc : 计算金额
  81. * @author : 周兴
  82. * @date : 2024/4/1
  83. */
  84. countSummaryAmount() {
  85. let item = this.data.curentAdItem;
  86. let staffCount = this.data.staffCount;
  87. let summaryInfo = this.data.summaryInfo
  88. let amount = 0;
  89. // 先清空
  90. summaryInfo.amountInfo = '';
  91. // 共通用户
  92. if (staffCount.maxNum) {
  93. summaryInfo.amountInfo = item.stdPrice + '(打包价格)*' + staffCount.maxNum
  94. amount += item.stdPrice * staffCount.maxNum
  95. }
  96. // 手机端用户
  97. if (staffCount.wxMaxNum) {
  98. if (summaryInfo.amountInfo) {
  99. summaryInfo.amountInfo += ' + '
  100. }
  101. summaryInfo.amountInfo += item.wxPrice + '(手机端价格)*' + staffCount.wxMaxNum
  102. amount += item.wxPrice * staffCount.wxMaxNum
  103. }
  104. // 电脑端用户
  105. if (staffCount.webMaxNum) {
  106. if (summaryInfo.amountInfo) {
  107. summaryInfo.amountInfo += ' + '
  108. }
  109. summaryInfo.amountInfo += item.webPrice + '(电脑端价格)*' + staffCount.webMaxNum
  110. amount += item.webPrice * staffCount.webMaxNum
  111. }
  112. if (summaryInfo.amountInfo) {
  113. summaryInfo.amountInfo += ' = ' + amount + '(元)'
  114. }
  115. this.setData({
  116. summaryInfo: summaryInfo
  117. })
  118. // 统计两端用户数
  119. this.countStaffInfo();
  120. },
  121. /**
  122. * @desc : 统计电脑端和手机端的用户数
  123. * @author : 周兴
  124. * @date : 2024/4/1
  125. */
  126. countStaffInfo() {
  127. let summaryInfo = this.data.summaryInfo;
  128. let staffCount = this.data.staffCount;
  129. if (!staffCount) {
  130. return;
  131. }
  132. let webNum = staffCount.webMaxNum + staffCount.maxNum
  133. let wxNum = staffCount.wxMaxNum + staffCount.maxNum
  134. summaryInfo.staffInfo = '可配置手机端授权' + wxNum + '个;电脑端授权' + webNum + '个(包含当前用户)'
  135. summaryInfo.webMaxNum = webNum
  136. summaryInfo.wxMaxNum = wxNum
  137. this.setData({
  138. summaryInfo: summaryInfo
  139. })
  140. },
  141. /**
  142. * @desc : 修改用户数
  143. * @author : 周兴
  144. * @date : 2024/4/1
  145. */
  146. changeStaffCount(e) {
  147. let staffCount = this.data.staffCount
  148. let ds = e.currentTarget.dataset
  149. if (ds.type == 'wx') {
  150. staffCount.wxMaxNum = e.detail
  151. } else if (ds.type == 'web') {
  152. staffCount.webMaxNum = e.detail
  153. } else {
  154. staffCount.maxNum = e.detail
  155. }
  156. this.setData({
  157. staffCount: staffCount
  158. })
  159. // 计算金额
  160. this.countSummaryAmount();
  161. },
  162. /**
  163. * @desc : 校验
  164. * @author : 周兴
  165. * @date : 2024/4/1
  166. */
  167. validData() {
  168. if (!this.data.readFlag) {
  169. util.showToast('请勾选阅读须知');
  170. return false;
  171. }
  172. let curentAdItem = this.data.curentAdItem;
  173. if (!curentAdItem) {
  174. util.showToast('未选择活动');
  175. return false
  176. }
  177. return true;
  178. },
  179. /**
  180. * @desc : 设置保存参数
  181. * @author : 周兴
  182. * @date : 2024/4/1
  183. */
  184. setParams(params) {
  185. let summaryInfo = this.data.summaryInfo
  186. if (!summaryInfo) return;
  187. params.webMaxNum = summaryInfo.webMaxNum
  188. params.wxMaxNum = summaryInfo.wxMaxNum
  189. params.endDate = summaryInfo.endDate
  190. params.gradeCode = app.globalData.company.gradeCode
  191. params.cpId = app.globalData.company.cpId
  192. return params;
  193. },
  194. /**
  195. * @desc : 保存数据
  196. * @author : 周兴
  197. * @date : 2024/5/17
  198. */
  199. saveData(params) {
  200. return this.excute(this.data.service, this.data.service.reNewCompany, this.data.params)
  201. },
  202. /**
  203. * @desc : 查询活动
  204. * @author : 周兴
  205. * @date : 2024/4/1
  206. */
  207. getActivity() {
  208. let params = {
  209. appCode: Constants.APP_CODE,
  210. activityTypeList: [Constants.kindCode.activityGrade, Constants.kindCode.activityMenu],
  211. gradeCode: app.globalData.company.gradeCode
  212. }
  213. let service = app.globalData['activityService']
  214. this.excute(service, service.selectActivityItems, params).then(res => {
  215. if (res.data.code == Constants.SUCESS_CODE) {
  216. if (res.data && res.data.data) {
  217. let activityTable = res.data.data;
  218. this.setData({
  219. activityTable: activityTable
  220. })
  221. }
  222. }
  223. });
  224. },
  225. /**
  226. * 生命周期函数--监听页面加载
  227. */
  228. onLoad(options) {
  229. this.setData({
  230. companyName: app.globalData.company.cpName,
  231. staffName: app.globalData.user.staffName,
  232. cpEndDate: app.globalData.company.endDate,
  233. })
  234. // 获取活动
  235. this.getActivity();
  236. },
  237. })