12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <template>
- <view>
- <view class="rnwdList">
-
-
- <ul >
- <li >
-
- <h3>{{matterlist.title }}</h3>
- <p>{{ matterlist.content }}</p>
- <button @click="toggleFavorite">{{ isFavorite ? '❤️' : '🤍' }}</button>
- </li>
- </ul>
-
-
- </view>
- </view>
- </template>
- <script>
- import {
- getDept, addsc, delDept, getsc
- } from '@/api/handleAffairs/matter.js';
- export default {
- data() {
- return {
- matterlist:[],
- isFavorite: false,
- };
- },
- created() {
- this.getList();
-
- },
-
-
- methods: {
- getList(){
- const _that = this;
- const id = uni.getStorageSync('id');
- console.log(uni.getStorageSync('id'),"11111111")
- getDept(id).then(res =>{
- _that.matterlist = res.data
- this.checkFavorite();
- })
- },
- toggleFavorite() {
- const userId = getApp().globalData.userId;
- if (this.isFavorite) {
- delDept(this.matterlist.id).then(() => {
- this.isFavorite = false;
- });
- } else {
- const userId = getApp().globalData.userId
- const matterId = this.matterlist.id
- addsc({ matterId:this.matterlist.id , userId }).then(() => {
- this.isFavorite = true;
- });
- }
- },
-
- checkFavorite() {
- const userId = getApp().globalData.userId
- getsc(userId).then(res => {
- this.isFavorite = res.data;
- });
- },
-
- },
- }
- </script>
- <style scoped>
- </style>
|