Browse Source

feat: 分享新增toast提示

lvkun996 2 years ago
parent
commit
2b44432cbd
4 changed files with 24 additions and 21 deletions
  1. BIN
      dist.zip
  2. 1 0
      src/pages/LearnPlan/main.ts
  3. 19 19
      src/pages/LearnPlan/views/LearnReport/index.vue
  4. 4 2
      src/utils/vant.ts

BIN
dist.zip


+ 1 - 0
src/pages/LearnPlan/main.ts

@@ -6,6 +6,7 @@ import 'normalize.css'
 import * as Pinia from 'pinia'
 import VConsole from 'vconsole'
 import '@/utils/vant'
+
 // import store from './store'
 
 // new VConsole()

+ 19 - 19
src/pages/LearnPlan/views/LearnReport/index.vue

@@ -179,19 +179,16 @@
 
 <script setup lang="ts">
 
-import { ref, nextTick, onMounted, reactive } from 'vue'
-import { useAudioManager } from '@/hook/index'
+import { ref, nextTick, onMounted, reactive, getCurrentInstance } from 'vue'
+import { useAudioManager, useSchedulerOnce } from '@/hook/index'
 import AbleChart from '../../components/AbleChart.vue'
 import { screenShot, createQrcode } from '@/utils/utils'
 import { getReportByUser, shareUserReport } from "@/api/learnPlan"
 import { useRoute } from 'vue-router'
 import { useAppRouter, useAppFunc } from '@/hook/appHook'
-import { Overlay, ActionSheet } from 'vant'
+import { Overlay, ActionSheet, showToast } from 'vant'
 import OpenApp from '@/components/OpenApp/index.vue'
 import { registerWxopenButton } from '@/utils/utils'
-
-
-
 export interface QueryParams {
   i: string,
   u?: string,
@@ -218,12 +215,6 @@ const [fco, atx] = useAudioManager({
 
 const queryParams = useRoute().query as unknown as QueryParams
 
-console.log('timeStamp');
-
-
-console.log('queryParams:', queryParams);
-
-
 // queryParams.i = "1630466274125459458"
 // queryParams.u = "1430026961974345730"
 
@@ -296,12 +287,19 @@ const openModal = () => {
   createPoster()
 }
 
-const savePoster = () => {
-  appFunc.savePoster(posterblob.value)
+const savePoster = async () => {
+  await _shareUserReport()
+  useSchedulerOnce({
+    cb: () => appFunc.savePoster(posterblob.value),
+    delay: 500
+  }) 
 }
 
 const _shareUserReport = async () => {
-  await shareUserReport({ "itemId": queryParams.i, "userId": queryParams.u! })
+  const { data  } = await shareUserReport({ "itemId": queryParams.i, "userId": queryParams.u! })
+  if (data.state !== 0) {
+    showToast(`分享成功, 获得${data.winWisdomCoin}个智慧币`)
+  }
 }
 
 const updatePercentage = (e) => {
@@ -313,9 +311,12 @@ const updatePercentage = (e) => {
 }
 
 // 分享海报到微信
-const shareWx = () => {
-  appFunc.shareWx(posterblob.value)
-  _shareUserReport()
+const shareWx = async () => {
+  await _shareUserReport()
+  useSchedulerOnce({
+    cb: () =>   appFunc.shareWx(posterblob.value),
+    delay: 500
+  })
 }
 
 // 获取用户报告信息
@@ -352,7 +353,6 @@ const getQrcodeUrl = async () => {
 
 onMounted(async () => {
 
-
   if (queryParams.u) {
    _getReportByUser()
   } else {

+ 4 - 2
src/utils/vant.ts

@@ -1,7 +1,9 @@
-import { createApp } from 'vue'
+import { createApp, getCurrentInstance } from 'vue'
 
 import {
-  Button
+  Button,
+  Toast
 } from 'vant'
 
 import 'vant/lib/index.css'
+