wangfukang 3 days ago
parent
commit
61036e9b42
  1. 18
      package1/ieBrowser/dailyQuestion.vue
  2. 39
      package1/ieBrowser/index.vue
  3. 27
      package1/ieBrowser/mySpace.vue

18
package1/ieBrowser/dailyQuestion.vue

@ -69,7 +69,8 @@
</template> </template>
<script> <script>
import { getIeDailyQuestion, answerIeDailyQuestion, pageIeDailyAnswers, matchIeByAnswer } from '@/common/ieApi.js' import { getIeProfile, getIeDailyQuestion, answerIeDailyQuestion, pageIeDailyAnswers, matchIeByAnswer } from '@/common/ieApi.js'
import { ensureIeVerifiedBeforeAction } from '@/common/ieRealNameAuth.js'
export default { export default {
data() { data() {
@ -77,6 +78,7 @@
menuButtonInfo: { top: 44 }, menuButtonInfo: { top: 44 },
loading: true, loading: true,
question: { exists: false }, question: { exists: false },
profile: {},
draft: '', draft: '',
submitting: false, submitting: false,
answers: [], answers: [],
@ -97,6 +99,7 @@
if (uni.getMenuButtonBoundingClientRect) { if (uni.getMenuButtonBoundingClientRect) {
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect() this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
} }
this.loadProfile()
this.loadQuestion() this.loadQuestion()
}, },
onReachBottom() { onReachBottom() {
@ -121,9 +124,22 @@
this.loadAnswers() this.loadAnswers()
} }
}, },
async loadProfile() {
const profile = await getIeProfile().catch(() => null)
if (profile) this.profile = profile
},
async submit() { async submit() {
const content = this.draft.trim() const content = this.draft.trim()
if (!content || this.submitting) return if (!content || this.submitting) return
const verified = await ensureIeVerifiedBeforeAction({
profile: this.profile,
actionText: '提交每日同频一题回答',
cancelText: '暂不提交',
reload: async () => {
await this.loadProfile()
}
})
if (!verified) return
this.submitting = true this.submitting = true
try { try {
const res = await answerIeDailyQuestion(content) const res = await answerIeDailyQuestion(content)

39
package1/ieBrowser/index.vue

@ -276,6 +276,7 @@
<script> <script>
import { ieHome, getIeUnreadCount, updateIeStatus, startIeMatch, matchIeProfile, getIeDailyQuestion, saveIeProfile } from '@/common/ieApi.js' import { ieHome, getIeUnreadCount, updateIeStatus, startIeMatch, matchIeProfile, getIeDailyQuestion, saveIeProfile } from '@/common/ieApi.js'
import { ensureIeVerifiedBeforeAction } from '@/common/ieRealNameAuth.js'
import IeBottomTab from '@/components/ie-bottom-tab/ie-bottom-tab.vue' import IeBottomTab from '@/components/ie-bottom-tab/ie-bottom-tab.vue'
export default { export default {
@ -303,6 +304,7 @@
showTargetPanel: false, showTargetPanel: false,
showCompanionEditor: false, showCompanionEditor: false,
matching: false, matching: false,
realNameVerifying: false,
savingCompanionIntent: false, savingCompanionIntent: false,
keyboardHeight: 0, keyboardHeight: 0,
profileReady: false, profileReady: false,
@ -579,7 +581,16 @@
if (res) this.dailyQuestion = res if (res) this.dailyQuestion = res
}).catch(() => {}) }).catch(() => {})
}, },
goDailyQuestion() { async goDailyQuestion() {
const verified = await ensureIeVerifiedBeforeAction({
profile: this.profile,
actionText: '参与每日同频一题',
cancelText: '暂不回答',
reload: async () => {
await this.loadHome()
}
})
if (!verified) return
uni.navigateTo({ url: '/package1/ieBrowser/dailyQuestion' }) uni.navigateTo({ url: '/package1/ieBrowser/dailyQuestion' })
}, },
toggleIntent(key) { toggleIntent(key) {
@ -608,14 +619,10 @@
return return
} }
if (!home) return if (!home) return
if (home.profileCompleted !== 1) {
uni.redirectTo({ url: '/package1/ieBrowser/profileSetup' })
return
}
this.profile = home.profile || {} this.profile = home.profile || {}
this.customCompanionIntent = this.profile.companionIntent || this.customCompanionIntent this.customCompanionIntent = this.profile.companionIntent || this.customCompanionIntent
this.editCompanionIntent = this.customCompanionIntent this.editCompanionIntent = this.customCompanionIntent
this.profileReady = true this.profileReady = !!(this.profile && this.profile.exists && this.profile.profileCompleted === 1)
this.onlineCountBase = Number(home.onlineCount) || 0 this.onlineCountBase = Number(home.onlineCount) || 0
this.awakeCount = this.randomAwakeCount(this.onlineCountBase) this.awakeCount = this.randomAwakeCount(this.onlineCountBase)
this.waitingCount = home.waitingCount || this.waitingCount this.waitingCount = home.waitingCount || this.waitingCount
@ -706,6 +713,8 @@
uni.showToast({ title: '请先选择校区', icon: 'none' }) uni.showToast({ title: '请先选择校区', icon: 'none' })
return return
} }
const verified = await this.ensureRealNameBeforeMatch()
if (!verified) return
this.matching = true this.matching = true
try { try {
const matchAnimation = this.wait(2000) const matchAnimation = this.wait(2000)
@ -801,6 +810,8 @@
}, },
async matchDriftUser(item) { async matchDriftUser(item) {
if (this.matching) return if (this.matching) return
const verified = await this.ensureRealNameBeforeMatch()
if (!verified) return
this.matching = true this.matching = true
try { try {
const match = await matchIeProfile(item.userId) const match = await matchIeProfile(item.userId)
@ -814,6 +825,22 @@
this.matching = false this.matching = false
} }
}, },
async ensureRealNameBeforeMatch() {
if (this.realNameVerifying) return false
this.realNameVerifying = true
try {
return await ensureIeVerifiedBeforeAction({
profile: this.profile,
actionText: '开始匹配',
cancelText: '暂不匹配',
reload: async () => {
await this.loadHome()
}
})
} finally {
this.realNameVerifying = false
}
},
playMoodCopy(text) { playMoodCopy(text) {
if (this.moodTypeTimer) { if (this.moodTypeTimer) {
clearInterval(this.moodTypeTimer) clearInterval(this.moodTypeTimer)

27
package1/ieBrowser/mySpace.vue

@ -71,7 +71,8 @@
</template> </template>
<script> <script>
import { getIeProfile, pageIeMoments, publishIeMoment, deleteIeMoment } from '@/common/ieApi.js' import { ieHome, getIeProfile, pageIeMoments, publishIeMoment, deleteIeMoment } from '@/common/ieApi.js'
import { ensureIeVerifiedBeforeAction } from '@/common/ieRealNameAuth.js'
import tui from '@/common/httpRequest.js' import tui from '@/common/httpRequest.js'
export default { export default {
@ -87,7 +88,8 @@
composeText: '', composeText: '',
composeImages: [], composeImages: [],
composeVideo: null, composeVideo: null,
publishing: false publishing: false,
realNameVerifying: false
} }
}, },
computed: { computed: {
@ -119,7 +121,8 @@
uni.navigateBack({ fail: () => uni.redirectTo({ url: '/package1/ieBrowser/universe' }) }) uni.navigateBack({ fail: () => uni.redirectTo({ url: '/package1/ieBrowser/universe' }) })
}, },
async loadProfile() { async loadProfile() {
const profile = await getIeProfile() const home = await ieHome().catch(() => null)
const profile = home && home.profile ? home.profile : await getIeProfile()
if (profile) this.profile = profile if (profile) this.profile = profile
}, },
async loadMoments(reset, force = false) { async loadMoments(reset, force = false) {
@ -202,8 +205,24 @@
} }
}) })
}, },
openComposer() { async openComposer() {
if (this.realNameVerifying) return
this.realNameVerifying = true
try {
await this.loadProfile()
const verified = await ensureIeVerifiedBeforeAction({
profile: this.profile,
actionText: '发布动态',
cancelText: '暂不发布',
reload: async () => {
await this.loadProfile()
}
})
if (!verified) return
this.showComposer = true this.showComposer = true
} finally {
this.realNameVerifying = false
}
}, },
closeComposer() { closeComposer() {
this.showComposer = false this.showComposer = false

Loading…
Cancel
Save