|
| 1 | +<script setup> |
| 2 | + import wechatImage from '@/static/images/contact/image-wechat.png?url' |
| 3 | +
|
| 4 | + const userStore = useUserStore() |
| 5 | + const userInfo = computed(() => userStore.userInfo) |
| 6 | + const router = useRouter() |
| 7 | +
|
| 8 | + // 添加中间件拦截 (只有路由对象中 携带test的路由会走此部分) |
| 9 | + // /src/router/helper.js |
| 10 | + // defineMiddleware( |
| 11 | + // 'test', |
| 12 | + // function (router) { |
| 13 | + // router.beforeEach((to, from, next) => { |
| 14 | + // uni.showModal({ |
| 15 | + // title: '提示', |
| 16 | + // content: '触发了路由中间件,是否允许通过?', |
| 17 | + // success: (res) => { |
| 18 | + // if (res.cancel) { |
| 19 | + // next(false) |
| 20 | + // } else { |
| 21 | + // next() |
| 22 | + // } |
| 23 | + // } |
| 24 | + // }) |
| 25 | + // }) |
| 26 | +
|
| 27 | + // router.afterEach(() => {}) |
| 28 | + // }, |
| 29 | + // { router } |
| 30 | + // ) |
| 31 | +
|
| 32 | + // 复制文本到剪贴板 |
| 33 | + function handleCopy(text) { |
| 34 | + uni.setClipboardData({ |
| 35 | + data: text, |
| 36 | + success: () => { |
| 37 | + showToast('复制成功') |
| 38 | + } |
| 39 | + }) |
| 40 | + } |
| 41 | +
|
| 42 | + // 拨打电话 |
| 43 | + function handleCall(phone) { |
| 44 | + uni.makePhoneCall({ |
| 45 | + phoneNumber: phone, |
| 46 | + fail: () => { |
| 47 | + showToast('拨打电话失败') |
| 48 | + } |
| 49 | + }) |
| 50 | + } |
| 51 | +
|
| 52 | + // 预览图片 |
| 53 | + function previewImage(url) { |
| 54 | + console.log('previewImage', url) |
| 55 | + uni.previewImage({ |
| 56 | + urls: [url], |
| 57 | + current: url |
| 58 | + }) |
| 59 | + } |
| 60 | +
|
| 61 | + // 保存二维码到相册 |
| 62 | + function handleSaveQrCode() { |
| 63 | + uni.saveImageToPhotosAlbum({ |
| 64 | + filePath: wechatImage, |
| 65 | + success: () => { |
| 66 | + showToast('保存成功') |
| 67 | + }, |
| 68 | + fail: () => { |
| 69 | + showToast('保存失败,请检查权限设置', 'none') |
| 70 | + } |
| 71 | + }) |
| 72 | + } |
| 73 | +
|
| 74 | + // 显示提示信息 |
| 75 | + function showToast(title, icon = 'success') { |
| 76 | + uni.showToast({ |
| 77 | + title, |
| 78 | + icon, |
| 79 | + duration: 2000000 |
| 80 | + }) |
| 81 | + } |
| 82 | +</script> |
| 83 | + |
| 84 | +<template> |
| 85 | + <view class="contact-page h-full flex flex-col bg-gray-50"> |
| 86 | + <view class="header-section relative"> |
| 87 | + <image |
| 88 | + src="@/static/images/contact/image-banner.jpg" |
| 89 | + mode="aspectFill" |
| 90 | + class="h-50 w-full rounded-b-3xl object-cover shadow-md" |
| 91 | + /> |
| 92 | + |
| 93 | + <view class="absolute inset-0 rounded-b-3xl from-black/0 to-black/60 bg-gradient-to-b"></view> |
| 94 | + |
| 95 | + <view class="absolute bottom-4 left-0 w-full p-6 text-white"> |
| 96 | + <view class="mb-1 text-2xl font-bold"> 联系我们 </view> |
| 97 | + <view class="text-sm text-white/80"> 为您提供有限的帮助与支持 </view> |
| 98 | + </view> |
| 99 | + </view> |
| 100 | + |
| 101 | + <view class="contact-cards relative z-10 px-4 -mt-4"> |
| 102 | + <view class="overflow-hidden rounded-xl bg-white shadow-lg"> |
| 103 | + <view class="border-b border-gray-100 px-5 py-4"> |
| 104 | + <view class="text-lg text-gray-800 font-bold"> 联系方式 </view> |
| 105 | + </view> |
| 106 | + |
| 107 | + <view class="divide-y divide-gray-100"> |
| 108 | + <view class="contact-item" @click="handleCopy(userInfo.email)"> |
| 109 | + <view class="icon-container"> |
| 110 | + <view class="i-carbon-email size-6 text-blue-500"></view> |
| 111 | + </view> |
| 112 | + <view class="info-container"> |
| 113 | + <view class="label"> 电子邮箱 </view> |
| 114 | + <view class="value"> |
| 115 | + {{ userInfo.email }} |
| 116 | + </view> |
| 117 | + </view> |
| 118 | + <view class="action-container"> |
| 119 | + <view class="copy-button"> 复制 </view> |
| 120 | + </view> |
| 121 | + </view> |
| 122 | + |
| 123 | + <view class="contact-item" @click="handleCopy(userInfo.wechat)"> |
| 124 | + <view class="icon-container"> |
| 125 | + <view class="i-carbon-logo-wechat size-6 text-blue-500"></view> |
| 126 | + </view> |
| 127 | + <view class="info-container"> |
| 128 | + <view class="label"> 微信号 </view> |
| 129 | + <view class="value"> |
| 130 | + {{ userInfo.wechat }} |
| 131 | + </view> |
| 132 | + </view> |
| 133 | + <view class="action-container"> |
| 134 | + <view class="copy-button"> 复制 </view> |
| 135 | + </view> |
| 136 | + </view> |
| 137 | + </view> |
| 138 | + </view> |
| 139 | + |
| 140 | + <view class="mt-4 overflow-hidden rounded-xl bg-white shadow-lg"> |
| 141 | + <view class="border-b border-gray-100 px-5 py-4"> |
| 142 | + <view class="text-lg text-gray-800 font-bold"> 微信二维码 </view> |
| 143 | + </view> |
| 144 | + <view class="flex flex-col items-center p-5"> |
| 145 | + <image |
| 146 | + :src="wechatImage" |
| 147 | + mode="aspectFit" |
| 148 | + class="h-50 w-50 border border-gray-100 rounded-lg" |
| 149 | + @click="previewImage(wechatImage)" |
| 150 | + /> |
| 151 | + <view class="mt-3 text-sm text-gray-500"> 点击二维码可放大查看 </view> |
| 152 | + <button |
| 153 | + class="mt-4 w-full rounded-lg bg-blue-500 py-1 text-white font-medium transition-colors duration-200 active:bg-blue-600" |
| 154 | + hover-class="bg-blue-600" |
| 155 | + @click="handleSaveQrCode" |
| 156 | + > |
| 157 | + 保存二维码到相册 |
| 158 | + </button> |
| 159 | + </view> |
| 160 | + </view> |
| 161 | + </view> |
| 162 | + |
| 163 | + <view class="footer-section mt-auto p-4 text-center text-xs text-gray-400"> |
| 164 | + <view class="mt-1"> © {{ new Date().getFullYear() }} {{ userInfo.name }} 版权所有 </view> |
| 165 | + </view> |
| 166 | + </view> |
| 167 | +</template> |
| 168 | + |
| 169 | +<style scoped> |
| 170 | + /* 联系方式项样式 */ |
| 171 | + .contact-item { |
| 172 | + @apply flex items-center px-5 py-4 active:bg-gray-50 transition-colors duration-200; |
| 173 | + } |
| 174 | +
|
| 175 | + .icon-container { |
| 176 | + @apply flex-none w-10 flex items-center justify-center; |
| 177 | + } |
| 178 | +
|
| 179 | + .info-container { |
| 180 | + @apply flex-1 min-w-0; |
| 181 | + } |
| 182 | +
|
| 183 | + .label { |
| 184 | + @apply text-sm text-gray-500; |
| 185 | + } |
| 186 | +
|
| 187 | + .value { |
| 188 | + @apply text-gray-800 font-medium mt-0.5; |
| 189 | + } |
| 190 | +
|
| 191 | + .action-container { |
| 192 | + @apply flex-none ml-2; |
| 193 | + } |
| 194 | +
|
| 195 | + .copy-button { |
| 196 | + @apply flex items-center text-sm px-3 py-1.5 rounded-full bg-gray-100 text-gray-600 active:bg-gray-200 transition-colors duration-200; |
| 197 | + } |
| 198 | +
|
| 199 | + .call-button { |
| 200 | + @apply flex items-center text-sm px-3 py-1.5 rounded-full bg-blue-50 text-blue-600 active:bg-blue-100 transition-colors duration-200; |
| 201 | + } |
| 202 | +</style> |
0 commit comments