Compare commits

...

6 Commits

Author SHA1 Message Date
kk 580350cb33 常见问答修改
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 39s
2026-07-11 21:47:29 +08:00
kk 020e131df0 解决user_id为空提示
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 42s
2026-07-11 20:43:56 +08:00
kk 533170f0a9 接口返回数据结构问题处理
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 39s
2026-07-11 20:33:58 +08:00
kk b1924e2623 userId 改为依赖 this.userInfo.user_id
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 47s
2026-07-11 20:29:00 +08:00
kk e12663052f 查询用户信息接口增加open_id参数
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 47s
2026-07-11 20:21:58 +08:00
kk 842defea21 注册成功后保存用户id与手机号
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 44s
2026-07-11 18:30:16 +08:00
4 changed files with 25 additions and 38 deletions
+4 -2
View File
@@ -151,17 +151,19 @@ export default {
},
methods: {
// 外部调用:启动开门流程
async open() {
async open(userId) {
if (this.step) return;
this.cancelled = false;
this.step = 'opening';
const uid = userId || this.userId;
try {
const res = await post('/device-scan/open', {
device_id: this.deviceId,
door_index: 0,
user_id: this.userId
user_id: uid
});
const ret = res.data || {};
+2 -22
View File
@@ -44,17 +44,7 @@ export default {
faqList: [
{
question: '如何购买商品?',
answer: '在首页浏览商品,点击商品卡片选择商品,确认后即可完成购买。支持微信支付和支付宝支付。',
expanded: false
},
{
question: '如何开门取货?',
answer: '下单成功后,点击首页底部中间的"开门"按钮,柜门会自动打开,取出商品后关闭柜门即可。',
expanded: false
},
{
question: '商品质量问题怎么办?',
answer: '如发现商品有质量问题,请在24小时内通过"联系客服"反馈,我们会为您办理退款或换货。',
answer: '使用微信或支付宝扫描柜体上的二维码,进入开门页面,如果是首次使用需先进行授权登录与注册,浏览设备中售卖的商品及价格,点击开门,待门锁打开后,拉开门选购商品,关门即完成购买,约1-2分钟内系统将自动识别并完成扣款。',
expanded: false
},
{
@@ -62,16 +52,6 @@ export default {
answer: '进入"我的"页面,点击"我的订单"可查看所有订单记录,包括待付款、已完成、已退款等状态。',
expanded: false
},
{
question: '忘记密码怎么办?',
answer: '在登录页面点击"忘记密码",输入注册手机号,通过短信验证码即可重置密码。',
expanded: false
},
{
question: '如何修改收货地址?',
answer: '进入"我的"页面,点击"收货地址",可以新增、编辑或删除收货地址信息。',
expanded: false
},
{
question: '支持哪些支付方式?',
answer: '目前支持微信支付、支付宝支付两种方式,后续将开通更多支付渠道。',
@@ -79,7 +59,7 @@ export default {
},
{
question: '退款多久到账?',
answer: '退款申请审核通过后,微信支付1-3个工作日到账,支付宝1-5个工作日到账,具体以银行处理时间为准。',
answer: '审核通过后,一般1-3个工作日到账,具体到账时间以支付渠道为准。',
expanded: false
}
]
+13 -11
View File
@@ -181,7 +181,7 @@ export default {
loading: false,
categoryList: [],
activeCategory: 'all',
userInfo: { nickname: '', phone: '', avatar: '' },
userInfo: { user_id: '', nickname: '', phone: '', avatar: '' },
avatarClickCount: 0,
avatarClickTimer: null,
fromPage: '', // 记录从哪个页面跳转过来的
@@ -199,8 +199,7 @@ export default {
},
computed: {
userId() {
const info = getCachedUserInfo();
return (info && info.user_id) || '';
return this.userInfo.user_id || '';
},
canGoBack() {
// 有上一页,或者从 tab 切换过来的,都可以返回
@@ -304,7 +303,7 @@ export default {
if (cached) {
this.userInfo = { ...this.userInfo, ...cached };
} else {
this.userInfo = { nickname: '', phone: '', avatar: '' };
this.userInfo = { user_id: '', nickname: '', phone: '', avatar: '' };
}
console.log('[index] this.userInfo:', JSON.stringify(this.userInfo, null, 2));
},
@@ -317,6 +316,7 @@ export default {
this.userInfo = { ...this.userInfo, ...cached };
} else {
this.userInfo = {
user_id: config.mockUser.user_info.user_id || '',
nickname: config.mockUser.user_info.nickname || '',
phone: config.mockUser.user_info.phone || '',
avatar: config.mockUser.user_info.avatar || '',
@@ -415,16 +415,18 @@ export default {
// 检查用户信息,若缓存中没有则调接口获取
if (!this.userId) {
try {
const infoRes = await gatewayGet('/api/v1/user/info', {});
const openId = uni.getStorageSync('openid') || '';
const infoRes = await gatewayGet('/api/v1/user/info', { open_id: openId });
const infoData = (infoRes.data || {}).data || {};
if (infoData.user_id) {
const userInfo = infoData.user_info || {};
if (userInfo.user_id) {
const existing = getCachedUserInfo() || {};
uni.setStorageSync('user_info', {
...existing,
user_id: infoData.user_id,
nickname: infoData.nickname || existing.nickname || '',
avatar: infoData.avatar || existing.avatar || '',
phone: infoData.phone || existing.phone || '',
user_id: userInfo.user_id,
nickname: userInfo.nickname || existing.nickname || '',
avatar: userInfo.avatar || existing.avatar || '',
phone: userInfo.phone || existing.phone || '',
});
this.loadUserInfo();
}
@@ -439,7 +441,7 @@ export default {
}
// 调用组件方法启动开门流程
this.$refs.doorPanel.open();
this.$refs.doorPanel.open(this.userId);
},
handleMenuClick(item) {
switch (item.action) {
+6 -3
View File
@@ -183,15 +183,18 @@ export default {
});
const ret = res.data || {};
console.log('[register] 注册响应:', JSON.stringify(ret, null, 2));
if (ret.code === 0 && ret.data) {
// 保存 token
uni.setStorageSync('token', ret.data.token);
// 存储 user_info至少有 user_id 就能开门
// 存储 user_info接口返回 user_info.user_id 和 phone
const existing = uni.getStorageSync('user_info') || {};
const apiUserInfo = ret.data.user_info || {};
const userInfo = {
user_id: ret.data.user_id || existing.user_id || '',
phone: this.phone || existing.phone || '',
user_id: apiUserInfo.user_id || existing.user_id || '',
phone: apiUserInfo.phone || this.phone || existing.phone || '',
nickname: existing.nickname || '',
avatar: existing.avatar || '',
};