ios download
This commit is contained in:
parent
ec2090567b
commit
e42d8945d0
|
@ -49,7 +49,7 @@ export function increaseDownloadData(value, callback) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function recordDownloadDetail({text, value, type, params, history}) {
|
export function recordDownloadDetail({text, value, type, params, history}, callback) {
|
||||||
if (!isLogin) return;
|
if (!isLogin) return;
|
||||||
db.collection('QRDownloadData').add({
|
db.collection('QRDownloadData').add({
|
||||||
date: new Date().toString(),
|
date: new Date().toString(),
|
||||||
|
@ -58,5 +58,7 @@ export function recordDownloadDetail({text, value, type, params, history}) {
|
||||||
type: type,
|
type: type,
|
||||||
params: params,
|
params: params,
|
||||||
history: history
|
history: history
|
||||||
}).catch(console.error)
|
}).then(res => {
|
||||||
|
if (callback) callback(res);
|
||||||
|
}).catch(console.error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,15 +5,8 @@ import {getDownloadCount, increaseDownloadData, recordDownloadDetail} from "../.
|
||||||
import {getParamDetailedValue, outerHtml} from "../../utils/util";
|
import {getParamDetailedValue, outerHtml} from "../../utils/util";
|
||||||
|
|
||||||
function saveDB(state, type, updateDownloadData) {
|
function saveDB(state, type, updateDownloadData) {
|
||||||
|
return new Promise(resolve => {
|
||||||
increaseDownloadData(state.value, () => {
|
increaseDownloadData(state.value, () => {
|
||||||
getDownloadCount((res) => {
|
|
||||||
let downloadData = [];
|
|
||||||
res.data.forEach((item) => {
|
|
||||||
downloadData[item.value] = item.count;
|
|
||||||
});
|
|
||||||
updateDownloadData(downloadData);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
recordDownloadDetail({
|
recordDownloadDetail({
|
||||||
text: state.textUrl,
|
text: state.textUrl,
|
||||||
value: state.value,
|
value: state.value,
|
||||||
|
@ -28,6 +21,17 @@ function saveDB(state, type, updateDownloadData) {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
history: state.history
|
history: state.history
|
||||||
|
}, () => {
|
||||||
|
getDownloadCount((res) => {
|
||||||
|
let downloadData = [];
|
||||||
|
res.data.forEach((item) => {
|
||||||
|
downloadData[item.value] = item.count;
|
||||||
|
});
|
||||||
|
updateDownloadData(downloadData);
|
||||||
|
resolve()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,12 +39,17 @@ const mapStateToProps = (state, ownProps) => ({
|
||||||
value: state.value,
|
value: state.value,
|
||||||
downloadCount: state.downloadData[state.value],
|
downloadCount: state.downloadData[state.value],
|
||||||
onSvgDownload: () => {
|
onSvgDownload: () => {
|
||||||
saveSvg(state.value, outerHtml(state.selectedIndex))
|
saveSvg(state.value, outerHtml(state.selectedIndex));
|
||||||
saveDB(state, 'svg', ownProps.updateDownloadData)
|
saveDB(state, 'svg', ownProps.updateDownloadData);
|
||||||
},
|
},
|
||||||
onJpgDownload: () => {
|
onJpgDownload: () => {
|
||||||
saveDB(state, 'jpg', ownProps.updateDownloadData)
|
return new Promise(resolve => {
|
||||||
return saveImg(state.value, outerHtml(state.selectedIndex), 1500, 1500)
|
saveImg(state.value, outerHtml(state.selectedIndex), 1500, 1500).then((res) => {
|
||||||
|
saveDB(state, 'jpg', ownProps.updateDownloadData).then(() => {
|
||||||
|
resolve(res)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue