123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <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');
- 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>
|