| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624 |
- //个人信息初始化
- function load(){
- layer.load(3);
- $.ajax({
- url: "/personal/getPresonalMessage",
- type: "get",
- data: {},
- headers: {"token": localStorage.getItem("token")},
- dataType: "json",
- success: (data) => {
- if(data.msg == "200"){
- $(".name_div_val").find("div").html(data.data.name);
- $(".buy_account").html("充值人: " + data.data.name);
- $(".phoen_left").find(".phone_val").html(data.data.phone );
- $(".account_div .blance_content").find("p").html(data.data.balanceOf);
- $(".permissions_div .blance_content").find("p").html(data.data.offerNum);
- $(".headpir_img").attr("src", data.data.headpir);
- //首页报价单权限余额 账户信息业务无用
- $(".offer_num_div .balance_of_fount").find("p").html(data.data.offerNum);
- //收支明细
- $(".bottom_content div").remove();
- $.each(data.payments.data, (index, item) => {
- var totalFee = item.total_fee;//付款金额
- var refundFee = item.refund_fee == undefined ? 0 : item.refund_fee;//退款金额
- var percentageFee = data.system.percentage_fee;
- //平台手续费,付款金额 - 退款金额 - (付款金额 * 平台手续费) = 实际收入
- var income = (totalFee - refundFee) == 0 ? (totalFee - refundFee) : (totalFee - refundFee - (totalFee * percentageFee))
- $(".bottom_content").append("<div class=\"content_div_font\" uuid=\""+ item.uuid +"\">\n" +
- " <div class=\"date_detail\">"+ item.jdrq +"</div>\n" +
- " <div class=\"content_detail\">"+ item.offer_name +"</div>\n" +
- " <div class=\"amount_detail\">¥"+ income.toFixed(2) +"</div>\n" +
- " </div>");
- });
- }
- layer.closeAll("loading");
- },
- error: () => {
- layer.closeAll("loading");
- layer.alert("网络错误 请联系管理员");
- }
- });
- }
- //充值弹框
- function topUp(){
- topUpNum();//次数渲染 余额渲染
- layer.open({
- type: 1,
- title: false,
- shadeClose: true,
- anim: 1,
- closeBtn: 0,
- area: ['auto', '700px'],
- content: $(".top_up_div"),
- end: () => {
- clearInterval(runInterval);
- $("#qrcode").find("img").remove();
- $("input[name=totalFee]").val("");
- runInterval = null;
- },
- cancel: () => {
- clearInterval(runInterval);
- $("#qrcode").find("img").remove();
- $("input[name=totalFee]").val("");
- runInterval = null;
- }
- });
- }
- //权限购买弹框
- function buyPermissions(){
- getByNumber();
- layer.open({
- type: 1,
- title: false,
- shadeClose: true,
- anim: 1,
- closeBtn: 0,
- area: ['auto', '700px'],
- content: $(".quotation_number"),
- end: () => {
- clearInterval(offerNumPayRunInterval);
- offerNumPayRunInterval = null;
- getByNumber();
- gysTopUpNum();
- },
- cancel: () => {
- clearInterval(offerNumPayRunInterval);
- offerNumPayRunInterval = null;
- getByNumber();
- gysTopUpNum();
- }
- });
- }
- //充值自定义切换
- function selectAmout(obj){
- if($(obj).hasClass("select_amount_val_click")){
- $(obj).removeClass("select_amount_val_click");
- } else {
- $(".select_amount_val").removeClass("select_amount_val_click");
- $(obj).addClass("select_amount_val_click");
- }
- }
- //选择支付方式
- function selectPay(obj){
- $(".pay_div_mode").removeClass("select_pay_click");
- $(".pay_div_mode").find("div").html(" ");
- $(obj).addClass("select_pay_click");
- $(".select_pay_click").find("div").html("<i class=\"layui-icon\"></i>")
- }
- //支付宝余额充值
- function zfbSupplierBalance(){
- layer.load(3);
- var totalFee = 0;
- //判断是否选择给定的金额
- if(typeof($(".top_up_div .select_amount_val_click").attr("value")) != "undefined"){
- totalFee = $(".top_up_div .select_amount_val_click").attr("value");
- }
- //获取输入的自定义金额
- if($("input[name=totalFee]").val() != null && $("input[name=totalFee]").val() != ""){
- totalFee = $("input[name=totalFee]").val();
- }
- //判断金额不能小于1
- if(totalFee < 1){
- layer.msg("金额不能小于1", {icon: 2});
- layer.closeAll("loading");
- return false;
- }
- //非空验证
- if(totalFee == 0){
- layer.msg("请填写或选择金额", {icon: 2});
- layer.closeAll("loading");
- return false;
- }
- $.ajax({
- url: "https://www.tuyatrip.com/api/pay/zfbpaySupplierBalance",
- type: "get",
- data: {
- "price": totalFee
- },
- dataType: "text",
- headers: {"token": localStorage.getItem("token")},
- success: (data) => {
- layer.confirm("是否已完成支付?",{
- btn: ['确认', '取消'],
- title: "昵称修改",
- skin: 'layclass'
- }, function () {
- layer.load(3);
- load();
- layer.closeAll()
- }, function(){
- load();
- layer.closeAll()
- });
- const div = document.createElement('divform');
- div.innerHTML = data; // data就是接口返回的form 表单字符串
- document.body.appendChild(div);
- let len = document.forms.length - 1;
- document.forms[len].setAttribute('target', '_blank'); // 新开窗口跳转
- document.forms[len].submit();
- layer.closeAll("loading");
- },
- error: () => {
- layer.alert("服务器异常,请联系管理员", {icon: 2});
- layer.closeAll("loading");
- }
- });
- }
- //生成二维码
- function onblurEle(){
- layer.load(3);
- let name = $(".top_up_div .select_pay_click span").text();
- if(name == "支付宝"){
- zfbSupplierBalance();
- return false;
- }
- var totalFee = 0;
- //判断是否选择给定的金额
- if(typeof($(".top_up_div .select_amount_val_click").attr("value")) != "undefined"){
- totalFee = $(".top_up_div .select_amount_val_click").attr("value");
- }
- //获取输入的自定义金额
- if($("input[name=totalFee]").val() != null && $("input[name=totalFee]").val() != ""){
- totalFee = $("input[name=totalFee]").val();
- }
- //判断金额不能小于1
- if(totalFee < 1){
- layer.msg("金额不能小于1", {icon: 2});
- layer.closeAll("loading");
- return false;
- }
- //非空验证
- if(totalFee == 0){
- layer.msg("请填写或选择金额", {icon: 2});
- layer.closeAll("loading");
- return false;
- }
- $("#qrcode").find("img").remove();
- clearInterval(runInterval);
- runInterval = null;
- $.ajax({
- url: "/wxpay/wxpaySupplierBalance",
- type: "get",
- data: {
- "price": totalFee
- },
- headers: {"token": localStorage.getItem("token")},
- dataType: "json",
- success: (data) => {
- var qrcode = new QRCode(document.getElementById("qrcode"), { // 显示二维码的元素或该元素的 ID
- text: data.code_url, // 内容可以是文字,链接,邮箱
- width: 120, //设置宽度
- height: 120, // 设置高度
- colorDark : "#000", // 设置前景色
- colorLight : "#fff", // 设置背景色
- // correctLevel : QRCode.CorrectLevel.L // 设置容错级别,上面有介绍
- });
- rotationTrainingStatus(data.out_trade_no);
- layer.closeAll("loading");
- },
- error: () => {
- layer.alert("服务器异常,请联系管理员", {icon: 2});
- layer.closeAll("loading");
- }
- });
- }
- //生成二维码
- function qrCode(){
- layer.load(3);
- }
- //轮训查询状态
- var runInterval; //定时任务
- function rotationTrainingStatus(uuid){
- runInterval = setInterval(function (){
- $.ajax({
- url: "/wxpay/getTopUp",
- type: "get",
- data: {
- "uuid": uuid
- },
- headers: {"token": localStorage.getItem("token")},
- dataType: "json",
- success: (data) => {
- if(data.data == 1){
- clearInterval(runInterval);
- layer.closeAll();
- parent.layer.msg("充值成功", {icon: 1});
- load();
- }
- },
- error: () => {
- layer.alert("服务器异常,请联系管理员", {icon: 2});
- layer.closeAll("loading");
- }
- });
- }, 1000)
- }
- //查询报价单单价
- function getByNumber(){
- layer.load(3);
- $.ajax({
- url: "/personal/getByNumber",
- type: "get",
- data: {},
- headers: {"token": localStorage.getItem("token")},
- dataType: "json",
- success: (data) => {
- $(".price_calculate").html(data.data.power_unit);
- unitPrice = data.data.power_unit;
- topUpNum();//次数渲染 余额渲染
- eachNumberAmout(); //次数余额
- layer.closeAll("loading");
- },
- error: () => {
- layer.alert("服务器异常,请联系管理员", {icon: 2});
- layer.closeAll("loading");
- }
- });
- }
- //监听输入框
- function getValue(obj){
- var num = $(obj).val();
- $("#qrcode_ok").find("img").remove();
- $(".price_calculate").html((Number(num * unitPrice).toFixed(2)));
- }
- //支付方式
- function payType(obj){
- var offerNum = $("input[name=offerNum]").val();//次数
- var offerNumSelect = $(".quotation_number .select_amount_val_click").attr("value");//次数
- if(offerNum == "" && typeof(offerNumSelect) == "undefined"){
- layer.msg("次数不能为空,请输入或者选择购买次数");
- return false;
- }
- $(".quotation_number .pay_div_mode").removeClass("select_pay_click");
- $(".quotation_number .pay_div_mode").find("div").html(" ");
- $(obj).addClass("select_pay_click");
- $(".select_pay_click").find("div").html("<i class=\"layui-icon\"></i>");
- var name = $(obj).find("span").text();
- if(name == "余额支付"){
- $(".blance_button").show();
- $("#qrcode_ok").find("img").remove();
- clearInterval(offerNumPayRunInterval);
- } else if(name == "微信支付"){
- $(".blance_button").hide();
- offerNumPay();
- } else if(name == "支付宝"){
- $("#qrcode_ok").find("img").remove();
- clearInterval(offerNumPayRunInterval);
- }
- }
- //支付宝购买次数
- function zfbOfferNumPay(){
- layer.load(3);
- var offerNum = $("input[name=offerNum]").val();//次数
- var offerNumSelect = $(".select_amount_val_click").attr("value");//次数
- var numOffer = 0;
- if(typeof(offerNumSelect) != "undefined"){
- numOffer = offerNumSelect;
- }
- if(offerNum != "" && offerNum != null){
- numOffer = offerNum;
- }
- $.ajax({
- url: "https://www.tuyatrip.com/api/pay/zfbpaySupplierOfferNum",
- type: "get",
- data: {
- "offerNum": numOffer
- },
- headers: {"token": localStorage.getItem("token")},
- dataType: "text",
- success: (data) => {
- layer.confirm("是否已完成支付?",{
- btn: ['确认', '取消'],
- title: false,
- skin: 'layclass'
- }, function () {
- layer.load(3);
- load();
- layer.closeAll();
- }, function(){
- load();
- layer.closeAll()
- });
- const div = document.createElement('divform');
- div.innerHTML = data; // data就是接口返回的form 表单字符串
- document.body.appendChild(div);
- let len = document.forms.length - 1;
- document.forms[len].setAttribute('target', '_blank'); // 新开窗口跳转
- document.forms[len].submit();
- layer.closeAll("loading");
- },
- error: () => {
- layer.alert("服务器异常,请联系管理员", {icon: 2});
- layer.closeAll("loading");
- }
- });
- }
- //购买次数生成二维码
- var offerNumPayRunInterval = null;
- function offerNumPay(){
- layer.load(3);
- clearInterval(offerNumPayRunInterval);
- offerNumPayRunInterval = null;
- //如果存在二维码则不执行下面信息
- if($("#qrcode_ok").html().indexOf("<img") != -1){
- return false;
- }
- var offerNum = $("input[name=offerNum]").val();//次数
- var offerNumSelect = $(".select_amount_val_click").attr("value");//次数
- var numOffer = 0;
- if(typeof(offerNumSelect) != "undefined"){
- numOffer = offerNumSelect;
- }
- if(offerNum != "" && offerNum != null){
- numOffer = offerNum;
- }
- $.ajax({
- url: "/wxpay/wxpaySupplierOfferNum",
- type: "get",
- data: {
- "offerNum": numOffer
- },
- headers: {"token": localStorage.getItem("token")},
- dataType: "json",
- success: (data) => {
- var qrcode = new QRCode(document.getElementById("qrcode_ok"), { // 显示二维码的元素或该元素的 ID
- text: data.code_url, // 内容可以是文字,链接,邮箱
- width: 120, //设置宽度
- height: 120, // 设置高度
- colorDark : "#000", // 设置前景色
- colorLight : "#fff", // 设置背景色
- // correctLevel : QRCode.CorrectLevel.L // 设置容错级别,上面有介绍
- });
- rotationTrainingOfferNum(data.out_trade_no);
- layer.closeAll("loading");
- },
- error: () => {
- layer.alert("服务器异常,请联系管理员", {icon: 2});
- layer.closeAll("loading");
- }
- });
- }
- //供应商充值次数回调
- function rotationTrainingOfferNum(uuid){
- offerNumPayRunInterval = setInterval(function (){
- $.ajax({
- url: "/wxpay/getOfferNum",
- type: "get",
- data: {
- "uuid": uuid
- },
- headers: {"token": localStorage.getItem("token")},
- dataType: "json",
- success: (data) => {
- if(data.data == 1){
- clearInterval(offerNumPayRunInterval);
- gysTopUpNum();
- layer.closeAll();
- layer.msg("充值成功", {icon: 1});
- load();
- }
- },
- error: () => {
- layer.alert("服务器异常,请联系管理员", {icon: 2});
- layer.closeAll("loading");
- }
- });
- }, 1000)
- }
- //余额确认
- function balanceOfOk(){
- var name = $(".quotation_number .select_pay_click span").text();
- if(name == "支付宝"){
- zfbOfferNumPay();
- return false;
- }
- var offerNum = $("input[name=offerNum]").val();//次数
- var offerNumSelect = $(".select_amount_val_click").attr("value");//次数
- if(offerNum == "" && typeof(offerNumSelect) == "undefined"){
- layer.msg("次数不能为空,请输入或者选择购买次数");
- return false;
- }
- var numOffer;
- if(typeof(offerNumSelect) != "undefined"){
- numOffer = offerNumSelect;
- }
- if(offerNum != "" && offerNum != null){
- numOffer = offerNum;
- }
- layer.load(3);
- $.ajax({
- url: "/personal/payBlance",
- type: "get",
- data: {"offerNum": numOffer},
- headers: {"token": localStorage.getItem("token")},
- dataType: "json",
- success: (data) => {
- if(data.msg == "200"){
- parent.layer.msg("购买成功", {icon: 1});
- gysTopUpNum();
- layer.closeAll();
- load();
- } else if(data.msg == "500"){
- layer.msg(data.errMsg, {icon: 2});
- }
- layer.closeAll("loading");
- },
- error: () => {
- layer.alert("服务器异常,请联系管理员", {icon: 2});
- layer.closeAll("loading");
- }
- });
- }
- //将base64转换为blob
- function dataURLtoBlob (dataurl) {
- var arr = dataurl.split(','),
- mime = arr[0].match(/:(.*?);/)[1],
- bstr = atob(arr[1]),
- n = bstr.length,
- u8arr = new Uint8Array(n);
- while (n--) {
- u8arr[n] = bstr.charCodeAt(n);
- }
- return new Blob([u8arr], { type: mime });
- }
- //将blob转换为file
- function blobToFile(theBlob, fileName){
- let file = new window.File([theBlob], fileName, {type: theBlob.type});
- return file;
- }
- //上传到oos图片 修改头像
- function cutOos(formData){
- layer.load(2);
- $.ajax({
- url: "https://www.tuyatrip.com/api/upload/uploadFile",
- type: "post",
- data: formData,
- headers: {"token": localStorage.getItem("token")},
- processData: false,
- contentType: false,
- dataType: "json",
- success: (data) => {
- if(data.msg == "200"){
- $.ajax({
- url: "/personal/updateName",
- type: "put",
- data: {
- "headpir": data.data
- },
- // contentType: "application/json",
- headers: {"token": localStorage.getItem("token")},
- dataType: "json",
- success: (dataVal) => {
- if(dataVal.msg == "200"){
- layer.closeAll();
- parent.layer.msg("上传头像成功", {icon: 1});
- console.log(data.data)
- parent.$(".head_portrait").attr("src", data.data);
- parent.conn.updateOwnUserInfo({avatarurl: data.data});
- load();
- } else if(dataVal.msg == "300"){
- layer.closeAll("loading");
- layer.msg(dataVal.errMsg, {icon: 2});
- }
- },
- error: () => {
- layer.closeAll("loading");
- layer.alert("网络错误 请联系管理员");
- }
- });
- }
- },
- error: () => {
- layer.closeAll("loading");
- layer.alert("网络错误 请联系管理员");
- }
- });
- }
- //查询充值次数
- function topUpNum(){
- $.ajax({
- url: "/personal/topUpNum",
- type: "get",
- data: {},
- headers: {"token": localStorage.getItem("token")},
- dataType: "json",
- success: (data) => {
- if(data.msg == "200"){
- $(".balance_of_val").html(data.data.balance_of);//余额
- $(".cumulative_num").html(paramReturn("累计充值", parent.type)+ (typeof data.data.topUp == "undefined" ? "0" : data.data.topUp) + paramReturn("次", parent.type));//充值次数
- $(".quotation_num").html(paramReturn("报价单单价", parent.type) + ":" + unitPrice);//充值次数
- }
- layer.closeAll("loading");
- },
- error: () => {
- layer.closeAll("loading");
- layer.alert("网络错误 请联系管理员");
- }
- });
- }
- //循环计算次数金额
- function eachNumberAmout(){
- $.each($(".select_number_val"), (index, item) => {
- var num = $(item).attr("value");
- $(item).find(".amount_number_val").html("¥" + (Number(num * unitPrice).toFixed(2)));
- });
- }
- //供应商充值次数成功后元素恢复初始化
- function gysTopUpNum(){
- $("input[name=offerNum]").val("")
- $("#qrcode_ok").find("img").remove();
- if(!$($(".select_number_val")[0]).hasClass("select_amount_val_click")){
- $($(".select_number_val")[0]).click();
- }
- $(".quotation_number .pay_div_mode").removeClass("select_pay_click");
- $(".quotation_number .pay_div_mode").find("div").html(" ");
- $($(".quotation_number .pay_div_mode")[0]).addClass("select_pay_click");
- $(".quotation_number .select_pay_click").find("div").html("<i class=\"layui-icon\"></i>");
- $(".blance_button").show();
- }
- //支付宝提现
- function withdrawal(){
- let str = "<div class='phoneBox'>"
- +"<div class='phoneSmBox'>支付宝账号 <input type='text' name='identity' autocomplete='off' class='layui-input'></div>"
- +"<div class='phoneSmBox'>支付宝真实姓名 <input type='text' name='name' autocomplete='off' class='layui-input'></div>"
- +"<div class='phoneSmBox'>提现金额 <input type='text' name='money' autocomplete='off' class='layui-input'></div>"
- +"</div>";
- layer.confirm(str,{
- btn: ['确认', '取消'],
- title: false,
- skin: 'layclass'
- }, function () {
- layer.load(3);
- //修改
- $.ajax({
- url: "https://www.tuyatrip.com/api/zfbWithdrawal/zfbCash",
- type: "put",
- data: {
- "name": $("input[name=name]").val(),
- "identity": $("input[name=identity]").val(),
- "money": $("input[name=money]").val()
- },
- // contentType: "application/json",
- headers: {"token": localStorage.getItem("token")},
- dataType: "text",
- success: (data) => {
- if(data.msg =="500"){
- layer.closeAll();
- parent.layer.msg(data.errMsg, {icon: 3});
- } else {
- layer.closeAll();
- parent.layer.msg(data, {icon: 1});
- load();
- }
- },
- error: () => {
- layer.closeAll("loading");
- layer.alert("网络错误 请联系管理员");
- }
- });
- }, function(){
- layer.closeAll()
- });
- }
|