소스 검색

Merge branch 'master' of http://git.9026.com/richod/dcj

zhjx 6 년 전
부모
커밋
bb6a3474c7
4개의 변경된 파일346개의 추가작업 그리고 32개의 파일을 삭제
  1. 41 30
      app/Http/Controllers/Web/OrderController.php
  2. 1 2
      resources/views/web/order/index.blade.php
  3. 302 0
      resources/views/web/order/sms.blade.php
  4. 2 0
      routes/web.php

+ 41 - 30
app/Http/Controllers/Web/OrderController.php

xqd xqd
@@ -31,24 +31,51 @@ class OrderController extends Controller
 
     public $expireTime = '';
 
-    public function index(Request $request){
+    public function index(Request $request)
+    {
+        if($request->method() == 'POST') {
+            $data = $request->input();
+            $key = $this->keySmsCode . $data['mobile'];
+            $code = Cache::store('file')->get($key);
+            if ($code !== $data['verify']) {
+                $res['state'] = 0;
+                $res['err'] = '验证码错误!';
+                return $this->api($res);
+            }
+            $check = MedicalOrderModel::where('mobile',$data['mobile'])->first();
+            if($check&&!empty($check->pdf)){
+                $res['state'] = 2;
+                $res['err'] = '您已提交';
+                $res['redirect_url'] = url('web/Index/post').'?id='.$check->id;
+                $res['pdf_url'] = $check->pdf;
+            }elseif($check&&empty($check->pdf)){
+                $res['state'] = 1;
+                $res['err'] = '您已提交,请耐心等待结果';
+                $res['redirect_url'] = url('web/Index/post').'?id='.$check->id;
+            }elseif(!$check){
+                $res['state'] = 1;
+                $res['err'] = '请您先填写基本资料';
+                $res['redirect_url'] = url('web/Index/sms');
+            }
+        }else{
+            return view('web.order.sms');
+        }
+    }
+
+    public function sms(Request $request){
 
         $conf['nationality'] = '民族';
         $conf['name'] = '姓名';
         $conf['native_place'] = '籍贯';
         $conf['email'] = '邮件';
         $conf['work'] = '工作';
-        $conf['mobile'] = '电话';
         $conf['address'] = '通讯地址';
-        $conf['verify'] = '验证码';
-
 
 
         if($request->method() == 'POST') {
             $data = $request->input();
             dd($data);
-            $key = $this->keySmsCode . $data['mobile'];
-            $code = Cache::store('file')->get($key);
+
             foreach ($data as $key=>$val){
                 if(empty($val)&&$key!='sample_type'&&$key!='sex'){
                     $res['state'] = 0;
@@ -56,33 +83,17 @@ class OrderController extends Controller
                     return $this->api($res);
                 }
             }
-            if($code !== $data['verify']){
-                $res['state'] = 0;
-                $res['err'] = '验证码错误!';
-                return $this->api($res);
-            }
-            $check = MedicalOrderModel::where('mobile',$data['mobile'])->first();
-            if($check&&!empty($check->pdf)){
-                $res['state'] = 2;
-                $res['err'] = '您已提交';
-                $res['redirect_url'] = url('web/Index/post').'?id='.$check->id;
-                $res['pdf_url'] = $check->pdf;
-            }elseif($check&&empty($check->pdf)){
+
+            $query = MedicalOrderModel::create($data);
+            if($query){
                 $res['state'] = 1;
-                $res['err'] = '您已提交,请耐心等待结果';
-                $res['redirect_url'] = url('web/Index/post').'?id='.$check->id;
+                $res['err'] = '提交成功';
+                $res['redirect_url'] = url('web/Index/post').'?id='.$query->id;
             }else{
-                unset($data['verify']);
-                $query = MedicalOrderModel::create($data);
-                if($query){
-                    $res['state'] = 1;
-                    $res['err'] = '提交成功';
-                    $res['redirect_url'] = url('web/Index/post').'?id='.$query->id;
-                }else{
-                    $res['state'] = 0;
-                    $res['err'] ='网络错误';
-                }
+                $res['state'] = 0;
+                $res['err'] ='网络错误';
             }
+
            // dd($res);
             return $this->api($res);
         }else{

+ 1 - 2
resources/views/web/order/index.blade.php

xqd xqd
@@ -143,7 +143,7 @@
         //     alert('请输入正确手机号');
         // }else{
             $.ajax({
-                url:"{{ url('/web/Index/index') }}",
+                url:"{{ url('/web/Index/sms') }}",
                 traditional:true,
                 headers: {
                     'X-CSRF-TOKEN': "{{ csrf_token() }}"
@@ -160,7 +160,6 @@
                     email:$('#email').val(),
                     work:$('#work').val(),
                     address:$('#address').val(),
-                    verify:$('#verify').val()
                 },
                 success:function (msg) {
                     if(msg.state ==0){

+ 302 - 0
resources/views/web/order/sms.blade.php

xqd
@@ -0,0 +1,302 @@
+<!DOCTYPE html>
+<html lang="zh-cn">
+<head>
+    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
+    <link href="{{cdn_asset('/assets/css/bootstrap.min.css')}}" rel="stylesheet">
+    <title>tijian</title>
+    <script type="text/javascript">
+        (function (doc, win) {
+            var docEl = doc.documentElement,
+                resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
+                recalc = function () {
+                    var clientWidth = docEl.clientWidth;
+                    if (!clientWidth) return;
+                    if(clientWidth>=640){
+                        docEl.style.fontSize = '100px';
+                    }else{
+                        docEl.style.fontSize = 100 * (clientWidth / 640) + 'px';
+                    }
+                };
+
+            if (!doc.addEventListener) return;
+            win.addEventListener(resizeEvt, recalc, false);
+            doc.addEventListener('DOMContentLoaded', recalc, false);
+        })(document, window);
+    </script>
+    <style type="text/css">
+        .all{
+            width: 100%;
+            height: auto;
+        }
+        img{
+            width: 50px;
+            height: 50px;
+            margin-top: 18px;
+        }
+        h3{
+            text-align: center;
+        }
+        .all .main{
+            flex-wrap: wrap;
+            display: flex;
+        }
+        .all .input-group{
+            margin:4px 6%;
+        }
+        .all .danxuan{
+            width: 66.66%;
+            margin: 4px 16.66%;
+        }
+        #tanchuang{
+            position: fixed;
+            z-index: 999;
+            width: 100%;
+            height: 100%;
+            top: 0;
+            left: 0;
+            background: rgba(0,0,0,0.5);
+        }
+        #tanchuang .tanbox{
+            width: 240px;
+            height: auto;
+            background: #fff;
+            position: absolute;
+            left: 50%;
+            top: 50%;
+            margin-left: -120px;
+            margin-top: -60px;
+            border-radius: 15px;
+        }
+        .tanbox .status{
+            width: 80%;
+            height: 70%;
+            margin: 10%;
+        }
+        .tanbox .status text{
+            display: inline-block;
+            width: 100%;
+            text-align: center;
+            margin-top: 10px;
+        }
+        .tanbox .status .title{
+            display: inline-block;
+            width: 100%;
+            font-size: 20px;
+            font-weight: 700;
+            text-align: center;
+            color: #f04;
+            margin-top: 10px;
+        }
+        .tanbox .status button{
+            width: 80px;
+            margin-left: 52px;
+            margin-top: 10px;
+        }
+        .tanbox .b2 button{
+            width: 90px;
+            margin-left: 7px;
+            margin-top: 10px;
+            margin-bottom: 30px;
+        }
+        .imgbox img{
+            height: 40px;
+        }
+    </style>
+</head>
+<body>
+<script type="text/javascript">
+    var url = '';
+    var downurl = '';
+    var yan = 0;
+    var countdown = 60;
+    var sending = false;
+    function settime(obj) { //发送验证码倒计时
+        console.log(obj)
+
+        if (countdown == 0) {
+            obj.attr('disabled', false);
+            obj.val("发送验证码");
+            countdown = 60;
+            sending = false;
+            return;
+        } else {
+            obj.attr('disabled', true);
+            obj.val("重新发送(" + countdown + ")");
+            countdown--;
+        }
+        setTimeout(function () {
+            settime(obj);
+        }, 1000)
+    }
+
+    function submits(){
+        var mobile = $('#mobile').val();
+        if(mobile == '' || !phonenum(mobile)){
+            alert('请输入正确手机号');
+        }else{
+            $.ajax({
+                url:"{{ url('/web/Index/index') }}",
+                headers: {
+                    'X-CSRF-TOKEN': "{{ csrf_token() }}"
+                },
+                type:'POST',
+                data:{
+                    mobile:mobile,
+                    verify:$('#verify').val()
+                },
+                success:function (msg) {
+                    if(msg.state ==0){
+                        tijiao(0,'','',msg.err);
+                    } else if(msg.state ==1){
+                        tijiao(1,msg.redirect_url,'',msg.err);
+                    } else if(msg.state ==2){
+                        tijiao(2,msg.redirect_url,msg.pdf_url,msg.err);
+                    }
+                }
+            });
+        }
+
+    }
+
+    function tijiao(status,redirect_url,pdf_url,ttt){
+        window.url = redirect_url;
+        window.downurl = pdf_url;
+        var tanc=document.getElementById("tanchuang")
+        tanc.style="display:auto;"
+        //   var status = 0
+        var tbox = document.getElementsByClassName("status");
+        if(status==0){
+            tbox[0].style="display:auto;"
+            tbox[1].style="display:none;"
+            tbox[2].style="display:none;"
+            var txt1 = document.getElementById("txt1");
+            txt1.innerHTML = ttt+'!';
+            console.log(txt1)
+        }else if(status==1){
+            tbox[1].style="display:auto;"
+            tbox[0].style="display:none;"
+            tbox[2].style="display:none;"
+            var txt2 = document.getElementById("txt2");
+            txt2.innerHTML = ttt+'!';
+            console.log(txt2)
+        }else{
+            tbox[1].style="display:none;"
+            tbox[0].style="display:none;"
+            tbox[2].style="display:auto;"
+            var txt3 = document.getElementById("txt3");
+            txt3.innerHTML = ttt+'!';
+            console.log(txt3)
+        }
+    }
+    function thebtn(e){
+        var id = e.id;
+        console.log(id)
+        if(id=='fail'){
+            closebox();
+        }else if(id=='yeah'){
+            window.location.href=url
+        }else if(id=='download'){
+            window.location.href = downurl;
+        }else{
+            window.location.href=url
+        }
+    }
+    function closebox(){
+        var tanc=document.getElementById("tanchuang")
+        tanc.style="display:none;"
+    }
+    function phonenum(phone) {
+        var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
+        if (!myreg.test(phone)) {
+            return false;
+        } else {
+            return true;
+        }
+
+    }
+    function closeyan(){
+        var yanz=document.getElementById("yanz")
+        yanz.style="display:none;";
+    }
+    function yanzhengma(){
+
+        var mobile = $('#mobile').val();
+        if(mobile == '' || !phonenum(mobile)){
+            alert('请输入正确手机号');
+        }else{
+            var yanzheng = document.getElementById("yzma");
+            yanzheng.style="display:auto;";
+            sending = true;
+            var obj = $("#fasong");
+            settime(obj);
+            $.ajax({
+                headers: {
+                    'X-CSRF-TOKEN': "{{ csrf_token() }}"
+                },
+                type:'POST',
+                data:{
+                    mobile:mobile
+                },
+                url:"{{ url('/web/Index/getCode') }}",
+                success:function (msg) {
+                    var data = eval('('+msg+')');
+                    console.log(data['msg']);
+                    if(data['state'] ==1){
+                        alert('发送成功');
+                    }else{
+                        alert(data['msg']);
+                    }
+                }
+            });
+        }
+
+    }
+</script>
+<div class="all">
+    <div class="col-xs-0 col-lg-2"></div>
+    <div class="col-xs-12 col-lg-8 main" style="margin: 0 auto;margin-top: 10px;">
+        <div class="col-xs-12 col-lg-12 imgbox" style="width:100%;margin-bottom:20px;display: flex;height: auto;" >
+            <img  class="col-xs-3 col-lg-2" src="{{cdn_asset('/assets/img/logo.jpg')}}">
+            <img  class="col-xs-9 col-lg-10" src="{{cdn_asset('/assets/img/top.jpg')}}" alt="">
+        </div>
+
+        <form id="tform" class="bs-example bs-example-form" role="form">
+            <div class="col-xs-10 col-lg-10 input-group">
+                <span class="input-group-addon">手机号:</span>
+                <input type="text" name="mobile" id="mobile" class="form-control" placeholder="请输入手机号" required="">
+            </div>
+            <div id="yzma" class="col-xs-10 col-lg-10 input-group">
+                <span  class="input-group-addon">验证码:</span>
+                <input type="text" name="verify" id="verify" class="form-control" placeholder="请输入验证码" required="">
+            </div>
+            <div class="col-xs-10 col-lg-10 btn" style="display: flex;margin: 4px 6%;">
+                <input style="display:inline-block;height: 30px;font-size:10px;width: 40%;margin-right: 20px;" class="btn btn-default" id="fasong" value="获取验证码" onclick="yanzhengma()">
+                <button style="margin-bottom: 20px;height: 30px;width: 40%;font-size:10px;" type="button" onclick="submits()" class="btn btn-default">提交</button>
+            </div>
+    </div>
+    <div id="tanchuang" style="display: none;">
+        <div class="tanbox">
+            <div style="width: 20px;height: 20px;text-align: center;position: absolute;top: -5px;right: -5px;background: #000;font-weight:700;color:#fff;border-radius: 20px;" onclick="closebox()">X</div>
+            <div class="status b0">
+                <text id="txt1" class="title"></text>
+            </div>
+            <div class="status b1">
+                <text id="txt2" class="title"></text>
+                <button class="btn btn-default" id="yeah" type="button" onclick="thebtn(this)">查看详情!</button>
+            </div>
+            <div class="status b2">
+                <text id="txt3" class="title"></text>
+                <button class="btn btn-default" id="next" type="button" onclick="thebtn(this)">查看详情!</button>
+                <button class="btn btn-default" id="download" type="button" onclick="thebtn(this)">查看反馈!</button>
+            </div>
+        </div>
+    </div>
+    </form>
+</div>
+</div>
+<!-- jQuery (Bootstrap 的 JavaScript 插件需要引入 jQuery) -->
+<script src="{{cdn_asset('/assets/js/jquery-3.2.1.js')}}"></script>
+<script src="{{cdn_asset('/assets/js/bootstrap.min.js')}}"></script>
+
+</body>
+</html>

+ 2 - 0
routes/web.php

xqd
@@ -48,7 +48,9 @@ Route::group(['prefix' => 'web'], function () {
 
     // index
     Route::get('/Index/index', 'Web\OrderController@index');
+    Route::get('/Index/sms', 'Web\OrderController@sms');
     Route::post('/Index/index', 'Web\OrderController@index');
+    Route::post('/Index/sms', 'Web\OrderController@sms');
     Route::post('/Index/post', 'Web\OrderController@post');
     Route::post('/Index/smsJuHe', 'Web\OrderController@smsJuHe');
     Route::post('/Index/getCode', 'Web\OrderController@getCode');