reset.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <cwg-page-wrapper :isLoginPage="true">
  3. <view class="main-content">
  4. <view class="global-header-bar pc-header">
  5. <view class="header-inner">
  6. <view class="logo-placeholder"></view> <!-- 左侧可预留放logo或留空 -->
  7. <!-- 这里由于没有深色背景,传递深色文字颜色 -->
  8. <LoginHeaderGroup text-color="#141d22" icon-color="#141d22" />
  9. </view>
  10. </view>
  11. <view class="reset-container">
  12. <uni-row class="content">
  13. <uni-col :span="20" :offset="2" :sm="{ span: 14, offset: 5 }">
  14. <view class="reset-title">{{ t('pages.login.resetTitle') }}</view>
  15. <view class="reset-form">
  16. <view class="form-label">{{ t('newSignup.item7') }}</view>
  17. <uni-easyinput v-model="email" :placeholder="t('forget.form')" class="custom-input">
  18. </uni-easyinput>
  19. <view class="reset-button">
  20. <button class="btn" block :loading="loading" @click="handleReset">{{ t('forget.forget') }}</button>
  21. </view>
  22. <view class="login-link">
  23. <text @click="handleLogin" class="link-text">{{ t('signin.login') }}</text>
  24. </view>
  25. </view>
  26. </uni-col>
  27. </uni-row>
  28. </view>
  29. <view class="chat-icon" :class="{ 'chat-icon-expanded': isChatIconExpanded, 'chat-icon-hidden': type == 'chat' }"
  30. @click="handleChatIconClick">
  31. <cwg-icon name="chat" color="#fff" />
  32. </view>
  33. </view>
  34. </cwg-page-wrapper>
  35. </template>
  36. <script setup lang="ts">
  37. import { ref } from 'vue'
  38. import { useI18n } from 'vue-i18n'
  39. import useRouter from '@/hooks/useRouter'
  40. import { userApi } from '@/api/user'
  41. import config from '@/config'
  42. import LoginHeaderGroup from './components/LoginHeaderGroup.vue'
  43. import { useWindowWidth } from '@/composables/useWindowWidth'
  44. const windowWidth = useWindowWidth(300)
  45. const isMobile = computed(() => windowWidth.value <= 991)
  46. const { t } = useI18n()
  47. const router = useRouter()
  48. const loading = ref(false)
  49. const email = ref('')
  50. import LiveChatService from '@/utils/liveChat.js'
  51. async function handleReset() {
  52. if (!email.value) {
  53. uni.showToast({ title: t('vaildate.email.empty'), icon: 'none' })
  54. return
  55. }
  56. if (!config.Pattern.Email.test(email.value)) {
  57. uni.showToast({ title: t('vaildate.email.format'), icon: 'none' })
  58. return
  59. }
  60. loading.value = true
  61. try {
  62. const res = await userApi.forgetPwd({ email: email.value })
  63. uni.showToast({ title: res.msg, icon: 'success' })
  64. setTimeout(() => {
  65. router.push('/pages/login/index')
  66. }, 1000)
  67. } catch (error: any) {
  68. uni.showToast({ title: error.message, icon: 'none' })
  69. } finally {
  70. loading.value = false
  71. }
  72. }
  73. const isChatIconExpanded = ref(false)
  74. // 处理聊天图标点击
  75. const handleChatIconClick = () => {
  76. // 如果还没显示 → 先滑出来
  77. if (!isChatIconExpanded.value) {
  78. isChatIconExpanded.value = true
  79. return
  80. }
  81. if (isMobile.value) {
  82. router.push('/pages/common/chat')
  83. } else {
  84. if (LiveChatService) {
  85. LiveChatService.showChat();
  86. }
  87. }
  88. setTimeout(() => {
  89. isChatIconExpanded.value = false
  90. }, 300)
  91. }
  92. function handleChange(value: any) {
  93. if (value.key == 'email') {
  94. email.value = value.value
  95. }
  96. }
  97. function handleLogin() {
  98. router.push('/pages/login/index')
  99. }
  100. </script>
  101. <style scoped lang="scss">
  102. @import "@/uni.scss";
  103. .chat-icon {
  104. width: px2rpx(50);
  105. height: px2rpx(50);
  106. border-radius: 50%;
  107. background-color: #cf1322;
  108. display: flex;
  109. align-items: center;
  110. justify-content: center;
  111. position: fixed;
  112. bottom: px2rpx(25);
  113. right: px2rpx(-25);
  114. z-index: 999;
  115. cursor: pointer;
  116. transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  117. box-shadow: 0 px2rpx(8) px2rpx(20) rgba(0, 0, 0, 0.15);
  118. will-change: transform;
  119. }
  120. .chat-icon:hover {
  121. transform: scale(1.1);
  122. }
  123. .chat-icon-expanded {
  124. bottom: px2rpx(20);
  125. right: px2rpx(20);
  126. transform: scale(1.1);
  127. box-shadow: 0 px2rpx(12) px2rpx(30) rgba(0, 0, 0, 0.2);
  128. }
  129. .chat-icon-hidden {
  130. display: none;
  131. }
  132. :deep(uni-content) {
  133. padding-left: 0 !important;
  134. }
  135. .main-content {
  136. display: flex;
  137. flex-direction: column;
  138. }
  139. .global-header-bar {
  140. width: 100%;
  141. height: px2rpx(60);
  142. display: flex;
  143. align-items: center;
  144. justify-content: center;
  145. flex-shrink: 0;
  146. z-index: 100;
  147. &.pc-header {
  148. background-color: transparent;
  149. border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  150. }
  151. .header-inner {
  152. width: 100%;
  153. padding: 0 5%;
  154. display: flex;
  155. justify-content: space-between;
  156. /* 两端对齐,可放logo和组件 */
  157. align-items: center;
  158. }
  159. }
  160. .mobile-header-bar {
  161. position: absolute;
  162. top: px2rpx(20);
  163. right: px2rpx(20);
  164. z-index: 10;
  165. }
  166. .reset-container {
  167. margin-top: px2rpx(20);
  168. display: flex;
  169. flex-direction: column;
  170. align-items: center;
  171. justify-content: center;
  172. }
  173. .content {
  174. width: 100%;
  175. margin: 0 auto;
  176. }
  177. .reset-title {
  178. font-size: px2rpx(28);
  179. font-weight: bold;
  180. color: #141d22;
  181. margin-bottom: px2rpx(40);
  182. }
  183. .reset-form {
  184. width: 100%;
  185. }
  186. .form-label {
  187. font-size: px2rpx(14);
  188. color: #333;
  189. margin-bottom: px2rpx(8);
  190. }
  191. .custom-input {
  192. margin-bottom: px2rpx(40);
  193. :deep(.uni-easyinput__content) {
  194. height: px2rpx(40);
  195. border: 1px solid #dcdfe6;
  196. border-radius: px2rpx(4);
  197. }
  198. }
  199. .reset-button {
  200. margin-bottom: px2rpx(20);
  201. :deep(button) {
  202. width: 100%;
  203. height: px2rpx(44);
  204. line-height: px2rpx(44);
  205. border-radius: px2rpx(4);
  206. background-color: var(--color-error); // 主题黄
  207. border: none;
  208. color: #fff;
  209. font-size: px2rpx(16);
  210. font-weight: 500;
  211. margin: 0;
  212. &::after {
  213. border: none;
  214. }
  215. }
  216. :deep(u-button--loading) {
  217. opacity: 0.8;
  218. }
  219. }
  220. .login-link {
  221. text-align: center;
  222. .link-text {
  223. font-size: px2rpx(14);
  224. color: #005bbb;
  225. cursor: pointer;
  226. text-decoration: none;
  227. }
  228. }
  229. </style>