|
|
@@ -107,7 +107,9 @@
|
|
|
<FamilyChallengeCard
|
|
|
v-for="ch in activeChallenges"
|
|
|
:key="ch.id"
|
|
|
- :challenge="ch" />
|
|
|
+ :challenge="ch"
|
|
|
+ :showCheckin="showCheckinBtn"
|
|
|
+ @checkin="onChallengeCheckin" />
|
|
|
</view>
|
|
|
<view v-else>
|
|
|
<FamilyEmptyState type="card" />
|
|
|
@@ -376,7 +378,7 @@ import CircleCard from '../../components/CircleCard.vue'
|
|
|
import CircleDetail from '../../components/CircleDetail.vue'
|
|
|
import LoginGuideCard from '../../components/LoginGuideCard.vue'
|
|
|
import FamilyChallengeCard from '../../components/FamilyChallengeCard.vue'
|
|
|
-import { acceptParentInvite, productList, getActivityList, getFeaturedArticles, getFamilyEnergySandbox, getVisibleFamilyMembers, getTodayTasksByCategory, getChildren, getEnergyOverview, getProductsByDomain, getChallengeList, getMyCircles, discoverCircles, joinGeneralCircle, leaveGeneralCircle, switchToFamilyMember, getMyMembership } from '../../utils/api.js'
|
|
|
+import { acceptParentInvite, productList, getActivityList, getFeaturedArticles, getFamilyEnergySandbox, getVisibleFamilyMembers, getTodayTasksByCategory, getChildren, getEnergyOverview, getProductsByDomain, getChallengeList, getMyCircles, discoverCircles, joinGeneralCircle, leaveGeneralCircle, switchToFamilyMember, getMyMembership, updateChallengeProgress } from '../../utils/api.js'
|
|
|
import store from '../../store/index.js'
|
|
|
import config from '@/config.js'
|
|
|
|
|
|
@@ -517,6 +519,9 @@ export default {
|
|
|
if (!this.isMember) return true
|
|
|
return this.membershipDays > 0 && this.membershipDays <= 30
|
|
|
},
|
|
|
+ showCheckinBtn: function() {
|
|
|
+ return (uni.getStorageSync('role') || 'parent') === 'child'
|
|
|
+ },
|
|
|
memberEntryTitle: function() {
|
|
|
if (!this.isMember) return '开通会员,解锁全部特权'
|
|
|
return '会员即将到期,续费恢复权益'
|
|
|
@@ -710,6 +715,17 @@ export default {
|
|
|
self.activeChallenges = []
|
|
|
})
|
|
|
},
|
|
|
+ onChallengeCheckin: function(payload) {
|
|
|
+ var self = this
|
|
|
+ updateChallengeProgress({ challengeId: payload.challengeId, delta: 1 }).then(function(res) {
|
|
|
+ if (res && res.code === 200) {
|
|
|
+ uni.showToast({ title: '打卡成功', icon: 'success' })
|
|
|
+ self.loadChallenges()
|
|
|
+ } else {
|
|
|
+ uni.showToast({ title: (res && res.message) || '打卡失败', icon: 'none' })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
loadMyCircles: function() {
|
|
|
var self = this
|
|
|
if (!this.currentChildId) return
|