zhoux 1 год назад
Родитель
Сommit
56fc70dd69

+ 1 - 0
i18n/zh-CN.js

@@ -44,6 +44,7 @@ const button = {
   invalidSuccessfully: '作废成功',
   tipPop: '用户区分商品色号、非标号使用',
   updateSpecialized: '升级专业版',
+  reNew:'续费',
 }
 
 // 资金

+ 45 - 13
package-basic-data/pages/activity/activity.js

@@ -16,6 +16,9 @@ Page({
      * 页面的初始数据
      */
     data: {
+        // 升级标识
+        upgradeFlag:false,
+        gradeCode:null,
         freeFlag: false,
         // 企业名称
         companyName: null,
@@ -54,7 +57,11 @@ Page({
         // 计算截止日期
         let months = item.validLong + item.extraLong
         let endDate = app.globalData.company.endDate
-        endDate = new Date(endDate).addMonths(months)
+        // 升级需要从当天开始算
+        if(this.data.upgradeFlag){
+            endDate = new Date()
+        }
+        endDate = new Date(endDate).addMonths(months).addDays(-1)
         summaryInfo.endDate = endDate.toDateStr();
         this.setData({
             curentAdItem: item,
@@ -128,7 +135,7 @@ Page({
         let amount = 0;
         // 先清空
         summaryInfo.amountInfo = '';
-        let extendDays = null ;
+        let extendDays = null;
         let nowDate = new Date(new Date().toDateStr());
         if (summaryInfo.reCountFlag) {
             // 手机端用户
@@ -146,7 +153,7 @@ Page({
             if (summaryInfo.wxMaxNum) {
                 summaryInfo.amountInfo += item.wxPrice + '(元) / 365(天) * ' + extendDays + '(天) * ' + summaryInfo.wxMaxNum + '(个)'
                 amount = (item.wxPrice / 365 * extendDays * summaryInfo.wxMaxNum).toFixed(2)
-                console.log('amount',parseFloat(item.wxPrice / 365 * extendDays * summaryInfo.wxMaxNum),amount);
+                console.log('amount', parseFloat(item.wxPrice / 365 * extendDays * summaryInfo.wxMaxNum), amount);
             }
             if (summaryInfo.amountInfo) {
                 summaryInfo.amountInfo += ' = ' + amount + '(元)'
@@ -154,8 +161,8 @@ Page({
             }
         }
 
-         // 计算一授权一天的单价
-         if (summaryInfo.userEndDate) {
+        // 计算一授权一天的单价
+        if (summaryInfo.userEndDate) {
             let price = (summaryInfo.amount / summaryInfo.wxMaxNum / extendDays).toFixed(2);
             summaryInfo.priceInfo = price
             summaryInfo.extendDays = extendDays
@@ -181,8 +188,14 @@ Page({
         summaryInfo.staffInfo = '可配置手机端授权' + wxNum + '个;电脑端授权' + webNum + '个(包含当前用户)'
         summaryInfo.webMaxNum = webNum
         summaryInfo.wxMaxNum = wxNum
-        summaryInfo.buyBeginDate = new Date(this.data.cpEndDate).addDays(1).toDateStr();
-        summaryInfo.extendDays = new Date(summaryInfo.endDate).dayDiff(new Date(this.data.cpEndDate).addDays(1));
+        // 升级从当天算
+        if(this.data.upgradeFlag){
+            summaryInfo.buyBeginDate = new Date().addDays(1).toDateStr(); 
+            summaryInfo.extendDays = new Date(summaryInfo.endDate).dayDiff(new Date().addDays(1));
+        }else{
+            summaryInfo.buyBeginDate = new Date(this.data.cpEndDate).addDays(1).toDateStr();
+            summaryInfo.extendDays = new Date(summaryInfo.endDate).dayDiff(new Date(this.data.cpEndDate).addDays(1));
+        }
         // 计算一授权一天的单价
         let price = (summaryInfo.amount / (webNum + wxNum) / summaryInfo.extendDays).toFixed(2);
         summaryInfo.priceInfo = price
@@ -274,7 +287,7 @@ Page({
             }
             // 必须要选择一个授权
             let staffCount = this.data.staffCount
-            if (!staffCount.maxNum || !staffCount.webMaxNum || !staffCount.wxMaxNum) {
+            if (!staffCount.maxNum && !staffCount.webMaxNum && !staffCount.wxMaxNum) {
                 util.showToast('请选择一个授权');
                 return false
             }
@@ -301,7 +314,7 @@ Page({
         if (!summaryInfo || !cpEndDate) return;
         params.endDate = summaryInfo.endDate
         params.userEndDate = summaryInfo.userEndDate
-        params.gradeCode = app.globalData.company.gradeCode
+        params.gradeCode = this.data.gradeCode
         params.cpId = app.globalData.company.cpId
         params.tradeNo = this.generateRandomNo();
         params.wxUserId = app.globalData.user.userId
@@ -313,10 +326,10 @@ Page({
             params.buyEndDate = summaryInfo.userEndDate
             params.endDate = app.globalData.company.endDate
             params.wxMaxNum = summaryInfo.wxMaxNum
-            if(!summaryInfo.reCountFlag && summaryInfo.wxMaxNumSocial){
+            if (!summaryInfo.reCountFlag && summaryInfo.wxMaxNumSocial) {
                 params.wxMaxNum = summaryInfo.wxMaxNum + summaryInfo.wxMaxNumSocial
             }
-        }else{
+        } else {
             params.webMaxNum = summaryInfo.webMaxNum
             params.wxMaxNum = summaryInfo.wxMaxNum
         }
@@ -364,7 +377,7 @@ Page({
         let params = {
             appCode: Constants.APP_CODE,
             activityTypeList: [Constants.kindCode.activityGrade, Constants.kindCode.activityMenu],
-            gradeCode: app.globalData.company.gradeCode
+            gradeCode: this.data.gradeCode
         }
         let service = app.globalData['activityService']
         this.excute(service, service.selectActivityItems, params).then(res => {
@@ -397,7 +410,7 @@ Page({
             let months = item.validLong + item.extraLong
             let endDate = new Date().addMonths(months).addDays(-1)
             let dayDiffs = null;
-            if(summaryInfo.userEndDate){
+            if (summaryInfo.userEndDate) {
                 dayDiffs = new Date(summaryInfo.userEndDate).dayDiff(new Date(new Date().toDateStr()))
             }
             // 如果截止日期是空,就取活动中的截止日期
@@ -421,6 +434,25 @@ Page({
      * 生命周期函数--监听页面加载
      */
     onLoad(options) {
+        console.log('options', options);
+        // 升级
+        if (options && options.upgrade) {
+            wx.setNavigationBarTitle({
+                title: mixins.$t('updateSpecialized'),
+            })
+            this.setData({
+                gradeCode:Constants.gradeCode.PRO,
+                upgradeFlag:true
+            })
+        } else {
+            wx.setNavigationBarTitle({
+                title: mixins.$t('reNew'),
+            })
+            this.setData({
+                gradeCode:app.globalData.company.gradeCode
+            })
+        }
+
         this.setData({
             companyName: app.globalData.company.cpName,
             cpManager: app.globalData.company.cpManager,

+ 1 - 2
package-basic-data/pages/activity/activity.json

@@ -1,4 +1,3 @@
 {
-    "usingComponents": {},
-    "navigationBarTitleText": "续费"
+    "usingComponents": {}
 }

+ 2 - 2
package-basic-data/pages/activity/activity.wxml

@@ -11,8 +11,8 @@
 			<view class="cp-class">{{companyName}} <dk-tag style="margin-left: 20rpx;" type="primary" padding="0 10rpx" height="30rpx" color="linear-gradient(77.62deg, #CAA977 12.58%, #FFDA7A 85.49%),conic-gradient(from 154.5deg at 29.17% -8.33%, #FFE8BA -0.56deg, rgba(255, 230, 165, 0) 0.26deg, rgba(227, 184, 73, 0.34) 17.37deg, rgba(240, 187, 253, 0.23) 347.83deg, rgba(186, 234, 255, 0.38) 353.78deg, #FFE8BA 359.44deg, rgba(255, 230, 165, 0) 360.26deg);" textColor="#1B365D" radius="10rpx" fontSize="9px" value="{{gradeCode == 'STD'?$t['std']:$t['pro']}}" catchtap="expandCard" data-item="{{card}}" data-index="{{cardIndex}}"></dk-tag>
 			</view>
 			<view class="staff-class">{{cpManager + (cpPhone?(' | ' + cpPhone):'')}}</view>
-			<view class="end-date-class" wx:if="{{gradeCode != 'STD'}}">{{$t['cpEndDate'] + ':' + cpEndDate}}</view>
-			<view class="staff-count-class" wx:if="{{gradeCode != 'STD'}}">{{'手机端授权:' + wxMaxNum + '个,电脑端授权' + webMaxNum + '个' }}</view>
+			<view class="end-date-class" wx:if="{{gradeCode != 'STD' && !upgradeFlag}}">{{$t['cpEndDate'] + ':' + cpEndDate}}</view>
+			<view class="staff-count-class" wx:if="{{gradeCode != 'STD'}}">{{'手机端授权:' + wxMaxNum + '个,电脑端授权' + (webMaxNum?webMaxNum:0) + '个' }}</view>
 			<view class="staff-count-class" wx:if="{{gradeCode == 'STD'}}">{{'手机端授权:' + wxMaxNum + '个(额外购买)'}}</view>
 		</view>
 	</view>

+ 20 - 1
pages/mine/mine.js

@@ -209,7 +209,26 @@ Page({
       events: {
         // 保存成功后刷新页面
         refresh: function (data) {
-          console.log('dfffff',data);
+          // 刷新一览界面
+          wx.reLaunch({
+            url: '/pages/welcome/welcome',
+          })
+        }
+      },
+    })
+  },
+  /**
+  * @desc : 升级
+  * @author : 周兴
+  * @date : 2024/4/9
+  */
+  handleUpgrade(e){
+    let url = '/package-basic-data/pages/activity/activity?upgrade=true'
+    wx.navigateTo({
+      url: url,
+      events: {
+        // 保存成功后刷新页面
+        refresh: function (data) {
           // 刷新一览界面
           wx.reLaunch({
             url: '/pages/welcome/welcome',

+ 1 - 1
pages/mine/mine.wxml

@@ -116,7 +116,7 @@
     <!-- <view class="todo-view" style="margin-bottom: 4rpx;">
       <view class="todo-view-title" catch:tap="toTestExample">toTestExample</view>
     </view> -->
-    <view class="todo-view" style="display: flex;justify-content:space-between;align-items: center;margin-bottom: 4rpx;" wx:if="{{gradeCode == 'STD'}}">
+    <view class="todo-view" style="display: flex;justify-content:space-between;align-items: center;margin-bottom: 4rpx;" wx:if="{{gradeCode == 'STD'}}" catchtap="handleUpgrade">
       <view class="todo-view-title">标准版</view>
       <view class="todo-view-title" style="display: flex;justify-content:space-between;align-items: center;">
         <image src="{{imageUrl + 'diamond.png'}}" style="width:40rpx;height:40rpx; margin-right: 10rpx;" />

+ 24 - 5
pages/welcome/welcome.js

@@ -12,7 +12,8 @@ const app = getApp()
 const api = require('@/utils/api.js');
 const config = require('@/config/config.js');
 const Constants = require('@/utils/Constants.js');
-const util = require('@/utils/util.js')
+const util = require('@/utils/util.js');
+const { gradeCode } = require('@/utils/Constants.js');
 Page({
 
     /**
@@ -192,6 +193,23 @@ Page({
                     // 员工
                     let staff = res.data.data.staff
                     if (staff && staff.staffId) {
+                        // 判断当前用户是否到期 标准版
+                        if (app.globalData.company.gradeCode == Constants.gradeCode.STD && !staff.flgInit) {
+                            let userEndDate = app.globalData.company.userEndDate
+                            if (userEndDate) {
+                                let diffs = new Date(userEndDate).dayDiff(new Date(new Date().toDateStr()))
+                                // 说明已经到期,跳转到
+                                if (diffs < 0) {
+                                    // util.showToast('用户已到期,到期日期【' + userEndDate + '】')
+                                    // setTimeout(() => {
+                                    //     wx.reLaunch({
+                                    //         url: '../../pages/login/login',
+                                    //     })
+                                    // }, 2000)
+                                    // return;
+                                }
+                            }
+                        }
                         app.globalData.user.staffId = staff.staffId
                         app.globalData.user.staffCode = staff.staffCode
                         app.globalData.user.staffName = staff.staffName
@@ -201,6 +219,7 @@ Page({
                         app.globalData.user.defaultWhName = staff.defaultWhName
                         app.globalData.user.defaultWhId = staff.defaultWhId
                         app.globalData.user.flgBusiness = staff.flgBusiness
+                        console.log('ffffffd', app.globalData.company);
 
                         // 调转主页--注意有场景值的情况 
                         if (this.data.scene) {
@@ -231,10 +250,10 @@ Page({
                         //     }
                         // }
                         // 处理操作链接
-                        let filters = menuList.filter(it=>it.menuTags)
-                        if(filters && filters.length > 0){
-                            filters.forEach(t=>{
-                                if(t.menuTags.value){
+                        let filters = menuList.filter(it => it.menuTags)
+                        if (filters && filters.length > 0) {
+                            filters.forEach(t => {
+                                if (t.menuTags.value) {
                                     let val = JSON.parse(t.menuTags.value)
                                     t.guideUrl = val.guideUrl
                                 }