|
|
@@ -0,0 +1,222 @@
|
|
|
+const Constants = require('@/utils/Constants.js');
|
|
|
+const mixins = require('@/mixins/index.js');
|
|
|
+const config = require('@/config/config.js');
|
|
|
+const app = getApp()
|
|
|
+
|
|
|
+Page({
|
|
|
+ mixins: [mixins],
|
|
|
+ /**
|
|
|
+ * 页面的初始数据
|
|
|
+ */
|
|
|
+ data: {
|
|
|
+ userEndDateString: '',
|
|
|
+ funData: [],
|
|
|
+ userEndDate: null,
|
|
|
+ userEndDateFlg: false,
|
|
|
+ userEndDateString: '',
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面加载
|
|
|
+ */
|
|
|
+ onLoad(options) {
|
|
|
+ // 查询活动
|
|
|
+ this.getActivity()
|
|
|
+ setTimeout(() => {
|
|
|
+ // 用户到期日期
|
|
|
+ if (app.globalData.company.userEndDate) {
|
|
|
+ this.setData({
|
|
|
+ userEndDate: app.globalData.company.userEndDate
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ //获取服务器的最新时间
|
|
|
+ this.getCurrentDate()
|
|
|
+ }
|
|
|
+ }, 200)
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 服务器的日期
|
|
|
+ * @author : 姜永辉
|
|
|
+ * @date : 2024/4/1
|
|
|
+ */
|
|
|
+ getCurrentDate() {
|
|
|
+ let _this = this
|
|
|
+ let service = app.globalData['commonService']
|
|
|
+ _this.excute(service, service.getCurrentDate, {}).then(res => {
|
|
|
+ if (res.data.code == Constants.SUCESS_CODE) {
|
|
|
+ //服务器的时间
|
|
|
+ let nowDate = res.data.data.currentDate
|
|
|
+ let endDate = new Date(nowDate).addMonths(12).addDays(-1).toDateStr()
|
|
|
+ // 用户到期日期
|
|
|
+ if (_this.data.userEndDate == null || !_this.data.userEndDate) {
|
|
|
+ this.setData({
|
|
|
+ userEndDate: endDate,
|
|
|
+ userEndDateFlg: true,
|
|
|
+ userEndDateString: _this.data.funData.wxPrice + '元/年(' + _this.data.funData.activityItemDescribe + ')',
|
|
|
+ factAmt: _this.data.funData.wxPrice,
|
|
|
+ extendDays: 365,
|
|
|
+ nowDate,
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 和 服务器的时间一致
|
|
|
+ if (_this.data.userEndDate == endDate) {
|
|
|
+ this.setData({
|
|
|
+ userEndDateFlg: true,
|
|
|
+ userEndDateString: _this.data.funData.wxPrice + '元/年(' + _this.data.funData.activityItemDescribe + ')',
|
|
|
+ factAmt: _this.data.funData.wxPrice,
|
|
|
+ extendDays: 365,
|
|
|
+ nowDate,
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ let extendDays = Math.ceil(new Date(_this.data.userEndDate).dayDiff(new Date(nowDate)) + 1);
|
|
|
+
|
|
|
+ let price = (Math.round((_this.data.funData.wxPrice / 365 + Number.EPSILON) * 100) / 100).toFixed(2)
|
|
|
+ console.log(price);
|
|
|
+ let factAmt = (Number(price) * extendDays).toFixed(2)
|
|
|
+ this.setData({
|
|
|
+ userEndDateFlg: false,
|
|
|
+ userEndDateString: price + '元/天(' + _this.data.funData.activityItemDescribe + ')* ' + extendDays + '天=' + factAmt + '元',
|
|
|
+ factAmt: factAmt,
|
|
|
+ extendDays,
|
|
|
+ nowDate,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 查询活动
|
|
|
+ * @author : 周兴
|
|
|
+ * @date : 2024/4/1
|
|
|
+ */
|
|
|
+ getActivity() {
|
|
|
+ let params = {
|
|
|
+ appCode: Constants.APP_CODE,
|
|
|
+ activityStatus: Constants.kindCode.activityStatus,
|
|
|
+ cpId: app.globalData.company.cpId,
|
|
|
+ gradeCode: this.data.gradeCode,
|
|
|
+ activityTypeList: [Constants.kindCode.activityFunc],
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 funData = []
|
|
|
+ let data = res.data.data
|
|
|
+ data.forEach(it => {
|
|
|
+ if (it.activityItemDescribe == '报表功能包') {
|
|
|
+ funData = it
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ funData: funData
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 设置保存参数
|
|
|
+ * @author : 周兴
|
|
|
+ * @date : 2024/4/1
|
|
|
+ */
|
|
|
+ setParams(params) {
|
|
|
+ let funPackage = app.globalData.company.funPackage || []
|
|
|
+ params.endDate = app.globalData.company.endDate
|
|
|
+ params.userEndDate = this.data.userEndDate
|
|
|
+ params.gradeCode = app.globalData.company.gradeCode
|
|
|
+ params.cpId = app.globalData.company.cpId
|
|
|
+ params.tradeNo = this.generateRandomNo();
|
|
|
+ params.wxUserId = app.globalData.user.userId
|
|
|
+ params.tradeAmount = Number(this.data.factAmt)
|
|
|
+ params.buyBeginDate = this.data.nowDate;
|
|
|
+ params.buyEndDate = this.data.userEndDate
|
|
|
+ params.extendDays = 0;
|
|
|
+ params.wxMaxNum = app.globalData.company.wxMaxNum
|
|
|
+ params.webMaxNum = app.globalData.company.webMaxNum
|
|
|
+ funPackage.push({
|
|
|
+ funUuids: this.data.funData.funUuids,
|
|
|
+ activityId: this.data.funData.activityId,
|
|
|
+ })
|
|
|
+ params.funPackage = funPackage
|
|
|
+ if (app.globalData.company.vip) {
|
|
|
+ params.vip = true;
|
|
|
+ }
|
|
|
+ params.buyLong = this.data.extendDays + '天'
|
|
|
+ console.log(params);
|
|
|
+ return params;
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 保存数据
|
|
|
+ * @author : 周兴
|
|
|
+ * @date : 2024/5/17
|
|
|
+ */
|
|
|
+ saveData(params) {
|
|
|
+ let service = app.globalData['companyService']
|
|
|
+ return this.excute(service, service.saveFunc, this.data.params).then(res => {
|
|
|
+ if (res.data.code == Constants.SUCESS_CODE) {
|
|
|
+ // 成功后跳转支付
|
|
|
+ this.toPay(res.data.data);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 体验跳转
|
|
|
+ * @author : 常皓宁
|
|
|
+ * @date : 2024/7/4 13:16
|
|
|
+ */
|
|
|
+ handleTitleBtn(e) {
|
|
|
+ let type = e.currentTarget.dataset.item
|
|
|
+ //收发存汇总表
|
|
|
+ if (type == 'INT') {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/package-inventory/pages/ivt-sum-report/ivt-sum-report',
|
|
|
+ success: function (res) {
|
|
|
+ let params = {
|
|
|
+ testFlag: true
|
|
|
+ }
|
|
|
+ res.eventChannel.emit('params', {
|
|
|
+ params: params
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ //客户收支表
|
|
|
+ else if (type == 'CUS') {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/package-business-analysis/pages/cus-rec-pay-report/cus-rec-pay-report',
|
|
|
+ success: function (res) {
|
|
|
+ let params = {
|
|
|
+ testFlag: true
|
|
|
+ }
|
|
|
+ res.eventChannel.emit('params', {
|
|
|
+ params: params
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ //利润表
|
|
|
+ else {
|
|
|
+ let this_ = this
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/package-business-analysis/pages/profit-report/profit-report',
|
|
|
+ success: function (res) {
|
|
|
+ let params = {
|
|
|
+ testFlag: true
|
|
|
+ }
|
|
|
+ res.eventChannel.emit('params', {
|
|
|
+ params: params
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+})
|