lrf402788946 4 роки тому
батько
коміт
61f36077c3

+ 56 - 20
pages/achieveList/achieveList.js

@@ -4,34 +4,70 @@ 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: '辽宁省' },
-    ],
+    word: '昨日新增',
+    type: 'yesterday',
+    list: [],
+    provinceList: [],
     province: ''
   },
   // 事件处理
   // 选择省份
   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 })
+        }
+        this.setData({
+          list: arr
+        })
+      }
+    })
+  },
+
+  /**
+   * 查询行政区划
+   * @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>0</text>)
       </view>
       <view class="downTable">
         <view class="th">

+ 4 - 4
pages/home/home.wxml

@@ -33,28 +33,28 @@
       </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>
-      <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>
-      <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>
-      <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>