import { fetchEnterpriseCount } from '../../services/enterprise/fetchEnterprise';
|
import { fetchCreditCodeCount } from '../../services/enterprise/fetchCreditCode';
|
import { fetchRiskCount } from '../../services/enterprise/fetchRisk';
|
|
/**
|
* 线上监管相关信息获取逻辑
|
*/
|
export const useSupervision = Behavior({
|
data: {
|
supervisionLoading: false,
|
enterpriseCountRes: [],
|
riskPeriod: '',
|
riskRes: [],
|
creditPeriod: '',
|
creditRes: [],
|
// 取消网络请求标志
|
cancelFetch: [],
|
},
|
lifetimes: {
|
attached: function () {},
|
},
|
methods: {
|
/**
|
* 线上监管统计信息
|
*/
|
fetchSupervision(page) {
|
const { provinceName, cityName, districtName, townName, sceneTypeValue } = this.data;
|
const params = { provinceName, cityName, districtName, townName, sceneTypes: sceneTypeValue };
|
this._fetchSupervision(page, params);
|
},
|
|
_fetchSupervision(page, params) {
|
// 取消正在进行中的上一次请求
|
let { cancelFetch } = this.data;
|
if (cancelFetch.length > 0) {
|
cancelFetch[0] = true;
|
cancelFetch = [];
|
}
|
let abort = false;
|
cancelFetch.push(abort);
|
this.setData({ cancelFetch });
|
this.setData({ supervisionLoading: true });
|
// 企业数量
|
const f1 = fetchEnterpriseCount({
|
data: params,
|
}).then(res => {
|
if (!abort) {
|
this.setData({
|
enterpriseCountRes: res.data,
|
});
|
}
|
});
|
// 综合风险
|
const f2 = fetchRiskCount({
|
data: params,
|
}).then(res => {
|
if (!abort) {
|
this.setData({
|
riskPeriod: res.data.period,
|
riskRes: res.data.count,
|
});
|
}
|
});
|
// 环信码
|
const f3 = fetchCreditCodeCount({
|
data: params,
|
}).then(res => {
|
if (!abort) {
|
this.setData({
|
creditPeriod: res.data.period,
|
creditRes: res.data.count,
|
});
|
}
|
});
|
|
Promise.all([f1, f2, f3]).finally(() => {
|
setTimeout(() => {
|
this.setData({ supervisionLoading: false });
|
}, 500);
|
});
|
},
|
|
navToEnterprise() {},
|
|
// 跳转合规风险界面
|
navToRisk(e) {
|
const { index } = e.detail;
|
const { riskPeriod } = this.data;
|
let url = '/pages/supervision/risk/index';
|
url += this._navParams();
|
url += `&period=${riskPeriod}`;
|
url += `&riskType=${index}`;
|
wx.navigateTo({
|
url: url,
|
});
|
},
|
|
// 跳转环信码界面
|
navToEcCode(e) {
|
const { index } = e.detail;
|
const { creditPeriod } = this.data;
|
let url = '/pages/supervision/ec-code/index';
|
url += this._navParams();
|
url += `&period=${creditPeriod}`;
|
url += `&ecCodeType=${index}`;
|
wx.navigateTo({
|
url: url,
|
});
|
},
|
|
_navParams() {
|
const { provinceName, cityName, districtName, townName, sceneTypeValue, locationValue } =
|
this.data;
|
let url = `?sceneType=${sceneTypeValue[0]}`;
|
if (provinceName) url += `&province=${provinceName}`;
|
if (cityName) url += `&city=${cityName}`;
|
if (districtName) url += `&district=${districtName}`;
|
if (townName) url += `&town=${townName}`;
|
if (locationValue) url += `&locationValue=${locationValue}`;
|
return url;
|
},
|
},
|
});
|