云链智安app
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <view class="container">
  3. <!-- 顶部导航栏 -->
  4. <view class="navigation"></view>
  5. <view class="log">
  6. <view class="log_title">
  7. <view>{{$t('login.welcome')}},</view>
  8. <view class="log_titlefull">{{$t('login.full')}}</view>
  9. </view>
  10. <view><image class="log_image" src="https://esos-iot.bjdexn.cn/wx_images/logo.png" mode=""/></view>
  11. </view>
  12. <view class="log_bottom">
  13. <view class="lswitch">
  14. <l-switch :value="defaultValue" :placeholder="['English', '中文']" dotSize="14px" height="22px" width="32px" @click="changeLanguage"></l-switch>
  15. </view>
  16. <view class="account_number">
  17. <view class="account">{{$t('login.username')}}</view>
  18. <view class="password">
  19. <image class="login_imgae1" src="https://esos-iot.bjdexn.cn/wx_images/login_user.png" mode=""/>
  20. <input class="weui-input" :value="account" :placeholder="$t('login.username_placeholder')" @input="bindKeyInput1"/></view>
  21. </view>
  22. <view class="number">
  23. <view class="account">{{$t('login.password')}}</view>
  24. <view class="password">
  25. <image class="login_imgae1" src="https://esos-iot.bjdexn.cn/wx_images/password.png" mode=""/>
  26. <input class="weui-input" :value="password" :password="passwordtype" :placeholder="$t('login.password_placeholder')" @input="bindKeyInput2"/>
  27. <image class="login_imgae" src="https://esos-iot.bjdexn.cn/wx_images/password_1.png" v-if="passwordtype" @click="onpassword" mode=""/>
  28. <image class="login_imgae" src="https://esos-iot.bjdexn.cn/wx_images/password_2.png" v-else @click="onpassword" mode=""/>
  29. </view>
  30. </view>
  31. <view class="button_button">
  32. <button class="button_button" color="#F0F5F5" @click="onLogin">{{$t('login.submit')}}</button>
  33. </view>
  34. <view class="agreement">
  35. <radio @click.stop="checkboxChange" value="1" :checked="checked" color="#007545" />
  36. {{$t('login.terms')}}<text class="agreement_color" data-name="服务协议" @click="onprivacy"> {{$t('login.Terms')}}</text> {{$t('login.&')}}<text class="agreement_color" data-name="隐私政策" @click="onprivacy"> {{$t('login.Privacy')}}</text> </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script setup>
  41. import request from '@/utils/request';
  42. import { useI18n } from 'vue-i18n';
  43. const { t } = useI18n()
  44. import { onMounted,ref } from 'vue';
  45. const account = ref('')
  46. const password = ref('')
  47. const passwordtype = ref(true)
  48. const checked = ref(false)
  49. const defaultValue=ref()
  50. const bindKeyInput1 = (e) => {
  51. account.value = e.detail.value
  52. };
  53. const bindKeyInput2 = (e) => {
  54. password.value = e.detail.value
  55. };
  56. const onpassword = () => {
  57. passwordtype.value = !passwordtype.value
  58. };
  59. const onLogin = async () => {
  60. if (!checked.value) {
  61. return uni.showToast({
  62. title: '请先阅读协议并勾选同意按钮',
  63. icon: 'none',
  64. });
  65. }else if(account.value==''||password.value=='' ){
  66. return uni.showToast({
  67. title: '请输入正确的账户与密码',
  68. icon: 'none',
  69. });
  70. }
  71. try {
  72. const response = await request({
  73. url: '/platform/login',
  74. method: 'POST',
  75. header:{'Content-Type': 'application/x-www-form-urlencoded'},
  76. withCredentials: true, // 启用凭证
  77. data: {
  78. username: account.value,
  79. password: password.value,
  80. tenantNo: '',
  81. rememberMe: false,
  82. },
  83. });
  84. console.log('登录成功:', response);
  85. uni.switchTab({
  86. url:'/pages/index/index'
  87. })
  88. } catch (error) {
  89. console.error('登录失败:', error);
  90. }
  91. };
  92. const checkboxChange = (e) => {
  93. checked.value = !checked.value
  94. };
  95. const onprivacy = (e) => {
  96. // uni.navigateTo({
  97. // url: `/pages/privacy/index?name=${e.target.dataset.name}`,
  98. // })
  99. // if (options.name=='服务协议') {
  100. // this.setData({
  101. // URL:'https://esos-iot.bjdexn.cn/wx_images/service.png'
  102. // })
  103. // }else{
  104. // this.setData({
  105. // URL:'https://esos-iot.bjdexn.cn/wx_images/privacy.png'
  106. // })
  107. // }
  108. };
  109. onMounted(() => {
  110. try {
  111. const language = uni.getStorageSync('userLanguage');
  112. defaultValue.value = language === 'en';
  113. getServerData();
  114. } catch (error) {
  115. console.error('读取 Storage 失败:', error);
  116. }
  117. });
  118. const { locale } = useI18n(); // 使用 Composition API
  119. const changeLanguage=()=>{
  120. if(defaultValue.value){
  121. locale.value = 'zh-Hans'; // 使用响应式 locale
  122. uni.setStorageSync('userLanguage', 'zh-Hans');
  123. defaultValue.value = false
  124. }else{
  125. locale.value = 'en'; // 使用响应式 locale
  126. uni.setStorageSync('userLanguage', 'en');
  127. defaultValue.value = true
  128. }
  129. uni.setTabBarItem({
  130. index:0,
  131. text:t('tabBar.publicize')
  132. })
  133. uni.setTabBarItem({
  134. index:1,
  135. text:t('tabBar.products')
  136. })
  137. uni.setTabBarItem({
  138. index:2,
  139. text:t('tabBar.Devices')
  140. })
  141. uni.setTabBarItem({
  142. index:3,
  143. text:t('tabBar.My')
  144. })
  145. };
  146. const getServerData = () => {
  147. }
  148. </script>
  149. <!--
  150. -->
  151. <style scoped>
  152. .uni-page{
  153. width: 100%;
  154. height: 100%;
  155. }
  156. .container {
  157. height: 100vh;
  158. background: linear-gradient(to bottom, #007545 -40%, #f0f5f5 40%, #f0f5f5 100%);
  159. box-sizing: border-box;
  160. }
  161. .navigation {
  162. width: 100%;
  163. height: 100px;
  164. }
  165. .title{
  166. font-size: 36rpx;
  167. text-align: center;
  168. margin-top: 16rpx;
  169. }
  170. .log{
  171. width: 100%;
  172. height: 440rpx;
  173. display: flex;
  174. justify-content: space-around;
  175. align-items: center;
  176. padding: 0rpx 30rpx;
  177. box-sizing: border-box;
  178. }
  179. .log_title{
  180. font-size: 36rpx;
  181. line-height:72rpx;
  182. font-weight: 600;
  183. }
  184. .log_titlefull{
  185. font-size: 32rpx;
  186. line-height:72rpx;
  187. font-weight: 600;
  188. }
  189. .log_image{
  190. width: 194rpx;
  191. height: 232rpx;
  192. }
  193. .log_bottom{
  194. width: 100%;
  195. height: 100%;
  196. border-radius: 40rpx;
  197. background-color: #fff;
  198. padding: 0rpx 40rpx;
  199. box-sizing: border-box;
  200. }
  201. .account_number{
  202. width: 100%;
  203. padding-top: 80rpx;
  204. }
  205. .lswitch{
  206. float: right;
  207. margin-top: 20rpx;
  208. }
  209. .number{
  210. margin-top: 40rpx;
  211. }
  212. .account{
  213. font-size: 32rpx;
  214. }
  215. .weui-input{
  216. flex: 1;
  217. height: 100rpx;
  218. }
  219. .password{
  220. display: flex;
  221. align-items: center;
  222. font-size: 28rpx;
  223. margin-top: 10rpx;
  224. padding-bottom: 0rpx;
  225. border-bottom:1rpx #cccccc solid;
  226. }
  227. .login_imgae1{
  228. margin-right: 20rpx;
  229. width: 40rpx;
  230. height: 40rpx;
  231. }
  232. .login_imgae{
  233. width: 40rpx;
  234. height: 40rpx;
  235. margin-left: 20rpx;
  236. }
  237. .button_button{
  238. margin-top: 100rpx;
  239. color: #fff;
  240. background-color: #007545;
  241. background-color: rgba(0,117,68, 0.3); /* 红色,50%透明度 */
  242. }
  243. .agreement{
  244. margin-top: 20rpx;
  245. display: flex;
  246. align-items: center;
  247. font-size: 28rpx;
  248. }
  249. .agreement_color{
  250. color:#26B1A1;
  251. margin:0rpx 6rpx;
  252. }
  253. .checkbox-group__icon-dot::after{
  254. background: var(--td-radio-icon-checked-color, var(--td-brand-color, var(--td-primary-color-7, #26B1A1))) !important;
  255. }
  256. .checkbox-group__icon--checked {
  257. color: var(--td-radio-icon-checked-color, var(--td-brand-color, var(--td-primary-color-7, #26B1A1))) !important;
  258. }
  259. .checkbox-group__icon-dot{
  260. border: 3px solid var(--td-radio-icon-checked-color, var(--td-brand-color, var(--td-primary-color-7, #26B1A1))) !important;
  261. }
  262. .checkbox-group--block{
  263. padding: var(--td-radio-vertical-padding, 0rpx) !important;
  264. }
  265. /* index.wxss */
  266. .radio-group {
  267. margin-bottom: 20px;
  268. }
  269. .radio-label {
  270. font-size: 16px;
  271. }
  272. .login-button {
  273. width: 100px;
  274. height: 40px;
  275. }
  276. /* 定义晃动动画 */
  277. .container {
  278. display: flex;
  279. flex-direction: column;
  280. align-items: center;
  281. }
  282. .radio-group {
  283. margin-bottom: 20px;
  284. }
  285. .radio-label {
  286. font-size: 16px;
  287. }
  288. .login-button {
  289. width: 100px;
  290. height: 40px;
  291. }
  292. /* 定义晃动动画 */
  293. @keyframes shake {
  294. 0% { transform: translateX(0); }
  295. 25% { transform: translateX(-10px); }
  296. 50% { transform: translateX(10px); }
  297. 75% { transform: translateX(-10px); }
  298. 100% { transform: translateX(0); }
  299. }
  300. .shake {
  301. animation: shake 0.5s;
  302. }
  303. .uni-checkbox-input svg{
  304. color: #007545 !important;
  305. }
  306. </style>