注: 尚硅谷基于网易云音乐API的硅谷云音乐微信小程序
-
网易云音乐API: github.com/Binaryify/N…
-
官方文档地址: binaryify.github.io/NeteaseClou…
-
问题描述:
-
排行榜接口正常, 但调试器的AppData topList(请求回存放排行榜数据的数组)死活没数据:
-
手机号无法登录, 据官方文档需要二维码验证, 如何解决?
- 注: 查看下方后端验证部分
// 登录的回调 async login() { // 1. 搜集表单项数据 let {phone, password} = this.data; // 2. 前端验证 if (!phone) { // 提示用户 wx.showToast({ title: '手机号不能为空', icon: 'none' }) return; } // 定义正则表达式 let phoneReg = /^1(3|4|5|6|7|8|9)\d{9}$/; if (!phoneReg.test(phone)) { wx.showToast({ title: '手机号格式错误', icon: 'none' }) return; } if (!password) { wx.showToast({ title: '密码不能为空', icon: 'none' }) return; } // 后端验证 let result = await request('/login/cellphone', {phone, password}) if (result.code === 200) { // 登陆成功 wx.showToast({ title: '登录成功', }) // 将用户信息存储到本地 wx.setStorageSync('userInfo', JSON.stringify(result.profile)) // 跳转至个人中心personal页面, !!!未验证 wx.switchTab({ url: '/pages/personal/personal' }) } else if (result.code === 400) { wx.showToast({ title: '手机号错误', icon: 'none' }) } else if (result.code === 502) { wx.showToast({ title: '密码错误', icon: 'none' }) } else { wx.showToast({ title: '登录失败, 请重新登录', icon: 'none' }) } },
-
-
附: 上方的请求头