소스 검색

updating: 跑马灯客户端

yll 4 년 전
부모
커밋
ee85ff5f8d
3개의 변경된 파일60개의 추가작업 그리고 22개의 파일을 삭제
  1. 48 19
      view/xcx/pages/index/index.js
  2. 2 2
      view/xcx/pages/index/index.wxml
  3. 10 1
      view/xcx/pages/leader_board/index.js

+ 48 - 19
view/xcx/pages/index/index.js

@@ -1,6 +1,6 @@
 const app = getApp();
 import wxh from '../../utils/wxh.js';
-import { getIndexData, getCoupons, getTemlIds, getLiveList } from '../../api/api.js';
+import { getIndexData, getCoupons, getTemlIds, getLiveList, getNotifications } from '../../api/api.js';
 import { CACHE_SUBSCRIBE_MESSAGE } from '../../config.js';
 import { getCategoryList, getProductHot, getProductslist } from '../../api/store.js';
 import { getCouponReceive} from '../../api/user.js';
@@ -16,20 +16,19 @@ Page({
     logoUrl:'',
     categoryOne:[],
     banner: [],
-    itemNew: [],
+    itemNew: [],    // 跑马灯列表
     menus: [],
-    getCouponList:[],
+    getCouponList:[],//@deprecated 
     activity:[],
-    timeList: [],
-    killIndex: 0,//点击当前index值;
-    seckillTimeIndex: 0, //当前秒杀index;
-    killIndexTime: 0,//点击当前index值所对应的秒杀时间;
-    killIndexLen: 0,//当前秒杀的产品列表长度
-    seckillList:[],
-    scrollLeft: 0,
-    elementWidth:0,
-    status:1,
-    lovely: [],
+    timeList: [], //@deprecated 
+    killIndex: 0,//@deprecated 点击当前index值;
+    seckillTimeIndex: 0, //@deprecated 当前秒杀index;
+    killIndexTime: 0,//@deprecated 点击当前index值所对应的秒杀时间;
+    killIndexLen: 0,//@deprecated 当前秒杀的产品列表长度
+    seckillList:[], //@deprecated 
+    scrollLeft: 0, //@deprecated 
+    status:1, //@deprecated 
+    lovely: [], //@deprecated 
     info: {
       fastList: [],
       bastBanner: [],
@@ -40,9 +39,9 @@ Page({
     likeInfo: [],
     benefit:[],
     hostProduct: [],
-    indicatorDots: false,
+    indicatorDots: false, // 跑马灯轮播图不带点
     circular: true,
-    autoplay: true,
+    autoplay: true,   // 跑马灯轮播图自动播放
     intervalNew: 3500,
     durationNew: 700,
     parameter:{
@@ -78,9 +77,10 @@ Page({
     countDownHour: "00",
     countDownMinute: "00",
     countDownSecond: "00",
-    seckillCont:true,
-    interval:null,
-    newGoodsBananr: '',
+    seckillCont:true, //@deprecated 
+    interval:null,  
+    timerNotification: null,
+    newGoodsBananr: '', //@deprecated 
     liveList: [],
     liveInfo: {}
   },
@@ -154,6 +154,25 @@ Page({
     // this.getCoupon();
     this.getIndexConfig();
     // this.getSeckillTime();
+
+    var that = this
+    this.setData({
+      timerNotification: setInterval(function(){
+        that.loadNotifications()
+      }, 1000 * 60 * 3)
+    })
+  },
+
+  // 加载通知,目前只有跑马灯
+  loadNotifications: function() {
+    var that = this
+    getNotifications().then(res=>{
+      if(res.data.carousel.length > 0) {
+        that.setData({
+          itemNew: res.data.carousel
+        })
+      }
+    })
   },
 
   getIndexConfig:function(){
@@ -322,6 +341,7 @@ Page({
   //   });
   // },
 
+  // 页面事件, 不再使用
   setTime: function (e) {
     var that = this, index = e.currentTarget.dataset.index;
     that.setData({
@@ -331,6 +351,7 @@ Page({
     that.getSeckillLists();
   },
 
+  // 不再触发
   getSeckillLists: function () {
     let that = this;
     let timeId = that.data.timeList[that.data.killIndex].id;
@@ -375,7 +396,7 @@ Page({
     });
   },
 
-  /** 获取优惠券列表 */
+  /** 获取优惠券列表 不再触发*/
   getCoupon: function () {
     var that = this;
     getCoupons({page: 1,limit: 6}).then(res => {
@@ -389,6 +410,7 @@ Page({
     });
   },
 
+  // 页面回调,不再触发
   receiveCoupon: function (e) {
     if (!app.globalData.isLog) {
       this.setData({
@@ -423,8 +445,15 @@ Page({
    * 生命周期函数--监听页面隐藏
    */
   onHide: function () {
+    console.log('onhide()');
     this.setData({ window:false});
     this.data.interval !== null && clearInterval(this.data.interval);
+    if (this.data.timerNotification != null) {
+      clearInterval(this.data.timerNotification);
+      this.setData({
+        timerNotification: null,
+      })
+    }
   },
 
   /**

+ 2 - 2
view/xcx/pages/index/index.wxml

@@ -48,14 +48,14 @@
                       <view class='label border2' wx:if="{{item.id%2 == 0}}">最新</view>
                       <view class='newsTitle line1'>{{item.info}}</view>
                     </view>
-                    <view class='iconfont icon-xiangyou'></view>
+                    <!-- <view class='iconfont icon-xiangyou'></view> -->
                   </navigator>
                   <navigator wx:else open-type='navigate' url='{{item.url}}'  class='acea-row row-between-wrapper' hover-class='none'>
                     <view class='text acea-row row-between-wrapper'>
                       <view class='label border2' wx:if="{{item.id%2 == 0}}">最新</view>
                       <view class='newsTitle line1'>{{item.info}}</view>
                     </view>
-                    <view class='iconfont icon-xiangyou'></view>
+                    <!-- <view class='iconfont icon-xiangyou'></view> -->
                   </navigator>
                 </swiper-item>
               </block>

+ 10 - 1
view/xcx/pages/leader_board/index.js

@@ -1,6 +1,8 @@
 // pages/leader_board/index.js
 import {getLeaderBoard} from '../../api/api.js'
 
+const app = getApp();
+
 Page({
   data: {
     parameter: {
@@ -16,6 +18,9 @@ Page({
   },
 
   onLoad: function (options) {
+  },
+
+  loadLeaderBoard: function() {
     var that = this
     getLeaderBoard().then(res => {
       if (res.data) {
@@ -30,5 +35,9 @@ Page({
     err => {
       console.log(err)
     })
-  }
+  },
+
+  onShow: function () {
+      this.loadLeaderBoard() 
+  },
 })