feat: 新增工单中心、房间巡查、失物招领等业务模块
- 新增工单中心(ticket_center)与工单工作台(ticket_workbench)页面 - 新增房间巡查(room_inspection)与失物招领发布(lost_found_publish)页面 - 预约看样流程新增房型/楼栋/楼层选择器组件 - 新增工具模块: booking-entry、privacy、reservation-flow - api/index.js 补充楼层列表、看样提交等接口 - locales/messages.js 补充多语言文案 - manifest.json 开启微信小程序隐私检查 - 完善登录、注册、申请详情、账单等相关页面交互
This commit is contained in:
86
utils/privacy.js
Normal file
86
utils/privacy.js
Normal file
@@ -0,0 +1,86 @@
|
||||
const privacyAuthorizationHandlers = []
|
||||
let hasBoundPrivacyAuthorizationListener = false
|
||||
|
||||
function getActivePrivacyAuthorizationHandler() {
|
||||
return privacyAuthorizationHandlers.length
|
||||
? privacyAuthorizationHandlers[privacyAuthorizationHandlers.length - 1]
|
||||
: null
|
||||
}
|
||||
|
||||
export function bindPrivacyAuthorizationListener(handler) {
|
||||
if (typeof handler !== 'function') {
|
||||
return
|
||||
}
|
||||
|
||||
const existedIndex = privacyAuthorizationHandlers.indexOf(handler)
|
||||
if (existedIndex !== -1) {
|
||||
privacyAuthorizationHandlers.splice(existedIndex, 1)
|
||||
}
|
||||
privacyAuthorizationHandlers.push(handler)
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
if (hasBoundPrivacyAuthorizationListener || typeof wx === 'undefined' || !wx.onNeedPrivacyAuthorization) {
|
||||
return
|
||||
}
|
||||
|
||||
wx.onNeedPrivacyAuthorization((resolve) => {
|
||||
const activeHandler = getActivePrivacyAuthorizationHandler()
|
||||
if (typeof activeHandler === 'function') {
|
||||
activeHandler(resolve)
|
||||
}
|
||||
})
|
||||
hasBoundPrivacyAuthorizationListener = true
|
||||
// #endif
|
||||
}
|
||||
|
||||
export function unbindPrivacyAuthorizationListener(handler) {
|
||||
const existedIndex = privacyAuthorizationHandlers.lastIndexOf(handler)
|
||||
if (existedIndex !== -1) {
|
||||
privacyAuthorizationHandlers.splice(existedIndex, 1)
|
||||
}
|
||||
}
|
||||
|
||||
export function getPrivacyAuthorizationStatus() {
|
||||
// #ifdef MP-WEIXIN
|
||||
return new Promise((resolve) => {
|
||||
if (typeof wx === 'undefined' || !wx.getPrivacySetting) {
|
||||
resolve({ needAuthorization: false })
|
||||
return
|
||||
}
|
||||
|
||||
wx.getPrivacySetting({
|
||||
success: (res) => {
|
||||
resolve({
|
||||
...res,
|
||||
needAuthorization: !!(res && res.needAuthorization)
|
||||
})
|
||||
},
|
||||
fail: () => {
|
||||
resolve({ needAuthorization: false })
|
||||
}
|
||||
})
|
||||
})
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
return Promise.resolve({ needAuthorization: false })
|
||||
// #endif
|
||||
}
|
||||
|
||||
export function openWechatPrivacyContract() {
|
||||
// #ifdef MP-WEIXIN
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof wx === 'undefined' || !wx.openPrivacyContract) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
|
||||
wx.openPrivacyContract({
|
||||
success: resolve,
|
||||
fail: reject
|
||||
})
|
||||
})
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
return Promise.resolve()
|
||||
// #endif
|
||||
}
|
||||
Reference in New Issue
Block a user