瀏覽代碼

feat: 弹窗逻辑完善

zhangyuhan 4 年之前
父節點
當前提交
bf088a7800
共有 1 個文件被更改,包括 53 次插入31 次删除
  1. 53 31
      src/web/templates/pc/createOrderPage.html

+ 53 - 31
src/web/templates/pc/createOrderPage.html

@@ -64,7 +64,7 @@
                     <p>数据流量包扣除 <i id="llb-tip" class="iconfont icon-bangzhu"
                                 style="font-size: 18px;color: #2CB7CA;line-height: 37px;cursor: pointer;"></i>
                     </p>
-                    <div id="llb-tip-block" style="width: 164px;height: 48px;opacity: 1;background: rgba(0,0,0,0.75);text-align: center;padding: 4px;
+                    <div id="llb-tip-block" style="width: 164px;height: 28px;opacity: 1;background: rgba(0,0,0,0.75);text-align: center;padding: 4px;
                         border-radius: 4px;box-shadow: 0px 0px 28px 0px rgba(0,0,0,0.08);
                         position: relative;top: -90px;right: -34px;display: none">
                         <p style="color: #ffffff;line-height: 20px;font-size: 12px;">原企业数据量扣除</p>
@@ -258,6 +258,8 @@
 <script>
 
     var pageDataMap = {
+        isPackLength: 0,
+        isNoPack: false,
         submitLoading: false,
         id: '{{.T._id}}',
         payType: '个人支付',
@@ -592,12 +594,6 @@
             success: function (r) {
                 if (r.error_msg == '') {
                     pageDataMap.dataExportPackInfo = r.data
-                    if (!r.data.personalPack) {
-                        pageDataMap.dataExportPackInfo.personalPack = {
-                            normalTotal: 0,
-                            seniorTotal: 0
-                        }
-                    }
                     checkNowSupportPayType()
                 }
             }
@@ -665,6 +661,16 @@
 
     // 根据接口返回值,检查当前可选择支付类型
     function checkNowSupportPayType () {
+        function createTempDom (level, parentDom) {
+            var tempDom = $("#select-ent-item-template").clone()
+            tempDom.css('display', 'initial')
+            tempDom.addClass('center-text')
+            tempDom.removeAttr('id')
+            tempDom.attr('data-level', level)
+            tempDom.find('p').text('线上充值账户')
+            tempDom.find('.info-dec').text('(' + (level == '1' ? '标准' : '高级') + '字段包)')
+            parentDom.append(tempDom)
+        }
         // 数据流量包
         if (pageDataMap.dataExportPackInfo) {
             var parentDom = $("#select-ent-datapack .switch-dataType")
@@ -681,25 +687,11 @@
             }
             // 数据流量包  线上
             if (pageDataMap.dataExportPackInfo.personalPack) {
-                if (pageDataMap.dataExportPackInfo.personalPack.normalTotal >= 0) {
-                    var tempDom = $("#select-ent-item-template").clone()
-                    tempDom.css('display', 'initial')
-                    tempDom.addClass('center-text')
-                    tempDom.removeAttr('id')
-                    tempDom.attr('data-level', '1')
-                    tempDom.find('p').text('线上充值账户')
-                    tempDom.find('.info-dec').text('(标准字段包)')
-                    parentDom.append(tempDom)
+                if (pageDataMap.dataExportPackInfo.personalPack.normalTotal > 0) {
+                    createTempDom(1, parentDom)
                 }
-                if (pageDataMap.dataExportPackInfo.personalPack.seniorTotal >= 0) {
-                    var tempDom = $("#select-ent-item-template").clone()
-                    tempDom.css('display', 'initial')
-                    tempDom.addClass('center-text')
-                    tempDom.attr('data-level', '2')
-                    tempDom.removeAttr('id')
-                    tempDom.find('p').text('线上充值账户')
-                    tempDom.find('.info-dec').text('(高级字段包)')
-                    parentDom.append(tempDom)
+                if (pageDataMap.dataExportPackInfo.personalPack.seniorTotal > 0) {
+                    createTempDom(2, parentDom)
                 }
             }
             // 移除模版
@@ -707,6 +699,7 @@
 
             // 是否展示数据流量包类型
             var tempDom = $("#payTypeSelect .no-select[data-pay-type='数据流量包']")
+            pageDataMap.isPackLength = parentDom.children('.no-select').length
             pageDataMap.typeMap['数据流量包'].show = parentDom.children('.no-select').length > 0
             if (pageDataMap.typeMap['数据流量包'].show) {
                 // 默认加载第一项去重数据
@@ -725,14 +718,29 @@
                     }, false)
                 }
 
-                parentDom.children('.no-select').eq(0).addClass('active')
-                if (parentDom.children('.no-select').length == 1) {
-                    $("#select-ent-datapack").hide()
-                    $("#select-ent-datapack").removeAttr('data-show-type')
-                }
                 tempDom.show()
             } else {
-                tempDom.hide()
+                pageDataMap.dataExportPackInfo.personalPack = {
+                    normalTotal: 0
+                }
+                pageDataMap.isNoPack = true
+                pageDataMap.isPackLength = 1
+                pageDataMap.cacheForDataPack['normal' + '_' + pageDataMap.id] = {
+                    repeat: 0,
+                    deduct: pageDataMap.msgCount
+                }
+                createTempDom(1, parentDom)
+                pageDataMap.typeMap['数据流量包'].level = 1
+                pageDataMap.typeMap['数据流量包'].online = true
+                getExportForRepeatInfo({
+                    packType: 'normal'
+                }, false)
+                tempDom.show()
+            }
+            parentDom.children('.no-select').eq(0).addClass('active')
+            if ( pageDataMap.isPackLength == 1) {
+                $("#select-ent-datapack").hide()
+                $("#select-ent-datapack").removeAttr('data-show-type')
             }
         }
         // 单日限量包
@@ -1101,6 +1109,20 @@
             location.href ="/front/dataPack/createOrder"
             return
         }
+        if (nowText == '我知道了') {
+            if (pageDataMap.payType == '单日限量包') {
+                togglePayType('个人支付')
+            } else {
+                if (pageDataMap.isPackLength == 1) {
+                    togglePayType('个人支付')
+                }
+            }
+        }
+        if (nowText == '取消') {
+            if (pageDataMap.isPackLength == 1) {
+                togglePayType('个人支付')
+            }
+        }
         $("#dataexport-tip").modal('hide');
     })
     function showTip(title, content, cancel) {