猿问

如何解决JS中数据传输的问题?

我有支付功能。例如,如果我在关税计划 8 上按下购买按钮,我将被重定向到为关税计划 1 付费,如果我尝试购买任何其他关税计划(不是第一个),同样的问题。


在我的页面按钮中有代码: <button onclick="buystars(7);">


我的buystars功能:


function buystars(tickid) {

                    $.ajax({

                        url: '/payment/pay',

                        type: 'POST',

                        data: {

                            "tickID": tickid

                        },

                        success : function(data) {

                            toastr.success('Good. Redirect');

                            delay: 5000


                            window.location.href = data.redirect;


                        },

                    });

                    return false;

                };

和公共支付功能:


public function pay(Request $request)

    {

        $ticketID = $request->get('tickID');

        if($ticketID = 1){

            $sum = 50;

        }elseif($ticketID = 2){

            $sum = 100;

        }elseif($ticketID = 3){

            $sum = 500;

        }elseif($ticketID = 4){

            $sum = 1000;

        }elseif($ticketID = 5){

            $sum = 2500;

        }elseif($ticketID = 6){

            $sum = 6000;

        }elseif($ticketID = 7){

            $sum = 10000;

        }elseif($ticketID = 8){

            $sum = 15000;

        }

        $u = $this->user->steamid64;

        $merchant_id = '534';

        $secret_word1 = '534';

        $sign = md5($merchant_id.':'.$sum.':'.$secret_word1.':'.$u);

        $url = 'https://www.free-kassa.ru/merchant/cash.php?m='.$merchant_id.'&oa='.$sum.'&o='.$u.'&s='.$sign.'&lang=ru&i=&em=';

        $returnValue = [

            'redirect' => $url

        ];

        return $returnValue;

    }

怎么了?


人到中年有点甜
浏览 144回答 1
1回答

qq_遁去的一_1

你if conditional错了!正确的做法是:if($ticketID == 1){&nbsp; &nbsp; $sum = 50;} else if($ticketID == 2) {&nbsp; &nbsp; $sum = 100;} else if($ticketID == 3) {&nbsp; &nbsp; $sum = 500;} else if($ticketID == 4) {&nbsp; &nbsp; $sum = 1000;} else if($ticketID == 5) {&nbsp; &nbsp; $sum = 2500;} else if($ticketID == 6) {&nbsp; &nbsp; $sum = 6000;} else if($ticketID == 7) {&nbsp; &nbsp; $sum = 10000;} else if($ticketID == 8) {&nbsp; &nbsp; $sum = 15000;}注1:两者==具有可比性。注 2:如果此系统不是用于研究,则不建议使用像这样更改 html 中的价格的值:<button onclick = "buystars (7);">因为编辑此值非常简单。
随时随地看视频慕课网APP
我要回答