Commit 880f9e36 authored by 王波's avatar 王波

Merge branch 'b-template-addStatistic' into 'b-template-component-bugfixed-0.1'

B端模板添加数据需求导出

See merge request !13
parents d914429c 8b548be0
...@@ -35,6 +35,8 @@ const API = { ...@@ -35,6 +35,8 @@ const API = {
// 搜索条件查询中奖信息 // 搜索条件查询中奖信息
downloadFile: (params) => request("downloadFile", "POST", params), downloadFile: (params) => request("downloadFile", "POST", params),
getAwardsList: (params) => request("getAwardsList", "POST", params), getAwardsList: (params) => request("getAwardsList", "POST", params),
// 导出数据需求
getStats: (params) => request("getStats", "POST", params, { cloudFnType: 'c' })
}; };
export default API; export default API;
.statistic-dialog-wrap {
max-height: 400px;
overflow: scroll
}
.statistic-dialog-wrap .operator-btns {
margin-bottom: 10px;
}
.statistic-dialog-wrap .long-item .next-select {
width: 150px;
}
<dialog-wrap
title="导出数据需求"
visible="{{visible}}"
onClose="onCloseDialog"
width="500"
>
<view class="statistic-dialog-wrap">
<!-- 数据需求时间范围 -->
<form class="edit-content-form" data-name="form" inline="true" labelTextAlign="center" size="large">
<form-item class="edit-content-formItem" label="统计时间" labelTextAlign="center" asterisk="{{false}}">
<range-picker style="width: 400px" onChange="handleTimeRangeChange" hasClear="true" value="{{timeRange}}" class="block" data-time="{{timeRange}}"/>
</form-item>
<view class="operator-btns" style="textAlign:center">
<button style="margin-left:20px;height:32px" type="primary" onTap="handleExport" size="medium">导出</button>
</view>
</form>
</view>
</dialog-wrap>
\ No newline at end of file
import { getStats } from '/api';
Component({
mixins: [],
data: {
// 数据统计开始结束时间
timeRange: []
},
props: {
onClose: () => { },
onShowExportDialog: () => { },
selectedItem: {}
},
didMount() {
},
methods: {
// 关闭弹窗
onCloseDialog() {
this.setData({
startDay: '',
endDay: ''
});
this.props.onClose && this.props.onClose();
},
// 监听时间变化
handleTimeRangeChange(e) {
console.log(e.detail.value)
const [startTime, endTime] = e.detail.value;
this.setData({
timeRange: [startTime, endTime]
});
},
// 导出
async handleExport(evt) {
console.log(this.props);
// 未选择任何条件搜索
if (!this.data.timeRange.length && !this.data.timeRange[0] && !this.data.timeRange[1]) {
my.showToast({
type: 'fail',
content: '请选择统计时间范围'
});
return;
}
const { activityId } = this.props.selectedItem;
let params = {
activityId,
startDay: this.data.timeRange[0],
endDay: this.data.timeRange[1]
};
my.showLoading({
content: '生成文件中...'
});
try {
let { success, data, message } = (await getStats(params)) || {};
console.log(success, data, message, '复制链接');
if (success) {
this.props.onShowExportDialog({
exportLinkUrl: data.url.replace(/amp;/g, '')
});
console.log(data, '下载链接');
} else {
my.showToast({
type: 'fail',
content: message
});
}
my.hideLoading();
} catch (error) {
my.hideLoading();
console.log(error, 'exportStatistics-error');
}
}
}
});
{
"component": true,
"usingComponents": {
"dialog-wrap": "../../basic/dialiog-wrap/dialiog-wrap"
}
}
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
<button a:if="{{buttons.includes('delete')}}" class="tb-list-edit" type="primary" text="true" data-x="{{x}}" onTap="handleTapDelete">删除</button> <button a:if="{{buttons.includes('delete')}}" class="tb-list-edit" type="primary" text="true" data-x="{{x}}" onTap="handleTapDelete">删除</button>
<button a:if="{{buttons.includes('copyLink')}}" class="tb-list-edit" type="primary" text="true" data-x="{{x}}" onTap="onCopyLink">复制活动链接</button> <button a:if="{{buttons.includes('copyLink')}}" class="tb-list-edit" type="primary" text="true" data-x="{{x}}" onTap="onCopyLink">复制活动链接</button>
<button a:if="{{buttons.includes('copyNewActivity')}}" class="tb-list-edit" type="primary" text="true" data-x="{{x}}" onTap="onCreateNewActivity">复制新活动</button> <button a:if="{{buttons.includes('copyNewActivity')}}" class="tb-list-edit" type="primary" text="true" data-x="{{x}}" onTap="onCreateNewActivity">复制新活动</button>
<button a:if="{{buttons.includes('exportStatistics')}}" class="tb-list-edit" type="primary" text="true" data-x="{{x}}" onTap="onExportStatistics">导出数据需求</button>
</view> </view>
</table-column> </table-column>
</table> </table>
...@@ -39,4 +40,5 @@ ...@@ -39,4 +40,5 @@
/> />
<rank-dialog a:if="{{winnerListDialogVisible}}" visible="{{winnerListDialogVisible}}" onClose="onCloseWinnerListDialog" onShowExportDialog="showExportDialog" selectedItem="{{selectedItem}}"/> <rank-dialog a:if="{{winnerListDialogVisible}}" visible="{{winnerListDialogVisible}}" onClose="onCloseWinnerListDialog" onShowExportDialog="showExportDialog" selectedItem="{{selectedItem}}"/>
\ No newline at end of file <statistic-dialog a:if="{{statisticDialogVisible}}" visible="{{statisticDialogVisible}}" onClose="onCloseStatisticDialog" onShowExportDialog="showExportDialog" selectedItem="{{selectedItem}}"/>
\ No newline at end of file
...@@ -5,7 +5,7 @@ import { ...@@ -5,7 +5,7 @@ import {
delActivity, delActivity,
findWinnerInfoList, findWinnerInfoList,
uploadDataCreateFile, uploadDataCreateFile,
createCopyActivity, createCopyActivity
} from "/api"; } from "/api";
import { appId } from "/config"; import { appId } from "/config";
import { setClipboard } from "/utils"; import { setClipboard } from "/utils";
...@@ -27,6 +27,7 @@ Component({ ...@@ -27,6 +27,7 @@ Component({
}, },
deleteId: "", deleteId: "",
winnerListDialogVisible: false, winnerListDialogVisible: false,
statisticDialogVisible: false,
selectedItem: {} selectedItem: {}
}, },
props: { props: {
...@@ -202,5 +203,18 @@ Component({ ...@@ -202,5 +203,18 @@ Component({
const { value } = evt.detail; const { value } = evt.detail;
this.getList(value); this.getList(value);
}, },
// 关闭数据需求弹窗
onCloseStatisticDialog() {
this.setData({
statisticDialogVisible: false
});
},
// 导出数据需求
async onExportStatistics(evt) {
this.setData({
statisticDialogVisible: true,
selectedItem: evt.target.dataset.x.record
});
},
}, },
}); });
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
"copy-link-dialog": "/components/dialog/copy-link-dialog/copy-link-dialog", "copy-link-dialog": "/components/dialog/copy-link-dialog/copy-link-dialog",
"confirm-dialog": "/components/dialog/confirm-dialog/confirm-dialog", "confirm-dialog": "/components/dialog/confirm-dialog/confirm-dialog",
"rank-dialog": "/components/dialog/rank-dialog/rank-dialog", "rank-dialog": "/components/dialog/rank-dialog/rank-dialog",
"winner-list-dialog": "/components/dialog/winner-list-dialog/winner-list-dialog" "winner-list-dialog": "/components/dialog/winner-list-dialog/winner-list-dialog",
"statistic-dialog": "/components/dialog/statistic-dialog/statistic-dialog"
} }
} }
\ No newline at end of file
...@@ -8,6 +8,9 @@ export default { ...@@ -8,6 +8,9 @@ export default {
// 默认云函数名称 // 默认云函数名称
cloudFnName: 'duibats', cloudFnName: 'duibats',
// C端云函数名称(数据需求调用)
cCloudFnName: 'CommonToC',
// 小程序appId // 小程序appId
appId: "<%=appId%>", appId: "<%=appId%>",
......
...@@ -2,11 +2,12 @@ const { ...@@ -2,11 +2,12 @@ const {
cloud cloud
} = getApp(); } = getApp();
import { requestType, cloudFnName } from '../config'; import { requestType, cloudFnName, cCloudFnName } from '../config';
const request = (url, method, params, ext = {}) => { const request = (url, method, params, ext = {}) => {
const { const {
isShowLoading isShowLoading,
cloudFnType
} = ext; } = ext;
const hideMyLoading = () => { const hideMyLoading = () => {
if (isShowLoading) { if (isShowLoading) {
...@@ -17,9 +18,12 @@ const request = (url, method, params, ext = {}) => { ...@@ -17,9 +18,12 @@ const request = (url, method, params, ext = {}) => {
my.showLoading(); my.showLoading();
} }
// 云函数名
const cloudFn = cloudFnType === 'c' ? cCloudFnName : cloudFnName
const requestAms = () => { const requestAms = () => {
return my.request({ return my.request({
url: `https://ams.dui88.com/server/index.php?g=Web&c=Mock&o=simple&projectID=218&uri=${cloudFnName}.${url}`, url: `https://ams.dui88.com/server/index.php?g=Web&c=Mock&o=simple&projectID=218&uri=${cloudFn}.${url}`,
method, method,
data: params, data: params,
dataType: 'json' dataType: 'json'
...@@ -32,7 +36,7 @@ const request = (url, method, params, ext = {}) => { ...@@ -32,7 +36,7 @@ const request = (url, method, params, ext = {}) => {
} }
const requestCloud = () => { const requestCloud = () => {
return cloud.function.invoke(cloudFnName, params, url).then(res => { return cloud.function.invoke(cloudFn, params, url).then(res => {
hideMyLoading(); hideMyLoading();
return res; return res;
}).catch(() => { }).catch(() => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment