diff --git a/pages/buyer/goods-detail.js b/pages/buyer/goods-detail.js new file mode 100644 index 0000000..e69de29 diff --git a/pages/buyer/goods-detail.json b/pages/buyer/goods-detail.json new file mode 100644 index 0000000..e69de29 diff --git a/pages/buyer/goods-detail.wxml b/pages/buyer/goods-detail.wxml new file mode 100644 index 0000000..e69de29 diff --git a/pages/buyer/goods-detail.wxss b/pages/buyer/goods-detail.wxss new file mode 100644 index 0000000..e69de29 diff --git a/pages/buyer/index.js b/pages/buyer/index.js index 37d4270..044b6af 100644 --- a/pages/buyer/index.js +++ b/pages/buyer/index.js @@ -132,6 +132,10 @@ Page({ return; } + // 点击"我想要"后,将用户类型设置为buyer + const API = require('../../utils/api.js'); + API.updateUserType('buyer'); + // 1. 前置验证 if (!goodsId) { console.error('商品ID为空,无法预约'); diff --git a/pages/buyer/index.wxml b/pages/buyer/index.wxml index d9d22aa..74c404d 100644 --- a/pages/buyer/index.wxml +++ b/pages/buyer/index.wxml @@ -137,33 +137,25 @@ - - - - 提示 - - - 请先登录后再预约商品 - - - - + + + 提示 + 请先登录后再操作 + + + - - - - 授权登录 - - - 请授权获取您的手机号用于登录 - - - - + + + 授权登录 + 请授权获取您的手机号用于登录 + + + diff --git a/pages/buyer/index.wxss b/pages/buyer/index.wxss index f2a7f32..a4bd8c9 100644 --- a/pages/buyer/index.wxss +++ b/pages/buyer/index.wxss @@ -475,4 +475,67 @@ button:after { height: 32vh; width: 100%; box-sizing: border-box; +} + +/* 统一登录授权弹窗样式 */ +.auth-modal-overlay { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: rgba(0, 0, 0, 0.5); + display: flex; + justify-content: center; + align-items: center; + z-index: 1002; +} + +.auth-modal-container { + background-color: #fff; + border-radius: 20rpx; + width: 80%; + max-width: 500rpx; + padding: 40rpx; + box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.15); +} + +.auth-modal-title { + font-size: 36rpx; + font-weight: bold; + color: #333; + text-align: center; + margin-bottom: 30rpx; +} + +.auth-modal-content { + font-size: 32rpx; + line-height: 1.5; + color: #666; + text-align: center; + margin-bottom: 40rpx; +} + +.auth-modal-buttons { + display: flex; + flex-direction: column; + gap: 20rpx; +} + +.auth-primary-button { + background-color: #1677ff; + color: #fff; + font-size: 32rpx; + line-height: 1.5; + border-radius: 8rpx; + padding: 20rpx 0; +} + +.auth-cancel-button { + background-color: #f5f5f5; + color: #666; + font-size: 32rpx; + line-height: 1.5; + border-radius: 8rpx; + padding: 20rpx 0; } \ No newline at end of file diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 7466c01..a07ec97 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -19,37 +19,25 @@ - - - - 提示 - - - 您还没有授权登录 - - - - + + + 提示 + 请先登录后再操作 + + + - - - - 授权登录 - - - 请授权获取您的手机号用于登录 - - - - + + + 授权登录 + 请授权获取您的手机号用于登录 + + + diff --git a/pages/index/index.wxss b/pages/index/index.wxss index e792b37..8568058 100644 --- a/pages/index/index.wxss +++ b/pages/index/index.wxss @@ -109,7 +109,7 @@ page { } /* 弹窗样式 */ -.modal-overlay { +.auth-modal-overlay { position: fixed; top: 0; left: 0; @@ -119,38 +119,56 @@ page { display: flex; justify-content: center; align-items: center; - z-index: 999; + z-index: 1002; } -.modal-container { - background-color: white; - border-radius: 16rpx; +.auth-modal-container { + background-color: #fff; + border-radius: 20rpx; width: 80%; + max-width: 500rpx; padding: 40rpx; + box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.15); } -.modal-title { - text-align: center; - margin-bottom: 30rpx; -} - -.modal-title text { +.auth-modal-title { font-size: 36rpx; font-weight: bold; + color: #333; + text-align: center; + margin-bottom: 30rpx; } -.modal-content { +.auth-modal-content { + font-size: 32rpx; + line-height: 1.5; + color: #666; text-align: center; margin-bottom: 40rpx; - color: #666; } -.modal-content text { +.auth-modal-buttons { + display: flex; + flex-direction: column; + gap: 20rpx; +} + +.auth-primary-button { + background-color: #1677ff; + color: #fff; font-size: 32rpx; + line-height: 1.5; + border-radius: 8rpx; + padding: 20rpx 0; } -.modal-buttons { - text-align: center; +.auth-cancel-button { + background-color: #f5f5f5; + color: #666; + font-size: 32rpx; + line-height: 1.5; + border-radius: 8rpx; + padding: 20rpx 0; } .primary-button { diff --git a/pages/seller/index.js b/pages/seller/index.js index 32272fb..f581ad8 100644 --- a/pages/seller/index.js +++ b/pages/seller/index.js @@ -1165,6 +1165,10 @@ Page({ try { const res = await API.uploadUserInfo(uploadData) console.log('用户信息上传成功:', res) + + // 入驻成功后,将用户类型设置为seller + API.updateUserType('seller'); + return res } catch (err) { console.error('用户信息上传失败:', err) @@ -1207,10 +1211,12 @@ Page({ wx.switchTab({ url: '/pages/buyer/index' }) } else { // 卖家登录成功后,重新显示创建货源弹窗 + // 从本地存储加载保存的表单数据 + const savedSupply = wx.getStorageSync('newSupplyDraft') || { name: '', price: '', minOrder: '', yolk: '', spec: '', imageUrls: [] }; this.setData({ showImagePreview: false, showModal: true, - newSupply: { name: '', price: '', minOrder: '', yolk: '', spec: '', imageUrls: [] } + newSupply: savedSupply }); this.disablePageScroll(); } @@ -1397,6 +1403,8 @@ Page({ if (!userId || !openid || !userInfo) { console.log('用户未登录,显示登录提示'); + // 登录前保存当前表单数据到本地存储 + wx.setStorageSync('newSupplyDraft', this.data.newSupply); // 用户未登录,显示未授权提示弹窗 wx.showModal({ title: '登录提示', @@ -2895,6 +2903,29 @@ Page({ }); }, + // 双击检测变量 + lastTapTime: {}, + tapCount: {}, + + // 通用双击检测函数 + handleDoubleTap: function(e, type, callback) { + const currentTime = Date.now(); + const tapKey = `${type}-${e.currentTarget.dataset.index}`; + const lastTap = this.lastTapTime[tapKey] || 0; + const tapInterval = currentTime - lastTap; + + if (tapInterval < 300 && tapInterval > 0) { + // 双击事件触发,执行确认选择 + callback(); + } else { + // 单击事件触发,执行选择操作 + this.lastTapTime[tapKey] = currentTime; + setTimeout(() => { + delete this.lastTapTime[tapKey]; + }, 300); + } + }, + // 弹窗中选择规格 onModalSpecSelect: function (e) { const index = e.currentTarget.dataset.index; @@ -2903,6 +2934,11 @@ Page({ selectedModalSpecIndex: index, modalSpecSearchKeyword: selectedSpec // 自动填充搜索框为当前选择的规格 }); + + // 检测双击 + this.handleDoubleTap(e, 'spec', () => { + this.confirmSpecSelection(); + }); }, // 确认规格选择 @@ -3393,6 +3429,11 @@ Page({ this.setData({ selectedNameIndex: index }); + + // 检测双击 + this.handleDoubleTap(e, 'name', () => { + this.confirmNameSelection(); + }); }, confirmNameSelection() { @@ -3469,6 +3510,11 @@ Page({ this.setData({ selectedYolkIndex: index }); + + // 检测双击 + this.handleDoubleTap(e, 'yolk', () => { + this.confirmYolkSelection(); + }); }, confirmYolkSelection() { diff --git a/pages/seller/index.wxml b/pages/seller/index.wxml index d7fa512..d81f1dc 100644 --- a/pages/seller/index.wxml +++ b/pages/seller/index.wxml @@ -803,16 +803,10 @@ - - 提示 - - - 您还没有授权登录 - + 提示 + 请先登录后再操作 - + diff --git a/pages/seller/index.wxss b/pages/seller/index.wxss index ddf5b6f..5daf727 100644 --- a/pages/seller/index.wxss +++ b/pages/seller/index.wxss @@ -529,38 +529,35 @@ button { left: 0; right: 0; bottom: 0; - background-color: rgba(0, 0, 0, 0.5); + background: rgba(0, 0, 0, 0.5); display: flex; justify-content: center; align-items: center; - z-index: 999; + z-index: 9999; } .auth-modal-container { - background-color: white; + background: white; + padding: 40rpx; border-radius: 16rpx; width: 80%; - padding: 40rpx; -} - -.auth-modal-title { + max-width: 500rpx; text-align: center; - margin-bottom: 30rpx; + box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.1); } -.auth-modal-title text { - font-size: 36rpx; +.auth-modal-title { + font-size: 32rpx; font-weight: bold; + margin-bottom: 30rpx; + color: #333; } .auth-modal-content { - text-align: center; - margin-bottom: 40rpx; + font-size: 28rpx; color: #666; -} - -.auth-modal-content text { - font-size: 32rpx; + margin-bottom: 40rpx; + line-height: 1.5; } .auth-modal-buttons { @@ -570,22 +567,18 @@ button { .auth-primary-button { background-color: #1677ff; color: white; - width: 100%; + font-size: 28rpx; + line-height: 80rpx; border-radius: 8rpx; margin-bottom: 20rpx; - border: none; - font-size: 32rpx; - font-weight: 600; - text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.2); } .auth-cancel-button { - background: none; - color: #666; - border: none; - font-size: 32rpx; - font-weight: 600; - text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.1); + background-color: #f5f5f5; + color: #333; + font-size: 28rpx; + line-height: 80rpx; + border-radius: 8rpx; } /* 头像选择样式 */ diff --git a/pages/settlement/index.js b/pages/settlement/index.js index 9bc1034..9d339db 100644 --- a/pages/settlement/index.js +++ b/pages/settlement/index.js @@ -37,6 +37,7 @@ Page({ // 登录弹窗相关 showAuthModal: false, + showOneKeyLoginModal: false, loginModalTitle: '请先登录', loginModalContent: '为了您的账户安全,请先完成手机号登录', showLoginButton: true @@ -825,6 +826,19 @@ Page({ }); }, + // 显示一键登录弹窗 + showOneKeyLogin() { + this.setData({ + showAuthModal: false, + showOneKeyLoginModal: true + }) + }, + + // 关闭一键登录弹窗 + closeOneKeyLoginModal() { + this.setData({ showOneKeyLoginModal: false }) + }, + // 处理手机号授权 async onGetPhoneNumber(e) { console.log('用户点击了手机号授权按钮', e.detail); diff --git a/pages/settlement/index.wxml b/pages/settlement/index.wxml index 46fc908..63e07e5 100644 --- a/pages/settlement/index.wxml +++ b/pages/settlement/index.wxml @@ -341,27 +341,26 @@ - - - - - 登录授权 - × + + + + 提示 + 请先登录后再操作 + + + - - 📱 - 为了提供更好的服务,需要获取您的手机号进行身份验证 - - - - - 授权后即可完成入驻申请 + + + + + + + 授权登录 + 请授权获取您的手机号用于登录 + + + \ No newline at end of file diff --git a/pages/settlement/index.wxss b/pages/settlement/index.wxss index 2eae155..5a46991 100644 --- a/pages/settlement/index.wxss +++ b/pages/settlement/index.wxss @@ -1552,28 +1552,63 @@ picker { } /* 登录授权弹窗 */ -.auth-modal { +/* 统一的授权登录弹窗样式 */ +.auth-modal-overlay { position: fixed; top: 0; left: 0; - width: 100%; - height: 100%; - background-color: rgba(0, 0, 0, 0.5); - z-index: 1002; + right: 0; + bottom: 0; + background: rgba(0, 0, 0, 0.5); display: flex; justify-content: center; align-items: center; + z-index: 9999; } -.auth-content { - background-color: white; - border-radius: 20rpx; - width: 85%; - max-width: 520rpx; - overflow: hidden; - display: flex; - flex-direction: column; - animation: modalSlideIn 0.3s ease-out; +.auth-modal-container { + background: white; + padding: 40rpx; + border-radius: 16rpx; + width: 80%; + max-width: 500rpx; + text-align: center; + box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.1); +} + +.auth-modal-title { + font-size: 32rpx; + font-weight: bold; + margin-bottom: 30rpx; + color: #333; +} + +.auth-modal-content { + font-size: 28rpx; + color: #666; + margin-bottom: 40rpx; + line-height: 1.5; +} + +.auth-modal-buttons { + text-align: center; +} + +.auth-primary-button { + background-color: #1677ff; + color: white; + font-size: 28rpx; + line-height: 80rpx; + border-radius: 8rpx; + margin-bottom: 20rpx; +} + +.auth-cancel-button { + background-color: #f5f5f5; + color: #333; + font-size: 28rpx; + line-height: 80rpx; + border-radius: 8rpx; } @keyframes modalSlideIn { diff --git a/utils/api.js b/utils/api.js index b75649c..ccbaa8f 100644 --- a/utils/api.js +++ b/utils/api.js @@ -1570,6 +1570,82 @@ module.exports = { return request('/api/user/upload', 'POST', data); }, + // 更新用户类型 + updateUserType: async (typeToAdd) => { + try { + const userId = wx.getStorageSync('userId'); + const openid = wx.getStorageSync('openid'); + const userInfo = wx.getStorageSync('userInfo'); + + if (!userId || !openid) { + console.log('用户未登录,无法更新用户类型'); + return; + } + + // 获取当前用户类型 + let users = wx.getStorageSync('users') || {}; + let currentType = users[userId] && users[userId].type ? users[userId].type : ''; + + // 计算新的用户类型 + let newType = currentType; + + // 如果要添加的类型与当前类型相同,则不改变 + if (newType === typeToAdd) { + return; + } + + // 如果当前类型为空,则直接设置为要添加的类型 + if (!newType) { + newType = typeToAdd; + } else { + // 如果当前类型是buyer,要添加seller,则变为both + if (newType === 'buyer' && typeToAdd === 'seller') { + newType = 'both'; + } + // 如果当前类型是seller,要添加buyer,则变为both + else if (newType === 'seller' && typeToAdd === 'buyer') { + newType = 'both'; + } + } + + // 如果类型没有变化,不需要更新 + if (newType === currentType) { + return; + } + + // 更新本地存储 + if (!users[userId]) { + users[userId] = {}; + } + users[userId].type = newType; + wx.setStorageSync('users', users); + + // 更新全局数据 + const app = getApp(); + app.globalData.userType = newType; + + // 上传到服务器 + const uploadData = { + userId, + openid, + ...userInfo, + type: newType, + timestamp: Date.now() + }; + + // 调用用户信息更新API + return API.request({ + url: '/api/user/update', + method: 'POST', + data: uploadData + }); + + } catch (error) { + console.error('更新用户类型失败:', error); + throw error; + } + }, + // 获取用户信息用于调试 getUserInfoForDebug: function () { const openid = wx.getStorageSync('openid');