增量提交
This commit is contained in:
139
Claw/client/wechat_app/components/auth-prompt/auth-prompt.js
Normal file
139
Claw/client/wechat_app/components/auth-prompt/auth-prompt.js
Normal file
@@ -0,0 +1,139 @@
|
||||
// 授权提示组件
|
||||
Component({
|
||||
properties: {
|
||||
show: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
authType: {
|
||||
type: String,
|
||||
value: 'userInfo' // userInfo, location, camera, record
|
||||
}
|
||||
},
|
||||
|
||||
data: {
|
||||
authConfig: {
|
||||
userInfo: {
|
||||
title: '授权用户信息',
|
||||
desc: '为了提供更好的服务,需要获取您的用户信息',
|
||||
buttonText: '授权',
|
||||
icon: '/assets/images/user-avatar.png'
|
||||
},
|
||||
location: {
|
||||
title: '授权地理位置',
|
||||
desc: '为了提供基于位置的服务,需要获取您的地理位置',
|
||||
buttonText: '授权',
|
||||
icon: '/assets/images/location-icon.png'
|
||||
},
|
||||
camera: {
|
||||
title: '授权相机',
|
||||
desc: '为了拍摄照片或视频,需要获取相机权限',
|
||||
buttonText: '授权',
|
||||
icon: '/assets/images/camera-icon.png'
|
||||
},
|
||||
record: {
|
||||
title: '授权录音',
|
||||
desc: '为了录制语音,需要获取录音权限',
|
||||
buttonText: '授权',
|
||||
icon: '/assets/images/mic-icon.png'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 授权按钮点击
|
||||
handleAuth() {
|
||||
const { authType } = this.properties
|
||||
|
||||
switch (authType) {
|
||||
case 'userInfo':
|
||||
this.authUserInfo()
|
||||
break
|
||||
case 'location':
|
||||
this.authLocation()
|
||||
break
|
||||
case 'camera':
|
||||
this.authCamera()
|
||||
break
|
||||
case 'record':
|
||||
this.authRecord()
|
||||
break
|
||||
}
|
||||
},
|
||||
|
||||
// 授权用户信息
|
||||
authUserInfo() {
|
||||
const app = getApp()
|
||||
app.triggerUserAuth((userInfo) => {
|
||||
if (userInfo) {
|
||||
this.triggerEvent('authSuccess', { authType: 'userInfo', data: userInfo })
|
||||
this.setData({ show: false })
|
||||
} else {
|
||||
console.error('用户信息授权失败')
|
||||
this.triggerEvent('authFail', { authType: 'userInfo', error: '授权失败' })
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 授权地理位置
|
||||
authLocation() {
|
||||
wx.getLocation({
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
this.triggerEvent('authSuccess', { authType: 'location', data: res })
|
||||
this.setData({ show: false })
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('地理位置授权失败:', err)
|
||||
this.triggerEvent('authFail', { authType: 'location', error: err })
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 授权相机
|
||||
authCamera() {
|
||||
wx.authorize({
|
||||
scope: 'scope.camera',
|
||||
success: () => {
|
||||
this.triggerEvent('authSuccess', { authType: 'camera' })
|
||||
this.setData({ show: false })
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('相机授权失败:', err)
|
||||
this.triggerEvent('authFail', { authType: 'camera', error: err })
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 授权录音
|
||||
authRecord() {
|
||||
wx.authorize({
|
||||
scope: 'scope.record',
|
||||
success: () => {
|
||||
this.triggerEvent('authSuccess', { authType: 'record' })
|
||||
this.setData({ show: false })
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('录音授权失败:', err)
|
||||
this.triggerEvent('authFail', { authType: 'record', error: err })
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 取消授权
|
||||
handleCancel() {
|
||||
this.triggerEvent('authCancel', { authType: this.properties.authType })
|
||||
this.setData({ show: false })
|
||||
},
|
||||
|
||||
// 打开设置
|
||||
openSettings() {
|
||||
wx.openSetting({
|
||||
success: (res) => {
|
||||
console.log('设置结果:', res.authSetting)
|
||||
this.triggerEvent('settingsOpen', { authType: this.properties.authType, settings: res.authSetting })
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {},
|
||||
"description": "授权提示组件"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<view class="auth-prompt" wx:if="{{show}}">
|
||||
<view class="auth-prompt-overlay" bindtap="handleCancel"></view>
|
||||
<view class="auth-prompt-content">
|
||||
<view class="auth-prompt-icon">
|
||||
<image src="{{authConfig[authType].icon}}" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="auth-prompt-title">{{authConfig[authType].title}}</view>
|
||||
<view class="auth-prompt-desc">{{authConfig[authType].desc}}</view>
|
||||
<view class="auth-prompt-buttons">
|
||||
<button class="auth-prompt-cancel" bindtap="handleCancel">取消</button>
|
||||
<button class="auth-prompt-confirm" bindtap="handleAuth">{{authConfig[authType].buttonText}}</button>
|
||||
</view>
|
||||
<view class="auth-prompt-tip">
|
||||
<text>如果授权失败,请在</text>
|
||||
<text class="auth-prompt-settings" bindtap="openSettings">设置</text>
|
||||
<text>中开启权限</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
106
Claw/client/wechat_app/components/auth-prompt/auth-prompt.wxss
Normal file
106
Claw/client/wechat_app/components/auth-prompt/auth-prompt.wxss
Normal file
@@ -0,0 +1,106 @@
|
||||
.auth-prompt {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 9999;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.auth-prompt-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.auth-prompt-content {
|
||||
position: relative;
|
||||
width: 80%;
|
||||
max-width: 400rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 40rpx;
|
||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.15);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.auth-prompt-icon {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
margin-bottom: 32rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.auth-prompt-icon image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.auth-prompt-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.auth-prompt-desc {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
text-align: center;
|
||||
line-height: 36rpx;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.auth-prompt-buttons {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.auth-prompt-cancel {
|
||||
flex: 1;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
background-color: #f5f5f5;
|
||||
border-radius: 8rpx 0 0 8rpx;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.auth-prompt-confirm {
|
||||
flex: 1;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
font-size: 28rpx;
|
||||
color: #fff;
|
||||
background-color: #07c160;
|
||||
border-radius: 0 8rpx 8rpx 0;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.auth-prompt-tip {
|
||||
font-size: 20rpx;
|
||||
color: #999;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.auth-prompt-settings {
|
||||
color: #07c160;
|
||||
margin: 0 4rpx;
|
||||
}
|
||||
|
||||
.auth-prompt-settings:active {
|
||||
text-decoration: underline;
|
||||
}
|
||||
@@ -1,27 +1,26 @@
|
||||
/* 任务卡片组件样式 */
|
||||
/* 任务卡片组件样式 - 深色主题 */
|
||||
.task-card {
|
||||
background: white;
|
||||
background: linear-gradient(180deg, #1a1a1a 0%, #161616 100%);
|
||||
border-radius: 20rpx;
|
||||
padding: 30rpx;
|
||||
margin: 20rpx 0;
|
||||
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
|
||||
border-left: 8rpx solid #e0e0e0;
|
||||
border-left: 8rpx solid #2a2a2a;
|
||||
}
|
||||
|
||||
.task-card.pending {
|
||||
border-left-color: #f0ad4e;
|
||||
border-left-color: #faad14;
|
||||
}
|
||||
|
||||
.task-card.processing {
|
||||
border-left-color: #10aeff;
|
||||
border-left-color: #1677FF;
|
||||
}
|
||||
|
||||
.task-card.completed {
|
||||
border-left-color: #07c160;
|
||||
border-left-color: #52c41a;
|
||||
}
|
||||
|
||||
.task-card.failed {
|
||||
border-left-color: #dd524d;
|
||||
border-left-color: #ff4d4f;
|
||||
}
|
||||
|
||||
.task-header {
|
||||
@@ -30,13 +29,13 @@
|
||||
align-items: center;
|
||||
margin-bottom: 20rpx;
|
||||
padding-bottom: 20rpx;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
border-bottom: 2rpx solid rgba(255,255,255,0.06);
|
||||
}
|
||||
|
||||
.task-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
color: #ffffff;
|
||||
flex: 1;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
@@ -50,23 +49,23 @@
|
||||
}
|
||||
|
||||
.task-status.pending {
|
||||
background-color: #fff3cd;
|
||||
color: #856404;
|
||||
background-color: rgba(250,173,20,0.15);
|
||||
color: #faad14;
|
||||
}
|
||||
|
||||
.task-status.processing {
|
||||
background-color: #cce5ff;
|
||||
color: #004085;
|
||||
background-color: rgba(22,119,255,0.15);
|
||||
color: #1677FF;
|
||||
}
|
||||
|
||||
.task-status.completed {
|
||||
background-color: #d4edda;
|
||||
color: #155724;
|
||||
background-color: rgba(82,196,26,0.15);
|
||||
color: #52c41a;
|
||||
}
|
||||
|
||||
.task-status.failed {
|
||||
background-color: #f8d7da;
|
||||
color: #721c24;
|
||||
background-color: rgba(255,77,79,0.15);
|
||||
color: #ff4d4f;
|
||||
}
|
||||
|
||||
.task-content {
|
||||
@@ -75,7 +74,7 @@
|
||||
|
||||
.task-description {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
color: #aaaaaa;
|
||||
line-height: 1.5;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
@@ -90,10 +89,11 @@
|
||||
.task-type,
|
||||
.task-priority {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
background: #f8f8f8;
|
||||
color: #888888;
|
||||
background: #222222;
|
||||
padding: 8rpx 16rpx;
|
||||
border-radius: 10rpx;
|
||||
border: 2rpx solid rgba(255,255,255,0.04);
|
||||
}
|
||||
|
||||
.task-timeline {
|
||||
@@ -104,7 +104,7 @@
|
||||
|
||||
.task-time {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.task-actions {
|
||||
@@ -113,7 +113,7 @@
|
||||
gap: 15rpx;
|
||||
margin-top: 20rpx;
|
||||
padding-top: 20rpx;
|
||||
border-top: 1rpx solid #f0f0f0;
|
||||
border-top: 2rpx solid rgba(255,255,255,0.06);
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
@@ -127,27 +127,27 @@
|
||||
}
|
||||
|
||||
.action-btn.primary {
|
||||
background: linear-gradient(135deg, #07c160 0%, #06a050 100%);
|
||||
background: linear-gradient(135deg, #1677FF 0%, #0958d9 100%);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.action-btn.success {
|
||||
background: linear-gradient(135deg, #28a745 0%, #218838 100%);
|
||||
background: linear-gradient(135deg, #52c41a 0%, #389e0d 100%);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.action-btn.warning {
|
||||
background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%);
|
||||
color: #212529;
|
||||
background: linear-gradient(135deg, #faad14 0%, #d48806 100%);
|
||||
color: #1a1a1a;
|
||||
}
|
||||
|
||||
.action-btn.info {
|
||||
background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
|
||||
background: linear-gradient(135deg, #13c2c2 0%, #08979c 100%);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.action-btn.danger {
|
||||
background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
|
||||
background: linear-gradient(135deg, #ff4d4f 0%, #cf1322 100%);
|
||||
color: white;
|
||||
}
|
||||
|
||||
@@ -164,21 +164,22 @@
|
||||
|
||||
.progress-text {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
color: #888888;
|
||||
min-width: 60rpx;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.task-result {
|
||||
background: #f8f9fa;
|
||||
background: #141414;
|
||||
border-radius: 10rpx;
|
||||
padding: 20rpx;
|
||||
margin-top: 20rpx;
|
||||
border: 2rpx solid rgba(255,255,255,0.06);
|
||||
}
|
||||
|
||||
.result-label {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
color: #888888;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10rpx;
|
||||
display: block;
|
||||
@@ -186,10 +187,10 @@
|
||||
|
||||
.result-content {
|
||||
font-size: 26rpx;
|
||||
color: #333;
|
||||
color: #e5e5e5;
|
||||
line-height: 1.5;
|
||||
background: white;
|
||||
background: #0d0d0d;
|
||||
padding: 15rpx;
|
||||
border-radius: 8rpx;
|
||||
border: 1rpx solid #e9ecef;
|
||||
}
|
||||
border: 2rpx solid #252525;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* 用户头像组件样式 */
|
||||
/* 用户头像组件样式 - 深色适配 */
|
||||
.user-avatar {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
@@ -29,10 +29,11 @@
|
||||
/* 形状样式 */
|
||||
.user-avatar.circle {
|
||||
border-radius: 50%;
|
||||
border: 3rpx solid rgba(22,119,255,0.35);
|
||||
}
|
||||
|
||||
.user-avatar.rounded {
|
||||
border-radius: 10rpx;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.user-avatar.square {
|
||||
@@ -54,24 +55,27 @@
|
||||
width: 20rpx;
|
||||
height: 20rpx;
|
||||
border-radius: 50%;
|
||||
border: 4rpx solid white;
|
||||
border: 3rpx solid #1a1a1a;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.status-indicator.online {
|
||||
background-color: #07c160;
|
||||
background-color: #52c41a;
|
||||
box-shadow: 0 0 6rpx rgba(82,196,26,0.5);
|
||||
}
|
||||
|
||||
.status-indicator.offline {
|
||||
background-color: #999;
|
||||
background-color: #555555;
|
||||
}
|
||||
|
||||
.status-indicator.busy {
|
||||
background-color: #f0ad4e;
|
||||
background-color: #faad14;
|
||||
box-shadow: 0 0 6rpx rgba(250,173,20,0.5);
|
||||
}
|
||||
|
||||
.status-indicator.away {
|
||||
background-color: #10aeff;
|
||||
background-color: #1677FF;
|
||||
box-shadow: 0 0 6rpx rgba(22,119,255,0.5);
|
||||
}
|
||||
|
||||
/* 徽章 */
|
||||
@@ -79,7 +83,7 @@
|
||||
position: absolute;
|
||||
top: -10rpx;
|
||||
right: -10rpx;
|
||||
background-color: #dd524d;
|
||||
background: linear-gradient(135deg, #ff4d4f, #cf1322);
|
||||
color: white;
|
||||
border-radius: 50%;
|
||||
min-width: 32rpx;
|
||||
@@ -91,6 +95,7 @@
|
||||
font-weight: bold;
|
||||
padding: 0 8rpx;
|
||||
z-index: 2;
|
||||
box-shadow: 0 4rpx 12rpx rgba(255,77,79,0.4);
|
||||
}
|
||||
|
||||
.badge-text {
|
||||
@@ -98,14 +103,14 @@
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
/* 加载遮罩 */
|
||||
/* 加载遮罩 - 深色 */
|
||||
.loading-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(255, 255, 255, 0.8);
|
||||
background-color: rgba(26,26,26,0.85);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@@ -115,8 +120,8 @@
|
||||
.loading-spinner {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
border: 4rpx solid #f3f3f3;
|
||||
border-top: 4rpx solid #07c160;
|
||||
border: 4rpx solid #2a2a2a;
|
||||
border-top: 4rpx solid #1677FF;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
@@ -134,10 +139,10 @@
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: linear-gradient(135deg, #07c160 0%, #06a050 100%);
|
||||
background: linear-gradient(135deg, #1677FF 0%, #0958d9 100%);
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.user-avatar.error::before {
|
||||
background: linear-gradient(135deg, #dd524d 0%, #c82333 100%);
|
||||
}
|
||||
background: linear-gradient(135deg, #ff4d4f 0%, #cf1322 100%);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user