Parcourir la source

feat: PC端活动页需求接口对接

zhangyuhan il y a 3 ans
Parent
commit
d354a5f795

+ 25 - 0
src/web/staticres/frontRouter/pc/activity/css/task.css

@@ -67,6 +67,10 @@
   background-repeat: no-repeat;
   background-size: contain;
 }
+.mission-list-item.complete .num,
+.mission-list-item.complete .text {
+  opacity: 0.6;
+}
 .mission-list-item.complete .m-list-item-bg {
   background-image: url(/frontRouter/pc/activity/image/bubble-2@2x.png);
 }
@@ -169,6 +173,18 @@
 .anchor.first {
   transform: none;
 }
+
+.anchor.wait .anchor-tip-text {
+  color: #fff;
+  cursor: pointer;
+}
+.anchor.received .anchor-tip-text {
+  cursor: no-drop;
+}
+.anchor.unreceived .anchor-tip-text {
+  cursor: no-drop;
+}
+
 .anchor-text {
   font-size: 18px;
   font-weight: 700;
@@ -252,6 +268,15 @@
   background: linear-gradient(176deg, #FA8920 0%, #FB4D27 65%, #DD1515 100%);
   border-radius: 14px;
 }
+.reward-empty {
+  font-size: 16px;
+  font-weight: 400;
+  color: #AAAAAA;
+  line-height: 24px;
+  text-align: center;
+  padding-top: 78px;
+  padding-bottom: 67px;
+}
 
 .tool-box {
   position: relative;

+ 242 - 43
src/web/staticres/frontRouter/pc/activity/js/task.js

@@ -113,6 +113,63 @@ function RandomCoordinate (conf) {
   this.init()
 }
 
+// 判断活动是否结束
+var initPageTime = new Date().getTime()
+var initActiveOverCheck = -1
+function activeOverCheck (endTime, callback) {
+  if (initPageTime >= endTime) {
+    return callback()
+  }
+  clearTimeout(initActiveOverCheck)
+  var reloadTime = endTime - new Date().getTime()
+  if (reloadTime <= (10 * 60 * 1000) ) {
+    initActiveOverCheck = setTimeout(function (){
+      callback()
+    }, reloadTime)
+  }
+}
+
+// toast上限提示
+function toastFn (text, duration) {
+  if (duration) {
+    duration = 1000
+  }
+  var _html = ""
+  _html+='<div class="custom-toast"><div class="mask" style="background-color: transparent;"></div><div class="toast-container">'
+  _html+='<span>' + text + '</span></div></div>'
+  $('body').append(_html)
+  setTimeout(function(){
+    $(".custom-toast").fadeOut().remove();
+  },duration)
+}
+
+// 展示弹窗
+function showDialogOfType (type) {
+  // $('#active-tip-modal').attr('data-modal-type', 'success').modal('show')
+  // $('#active-tip-modal').attr('data-modal-type', 'over').modal('show')
+  // $('#active-tip-modal').attr('data-modal-type', 'code').modal('show')
+
+  $('#active-tip-modal').attr('data-modal-type', type).modal('show')
+}
+
+// 固定事件
+$(function () {
+  // 扫一扫 二维码
+  $.ajax({
+    url: '/publicapply/shareFission/info',
+    success: function (res) {
+      if (res.error_code === 0 && res.data) {
+        $('#active-tip-modal .active-tip--code .code-img').attr('src', 'data:image/png;base64,' + res.data.erUrl)
+      }
+    }
+  })
+
+  // 弹窗按钮事件
+  $('#dialog-button--over').on('click', function () {
+    location.href = '/swordfish/frontPage/share/sess/index'
+  })
+  $('#dialog-button--success').on('click', function () {})
+})
 
 var task = new Vue({
   el: '#main-app',
@@ -121,27 +178,31 @@ var task = new Vue({
     progress: {
       min: 0,
       max: 1000,
-      current: 200, // 当前剑鱼币
+      current: 0, // 当前剑鱼币
       pointImgMap: {
         unreceived: '/frontRouter/pc/activity/image/unreceived@2x.png',
-        received: '/frontRouter/pc/activity/image/received@2x.png'
+        received: '/frontRouter/pc/activity/image/received@2x.png',
+        wait: '/frontRouter/pc/activity/image/received@2x.png'
       },
       anchorList: [
         {
+          id: '',
           className: 'first',
           rate: 0, // 进度,单位%,最大为100
           pointImg: '', // ''/unreceived/received
           anchorText: '0剑鱼币'
         },
         {
-          className: '',
+          id: '800',
+          className: 'unreceived',
           rate: 80,
-          pointImg: 'received',
+          pointImg: 'unreceived',
           anchorText: '800剑鱼币',
           tipText: '7天超级订阅'
         },
         {
-          className: 'last',
+          id: '1000',
+          className: 'unreceived',
           rate: 100,
           pointImg: 'unreceived',
           anchorText: '1000剑鱼币',
@@ -152,85 +213,73 @@ var task = new Vue({
     // 任务球
     missionsList: [
       {
-        id: 1,
+        id: 'subscribe',
         x: 0,
         y: 0,
         num: 300,
         unit: '剑鱼币',
         complete: false,
+        hide: false,
         name: '超级订阅' // 任务描述
       },
       {
-        id: 2,
+        id: 'invite',
         x: 0,
         y: 0,
         num: 500,
         unit: '剑鱼币',
         complete: false,
+        hide: false,
         name: '邀请领好礼'
       },
       {
-        id: 3,
+        id: 'improveInfo',
         x: 0,
         y: 0,
-        num: 300,
+        num: 200,
         unit: '剑鱼币',
-        complete: true,
+        complete: false,
+        hide: false,
         name: '完善信息'
       }
     ],
-    rewardList: [
-      {
-        id: '',
-        icon: 'jy-coin',
-        rewardText: '200剑鱼币',
-        receiveTime: 1234567890000,
-        receiveFrom: '邀请好友'
-      },
-      {
-        id: '',
-        icon: 'jy-svip',
-        rewardText: '200剑鱼币',
-        receiveTime: 1234567890000,
-        receiveFrom: '邀请好友'
-      }
-    ],
+    rewardList: [],
     toolBoxList: [
       {
         text: '超级订阅',
-        url: ''
+        url: '/front/subscribe.html'
       },
       {
         text: '大会员',
-        url: ''
+        url: '/big/page/index'
       },
       {
-        text: '企业管理',
-        url: ''
+        text: '企业商机管理',
+        url: '/swordfish/frontPage/entpc/free/enptc_index'
       },
       {
         text: '数据定制服务',
-        url: ''
+        url: '/front/structed/pc_index.html'
       },
       {
-        text: '数据自导出',
-        url: ''
+        text: '数据自导出',
+        url: '/front/dataExport/toSieve'
       },
       {
         text: '数据流量包',
-        url: ''
+        url: '/front/dataPack/createOrder'
       },
       {
         text: '电信行业解决方案',
-        url: ''
+        url: '/swordfish/frontPage/solution/free/index'
       },
       {
         text: '中标必听课',
-        url: ''
+        url: '/jyxspc'
       },
       {
         text: '剑鱼文库',
-        url: ''
+        url: '/swordfish/docs'
       },
     ],
     rulesList: [
@@ -283,12 +332,11 @@ var task = new Vue({
       })
     }
   },
-  watch: {
-    rate: function () {
-      this.calcProgressAnchorList()
-    }
+  created: function () {
+    this.ajaxActiveStatus()
+    this.ajaxProgress()
+    this.ajaxList()
   },
-  created: function () {},
   mounted: function () {
     this.calcPointList()
   },
@@ -305,6 +353,157 @@ var task = new Vue({
         this.missionsList[i].x = pointList[i].x
         this.missionsList[i].y = pointList[i].y
       }
+    },
+    onClickLink: function (item) {
+      window.open(item.url)
+    },
+    onClickListItem: function (item) {
+      if (item.icon === 'jy-svip') {
+        location.href = '/front/subscribe.html'
+      } else {
+        location.href = '/swordfish/integral/index/detail'
+      }
+    },
+    onClickReceive: function (type, item) {
+      var status = false
+      if (type === 'schedule' && item.className === 'wait') {
+        status = true
+      } else if (type === 'mission' && item.complete) {
+        status = true
+      }
+      if (!status) {
+        switch (item.id) {
+          case 'subscribe': {
+            showDialogOfType('code')
+            break
+          }
+          case 'invite': {
+            location.href = '/swordfish/frontPage/share/sess/index'
+            break
+          }
+          case 'improveInfo': {
+            // 留资
+            vm.isNeedSubmit('activity_free_plan', function(){
+              vm.showSuccess = true
+            })
+            break
+          }
+        }
+        return
+      }
+      var _this = this
+      this.ajaxReceive({ type: type, value: item.id }, function (result, msg) {
+        if (result) {
+          switch (item.id) {
+            case 'subscribe': {
+              toastFn('已成功领取300剑鱼币', 1500)
+              break
+            }
+            case 'invite': {
+              toastFn('已成功领取500剑鱼币', 1500)
+              break
+            }
+            case 'improveInfo': {
+              // 留资
+              toastFn('已成功领取200剑鱼币', 1500)
+              break
+            }
+            case '800': {
+              $('.active-tip--success .text-give-day').text('7')
+              showDialogOfType('success')
+              break
+            }
+            case '1000': {
+              $('.active-tip--success .text-give-day').text('30')
+              showDialogOfType('success')
+              break
+            }
+          }
+          _this.ajaxActiveStatus()
+          _this.ajaxProgress()
+          _this.ajaxList()
+        } else {
+          toastFn(msg, 1500)
+        }
+      })
+    },
+    ajaxReceive: function (data, callback) {
+      $.ajax({
+        url: '/jyActivity/bidderPlan/receive',
+        type: 'post',
+        data: data,
+        success: function (res) {
+          return callback(res.data)
+        }
+      })
+    },
+    ajaxProgress: function () {
+      var _this = this
+      $.ajax({
+        url: '/jyActivity/bidderPlan/schedule',
+        type:' post',
+        success: function (res) {
+          if (res.error_code === 0 && res.data) {
+            _this.progress.current = res.data.nowNum
+
+            _this.missionsList[0].complete = res.data.missions.subscribe === 1
+            _this.missionsList[1].complete = res.data.missions.invite === 1
+            _this.missionsList[2].complete = res.data.missions.improveInfo === 1
+
+            _this.missionsList[0].hide = res.data.missions.subscribe === -1
+            _this.missionsList[1].hide = res.data.missions.invite === -1
+            _this.missionsList[2].hide = res.data.missions.improveInfo === -1
+
+            var anchorStatus = {
+              1: 'wait',
+              0: 'unreceived',
+              '-1': 'received',
+            }
+
+            _this.progress.anchorList[1].className = anchorStatus[res.data.schedule['800']]
+            _this.progress.anchorList[2].className = anchorStatus[res.data.schedule['1000']]
+          }
+        }
+      })
+    },
+    ajaxActiveStatus: function () {
+      $.ajax({
+        url: '/jyActivity/bidderPlan/period',
+        type: 'get',
+        success: function (res) {
+          activeOverCheck(res.data.end * 1000, function () {
+            showDialogOfType('over')
+          })
+        }
+      })
+    },
+    ajaxList: function () {
+      var _this = this
+      $.ajax({
+        url: '/jyActivity/myAward/awardlist',
+        type: 'post',
+        data: {
+          code: 'bidderPlan',
+          pageSize: 10,
+          pageNum: 0
+        },
+        success: function (res) {
+          if (res.error_code === 0 && res.data) {
+            if (res.data.list && typeof res.data.list.map === 'function') {
+              _this.rewardList = res.data.list.map(function (v) {
+                return {
+                  id: v._id,
+                  icon: v.award.indexOf('订阅') !== -1 ? 'jy-svip' : 'jy-coin',
+                  rewardText: v.award,
+                  receiveTime: new Date(v.date * 1000).pattern('yyyy-MM-dd HH:mm:ss'),
+                  receiveFrom: v.getway
+                }
+              })
+            }
+          }
+        }
+      })
     }
-  },
+  }
+  ,
 })

+ 8 - 1
src/web/staticres/js/pc-collect-user-info.js

@@ -386,7 +386,8 @@ var vm = new Vue({
         article_purchase_intention: '请留下联系方式,我们会尽快联系您!开通大会员可抢先对接采购单位,帮助企业拓客!', // 三级页-采购意向
         article_proposed_project: '请留下联系方式,我们会尽快联系您!开通大会员可抢先获知拟建商机动态,提高中标机率!', // 三级页-拟建项目
         'ent-manage-pc': '欢迎留下联系方式,我们的大客户经理会在24小时内联系您!',
-        "jyarticle_see3_plus_pc":"请完善个人信息,获取更多免费查看公告权限"
+        "jyarticle_see3_plus_pc":"请完善个人信息,获取更多免费查看公告权限",
+        'activity_free_plan': '请完善信息,免费获取200剑鱼币'
       },
       isRefresh: false // 留完资是否需要刷新页面
     }
@@ -428,6 +429,9 @@ var vm = new Vue({
         if (this.source.indexOf('jyarticle_see3_plus_pc') > -1) {
           return ''
         }
+        if (this.source === 'activity_free_plan') {
+          return '完善信息任务已完成,快去领取剑鱼币吧~'
+        }
         return '我们会尽快联系您并预约演示时间,请耐心等待~<br>您将获得免费体验大会员全部功能!'
       }
     }
@@ -496,6 +500,9 @@ var vm = new Vue({
         } else if(source.indexOf('jyarticle_see3_plus_pc') > -1){
           this.dialogTitle = text
           this.dialogTitleTop = '完善信息'
+        } else if (source === 'activity_free_plan') {
+          this.dialogTitle = text
+          this.dialogTitleTop = '完善信息'
         }
         // else if (source.indexOf("article_collection") > -1){
         //   this.dialogTitle = text

+ 33 - 25
src/web/templates/frontRouter/pc/activity/sess/task.html

@@ -14,13 +14,30 @@
     <link href='{{Msg "seo" "cdn"}}/css/pc.css?v={{Msg "seo" "version"}}' rel="stylesheet"/>
     <link href='{{Msg "seo" "cdn"}}/pccss/public-nav-1200.css?v={{Msg "seo" "version"}}' rel="stylesheet" type="text/css"/>
     <link href="//cdn-common.jianyu360.com/cdn/lib/element-ui/2.15.7/lib/theme-chalk/index.css" rel="stylesheet" />
+    <link href='{{Msg "seo" "cdn"}}/css/collect-user-info.css?v={{Msg "seo" "version"}}' rel="stylesheet">
     <link href='{{Msg "seo" "cdn"}}/frontRouter/pc/activity/css/task.css?v={{Msg "seo" "version"}}' rel="stylesheet" />
-    <link href='{{Msg "seo" "cdn"}}/common-module/active/2022.5.20/task.css?v={{Msg "seo" "version"}}' rel="stylesheet" />
     <style>
         .page--web--index .page-container {
             min-height: calc(100vh - 364px);
             box-sizing: border-box;
         }
+        .custom-toast {
+          /* display: none; */
+        }
+        .custom-toast .toast-container{
+          /* display: none; */
+          position: fixed;
+          top: 50%;
+          left: 50%;
+          width: auto;
+          padding: 16px 32px;
+          font-size: 16px;
+          background: rgba(0, 0, 0, 0.65);
+          border-radius: 8px;
+          color: #fff;
+          transform: translateX(-50%) translateY(-50%);
+          z-index: 99;
+        }
     </style>
 </head>
 <body class="page--web--index">
@@ -31,13 +48,15 @@
         <div class="mission-list" ref="missions">
             <div
                 class="mission-list-item floating"
+                :class="{'complete': !item.complete}"
                 v-for="item in missionsList"
+                v-show="!item.hide"
                 :style="{ left: item.x + 'px', top: item.y + 'px' }"
                 :key="item.id">
                 <div class="m-list-item-bg">
                     <span class="num"><span class="num-add">+</span>${ item.num }</span>
                     <span class="text" v-text="item.unit"></span>
-                    <span class="button">${ item.complete ? '点击领取' : '去完成' }</span>
+                    <span @click="onClickReceive('mission', item)" class="button">${ item.complete ? '点击领取' : '去完成' }</span>
                 </div>
                 <div class="m-list-item-text" v-text="item.name"></div>
             </div>
@@ -56,10 +75,10 @@
                         :class="a.className">
                         <div class="anchor-text">${ a.anchorText }</div>
                         <div class="point-img" v-if="a.pointImg">
-                            <img :src="progress.pointImgMap[a.pointImg]" alt="">
+                            <img :src="progress.pointImgMap[a.className]" alt="">
                         </div>
-                        <div class="anchor-tip-text" v-show="a.tipText">
-                            <p>免费领</p>
+                        <div class="anchor-tip-text" v-show="a.tipText" @click="onClickReceive('schedule', a)">
+                            <p>${a.className === 'received' ? '已' : '免费'}领</p>
                             <p v-text="a.tipText"></p>
                         </div>
                     </div>
@@ -91,9 +110,10 @@
                             <div class="r-l-i-receive-time td" v-text="item.receiveTime"></div>
                             <div class="r-l-i-receive-from td" v-text="item.receiveFrom"></div>
                             <div class="r-l-i-action td">
-                                <button class="reward-action-button">查看</button>
+                                <button class="reward-action-button" @click="onClickListItem(item)">查看</button>
                             </div>
                         </div>
+                        <div class="reward-empty">暂未获得奖励,快去完成任务吧</div>
                     </div>
                 </div>
             </div>
@@ -105,6 +125,7 @@
                     class="tool-button"
                     v-for="(item, index) in toolBoxList"
                     v-text="item.text"
+                    @click="onClickLink(item)"
                     :key="index"></div>
             </div>
         </section>
@@ -152,7 +173,7 @@
   <div class="modal-dialog active-tip--success">
     <h5>领取成功</h5>
     <p>
-      恭喜成功领取 7 天超级订阅
+      恭喜成功领取 <i class="text-give-day">7</i> 天超级订阅
       <br>
       <span>可在“我的奖励”中查看</span>
     </p>
@@ -161,6 +182,8 @@
   </div>
 </div>
 <!--E-弹窗-->
+<!-- 用户留资 -->
+<div id="vue-collect-user-info"></div>
 <script src='{{Msg "seo" "cdn"}}/js/jquery.cookie.js?v={{Msg "seo" "version"}}' type="text/javascript"></script>
 <script src='{{Msg "seo" "cdn"}}/js/public-nav.js?v={{Msg "seo" "version"}}' type="text/javascript"></script>
 <script>
@@ -171,25 +194,10 @@
 <script src="//cdn-common.jianyu360.com/cdn/lib/vue/2.6.14/vue.min.js"></script>
 <script src="//cdn-common.jianyu360.com/cdn/lib/element-ui/2.15.7/lib/index.js"></script>
 <script src="{{Msg "seo" "cdn"}}/big-member/js/utils.js?v={{Msg "seo" "version"}}"></script>
+<script src='{{Msg "seo" "cdn"}}/common-module/public/js/china-map-data.js?v={{Msg "seo" "version"}}'></script>
+<script src='{{Msg "seo" "cdn"}}/common-module/selector/js/static-data.js?v={{Msg "seo" "version"}}'></script>
+<script src='{{Msg "seo" "cdn"}}/js/pc-collect-user-info.js?v={{Msg "seo" "version"}}'></script>
 <script src="{{Msg "seo" "cdn"}}/frontRouter/pc/activity/js/task.js?v={{Msg "seo" "version"}}"></script>
-<script>
-  $(function () {
-    $('#active-tip-modal').attr('data-modal-type', 'success').modal('show')
-    // $('#active-tip-modal').attr('data-modal-type', 'over').modal('show')
-    // $('#active-tip-modal').attr('data-modal-type', 'code').modal('show')
-
-    // 扫一扫 二维码
-    $('#active-tip-modal .active-tip--code .code-img').attr('src', '/front/downloadJyApp/qr?page=pc_bottom&source=pc_scan')
-
-    // 弹窗按钮事件
-    $('#dialog-button--over').on('click', function () {
-
-    })
-    $('#dialog-button--success').on('click', function () {
-
-    })
-  })
-</script>
 <!--S-百度统计-->
 {{include "/common/pcbottom.html"}}
 {{include "/common/baiducc.html"}}