reset.vue 6.3 KB

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