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