optimize: make page share reward
This commit is contained in:
@@ -113,6 +113,7 @@ import { ref, onMounted } from "vue";
|
||||
import { getBavBarHeight } from "@/utils/system";
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import { getPageDetail } from "@/api/system.js";
|
||||
import { saveViewRequest } from "@/utils/common.js";
|
||||
|
||||
const navBarHeight = ref(44);
|
||||
const statusBarHeight = ref(20);
|
||||
@@ -125,6 +126,7 @@ onLoad(async (options) => {
|
||||
const card = await getPageDetail(options.shareToken);
|
||||
cardId.value = card.id;
|
||||
cardDetail.value = card;
|
||||
saveViewRequest(options.shareToken, "card_generate", card.id);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
<uni-icons type="cloud-download" size="20" color="#888"></uni-icons>
|
||||
<view>保存</view>
|
||||
</button>
|
||||
<button open-type="share" class="btn primary" @tap="shareOrSave">
|
||||
<button open-type="share" class="btn primary">
|
||||
<uni-icons
|
||||
type="paperplane-filled"
|
||||
size="20"
|
||||
@@ -590,12 +590,16 @@ const preview = async () => {
|
||||
return;
|
||||
}
|
||||
const tempPath = await saveByCanvas(true);
|
||||
saveRecordRequest(tempPath, cardId.value || "", "card_generate");
|
||||
id = createCard();
|
||||
shareOrSave(id);
|
||||
saveRecordRequest(tempPath, id, "card_generate");
|
||||
|
||||
// uni.showToast({ title: '已保存到相册', icon: 'checkmarkempty' })
|
||||
};
|
||||
|
||||
const shareOrSave = async (id) => {
|
||||
if (!id) id = createCard();
|
||||
|
||||
const tempPath = await saveByCanvas(false);
|
||||
const imageUrl = await uploadImage(tempPath);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { getDeviceInfo } from "@/utils/system";
|
||||
import { saveRecord } from "@/api/system";
|
||||
import { saveRecord, viewRecord } from "@/api/system";
|
||||
|
||||
export const generateObjectId = (
|
||||
m = Math,
|
||||
@@ -47,3 +47,13 @@ export const saveRecordRequest = async (path, targetId, scene) => {
|
||||
deviceInfo,
|
||||
});
|
||||
};
|
||||
|
||||
export const saveViewRequest = async (shareToken, scene, targetId) => {
|
||||
const deviceInfo = getDeviceInfo();
|
||||
viewRecord({
|
||||
shareToken,
|
||||
scene,
|
||||
targetId,
|
||||
deviceInfo,
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user