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

添加数据需求导出

parent d914429c
......@@ -35,6 +35,8 @@ const API = {
// 搜索条件查询中奖信息
downloadFile: (params) => request("downloadFile", "POST", params),
getAwardsList: (params) => request("getAwardsList", "POST", params),
// 导出数据需求
getStats: () => request("getStats", "POST", params, { cloudFnType: 'c' })
};
export default API;
......@@ -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('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('exportStatistics')}}" class="tb-list-edit" type="primary" text="true" data-x="{{x}}" onTap="onExportStatistics">导出数据需求</button>
</view>
</table-column>
</table>
......
......@@ -6,6 +6,7 @@ import {
findWinnerInfoList,
uploadDataCreateFile,
createCopyActivity,
getStats
} from "/api";
import { appId } from "/config";
import { setClipboard } from "/utils";
......@@ -202,5 +203,32 @@ Component({
const { value } = evt.detail;
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 {
// 默认云函数名称
cloudFnName: 'duibats',
// C端云函数名称(数据需求调用)
cCloudFnName: 'CommonToC',
// 小程序appId
appId: "<%=appId%>",
......
......@@ -6,7 +6,8 @@ import { requestType, cloudFnName } from '../config';
const request = (url, method, params, ext = {}) => {
const {
isShowLoading
isShowLoading,
cloudFnType
} = ext;
const hideMyLoading = () => {
if (isShowLoading) {
......@@ -17,9 +18,12 @@ const request = (url, method, params, ext = {}) => {
my.showLoading();
}
// 云函数名
const cloudFn = cloudFnType === 'c' ? cCloudFnName : cloudFnName
const requestAms = () => {
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,
data: params,
dataType: 'json'
......@@ -32,7 +36,7 @@ const request = (url, method, params, ext = {}) => {
}
const requestCloud = () => {
return cloud.function.invoke(cloudFnName, params, url).then(res => {
return cloud.function.invoke(cloudFn, params, url).then(res => {
hideMyLoading();
return res;
}).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