自动发布开发环境 Nacos 配置 / publish (push) Successful in 25s
- 手机号/账号全场景一律脱敏:SensitiveFieldPolicy 删除完整值分支与 ADMIN_EDIT,SELF_PROFILE 同样脱敏;convertToVO 全调用点统一脱敏 - 联系信息接口不再返回号码:toContact 置空 phone 并给出 phoneAvailable,补齐 ensureUserCanSeeShop 真实可见范围校验 - 新增 POST /contact-info/dial,按 scene(SHOP_MANAGER/ORDER_ARTIST/PRODUCT_ARTIST/PLATFORM) 一次一取;DialTargetProvider 抽象直连/隐私号,未配置隐私号返回 9001 且不回退真实号;/contact-info/** 按用户限流并记录审计 - 验证码与换绑手机号改为服务端按当前登录用户取号,客户端 phone/oldPhone 参数兼容忽略;前端与小程序同步去掉回传 - 消息发布人昵称兜底改为脱敏账号,避免 account 明文写入 publisher_name - 新增 V5 账号加密与账号哈希、V6 协议文本改为全场景脱敏与单次拨号取号
351 lines
12 KiB
JavaScript
351 lines
12 KiB
JavaScript
/**
|
|
* Mini program API wrapper for this module.
|
|
* Call guide: require this module in a page, then invoke the matching method from page event handlers or lifecycle hooks.
|
|
*/
|
|
const request = require('../utils/request')
|
|
/**
|
|
* Purpose: actionGuard supports user.js by holding or executing the action guard page or API role.
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
const actionGuard = require('../utils/action-guard')
|
|
const { API_BASE_URL, REQUEST_TIMEOUT } = require('../utils/config')
|
|
|
|
/**
|
|
* Purpose: normalizeUploadResponse supports user.js by holding or executing the normalize upload response page or API role.
|
|
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
function normalizeUploadResponse(response) {
|
|
if (!response) {
|
|
throw new Error('头像上传失败')
|
|
}
|
|
|
|
if (response.statusCode === 401) {
|
|
throw new Error('登录已过期,请重新登录')
|
|
}
|
|
|
|
if (response.statusCode >= 400) {
|
|
throw new Error('头像上传失败')
|
|
}
|
|
|
|
let payload = response.data
|
|
if (typeof payload === 'string') {
|
|
try {
|
|
payload = JSON.parse(payload)
|
|
} catch (error) {}
|
|
}
|
|
|
|
if (payload && typeof payload === 'object' && Object.prototype.hasOwnProperty.call(payload, 'code')) {
|
|
if (payload.code === 200) {
|
|
return payload.data
|
|
}
|
|
throw new Error(payload.message || '头像上传失败')
|
|
}
|
|
|
|
return payload
|
|
}
|
|
|
|
module.exports = {
|
|
/**
|
|
* Purpose: getUserInfo supports user.js by holding or executing the get user info page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
getUserInfo() {
|
|
return request({
|
|
url: '/user/info'
|
|
})
|
|
},
|
|
|
|
// 我的页常用数据:
|
|
// 资产、余额流水、消息、公告、VIP 充值档位和所属关系都从这里拿。
|
|
getMyAsset() {
|
|
return request({
|
|
url: '/user/asset/me'
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: getMyBalanceHistory supports user.js by holding or executing the get my balance history page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
getMyBalanceHistory() {
|
|
return request({
|
|
url: '/user/balance/history/me'
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: listMyMessages supports user.js by holding or executing the list my messages page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
listMyMessages() {
|
|
return request({
|
|
url: '/system-message/my/list'
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: listMyPopupMessages supports user.js by holding or executing the list my popup messages page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
listMyPopupMessages() {
|
|
return request({
|
|
url: '/system-message/my/popup'
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: getMyUnreadMessageCount supports user.js by holding or executing the get my unread message count page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
getMyUnreadMessageCount() {
|
|
return request({
|
|
url: '/system-message/my/unread-count'
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: markMessagePopupShown supports user.js by holding or executing the mark message popup shown page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
markMessagePopupShown(id) {
|
|
return request({
|
|
url: `/system-message/my/${id}/popup-shown`,
|
|
method: 'PUT',
|
|
data: {}
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: markMessageRead supports user.js by holding or executing the mark message read page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
markMessageRead(id) {
|
|
return request({
|
|
url: `/system-message/my/${id}/read`,
|
|
method: 'PUT',
|
|
data: {}
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: listMyAnnouncements supports user.js by holding or executing the list my announcements page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
listMyAnnouncements() {
|
|
return request({
|
|
url: '/announcement/my/list'
|
|
})
|
|
},
|
|
|
|
// 这里只是“展示型充值档位”,不发起支付、不改余额。
|
|
listMyVipRechargePlans() {
|
|
return request({
|
|
url: '/vip-recharge-plan/my/list'
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 单次拨号取号:号码不缓存,仅用于本次拨号。
|
|
* scene: SHOP_MANAGER / ORDER_ARTIST / PRODUCT_ARTIST / PLATFORM
|
|
*/
|
|
dialContact(scene, targetId, artistId) {
|
|
return request({
|
|
url: '/contact-info/dial',
|
|
method: 'POST',
|
|
data: { scene, targetId, artistId }
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: getShopManagerContact supports user.js by holding or executing the get shop manager contact page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
getShopManagerContact(shopId) {
|
|
return request({
|
|
url: `/contact-info/shop/${shopId}/manager`
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: getProductArtistContact supports user.js by holding or executing the get product artist contact page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
getProductArtistContact(productId, artistId) {
|
|
return request({
|
|
url: `/contact-info/product/${productId}/artist/${artistId}`
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: getOrderArtistContact supports user.js by holding or executing the get order artist contact page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
getOrderArtistContact(orderId, artistId) {
|
|
return request({
|
|
url: `/contact-info/order/${orderId}/artist`,
|
|
params: artistId ? { artistId } : {}
|
|
})
|
|
},
|
|
|
|
getPlatformContact() {
|
|
return request({
|
|
url: '/contact-info/platform'
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: updateUserInfo supports user.js by holding or executing the update user info page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
updateUserInfo(data) {
|
|
return request({
|
|
url: '/user/update',
|
|
method: 'PUT',
|
|
data
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: updatePassword supports user.js by holding or executing the update password page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
updatePassword(data) {
|
|
return request({
|
|
url: '/user/password',
|
|
method: 'PUT',
|
|
data
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: bindPhone supports user.js by holding or executing the bind phone page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
bindPhone(data) {
|
|
return request({
|
|
url: '/user/bind-phone',
|
|
method: 'POST',
|
|
data
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: updatePhone supports user.js by holding or executing the update phone page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
updatePhone(data) {
|
|
return request({
|
|
url: '/user/phone',
|
|
method: 'PUT',
|
|
data
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: deactivateAccount supports user.js by holding or executing the deactivate account page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
deactivateAccount() {
|
|
return request({
|
|
url: '/user/deactivate',
|
|
method: 'DELETE'
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: uploadAvatar supports user.js by holding or executing the upload avatar page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
uploadAvatar(filePath) {
|
|
const signedHeaders = request.buildSignatureHeaders({
|
|
url: '/user/upload-avatar',
|
|
method: 'POST',
|
|
formData: {}
|
|
})
|
|
|
|
return actionGuard.run(null, `POST:/user/upload-avatar:${filePath || ''}`, () => new Promise((resolve, reject) => {
|
|
wx.uploadFile({
|
|
url: `${API_BASE_URL}/user/upload-avatar`,
|
|
filePath,
|
|
name: 'file',
|
|
timeout: REQUEST_TIMEOUT,
|
|
header: signedHeaders,
|
|
success: response => {
|
|
try {
|
|
resolve(normalizeUploadResponse(response))
|
|
} catch (error) {
|
|
reject(error)
|
|
}
|
|
},
|
|
fail: error => {
|
|
reject(new Error(error.errMsg || '头像上传失败'))
|
|
}
|
|
})
|
|
}), {
|
|
message: '上传处理中,请勿重复操作'
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: checkAccountAvailability supports user.js by holding or executing the check account availability page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
checkAccountAvailability(account) {
|
|
return request({
|
|
url: `/user/check/account/${encodeURIComponent(account)}`
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: checkLoginAccountAvailability supports user.js by holding or executing the check login account availability page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
checkLoginAccountAvailability(account) {
|
|
return request({
|
|
url: `/user/check/login-account/${encodeURIComponent(account)}`
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: getLoginShopsByAccount supports user.js by holding or executing the get login shops by account page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
getLoginShopsByAccount(account) {
|
|
return request({
|
|
url: `/user/check/login-shops/account/${encodeURIComponent(account)}`
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: getLoginShopsByPhone supports user.js by holding or executing the get login shops by phone page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
getLoginShopsByPhone(phone) {
|
|
return request({
|
|
url: `/user/check/login-shops/phone/${encodeURIComponent(phone)}`
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: checkPhoneAvailability supports user.js by holding or executing the check phone availability page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
checkPhoneAvailability(phone) {
|
|
return request({
|
|
url: `/user/check/phone/${encodeURIComponent(phone)}`
|
|
})
|
|
},
|
|
|
|
/**
|
|
* Purpose: sendVerificationCode supports user.js by holding or executing the send verification code page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
sendVerificationCode(data) {
|
|
return request({
|
|
url: '/user/send-verification-code',
|
|
method: 'POST',
|
|
data
|
|
})
|
|
}
|
|
}
|