Browse Source

Merge branch '销售漏斗' into 4.22更新

xiaohaizhao 2 years ago
parent
commit
c80baf83a3

+ 89 - 82
app.js

@@ -1,89 +1,96 @@
 import {
-    ApiModel
+  ApiModel
 } from './utils/api';
 
 App({
-    onLaunch(options) {
-        //小程序跳转进入
-        if (options.query.userMsg) {
-            wx.removeStorageSync('userMsg')
-            wx.removeStorageSync('auth')
-            wx.removeStorageSync('userauth');
-            wx.setStorageSync('userMsg', JSON.parse(options.query.userMsg));
-            wx.setStorageSync('auth', JSON.parse(options.query.auth));
-            wx.setStorageSync('siteP', JSON.parse(options.query.site));
-            //获取用户权限 
-            this.globalData.http.basic({
-                "classname": "sysmanage.develop.userauth.userauth",
-                "method": "query_userauth",
-                content: {
-                    nocache: true
-                }
-            }).then(res => {
-                console.log("跳转进入查询权限", res)
-                if (res.msg != '成功') return wx.showToast({
-                    title: '权限查询失败,请稍后再试',
-                    icon: "none"
-                })
-                wx.setStorageSync('userauth', res.data);
-            });
-            if (!wx.getStorageSync('templetList')) this.globalData.http.basic({
-                "classname": "sysmanage.develop.querytemplet.querytemplet",
-                "method": "query",
-                "content": {}
-            }).then(res => {
-                console.log("获取列表查询条件", res)
-                if (res.msg != '成功') return;
-                let data = res.data.find(v => v.templetname == '站点全部');
-                if (data) {
-                    res.data = res.data.filter(v => v.templetname != '站点全部')
-                    res.data.unshift(data)
-                }
-                wx.setStorageSync('templetList', res.data)
-                getCurrentPages()[getCurrentPages().length - 1].getList && getCurrentPages()[getCurrentPages().length - 1].getList(true);
-            })
-        };
-        wx.setStorageSync('appid', 'wx197f219a82a89d7b');
-    },
-    initSocket() {
-        let that = this;
-        this.globalData.SocketTask = wx.connectSocket({
-            url: (this.globalData.http.baseUrl + '/yos/webSocket/').replace("https", "wss").replace("http", "ws") + wx.getStorageSync('userMsg').token,
-            complete: (res) => {
-                console.log(res)
-            }
-        })
-        this.globalData.SocketTask.onOpen(function (res) {
-            that.globalData.socketEstablish = true;
-        })
-        this.globalData.SocketTask.onMessage(function (res) {
-            that.globalData.socketCallback(res)
-        })
-        this.globalData.SocketTask.onError(function (res) {
-            that.globalData.socketEstablish = false;
+  onLaunch(options) {
+    //小程序跳转进入
+    if (options.query.userMsg) {
+      wx.removeStorageSync('userMsg')
+      wx.removeStorageSync('auth')
+      wx.removeStorageSync('userauth');
+      wx.setStorageSync('userMsg', JSON.parse(options.query.userMsg));
+      wx.setStorageSync('auth', JSON.parse(options.query.auth));
+      wx.setStorageSync('siteP', JSON.parse(options.query.site));
+      //获取用户权限 
+      this.globalData.http.basic({
+        "classname": "sysmanage.develop.userauth.userauth",
+        "method": "query_userauth",
+        content: {
+          nocache: true
+        }
+      }).then(res => {
+        console.log("跳转进入查询权限", res)
+        if (res.msg != '成功') return wx.showToast({
+          title: '权限查询失败,请稍后再试',
+          icon: "none"
         })
-        this.globalData.SocketTask.onClose(function (res) {
-            that.globalData.socketEstablish = false;
+        wx.setStorageSync('userauth', res.data);
+      });
+      try {
+        if (!wx.getStorageSync('templetList')) getTempletList()
+      } catch (error) {
+        getTempletList()
+      }
+      function getTempletList() {
+        this.globalData.http.basic({
+          "classname": "sysmanage.develop.querytemplet.querytemplet",
+          "method": "query",
+          "content": {}
+        }).then(res => {
+          console.log("获取列表查询条件", res)
+          if (res.msg != '成功') return;
+          let data = res.data.find(v => v.templetname == '站点全部');
+          if (data) {
+            res.data = res.data.filter(v => v.templetname != '站点全部')
+            res.data.unshift(data)
+          }
+          wx.setStorageSync('templetList', res.data)
+          getCurrentPages()[getCurrentPages().length - 1].getList && getCurrentPages()[getCurrentPages().length - 1].getList(true);
         })
-    },
-    /**
-     * 查询是否为数据代理人
-     * @param {string} ownertable 数据表名
-     * @param {number} ownerid 数据id
-     */
-    agentOrNot: (ownertable, ownerid) => getApp().globalData.http.basic({
-        "id": 20230329122604,
-        "content": {
-            ownertable,
-            ownerid
-        }
-    }),
-    globalData: {
-        http: new ApiModel(), //接口文件
-        queryPer: require("./utils/queryPermissions"), //权限查询
-        socketEstablish: false, //是否已经建立socket
-        SocketTask: '', // Socket方法
-        socketCallback: null, // Socket回调
-        handleSelect: null, //处理选择结果  函数
-    },
+      };
+    }
+    wx.setStorageSync('appid', 'wx197f219a82a89d7b');
+  },
+  initSocket() {
+    let that = this;
+    this.globalData.SocketTask = wx.connectSocket({
+      url: (this.globalData.http.baseUrl + '/yos/webSocket/').replace("https", "wss").replace("http", "ws") + wx.getStorageSync('userMsg').token,
+      complete: (res) => {
+        console.log(res)
+      }
+    })
+    this.globalData.SocketTask.onOpen(function (res) {
+      that.globalData.socketEstablish = true;
+    })
+    this.globalData.SocketTask.onMessage(function (res) {
+      that.globalData.socketCallback(res)
+    })
+    this.globalData.SocketTask.onError(function (res) {
+      that.globalData.socketEstablish = false;
+    })
+    this.globalData.SocketTask.onClose(function (res) {
+      that.globalData.socketEstablish = false;
+    })
+  },
+  /**
+   * 查询是否为数据代理人
+   * @param {string} ownertable 数据表名
+   * @param {number} ownerid 数据id
+   */
+  agentOrNot: (ownertable, ownerid) => getApp().globalData.http.basic({
+    "id": 20230329122604,
+    "content": {
+      ownertable,
+      ownerid
+    }
+  }),
+  globalData: {
+    http: new ApiModel(), //接口文件
+    queryPer: require("./utils/queryPermissions"), //权限查询
+    socketEstablish: false, //是否已经建立socket
+    SocketTask: '', // Socket方法
+    socketCallback: null, // Socket回调
+    handleSelect: null, //处理选择结果  函数
+  },
 })

+ 43 - 4
components/Yl_Filtrate1/index.js

@@ -1,6 +1,9 @@
 import {
     getHeight
 } from "../../utils/getHeight";
+import {
+    formatTime
+} from "../../utils/getTime"
 Component({
     properties: {
         list: {
@@ -92,6 +95,7 @@ Component({
                 item,
                 index,
                 name: this.data.list[index].selectKey,
+                data: this.data.list[index],
                 list: this.data.list
             })
         },
@@ -130,6 +134,10 @@ Component({
                 name
             } = e.target.dataset;
             if (name == 'reset') {
+                this.setData({
+                    startdate: '',
+                    enddate: ''
+                })
                 this.setData({
                     list: this.data.list.map(v => {
                         let value = "",
@@ -144,13 +152,10 @@ Component({
                         }
                         v.value = value;
                         v.index = index;
+                        if (index != null && v.relevance == 'dateRange') this.queryMonths(v.list[index].queryMonths)
                         return v;
                     })
                 })
-                this.setData({
-                    startdate: '',
-                    enddate: ''
-                })
                 let MultilevelClass = this.selectComponent("#MultilevelClass");
                 if (MultilevelClass) MultilevelClass.clearChild()
             };
@@ -180,10 +185,44 @@ Component({
         changeDate(e) {
             const name = e.currentTarget.dataset.name,
                 value = e.detail.value;
+            let data = this.data.list.find(v => v.relevance == "dateRange")
+            if (data) {
+                data.index = null;
+                this.setData({
+                    list: this.data.list
+                })
+            }
             this.setData({
                 [name]: value
             })
         },
+        setTimeCycle(startdate = "", enddate = "") {
+            this.setData({
+                startdate,
+                enddate,
+            })
+        },
+        queryDays(num) {
+            let now = new Date().getTime(),
+                end = now,
+                beg = end - (num * 86400000);
+            this.setTimeCycle(formatTime(new Date(beg), '-').split(' ')[0], formatTime(new Date(end), '-').split(' ')[0])
+        },
+        queryMonths(period) {
+            let startdate = formatTime(new Date(), '-').split(' ')[0],
+                enddate = formatTime(new Date(), '-').split(' ')[0].split('-');
+            for (let i = period; i != 0; i--) {
+                enddate[1] = Number(enddate[1]) - 1;
+                if (enddate[1] == 0) {
+                    enddate[1] = 12;
+                    enddate[0] = enddate[0] - 1;
+                }
+                if (i == 1 && enddate[1] < 10) enddate[1] = "0" + enddate[1]
+            }
+            let lastDay = new Date(enddate[0], enddate[1], 0).getDate();
+            if (enddate[2] > lastDay) enddate[2] = lastDay;
+            this.setTimeCycle(startdate, enddate.join("-"))
+        },
         onClose() {
             this.setData({
                 show: false

+ 66 - 7
packageA/salesHourglass/index.js

@@ -48,7 +48,12 @@ Page({
             nocache: true,
             dataid: 0,
             type: 0,
-            dateType: 0
+            dateType: 0,
+            where: {
+                begdate: "",
+                enddate: "",
+                tradefield: ""
+            }
         },
         filtratelist: [null, {
             label: "时间筛选",
@@ -58,18 +63,24 @@ Page({
             value: "id", //选中值
             index: 0,
             default: 0,
+            interrupt: true,
+            relevance: "dateRange",
             list: [{
                 name: "近一年",
-                id: 1
+                id: 1,
+                queryMonths: 12
             }, {
                 name: "近九个月",
-                id: 2
+                id: 2,
+                queryMonths: 9
             }, {
                 name: "近六个月",
-                id: 3
+                id: 3,
+                queryMonths: 6
             }, {
                 name: "近三个月",
-                id: 4
+                id: 4,
+                queryMonths: 3
             }]
         }]
     },
@@ -123,19 +134,59 @@ Page({
                 "filtratelist[0]": data
             });
         });
+
+        _Http.basic({
+            "id": 20221223141802,
+            "content": {
+                "pageNumber": 1,
+                "pageSize": 9999,
+                "where": {
+                    "condition": ""
+                }
+            }
+        }, false).then(res => {
+            console.log("获取领域", res)
+            let filtratelist = this.data.filtratelist
+            if (res.msg == '成功') {
+                filtratelist.splice(filtratelist.length - 1, 0, {
+                    label: "领域",
+                    index: null,
+                    showName: "tradefield", //显示字段
+                    valueKey: "tradefield", //返回Key
+                    selectKey: "tradefield", //传参 代表选着字段 不传参返回整个选择对象
+                    value: "", //选中值
+                    list: res.data
+                })
+                this.setData({
+                    filtratelist
+                })
+            }
+        })
     },
     onReady() {
         this.setChartData();
+        this.selectComponent("#Yl_Filtrate1").queryMonths(12)
     },
     openFiltrate() {
         this.setData({
             showFiltrate: true
         })
     },
+    interrupt({
+        detail
+    }) {
+        console.log(detail)
+        if (detail.data.label == "时间筛选") this.selectComponent("#Yl_Filtrate1").queryMonths(detail.item.queryMonths)
+
+    },
     handleFilter(e) {
+        console.log(e)
         let {
             active,
-            dateType
+            dateType,
+            enddate,
+            startdate,
+            tradefield
         } = e.detail;
         if (active && active != 'id') {
             this.data.content.type = active.type == '人员' ? 0 : 1;
@@ -144,7 +195,15 @@ Page({
             this.data.content.type = 0;
             this.data.content.dataid = 0;
         }
-        this.data.content.dateType = dateType && dateType != 'id' ? dateType : 0
+        if (startdate && enddate) {
+            this.data.content.dateType = 0;
+            this.data.content.where.begdate = startdate;
+            this.data.content.where.enddate = enddate;
+        } else {
+            this.data.content.dateType = dateType && dateType != 'id' ? dateType : 0
+        }
+
+        this.data.content.tradefield = tradefield
         this.setChartData();
     },
     setChartData() {

+ 1 - 1
packageA/salesHourglass/index.wxml

@@ -41,4 +41,4 @@
     </view>
 </view>
 <My_empty wx:if="{{!statistics.length}}" />
-<Yl_Filtrate1 show='{{showFiltrate}}' dateRange='{{false}}' list="{{filtratelist}}" bindhandle="handleFilter" />
+<Yl_Filtrate1 id='Yl_Filtrate1' show='{{showFiltrate}}' dateRange='{{true}}' dateRangeName='创建日期' list="{{filtratelist}}" bindhandle="handleFilter" bindinterrupt='interrupt' />

+ 11 - 2
project.private.config.json

@@ -1,7 +1,8 @@
 {
     "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
     "setting": {
-        "urlCheck": false
+        "urlCheck": false,
+        "compileHotReLoad": true
     },
     "projectname": "Yos",
     "condition": {
@@ -90,8 +91,16 @@
                     "query": "",
                     "launchMode": "default",
                     "scene": null
+                },
+                {
+                    "name": "销售漏斗",
+                    "pathName": "packageA/salesHourglass/index",
+                    "query": "",
+                    "launchMode": "default",
+                    "scene": null
                 }
             ]
         }
-    }
+    },
+    "libVersion": "3.3.3"
 }