guhongwei 4 years ago
parent
commit
5066abf241

+ 63 - 21
pages/achieveList/achieveList.js

@@ -4,34 +4,76 @@ const app = getApp()
 
 Page({
   data: {
-    type: '昨日新增',
-    list: [
-      {
-        tc: '169套餐169套餐169套餐169套餐169套餐',
-        tzNum: 1,
-        jpNum: 1
-      },
-      {
-        tc: '129套餐',
-        tzNum: 2,
-        jpNum: 3
-      },
-    ],
-    provinceList: [
-      { name: '吉林省' },
-      { name: '黑龙江省' },
-      { name: '辽宁省' },
-    ],
-    province: ''
+    word: '昨日新增',
+    type: 'yesterday',
+    list: [],
+    provinceList: [],
+    province: '',
+    total: 0,
   },
   // 事件处理
   // 选择省份
   provinceChange: function (e) {
-    this.setData({ "province": this.data.provinceList[e.detail.value].name })
+    this.setData({ "province": this.data.provinceList[e.detail.value].name });
+    this.getCount(this.data.provinceList[e.detail.value])
   },
   onLoad: function (options) {
     var that = this;
     // 获取地址栏统计类型
-    that.setData({ type: options.type });
+    const { type } = options;
+    let word;
+    if (type === 'yesterday') word = "昨日新增";
+    else if (type === 'week') word = '本周新增';
+    else if (type === 'month') word = '本月新增';
+    else word = '团队统计'
+    that.setData({ type: options.type, word });
+    this.getXzqh();
+  },
+
+  /**
+   * 根据选择的省份进行统计
+   * @param {Object} object 选择的省份Object
+   */
+  getCount(object) {
+    const { code: province } = object;
+    wx.request({
+      url: `${app.globalData.publicUrl}/api/htyd/count/${this.data.type}?r_mobile=${app.globalData.userInfo.mobile}&province=${province}`,
+      method: 'get',
+      success: res => {
+        const { data } = res.data
+        const keys = Object.keys(data);
+        const arr = [];
+        for (const key of keys) {
+          arr.push({ tc: `${key.includes('套餐') ? key : `${key}-套餐`}`, tzNum: data[key], jpNum: 0 })
+        }
+        if (arr.length <= 0) wx.showToast({
+          title: '未查到相关数据',
+          icon: "none"
+        })
+        this.setData({
+          list: arr,
+          total: arr.reduce((p, n) => p + (n.tzNum || 0) + (n.jpNum || 0), 0)
+        })
+      }
+    })
+  },
+
+  /**
+   * 查询行政区划
+   * @param {String} pcode 上级code
+   */
+  getXzqh(pcode) {
+    const query = {};
+    if (pcode) query.pcode = pcode;
+    wx.request({
+      url: `${app.globalData.publicUrl}/api/htyd/xzqh`,
+      method: "get",
+      success: res => {
+        this.setData({
+          provinceList: res.data.data
+        })
+        console.log(this.data.provinceList);
+      }
+    })
   }
 })

+ 2 - 2
pages/achieveList/achieveList.wxml

@@ -6,7 +6,7 @@
     <view class="top">
       <view class="topView">号码归属省</view>
       <view class="topView">
-        <picker class="createTime" bindchange="provinceChange" name="province" value="{{province}}"
+        <picker class="createTime" bindchange="provinceChange" name="province" value="{{province.code}}"
           range="{{provinceList}}" range-key="{{'name'}}">
           <view class="picker">{{province||'归属省'}}
             <van-icon name="arrow" />
@@ -16,7 +16,7 @@
     </view>
     <view class="down">
       <view class="downTxt">
-        {{type}}(<text>0</text>)
+        {{word}}(<text>{{total}}</text>)
       </view>
       <view class="downTable">
         <view class="th">

+ 22 - 3
pages/home/home.js

@@ -5,13 +5,16 @@ const app = getApp()
 Page({
   data: {
     // 个人信息
-    videoUrl: 'http://broadcast.waityou24.cn/files/imgpath/20201221103327.mp4',
-    userInfo: {}
+    videoUrl: 'https://vd3.bdstatic.com/mda-kar9n2ip1u508ewq/hd/mda-kar9n2ip1u508ewq.mp4?pd=20',
+    userInfo: {},
+    yesterday: 0,
+    week: 0,
+    month: 0,
+    group: 0,
   },
   //事件处理函数
   // 统计信息
   achieveBtn: function (event) {
-    console.log(event.currentTarget.id);
     let type = event.currentTarget.id;
     wx.navigateTo({
       url: '/pages/achieveList/achieveList?type=' + type // 希望跳转过去的页面
@@ -114,5 +117,21 @@ Page({
         })
       }
     })
+    this.indexCount();
   },
+
+  /**
+   * 首页查询4块统计
+   * @property mobile 当前用户手机号,查询条件
+   */
+  indexCount() {
+    wx.request({
+      url: `${app.globalData.publicUrl}/api/htyd/count/index?mobile=${app.globalData.userInfo.mobile}`,
+      method: 'get',
+      success: res => {
+        const { data } = res.data
+        this.setData({ ...data })
+      }
+    })
+  }
 })

+ 8 - 8
pages/home/home.wxml

@@ -32,33 +32,33 @@
       </view>
     </van-col>
     <van-col span="24" class="three">
-      <view class="num" bindtap="achieveBtn" id="{{'昨日新增'}}">
+      <view class="num" bindtap="achieveBtn" id="yesterday">
         <view class="numOne">
           <text>昨日新增</text>
           <image src="/pages/images/zr.png"></image>
         </view>
-        <view class="numTwo">0</view>
+        <view class="numTwo">{{yesterday}}</view>
       </view>
-      <view class="num" bindtap="achieveBtn" id="{{'本周新增'}}">
+      <view class="num" bindtap="achieveBtn" id="week">
         <view class="numOne">
           <text>本周新增</text>
           <image src="/pages/images/zhou.png"></image>
         </view>
-        <view class="numTwo">0</view>
+        <view class="numTwo">{{week}}</view>
       </view>
-      <view class="num" bindtap="achieveBtn" id="{{'当月新增'}}">
+      <view class="num" bindtap="achieveBtn" id="month">
         <view class="numOne">
           <text>当月新增</text>
           <image src="/pages/images/yue.png"></image>
         </view>
-        <view class="numTwo">0</view>
+        <view class="numTwo">{{month}}</view>
       </view>
-      <view class="num" bindtap="achieveBtn" id="{{'团队统计'}}">
+      <view class="num" bindtap="achieveBtn" id="group">
         <view class="numOne">
           <text>团队统计</text>
           <image src="/pages/images/team.png"></image>
         </view>
-        <view class="numTwo">0</view>
+        <view class="numTwo">{{group}}</view>
       </view>
     </van-col>
     <van-col span="24" class="four">

+ 76 - 35
pages/integral/integral.js

@@ -20,24 +20,9 @@ Page({
   onLoad: function () {
     //处理直推积分
     var that = this;
-    let integralList = [
-      {
-        id: 1,
-        status: '已结算',
-        name: '张三哈',
-        money: '300.00',
-        grade: '一级',
-        time: '2020-10-2',
-        num: '11111111111',
-      },
-    ];
-    for (const val of integralList) {
-      val.name = val.name.substring(0, 1) + new Array(val.name.length).join('*');
-      val.num = val.num.substring(0, 3) + new Array(5).join('*') + val.num.substring(7, 11);
-    }
-    that.setData({ integralList: integralList });
+    this.directRecord();
     //处理开卡量
-    let cardList=[
+    let cardList = [
       {
         id: 1,
         status: '已结算',
@@ -48,27 +33,83 @@ Page({
         num: '11111111111',
       },
     ]
-    for(let val of cardList){
-      val.name=val.name.substring(0, 1) + new Array(val.name.length).join('*');
+    for (let val of cardList) {
+      val.name = val.name.substring(0, 1) + new Array(val.name.length).join('*');
       val.num = val.num.substring(0, 3) + new Array(5).join('*') + val.num.substring(7, 11);
     }
     that.setData({ cardList: cardList });
     //处理卡单分红
-    let bonusList=[
-      {
-        id: 1,
-        status: '已结算',
-        name: '张三哈',
-        money: '300.00',
-        grade: '一级',
-        time: '2020-10-2',
-        num: '11111111111',
-      },
-    ]
-    for(let val of bonusList){
-      val.name=val.name.substring(0, 1) + new Array(val.name.length).join('*');
-      val.num = val.num.substring(0, 3) + new Array(5).join('*') + val.num.substring(7, 11);
-    }
-    that.setData({ bonusList: bonusList });
+    this.bonusRecord()
   },
+
+  /**
+   * 查询直推开卡的积分记录
+   */
+  directRecord() {
+    wx.request({
+      url: `${app.globalData.publicUrl}/api/htyd/record?mobile=${app.globalData.userInfo.mobile}&opera=1`,
+      method: 'get',
+      success: res => {
+        let { data } = res.data
+        if (data.length <= 0) wx.showToast({
+          title: '未查到相关数据',
+          icon: "none"
+        })
+        data = data.map(i => {
+          i.word = ` ${i.name.split('')[0]} `;
+          i.mobile = `${i.mobile.substring(0, 3)}****${i.mobile.substring(7, 11)}`
+          i.create_time = i.create_time.split(' ')[0]
+          i.level = this.getLevel(i.params.level);
+          return i;
+        })
+        this.setData({
+          integralList: data,
+        })
+      }
+    })
+  },
+
+  /**
+   * 卡单分红
+   */
+  bonusRecord() {
+    wx.request({
+      url: `${app.globalData.publicUrl}/api/htyd/record?mobile=${app.globalData.userInfo.mobile}&opera=4`,
+      method: 'get',
+      success: res => {
+        let { data } = res.data
+        if (data.length <= 0) wx.showToast({
+          title: '未查到相关数据',
+          icon: "none"
+        })
+        data = data.map(i => {
+          i.word = ` ${i.name.split('')[0]} `;
+          i.mobile = `${i.mobile.substring(0, 3)}****${i.mobile.substring(7, 11)}`
+          i.create_time = i.create_time.split(' ')[0]
+          i.level = this.getLevel(i.params.level);
+          return i;
+        })
+        this.setData({
+          bonusList: data,
+        })
+      }
+    })
+  },
+
+  /**
+   * 用户等级数字换取中文
+   * @param {Number} level 用户等级
+   */
+  getLevel(level) {
+    let res;
+    if (level == 2) res = '经理'
+    else if (level == 3) res = '一星经理'
+    else if (level == 4) res = '二星经理'
+    else if (level == 5) res = '三星经理'
+    else if (level == 6) res = '四星经理'
+    else res = '业务员'
+    return res;
+  }
+
+
 })

+ 5 - 5
pages/integral/integral.wxml

@@ -8,20 +8,20 @@
         <view class="integral" wx:for="{{integralList}}" wx:key="id">
           <view class="list">
             <view class="status">
-              <text class="text">{{item.status}}</text>
+              <text class="text">{{item.word}}</text>
             </view>
             <view class="left1">
               <view class="top1">
                 <text class="name">{{item.name}}</text>
-                <text class="num">{{item.num}}</text>
+                <text class="num">{{item.mobile}}</text>
               </view>
               <view class="foot1">
-                <text class="name">等级:{{item.grade}}</text>
+                <text class="name">等级:{{item.level}}</text>
               </view>
             </view>
             <view class="right1">
-              <view class="money">{{item.money}}</view>
-              <view class="time">{{item.time}}</view>
+              <view class="money">{{item.points}}</view>
+              <view class="time">{{item.create_time}}</view>
             </view>
           </view>
         </view>