欢迎光临,了解微信小程序开发,就上易用通!

个税计算器 / 微信小程序开发

发布:2019-01-03 08:52浏览: 来源:网络 作者:cola

019年1月1日即将到来,码农们除了关心自己的技能之外,还有薪资是不是可以多拿点。 每次算的时候 都要百度一下个人所得税,但是很多都是老的税率计算,找一个新的出来还是比较麻烦,所以个人开发了一个最新税率的小程序。解决和我有着一样痛苦的码农们的问题。

根据最新税改后计算个人所得税的计算器。目前支持南京,后续开放 杭州 上海 北京等城市。 如果有疑问的可以加最下方 开发者微信。

  • 首先在微信官网下载微信小程序开发工具 https://mp.weixin.qq.com
  • 在https://mp.weixin.qq.com 注册小程序账号,完成个人实名认证。
  • 在小程序后台拿到appid,下面就可以开发了。

实例查看二维码:

 

个税计算器 / 微信小程序开发(图1)

先使用weui 小程序ui框架就行页面布局

 

个税计算器 / 微信小程序开发(图2)个税计算器 / 微信小程序开发(图3)

<button block type="dark" bindtap='calculationBindtap'>计算</button>

其次写JS代码(计算按钮逻辑代码)

import data from './data'

const app = getApp;

Page({
    data: {
        options1: data,
        value: '1',
        checked: true,
        standard: 1,
        marking: 5000,
        beforetaxCount: 0,
        specialitemCount: 0
    },
    

    calculationBindtap:function(){
        // 开始计算  计算完成把计算结果放在result对象中
        var beforetaxCount = this.data.beforetaxCount;
        var specialitemCount = this.data.specialitemCount;
        var marking = this.data.marking;
        if (beforetaxCount == null || beforetaxCount == 0 || beforetaxCount == ''){
            wx.showToast({
                title: '输入正确薪资',
                mask: true,
                icon: 'loading'
            })
            return;
        }
        if (specialitemCount == null || specialitemCount == ''){
            specialitemCount = 0;
        }
        // 开始计算

        var oldNum = 0.08;
        var medNum = 0.02;
        var unemNum = 0.005;
        var workNum = 0;
        var giveNum = 0;

        var providentfundNum = 0.08;

        var insuranceBase = 19935;
        var providentfundBase = 25300;

        var oldcount = 0;
        var medcount = 0;
        var unemcount = 0;
        var workcount = 0;
        var givecount = 0;

        var providentfundcount = 0;

        var privateFee = 0;
        var plusFee = 0;

        if(this.data.checked){
            if (parseFloat(beforetaxCount) > parseFloat(insuranceBase)) {
                oldcount = parseFloat(insuranceBase) * parseFloat(oldNum);
                medcount = parseFloat(insuranceBase) * parseFloat(medNum);
                unemcount = parseFloat(insuranceBase) * parseFloat(unemNum);
                workcount = parseFloat(insuranceBase) * parseFloat(workNum);
                givecount = parseFloat(insuranceBase) * parseFloat(giveNum);
            } else {
                oldcount = parseFloat(beforetaxCount) * parseFloat(oldNum);
                medcount = parseFloat(beforetaxCount) * parseFloat(medNum);
                unemcount = parseFloat(beforetaxCount) * parseFloat(unemNum);
                workcount = parseFloat(beforetaxCount) * parseFloat(workNum);
                givecount = parseFloat(beforetaxCount) * parseFloat(giveNum);
            }

            if (parseFloat(beforetaxCount) > parseFloat(providentfundBase)) {
                providentfundcount = parseFloat(providentfundBase) * parseFloat(providentfundNum);
            } else {
                providentfundcount = parseFloat(beforetaxCount) * parseFloat(providentfundNum);
            }
        }

        // 保险总费用
        var totalInsuranceFee = parseFloat(oldcount) + parseFloat(medcount) + parseFloat(unemcount) + parseFloat(workcount) + parseFloat(givecount);
        // 公积金费用 
        var totalProvidentfundFee = providentfundcount;

        // 下面的钱 交税
        console.log(this.data.marking);
        var otherFee = parseFloat(beforetaxCount) - parseFloat(totalInsuranceFee) - parseFloat(totalProvidentfundFee) - parseFloat(this.data.marking) - parseFloat(specialitemCount);
        
        if (parseFloat(otherFee) <= 3000 && parseFloat(otherFee) > 0) {
            privateFee = parseFloat(otherFee) * 0.03;
            plusFee = 0;
        }
        if (parseFloat(otherFee) <= 12000 && parseFloat(otherFee) > 3000) {
            privateFee = parseFloat(otherFee) * 0.1;
            plusFee = 210;
        }
        if (parseFloat(otherFee) <= 25000 && parseFloat(otherFee) > 12000) {
            privateFee = parseFloat(otherFee) * 0.2;
            plusFee = 1410;
        }
        if (parseFloat(otherFee) <= 35000 && parseFloat(otherFee) > 25000) {
            privateFee = parseFloat(otherFee) * 0.25;
            plusFee = 2660;
        }
        if (parseFloat(otherFee) <= 55000 && parseFloat(otherFee) > 35000) {
            privateFee = parseFloat(otherFee) * 0.3;
            plusFee = 4410;
        }
        if (parseFloat(otherFee) <= 80000 && parseFloat(otherFee) > 55000) {
            privateFee = parseFloat(otherFee) * 0.35;
            plusFee = 7160;
        }
        if ( parseFloat(otherFee) > 80000) {
            privateFee = parseFloat(otherFee) * 0.45;
            plusFee = 15160;
        }

        var result = {};
        
        result.insuranceCount = totalInsuranceFee;
        result.providentfundCount = totalProvidentfundFee;
        result.providentfundNum = parseFloat(providentfundNum) * 100;
        result.money = parseFloat(beforetaxCount) - parseFloat(totalInsuranceFee) - parseFloat(totalProvidentfundFee) - parseFloat(privateFee) + parseFloat(plusFee);
        result.privateFee = privateFee - parseFloat(plusFee);
        result.specialitemCount = specialitemCount;
        result.oldNum = parseFloat(oldNum) * 100;
        result.medNum = parseFloat(medNum) * 100;
        result.unemNum = parseFloat(unemNum) * 100;
        result.workNum = parseFloat(workNum) * 100;
        result.giveNum = parseFloat(giveNum) * 100;

        result.oldcount = parseFloat(oldcount);
        result.medcount = parseFloat(medcount);
        result.unemcount = parseFloat(unemcount);
        result.workcount = parseFloat(workcount);
        result.givecount = parseFloat(givecount);

        wx.setStorage({
            key: 'result',
            data: result,
            success:function(){
                wx.navigateTo({
                    url: '../calculation/calculationResult',
                })
            }
        })
        
    },

})

把计算好的结果放在result对象中 通过wx.setStorage 放在缓存中,传到下一个页面。最后展示出来。

 

 





免责声明:本站所有文章和图片均来自用户分享和网络收集,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服处理。