|
|
|
@ -1165,6 +1165,49 @@ module.exports = { |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 记录用户操作历史
|
|
|
|
addUserHistory: function (operation) { |
|
|
|
console.log('API.addUserHistory - 操作类型:', operation); |
|
|
|
|
|
|
|
// 获取用户手机号
|
|
|
|
let userPhone = ''; |
|
|
|
try { |
|
|
|
const userInfo = wx.getStorageSync('userInfo'); |
|
|
|
if (userInfo && userInfo.phoneNumber) { |
|
|
|
userPhone = userInfo.phoneNumber; |
|
|
|
} else { |
|
|
|
const users = wx.getStorageSync('users') || {}; |
|
|
|
const userId = wx.getStorageSync('userId'); |
|
|
|
if (userId && users[userId] && users[userId].phoneNumber) { |
|
|
|
userPhone = users[userId].phoneNumber; |
|
|
|
} else { |
|
|
|
userPhone = wx.getStorageSync('phoneNumber'); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
console.error('获取用户手机号失败:', e); |
|
|
|
} |
|
|
|
|
|
|
|
if (!userPhone) { |
|
|
|
console.warn('用户未登录,无法记录操作历史'); |
|
|
|
return Promise.resolve({ success: false, message: '用户未登录' }); |
|
|
|
} |
|
|
|
|
|
|
|
const requestData = { |
|
|
|
phone: userPhone, |
|
|
|
operation: operation |
|
|
|
}; |
|
|
|
|
|
|
|
return request('/api/user-history/add', 'POST', requestData).then(res => { |
|
|
|
console.log('操作历史记录成功:', res); |
|
|
|
return res; |
|
|
|
}).catch(err => { |
|
|
|
console.error('操作历史记录失败:', err); |
|
|
|
// 即使记录失败,也不影响主流程
|
|
|
|
return { success: false, message: '操作历史记录失败' }; |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 计算物流运费
|
|
|
|
calculateFreight: function (params) { |
|
|
|
console.log('API.calculateFreight - 开始计算运费'); |
|
|
|
|