Procházet zdrojové kódy

feat: PC数据包订单数据号收集

cuiyalong před 4 roky
rodič
revize
42ec4632a9

+ 48 - 1
src/web/staticres/dataExport/css/datapackage_order.css

@@ -446,6 +446,7 @@ body {
   font-size: 16px;
   border-radius: 6px;
   cursor: pointer;
+  background-color: #2CB7CA;
 }
 
 #pay .inner .info .right .btn_createOrder button:nth-of-type(2), #pay .inner .info .right .btn_createOrder button:nth-of-type(3) {
@@ -929,4 +930,50 @@ button {
 
 #guige p del + span {
   color: #2cb7ca;
-}
+}
+
+.order-phone-group {
+  margin: 32px 0;
+  background: #FFFFFF;
+  color: #000;
+  box-sizing: border-box;
+  font-size: 16px;
+  line-height: 24px;
+  letter-spacing: 0px;
+  text-align: left;
+}
+.order-phone-group label {
+  display: inline-block;
+  padding: 8px 0;
+  margin-right: 64px;
+}
+.order-phone-group.error input {
+  color: #FB483D;
+}
+.order-phone-group.error p {
+  display: inherit;
+}
+.order-phone-group input {
+  padding: 6px 10px;
+  color: #000;
+  border-radius: 4px;
+  background: #FFFFFF;
+  border: 1px solid #E0E0E0;
+  font-size: 14px;
+  line-height: 24px;
+  letter-spacing: 0px;
+  text-align: left;
+  width: 590px;
+}
+.order-phone-group input::placeholder {
+  color: #AAA;
+}
+.order-phone-group p {
+  display: none;
+  color: #FB483D;
+  font-size: 12px;
+  line-height: 18px;
+  letter-spacing: 0px;
+  text-align: left;
+  margin-top: 2px;
+}

+ 117 - 6
src/web/templates/pc/dataPack/createOrderForDataPackage.html

@@ -37,6 +37,9 @@
             min-width: 112px;
             margin-bottom: 0 !important;
         }
+        #pay .info .right .btn_createOrder button.toPay[disabled] {
+            background-color: #ddd;
+        }
     </style>
 </head>
 <body>
@@ -75,6 +78,11 @@
                 </div>
             </div>
         </div>
+        <div class="order-phone-group">
+            <label for="order_phone">手机号码</label>
+            <input id="order_phone" autocomplete="off" placeholder="请输入手机号码" maxlength="11" type="tel">
+            <p>手机号码输入错误</p>
+        </div>
         <!--字段包说明-->
         <span class="remind" style="display:none;">
             <span class="remindone_"></span>
@@ -108,7 +116,7 @@
 
                 </p>
                 <p class="btn_createOrder">
-                    <button class="toPay" data-need-bind-phone disabled="disabled">确认支付</button>
+                    <button class="toPay pay_btn" data-need-bind-phone disabled>确认支付</button>
                 </p>
             </div>
         </div>
@@ -118,6 +126,111 @@
 <script src='{{Msg "seo" "cdn"}}/js/coupon/coupon.js?v={{Msg "seo" "version"}}'></script>
 <script src='{{Msg "seo" "cdn"}}/js/coupon/coupon-usd.js?v={{Msg "seo" "version"}}'></script>
 <script>
+    var readClause = false
+        // @订单手机号-S
+    function OrderPhone (data) {
+        this.addListener = function () {
+        var _this = this
+        $(this.data.el).on('input propertychange change', function () {
+            _this.OrderPhoneCheck && clearTimeout(_this.OrderPhoneCheck)
+            var o_phone = $(this).val()
+            _this.result.phone = o_phone
+            _this.result.status = _this.check_phone(o_phone)
+            var o_parent = $(this).parents()
+            _this.OrderPhoneCheck = setTimeout( () => {
+                if (_this.result.status) {
+                    o_parent.removeClass('error')
+                    typeof _this.data.success === 'function' && _this.data.success()
+                } else {
+                    o_parent.addClass('error')
+                    typeof _this.data.error === 'function' && _this.data.error()
+                }
+            }, _this.data.time || 300)
+        })
+        }
+        this.check_phone = function (phone) {
+            if (phone.trim().length === 0) {
+                return true
+            }
+            var result = /^[1][3-9][0-9]{9}$/.test(phone)
+            if (result) {
+                sessionStorage.setItem(_this.OrderPhoneCheckKey, phone)
+            }
+            return result
+        }
+        this.update = function (str) {
+            if (this.check_phone(str)) {
+                $(this.data.el).val(str)
+                this.result.phone = str
+                this.result.status = true
+            }
+        }
+        this.ajaxPhone = function () {
+            var isCache = sessionStorage.getItem(this.OrderPhoneCheckKey)
+            if (isCache) {
+                this.update(isCache)
+            }
+            var _this = this
+            $.get("/jypay/user/getAccountInfo?t=" + new Date().getTime(), function (r) {
+                if (r && r.data && r.data.phone) {
+                    _this.update(r.data.phone)
+                }
+            })
+        }
+        this.removeCachePhone = function () {
+            var levelTime = sessionStorage.getItem(_this.OrderPhoneCheckKey + '_level_time') || false
+            if (levelTime) {
+                var nowTime = new Date().getTime()
+                if (nowTime - levelTime > 5 * 60 * 1000) {
+                sessionStorage.removeItem(_this.OrderPhoneCheckKey)
+                }
+            }
+            sessionStorage.setItem(_this.OrderPhoneCheckKey + '_level_time', nowTime)
+            window.addEventListener('pageshow', function(event) {
+                if (event.persisted || window.performance && window.performance.navigation.type != 2) {
+                sessionStorage.removeItem(_this.OrderPhoneCheckKey)
+                }
+            }, false);
+            window.addEventListener('beforeunload', function () {
+                sessionStorage.setItem(_this.OrderPhoneCheckKey + '_level_time', new Date().getTime())
+            })
+        }
+        this.data = data || {
+            el: 'input#order_phone',
+            time: 300
+        }
+        var _this = this
+        this.OrderPhoneCheck = null
+        this.OrderPhoneCheckKey = 'p19.3_order_phone'
+        this.result = {
+            phone: '',
+            status: true,
+            update: _this.update.bind(_this)
+        }
+        this.removeCachePhone()
+        this.addListener()
+        this.ajaxPhone()
+        return this.result
+    }
+    var OrderPhoneCheck = new OrderPhone({
+        el: 'input#order_phone',
+        time: 300,
+        success: function () {
+            checkSubmitStatus()
+        },
+        error: function () {
+            checkSubmitStatus()
+        }
+    })
+    function checkSubmitStatus () {
+        var phonePass = OrderPhoneCheck.status
+        var allPass = readClause && phonePass
+        console.log(readClause, phonePass)
+        $('.pay_btn').prop("disabled", !allPass)
+    }
+    // @订单手机号-E
+
+
     var getCouponParams = showCoupon(102, 100, false)
     var msgMaxCount, msgCount, discount, unitPrice_normal, unitPrice_senior;
     var orderMinPrice = 0;
@@ -197,6 +310,8 @@
                 param.userLotteryId = couponParam.userLotteryId
             }
 
+            param.order_phone = OrderPhoneCheck.phone
+
             $.ajax({
                 url: "/subscribepay/dataExportPack/createOrder",
                 data: param,
@@ -258,11 +373,7 @@
         $('#checkBoxjy').on('click', function () {
             $(this).toggleClass('hideBf');
             readClause = $(this).hasClass("hideBf")
-            if (readClause) {
-                $(".toPay").css("background-color", "#2CB7CA").removeAttr("disabled")
-            } else {
-                $(".toPay").css("background-color", "#ddd").attr("disabled", "disabled");
-            }
+            checkSubmitStatus()
         })
 
         ChangePayMoney()