唯心笔录

  • 随笔
  • 笔记
  • 口水
  • 备忘

Amazon bt chanify CodeServer docker fastadmin frp JS Linux MySql NAS openwrt photoprism photosync PHP Portainer Shortener SMB vfs wechat 亚马逊 内网穿透 升级 备份 宝塔 引号 微信 微擎 换行 文本分类 正则 照片 电报 短网址 缓存 群晖 迅雷

近期文章

  • 分本分类模型训练实战教程
  • 电报邀请链接机制
  • 如何批量下载Telegram群组视频图片等媒体
  • Navicat提示2002 10060无法连远程数据库
  • 群晖通过SSH工具命令行方式升级docker应用memos

供应商充值时js自动计算金额

  • jeechou
  • 2023-06-08
  • 0

fastadmin在给供应商充值的时候,需要点击add.html进行新增,这里可以实现JS自动获取供应商余额,根绝变更类型,自动计算相应金额并填写,edit.html同理,不过用的很少,就暂时不做了。

文件地址 public\assets\js\backend\your.js

add: function () {
            Controller.api.bindevent();
            console.log('点击了添加按钮');
            // (function(){
            //("#c-money").bind('input porpertychange',function(){
            //         console.log("输入了金额");
            //         let vipmanreseller = document.getElementById("c-vipmanreseller_id").value;
            //         let money = document.getElementById("c-money").value;
            //         let change = document.getElementById("c-change").value;
            //         console.log("分销商:"+vipmanreseller);
            //         console.log('变动金额:' + money);
            //         console.log(change);
            //     });
            // });
            ("#c-money").change(function(){
                vipmanreseller = document.getElementById("c-vipmanreseller_id").value;

                if (vipmanreseller<1) {
                    toastr.error("请选择分销商");
                    return false;
                 };

                 change = document.getElementById("c-change").value;
                 console.log(change);

                 money = document.getElementById("c-money").value;

                //查余额.ajax({
                    url:'/api/vip/tools/yourapiname?userid=' + vipmanreseller,
                    type:'GET',
                    success:(res)=>{
                        console.log(res);
                        if (1 > res) {
                            toastr.success("查询余额失败或需要核实");
                            return false;
                        }

                        console.log('修改金额');

                        if (change == '增加' || change == '充值') {
                            //这里需要转化一下字符串为浮点数,不然就是字符串相加了
                            aftermoney = parseFloat(money) + parseFloat(res);

                        }else if(change == '减少'){
                            aftermoney = res - money;
                        }

                        document.getElementById("c-beforemoney").value = res;
                        document.getElementById("c-aftermoney").value = aftermoney;
                        toastr.success("计算成功,请核实!");
                    },
                    error:(res)=>{
                        console.log('false');
                        toastr.error("获取余额失败,请核实!");
                    }
                });

//                console.log(vipmanreseller);
            });
        },
© 2025 唯心笔录
Theme by Wing
蜀ICP备2020027593号-1
  • {{ item.name }}
  • {{ item.name }}