Commit e67b52b2 authored by 杨梦雅's avatar 杨梦雅

添加数据需求导出

parent d914429c
...@@ -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: () => request("getStats", "POST", params, { cloudFnType: 'c' })
}; };
export default API; export default API;
...@@ -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>
......
...@@ -6,6 +6,7 @@ import { ...@@ -6,6 +6,7 @@ import {
findWinnerInfoList, findWinnerInfoList,
uploadDataCreateFile, uploadDataCreateFile,
createCopyActivity, createCopyActivity,
getStats
} from "/api"; } from "/api";
import { appId } from "/config"; import { appId } from "/config";
import { setClipboard } from "/utils"; import { setClipboard } from "/utils";
...@@ -202,5 +203,32 @@ Component({ ...@@ -202,5 +203,32 @@ Component({
const { value } = evt.detail; const { value } = evt.detail;
this.getList(value); this.getList(value);
}, },
// 导出数据需求
async onExportStatistics(evt) {
const { activityId, startTime, endTime } = evt.target.dataset.x.record;
my.showLoading({
content: '生成文件中...'
});
try {
let { success, data, message } = (await getStats({ activityId, startDay: startTime, endDay: endTime })) || {};
console.log(success, data, message, '复制链接');
if (success) {
this.showExportDialog({
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');
}
},
}, },
}); });
...@@ -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%>",
......
...@@ -6,7 +6,8 @@ import { requestType, cloudFnName } from '../config'; ...@@ -6,7 +6,8 @@ import { requestType, cloudFnName } 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