Files
yunzerwebsiteallinone/uniapp/api/guest.js
T
2026-11-03 11:13:59 +08:00

33 lines
991 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 游客轻身份接口(后端 controllers/guest.go)
* 失败均由调用方静默处理,不弹全局 toast。
*/
import { request } from '@/api/request.js'
/**
* 游客登录:微信手机号动态凭证换游客令牌
* @param {{ code: string, phoneCode: string, appid?: string }} params code=uni.login 的登录凭证
* @returns {Promise<{ token: string, guest_id: number, phone_mask: string, expires_in: number }>}
*/
export function guestMiniLogin({ code = '', phoneCode = '', appid = '' } = {}) {
return request({
url: '/api/guest/mini-login',
method: 'POST',
data: { code, phone_code: phoneCode, appid },
silent: true
})
}
/**
* 转正合并:正式登录令牌调用,把该手机号下的游客数据并入账号
* @returns {Promise<object>} 各模块合并条数,如 { notebook: 3, schedule: 1, passwordStore: 2 }
*/
export function guestMerge() {
return request({
url: '/api/guest/merge',
method: 'POST',
data: {},
silent: true
})
}