Przeglądaj źródła

spring activity

zz 6 lat temu
rodzic
commit
6bb6dff081

+ 50 - 1
app/Http/Controllers/Wap/Web/WelcomeController.php

@@ -538,7 +538,7 @@ class WelcomeController extends BaseController
         return view('pay.order.saleactivity', ['url' => '###', 'code' => 0]);
     }
 
-    public function springActivity(Request $request)
+    public function springActivityV1(Request $request)
     {
         $token = $request->input('token');
         $activity_info = ActivityService::getByToken($token);
@@ -584,6 +584,55 @@ class WelcomeController extends BaseController
         return view('pay.order.springactivity', ['url' => [], 'code' => 3]);
     }
 
+    public function springActivity(Request $request)
+    {
+        $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
+        $token = $request->input('token');
+        $activity_info = ActivityService::getByToken($token);
+        if (!$activity_info) {
+            $default_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
+            return redirect()->to($default_url);
+        }
+
+        $from = $request->input('fromtype', 'main');
+        $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
+        $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
+        $uv_key = sprintf($uv_key_format, $activity_info->id, $this->distribution_channel_id, date('Y-m-d'));
+        $pv_key = sprintf($pv_key_format, $activity_info->id, $this->distribution_channel_id);
+        Redis::sadd($uv_key, $this->uid);
+        Redis::hincrby($pv_key, date('Y-m-d'), 1);
+        $redirect_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
+        if ($request->input('redirect_url')) {
+            $redirect_url = $request->input('redirect_url');
+            $redirect_url = urldecode($redirect_url);
+        }
+
+        //未开始
+        if (time() < strtotime($activity_info->start_time)) {
+            return view('pay.order.springactivity2019', ['url' => ['javascript:void(0)', 'javascript:void(0)'], 'code' => -1]);
+        }
+        //结束
+        if (time() > strtotime($activity_info->end_time)) {
+            return view('pay.order.springactivity2019', ['url' => ['javascript:void(0)', 'javascript:void(0)'], 'code' => -2 ]);
+        }
+        $product_ids = [4063, 4064];
+        $url = [];
+        foreach ($product_ids as $product_id) {
+            $param = [
+                'uid' => $this->uid,
+                'distribution_channel_id' => $this->distribution_channel_id,
+                'product_id' => $product_id,
+                'activity_id' => $activity_info->id,
+                'fromtype' => $from,
+                'pay_redirect_url' => $redirect_url,
+                'limit' => 100,
+            ];
+            $url[] = env('CREATE_PAY_URL') . '?' . http_build_query($param);
+        }
+
+        return view('pay.order.springactivity2019', ['url' => $url, 'code' => 0]);
+    }
+
     /**
      *
      */

+ 207 - 0
resources/views/pay/order/springactivity2019.blade.php

@@ -0,0 +1,207 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8" />
+    <meta
+            name="viewport"
+            content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
+    />
+    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
+    <link rel=icon type=image/png href="data:image/png;base64,iVBORw0KGgo=">
+    <title>金猪贺岁-送平安如意红包</title>
+    <style>
+        html,
+        body {
+            margin: 0 auto;
+            padding: 0;
+            max-width: 450px;
+            font-size: 100px;
+        }
+
+        p {
+            padding: 0;
+            margin: 0;
+        }
+
+        html {
+            background: #c41f30;
+        }
+
+        .main_box,
+        .activity_one {
+            font-size: 0;
+            position: relative;
+        }
+
+        .main_box img {
+            width: 100%;
+        }
+
+        .recharge-item {
+            font-size: 0;
+            width: 90%;
+            margin: 0.3rem auto;
+        }
+
+        .list-item__top {
+            margin-bottom: 0.15rem;
+        }
+
+        .recharge_box {
+            width: 80%;
+            margin: 0 auto;
+            position: absolute;
+            left: 50%;
+            transform: translateX(-50%);
+            top: 48%;
+        }
+
+        .list {
+            margin-bottom: 0.15rem;
+        }
+
+        .list .list-item__flex {
+            display: flex;
+            justify-content: space-between;
+            align-items: center;
+            margin-bottom: 0.2rem;
+        }
+
+        .list-item__flex .list-item {
+            width: 48%;
+        }
+
+        .main_box img,
+        a {
+            -webkit-tap-highlight-color: transparent;
+            text-decoration: none;
+            color: currentColor;
+        }
+
+        .recharge_box a {
+            width: 100%;
+            display: block;
+            margin: 0 auto;
+        }
+
+        .recharge_box .beginning img {
+            width: 100%;
+        }
+
+        .to-activity__two {
+            position: absolute;
+            bottom: 0.6rem;
+            right: 0;
+            width: 1rem;
+        }
+
+        .activity_two__intro {
+            font-size: 0.12rem;
+            padding: 0 0.2rem;
+            color: #fff;
+            line-height: 1.5;
+        }
+
+        .activity_two__intro p {
+            margin-bottom: 0.1rem;
+        }
+
+        .activity_two__intro i {
+            font-style: normal;
+            color: #ffdc6e;
+        }
+
+        .d_none {
+            display: none;
+        }
+    </style>
+</head>
+
+<body>
+<main class="main_box">
+    <div class="activity_one">
+        <img src="https://cdn-novel.iycdm.com/h5/activity-2019-01-25/bg.jpg" alt="" />
+        <div class="recharge_box">
+            <div class="list">
+                <div class="list-item__flex">
+                    <div class="list-item">
+                        <img
+                                src="https://cdn-novel.iycdm.com/h5/activity-2019-01-25/btn1-active.png"
+                                data-active-src="https://cdn-novel.iycdm.com/h5/activity-2019-01-25/btn1-active.png"
+                                data-src="https://cdn-novel.iycdm.com/h5/activity-2019-01-25/btn1.png"
+                                data-focus="1"
+                                data-href="{{$url[0]}}"
+                                alt=""
+                        />
+                    </div>
+                    <div class="list-item">
+                        <img
+                                src="https://cdn-novel.iycdm.com/h5/activity-2019-01-25/btn2.png"
+                                data-active-src="https://cdn-novel.iycdm.com/h5/activity-2019-01-25/btn2-active.png"
+                                data-src="https://cdn-novel.iycdm.com/h5/activity-2019-01-25/btn2.png"
+                                data-focus="0"
+                                data-href="{{$url[1]}}"
+                                alt=""
+                        />
+                    </div>
+                </div>
+            </div>
+        @if($code == -1)
+            <!-- 活动未开始 -->
+                <a href="javascript:void(0)" class="un_begin">
+                    <img src="https://cdn-novel.iycdm.com/h5/activity-2019-01-25/undone.png" alt="" />
+                </a>
+        @elseif($code == 0)
+            <!-- 活动进行中 -->
+                <a href="{{$url[0]}}" class="beginning" id="paying">
+                    <img src="https://cdn-novel.iycdm.com/h5/activity-2019-01-25/doing.png" alt="" />
+                </a>
+        @elseif($code == -2)
+            <!-- 活动结束 -->
+                <a href="javascript:void(0)" class="over">
+                    <img src="https://cdn-novel.iycdm.com/h5/activity-2019-01-25/over.png" alt="" />
+                </a>
+            @endif
+        </div>
+    </div>
+</main>
+</body>
+<script>
+    var d = document;
+    var imgs = d.querySelectorAll(".list-item img");
+    var pay = d.querySelector('#paying');
+    var key = 0;
+    for (var i = 0; i < imgs.length; i++) {
+        (function(index) {
+            imgs[index].addEventListener(
+                    "click",
+                    function() {
+                        reset();
+                        var active = this.getAttribute("data-active-src");
+                        var un_active = this.getAttribute("data-src");
+                        var is_active = this.getAttribute("data-focus");
+                        var href = this.getAttribute("data-href");
+                        if (is_active === "0") {
+                            // 未勾选
+                            this.setAttribute("data-focus", "1");
+                            this.setAttribute("src", active);
+                            if(pay){
+                                pay.setAttribute('href',href);
+                            }
+                        }
+                        key = index;
+                    },
+                    false
+            );
+        })(i);
+    }
+    function reset() {
+        for (var i = 0; i < imgs.length; i++) {
+            (function(index) {
+                imgs[index].setAttribute("src", imgs[index].getAttribute("data-src"));
+                imgs[index].setAttribute("data-focus", "0");
+            })(i);
+        }
+    }
+</script>
+</html>