| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- /*******************************************************************************
- * Copyright(c) 2022 dongke All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:活动(用于续费、注册)
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 周兴 2024-5-15 1.00 新建
- *******************************************************************************/
- const Constants = require('@/utils/Constants.js');
- const util = require('@/utils/util.js')
- const mixins = require('@/mixins/index.js');
- const app = getApp()
- Page({
- mixins: [mixins],
- /**
- * 页面的初始数据
- */
- data: {
- // 企业名称
- companyName: null,
- staffName: null,
- staffPhone: null,
- webMaxNum: app.globalData.company.webMaxNum,
- wxMaxNum: app.globalData.company.wxMaxNum,
- cpEndDate: null,
- activityTable: null,
- readFlag: false,
- staffCount: {
- maxNum: 1,
- webMaxNum: 0,
- wxMaxNum: 0
- },
- curentAdItem: null,
- summaryInfo: {},
- routeObjName: 'company',
- pageFlag: false,
- //按钮
- buttonSaveList: [
- { code: 'save', title: mixins.$t('save'), width: '120rpx' }
- ],
- noticeInfo: {
- title: '注册须知:',
- cpName: '用于登录系统时显示公司信息。',
- contact: '负责人和联系电话:用于开通系统电话确认核实信息。',
- cpSize: '公司规模及门店规模:用于开通系统配置基础档案。'
- }
- },
- /**
- * @desc : 选择活动明细
- * @author : 周兴
- * @date : 2024/4/1
- */
- chooseAdItem(e) {
- let item = e.currentTarget.dataset.item;
- let summaryInfo = this.data.summaryInfo
- // 计算截止日期
- let months = item.validLong + item.extraLong
- let endDate = app.globalData.company.endDate
- endDate = new Date(endDate).addMonths(months)
- summaryInfo.endDate = endDate.toDateStr();
- this.setData({
- curentAdItem: item,
- summaryInfo: summaryInfo
- })
- // 计算金额
- this.countSummaryAmount(item);
- },
- /**
- * @desc : 勾选已阅读表示
- * @author : 周兴
- * @date : 2024/5/17
- */
- handleChangeCheckbox(e) {
- console.log('ee', e);
- this.setData({
- readFlag: e.detail
- })
- },
- /**
- * @desc : 计算金额
- * @author : 周兴
- * @date : 2024/4/1
- */
- countSummaryAmount() {
- let item = this.data.curentAdItem;
- let staffCount = this.data.staffCount;
- let summaryInfo = this.data.summaryInfo
- let amount = 0;
- // 先清空
- summaryInfo.amountInfo = '';
- // 共通用户
- if (staffCount.maxNum) {
- summaryInfo.amountInfo = item.stdPrice + '(打包价格)*' + staffCount.maxNum
- amount += item.stdPrice * staffCount.maxNum
- }
- // 手机端用户
- if (staffCount.wxMaxNum) {
- if (summaryInfo.amountInfo) {
- summaryInfo.amountInfo += ' + '
- }
- summaryInfo.amountInfo += item.wxPrice + '(手机端价格)*' + staffCount.wxMaxNum
- amount += item.wxPrice * staffCount.wxMaxNum
- }
- // 电脑端用户
- if (staffCount.webMaxNum) {
- if (summaryInfo.amountInfo) {
- summaryInfo.amountInfo += ' + '
- }
- summaryInfo.amountInfo += item.webPrice + '(电脑端价格)*' + staffCount.webMaxNum
- amount += item.webPrice * staffCount.webMaxNum
- }
- if (summaryInfo.amountInfo) {
- summaryInfo.amountInfo += ' = ' + amount + '(元)'
- summaryInfo.amount = amount;
- }
- this.setData({
- summaryInfo: summaryInfo
- })
- // 统计两端用户数
- this.countStaffInfo();
- },
- /**
- * @desc : 统计电脑端和手机端的用户数
- * @author : 周兴
- * @date : 2024/4/1
- */
- countStaffInfo() {
- let summaryInfo = this.data.summaryInfo;
- let staffCount = this.data.staffCount;
- if (!staffCount) {
- return;
- }
- let webNum = staffCount.webMaxNum + staffCount.maxNum
- let wxNum = staffCount.wxMaxNum + staffCount.maxNum
- summaryInfo.staffInfo = '可配置手机端授权' + wxNum + '个;电脑端授权' + webNum + '个(包含当前用户)'
- summaryInfo.webMaxNum = webNum
- summaryInfo.wxMaxNum = wxNum
- this.setData({
- summaryInfo: summaryInfo
- })
- },
- /**
- * @desc : 修改用户数
- * @author : 周兴
- * @date : 2024/4/1
- */
- changeStaffCount(e) {
- let staffCount = this.data.staffCount
- let ds = e.currentTarget.dataset
- if (ds.type == 'wx') {
- staffCount.wxMaxNum = e.detail
- } else if (ds.type == 'web') {
- staffCount.webMaxNum = e.detail
- } else {
- staffCount.maxNum = e.detail
- }
- this.setData({
- staffCount: staffCount
- })
- // 计算金额
- this.countSummaryAmount();
- },
- /**
- * @desc : 校验
- * @author : 周兴
- * @date : 2024/4/1
- */
- validData() {
- if (!this.data.readFlag) {
- util.showToast('请勾选阅读须知');
- return false;
- }
- let curentAdItem = this.data.curentAdItem;
- if (!curentAdItem) {
- util.showToast('未选择活动');
- return false
- }
- return true;
- },
- /**
- * @desc : 设置保存参数
- * @author : 周兴
- * @date : 2024/4/1
- */
- setParams(params) {
- let summaryInfo = this.data.summaryInfo
- let curentAdItem = this.data.curentAdItem
- let cpEndDate = this.data.cpEndDate
- if (!summaryInfo || !cpEndDate) return;
- params.webMaxNum = summaryInfo.webMaxNum
- params.wxMaxNum = summaryInfo.wxMaxNum
- params.endDate = summaryInfo.endDate
- params.gradeCode = app.globalData.company.gradeCode
- params.cpId = app.globalData.company.cpId
- params.tradeNo = this.generateRandomNo();
- params.wxUserId = app.globalData.user.userId
- params.tradeAmount = summaryInfo.amount
- console.log('cpEndDate',cpEndDate);
- params.buyBeginDate = new Date(cpEndDate).addDays(1).toDateStr();
- params.buyEndDate = summaryInfo.endDate
- params.extendDays = new Date(params.buyEndDate).dayDiff( new Date(cpEndDate).addDays(1));
- params.buyLong = curentAdItem.activityItemName
- return params;
- },
- /**
- * @desc : 保存数据
- * @author : 周兴
- * @date : 2024/5/17
- */
- saveData(params) {
- return this.excute(this.data.service, this.data.service.reNewCompany, this.data.params).then(res=>{
- if(res.data.code == Constants.SUCESS_CODE){
- // 成功后跳转支付
- this.toPay(res.data.data);
- }
- })
- },
- /**
- * @desc : 查询活动
- * @author : 周兴
- * @date : 2024/4/1
- */
- getActivity() {
- let params = {
- appCode: Constants.APP_CODE,
- activityTypeList: [Constants.kindCode.activityGrade, Constants.kindCode.activityMenu],
- gradeCode: app.globalData.company.gradeCode
- }
- let service = app.globalData['activityService']
- this.excute(service, service.selectActivityItems, params).then(res => {
- if (res.data.code == Constants.SUCESS_CODE) {
- if (res.data && res.data.data) {
- let activityTable = res.data.data;
- this.setData({
- activityTable: activityTable
- })
- }
- }
- });
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- this.setData({
- companyName: app.globalData.company.cpName,
- staffName: app.globalData.user.staffName,
- cpEndDate: app.globalData.company.endDate,
- })
- // 获取活动
- this.getActivity();
- },
- })
|