Files
MBTI_wang/miniprogram/pages/gaokao/index.js
Ghost a411bf7b21 高考版优化
审核模式优化
2026-04-29 18:01:26 +08:00

147 lines
4.5 KiB
JavaScript

const app = getApp()
Page({
data: {
statusBarHeight: 0,
navbarHeight: 88,
siteTitle: '高考版AI性格测试',
startButtonGaokao: '开始面部测试',
aiAnalysisText: '智能分析',
maintenanceMode: false,
reviewMode: false,
permFace: true,
showVersionPicker: false
},
_navigateByVersion(version) {
try {
getApp().globalData.appScope = version || 'personal'
getApp().globalData.selectedHomeVersion = version || 'personal'
} catch (e) {}
if (version === 'enterprise') {
wx.navigateTo({ url: '/pages/enterprise/index' })
return
}
if (version === 'gaokao') {
wx.navigateTo({ url: '/pages/gaokao/index' })
return
}
wx.switchTab({ url: '/pages/index/index' })
},
openVersionPicker() {
this.setData({ showVersionPicker: true })
},
closeVersionPicker() {
this.setData({ showVersionPicker: false })
},
noop() {},
selectVersion(e) {
const version = String(e.currentTarget.dataset.version || '')
this.setData({ showVersionPicker: false })
if (!version) return
this._navigateByVersion(version)
},
onLoad(options) {
try {
app.globalData.appScope = 'gaokao'
app.globalData.selectedHomeVersion = 'gaokao'
} catch (e) {}
try {
require('../../utils/thirdPartyContext.js').ingestThirdPartyOnPageLoad(options || {}, app)
} catch (e) {}
const systemInfo = wx.getSystemInfoSync()
const statusBarHeight = systemInfo.statusBarHeight || 0
const screenWidth = systemInfo.screenWidth || 375
const statusBarHeightRpx = (statusBarHeight * 750) / screenWidth
const navbarHeightRpx = statusBarHeightRpx + 88
const gd = app.globalData
const maintenanceMode = !!(gd.reviewMode || gd.maintenanceMode)
const ep = gd.enterprisePermissions
const pf = !ep || ep.face !== false
this.setData({
statusBarHeight: statusBarHeightRpx,
navbarHeight: navbarHeightRpx,
siteTitle: gd.siteTitle || '高考版AI性格测试',
startButtonGaokao: (maintenanceMode || !pf) ? '开始性格测试' : ((gd.textConfig && gd.textConfig.startButtonEnterprise) || '开始面部测试'),
aiAnalysisText: (gd.textConfig && gd.textConfig.aiAnalysisText) || '智能分析',
maintenanceMode,
reviewMode: maintenanceMode,
permFace: pf
})
},
onShow() {
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
const tabBar = this.getTabBar()
if (typeof tabBar.updateSelected === 'function') tabBar.updateSelected()
}
try {
getApp().globalData.appScope = 'gaokao'
getApp().globalData.selectedHomeVersion = 'gaokao'
} catch (e) {}
app.ensureLogin()
.then(() => app.getRuntimeConfig())
.then((cfg) => {
if (cfg && cfg.siteTitle) {
app.globalData.siteTitle = cfg.siteTitle
}
const gd = app.globalData
const maintenanceMode = !!(gd.reviewMode || gd.maintenanceMode)
const ep = gd.enterprisePermissions
const pf = !ep || ep.face !== false
this.setData({
siteTitle: gd.siteTitle || '高考版AI性格测试',
startButtonGaokao: (maintenanceMode || !pf) ? '开始性格测试' : ((gd.textConfig && gd.textConfig.startButtonEnterprise) || '开始面部测试'),
aiAnalysisText: (gd.textConfig && gd.textConfig.aiAnalysisText) || '智能分析',
maintenanceMode,
reviewMode: maintenanceMode,
permFace: pf
})
})
.catch(() => {})
},
switchVersion() {
const versions = (getApp().globalData.availableVersions || []).filter((v) => v === 'personal' || v === 'enterprise' || v === 'gaokao')
if (versions.length >= 3) {
this.openVersionPicker()
return
}
this._navigateByVersion('personal')
},
startAITest() {
const ep = getApp().globalData.enterprisePermissions
if (this.data.maintenanceMode || (ep && ep.face === false)) {
wx.navigateTo({ url: '/pages/test-select/index' })
return
}
wx.switchTab({ url: '/pages/index/camera' })
},
openTaskCenter() {
wx.navigateTo({ url: '/pages/gaokao/task-center' })
},
onShareAppMessage() {
const { getSharePath } = require('../../utils/share')
return {
title: '神仙团队AI性格测试 (高考版)',
path: getSharePath('/pages/gaokao/index')
}
},
onShareTimeline() {
const { buildShareQuery } = require('../../utils/share')
return {
title: '神仙团队AI性格测试 (高考版)',
query: buildShareQuery()
}
}
})