wangxy 3 hónapja
szülő
commit
5ea7e52959
2 módosított fájl, 34 hozzáadás és 17 törlés
  1. 14 2
      api/word.js
  2. 20 15
      pages/newEnglish/index.vue

+ 14 - 2
api/word.js

@@ -34,7 +34,7 @@ export function getWordInfo(data = {}) {
     timeout: 20000
   })
 }
-
+
 export function getWordInfoYk(data = {}) {
   return request({
     'url': '/common/word/info',
@@ -94,7 +94,7 @@ export function getWordShouCang(data = {}) {
     timeout: 20000
   })
 }
-
+
 export function wordXuewan(data = {}) {
   return request({
     'url': '/app/word/xuewan',
@@ -106,3 +106,15 @@ export function wordXuewan(data = {}) {
     timeout: 20000
   })
 }
+
+export function getWordCancel(data = {}) {
+  return request({
+    'url': '/app/word/collect',
+    headers: {
+      isToken: true
+    },
+    method: 'post',
+    data,
+    timeout: 20000
+  })
+}

+ 20 - 15
pages/newEnglish/index.vue

@@ -46,6 +46,7 @@
 		useAudioCache,
 		audioPlayer
 	} from "./components/useAudio.js"
+  import {getWordCancel} from "../../api/word";
 
 	const userCode = getUserIdentity();
 
@@ -190,21 +191,25 @@
 	}
 
 	function handleShouCang() {
-		httpApi.getWordShouCang({
-			wordId: data.activeId
-		}).then(res => {
-			if (res.data) {
-				uni.showToast({
-					title: '收藏成功'
-				})
-				data.collectFlag = 1;
-			} else {
-				uni.showToast({
-					title: '收藏取消'
-				})
-				data.collectFlag = 0;
-			}
-		})
+    if (data.collectFlag == 1) {
+      httpApi.getWordCancel({
+        wordId:data.activeId
+      }).then(res => {
+        uni.showToast({
+          title: '收藏取消'
+        })
+        data.collectFlag = 0;
+      })
+    } else {
+      httpApi.getWordShouCang({
+        wordId: data.activeId
+      }).then(res => {
+        uni.showToast({
+          title: '收藏成功'
+        })
+        data.collectFlag = 1;
+      })
+    }
 	}
 
 	function initWordInfo() {