|
@@ -1,28 +1,46 @@
|
|
|
-import { defineComponent, ref } from 'vue';
|
|
|
+import { defineComponent, onMounted, ref } from 'vue';
|
|
|
import SharePopup from '../share-popup/index.vue';
|
|
|
+import { homeApi } from '@/api';
|
|
|
import './index.hq.scss';
|
|
|
|
|
|
-const visitCount = localStorage.getItem('visitCount');
|
|
|
-
|
|
|
export default defineComponent({
|
|
|
name: 'HomeMenu',
|
|
|
setup() {
|
|
|
const shareVisible = ref(false);
|
|
|
const animationThumb = ref(false);
|
|
|
+ const visitCount = ref(0);
|
|
|
+ const likeCount = ref(0);
|
|
|
+
|
|
|
+ const getSceneDetail = async () => {
|
|
|
+ const { data } = await homeApi.getSceneDetail(window.number);
|
|
|
+ if (!data) return;
|
|
|
+ visitCount.value = data.visitSum;
|
|
|
+ likeCount.value = data.starSum;
|
|
|
+ };
|
|
|
|
|
|
const handleThumb = () => {
|
|
|
if (animationThumb.value) return;
|
|
|
|
|
|
animationThumb.value = true;
|
|
|
+ likeCount.value++;
|
|
|
+ homeApi.saveStar(window.number);
|
|
|
|
|
|
setTimeout(() => {
|
|
|
animationThumb.value = false;
|
|
|
}, 200);
|
|
|
};
|
|
|
|
|
|
+ onMounted(() => {
|
|
|
+ getSceneDetail();
|
|
|
+
|
|
|
+ homeApi.saveSceneVisit(window.number);
|
|
|
+ });
|
|
|
+
|
|
|
return {
|
|
|
shareVisible,
|
|
|
animationThumb,
|
|
|
+ visitCount,
|
|
|
+ likeCount,
|
|
|
handleThumb,
|
|
|
};
|
|
|
},
|
|
@@ -96,7 +114,7 @@ export default defineComponent({
|
|
|
<div class="pinBottom right">
|
|
|
<div id="thumb" class={{ active: this.animationThumb }} onClick={this.handleThumb}>
|
|
|
<div class="icon icon-slot" />
|
|
|
- <span>点赞</span>
|
|
|
+ <span>{this.likeCount > 0 ? `${this.likeCount} ` : ''}点赞</span>
|
|
|
</div>
|
|
|
<div id="sharing" onClick={() => (this.shareVisible = true)}>
|
|
|
<img class="icon icon-inside" src="images/hq/share.png" title="分享" />
|
|
@@ -121,7 +139,7 @@ export default defineComponent({
|
|
|
</div>
|
|
|
<div id="viewer" class="ui-icon wide">
|
|
|
<img class="icon icon-inside" src="images/hq/viewer.png" title="浏览量" />
|
|
|
- <p>{visitCount}</p>
|
|
|
+ <p>{this.visitCount}</p>
|
|
|
</div>
|
|
|
<div
|
|
|
id="gui-fullscreen"
|