login-account.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <view class="container">
  3. <view class="content">
  4. <view class="top">
  5. <image src="/static/images/logo_start.png" class="logo" mode="widthFix"></image>
  6. <view
  7. style="width: 100%;margin-bottom: 80rpx;display: flex;flex-direction: column;align-items: center;">
  8. <!-- <text style="font-size: 32rpx;">泰山云平台</text> -->
  9. <text style="font-size: 1.5rem;margin-top: 5rpx;">
  10. 大恒巡检保养工单系统
  11. </text>
  12. </view>
  13. <view class="cell">
  14. <view class="input-box">
  15. <uIcons type="auth" size="30"></uIcons>
  16. <input type="text" v-model="username" placeholder="请输入账号" class="ipt" placeholder-class="hold"
  17. @blur="handleInputCheck" />
  18. </view>
  19. </view>
  20. <view class="cell">
  21. <view class="input-box">
  22. <uIcons type="locked" size="30"></uIcons>
  23. <input type="password" v-model="password" placeholder="请输入密码" class="ipt"
  24. placeholder-class="hold" @blur="handleInputCheck" />
  25. </view>
  26. </view>
  27. <!-- <view class="agree">
  28. 登录即代表同意
  29. <text class="a">《用户协议》</text>
  30. <text class="a">《隐私政策》</text>
  31. </view> -->
  32. <!-- <view class="tip">未注册用户验证后将自动注册并登录</view> -->
  33. <view class="cell">
  34. <view
  35. style="margin-top: 30rpx;margin-right:24rpx;display: flex;justify-content: flex-end;flex-direction:row;">
  36. <checkbox-group @change="checkboxChange">
  37. <label style="font-size: 24rpx;">
  38. <checkbox value="rememberPw" :checked="rememberPw" />记住密码
  39. </label>
  40. </checkbox-group>
  41. </view>
  42. </view>
  43. <view class="cell">
  44. <button class="submit" @click="submit" :disabled="disabled">登录</button>
  45. </view>
  46. <!-- <navigator url="/pages/login/login-phone" hover-class="none" class="change">手机登录 ></navigator> -->
  47. </view>
  48. <!-- 社交账号登录 -->
  49. <!-- <view class="bottom">
  50. <view class="tag">社交账号登录</view>
  51. <view class="chat-arr">
  52. <image src="/static/images/wx.png" class="icon" mode=""></image>
  53. <image src="/static/images/qq.png" class="icon" mode=""></image>
  54. <image src="/static/images/wb.png" class="icon" mode=""></image>
  55. </view>
  56. </view> -->
  57. </view>
  58. <!-- -->
  59. </view>
  60. </template>
  61. <script>
  62. import md5 from '@/utils/md5.js'
  63. import uIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue'
  64. import {
  65. devUrl,
  66. prodUrl,
  67. contentType
  68. } from '@/common/setting'
  69. export default {
  70. components: {
  71. uIcons,
  72. },
  73. data() {
  74. return {
  75. tenantId: '000000',
  76. username: '',
  77. password: '',
  78. disabled: true,
  79. rememberPw: false,
  80. };
  81. },
  82. onLoad() {
  83. console.log("login+++")
  84. // uni.getPushClientId({
  85. // success: (res) => {
  86. // console.log("id11111111111 "+res.cid);
  87. // },
  88. // fail(err) {
  89. // console.log(err)
  90. // }
  91. // })
  92. // uni.getLocation({
  93. // type: 'gcj02',
  94. // geocode: true,
  95. // success: function (res) {
  96. // console.log('当前位置:' + JSON.stringify(res));
  97. // }
  98. // });
  99. let userLoginInfo = uni.getStorageSync("userLoginInfo");
  100. if (userLoginInfo) {
  101. this.rememberPw = true;
  102. this.disabled = false;
  103. this.username = userLoginInfo.username;
  104. this.password = userLoginInfo.pw;
  105. }
  106. },
  107. methods: {
  108. submit() {
  109. this.$u.api.token(this.tenantId, this.username, md5(this.password)).then(data => {
  110. console.log("token " + JSON.stringify(data))
  111. let dt = new Date();
  112. uni.setStorageSync("loginTime", dt.getTime());
  113. if (this.rememberPw) {
  114. uni.setStorageSync("userLoginInfo", {
  115. username: this.username,
  116. pw: this.password,
  117. });
  118. } else {
  119. uni.removeStorageSync("userLoginInfo");
  120. }
  121. this.$u.func.login(data)
  122. }).catch(err => {
  123. console.log(err)
  124. this.$u.func.showToast({
  125. title: '用户名或密码错误' + err,
  126. })
  127. })
  128. },
  129. handleInputCheck() {
  130. this.disabled = false
  131. },
  132. checkboxChange: function(e) {
  133. let values = e.detail.value;
  134. if (values.length > 0) {
  135. this.rememberPw = true;
  136. } else {
  137. this.rememberPw = false;
  138. }
  139. }
  140. }
  141. };
  142. </script>
  143. <style lang="scss">
  144. .container {
  145. min-height: 100vh;
  146. overflow: hidden;
  147. .set-icon {
  148. vertical-align: middle;
  149. width: 41rpx;
  150. height: auto;
  151. margin-right: 35rpx;
  152. }
  153. }
  154. .content {
  155. display: flex;
  156. flex-direction: column;
  157. justify-content: center;
  158. align-items: center;
  159. height: 90vh;
  160. width: 100%;
  161. .top {
  162. width: 100%;
  163. }
  164. .logo {
  165. display: block;
  166. width: 160rpx;
  167. height: auto;
  168. margin: 0 auto 40rpx;
  169. }
  170. .cell {
  171. width: 100%;
  172. padding: 0 85rpx;
  173. box-sizing: border-box;
  174. margin-top: 12rpx;
  175. .name {
  176. font-size: 22rpx;
  177. font-family: Source Han Sans CN;
  178. font-weight: 400;
  179. color: #3e4a59;
  180. line-height: 30rpx;
  181. opacity: 0.72;
  182. }
  183. .input-box {
  184. padding: 30rpx 0;
  185. border-bottom: 2rpx solid #f6f6f6;
  186. display: flex;
  187. align-items: center;
  188. .code {
  189. font-size: 22rpx;
  190. font-family: Source Han Sans CN;
  191. font-weight: 400;
  192. color: #0d0d0d;
  193. line-height: 30rpx;
  194. text {
  195. color: #14b9c8;
  196. }
  197. }
  198. .ipt {
  199. flex: 1;
  200. // height: 24rpx;
  201. font-size: 24rpx;
  202. padding-left: 10rpx;
  203. }
  204. .hold {
  205. font-size: 24rpx;
  206. font-family: Source Han Sans CN;
  207. font-weight: 400;
  208. color: #3e4a59;
  209. line-height: 30px;
  210. opacity: 0.45;
  211. }
  212. }
  213. }
  214. .agree {
  215. margin: 27rpx 95rpx 0;
  216. font-size: 22rpx;
  217. font-family: Adobe Heiti Std;
  218. font-weight: normal;
  219. color: #cacaca;
  220. line-height: 34rpx;
  221. .a {
  222. color: #000000;
  223. }
  224. }
  225. .submit {
  226. margin-top: 40rpx;
  227. border: none;
  228. width: 100%;
  229. height: 80rpx;
  230. line-height: 80rpx;
  231. box-sizing: border-box;
  232. border-radius: 15rpx;
  233. // font-size: 36rpx;
  234. background: linear-gradient(to right, #48b1f8, #3976f7);
  235. color: #ffffff;
  236. &::after {
  237. content: none;
  238. }
  239. &::before {
  240. content: none;
  241. }
  242. &[disabled='true'] {
  243. background: linear-gradient(to right, #48b1f8, #3976f7);
  244. font-size: 36rpx;
  245. font-family: Source Han Sans CN;
  246. font-weight: 500;
  247. color: #ffffff;
  248. }
  249. }
  250. .tip {
  251. margin-top: 30rpx;
  252. text-align: center;
  253. font-size: 22rpx;
  254. font-family: Adobe Heiti Std;
  255. font-weight: normal;
  256. color: #cacaca;
  257. line-height: 34rpx;
  258. }
  259. .change {
  260. margin-top: 20rpx;
  261. text-align: center;
  262. font-size: 22rpx;
  263. font-family: Adobe Heiti Std;
  264. font-weight: normal;
  265. color: #14b9c8;
  266. line-height: 34rpx;
  267. }
  268. .tag {
  269. display: flex;
  270. justify-content: center;
  271. align-items: center;
  272. font-size: 22rpx;
  273. font-family: Adobe Heiti Std;
  274. font-weight: normal;
  275. color: #9f9f9f;
  276. line-height: 34rpx;
  277. &::before {
  278. content: '';
  279. display: block;
  280. width: 160rpx;
  281. height: 1px;
  282. background: #d8d8d8;
  283. opacity: 0.86;
  284. }
  285. &::after {
  286. content: '';
  287. display: block;
  288. width: 160rpx;
  289. height: 1px;
  290. background: #d8d8d8;
  291. opacity: 0.86;
  292. }
  293. }
  294. .chat-arr {
  295. margin-top: 50rpx;
  296. display: flex;
  297. align-items: center;
  298. justify-content: space-between;
  299. .icon {
  300. width: 73rpx;
  301. height: 73rpx;
  302. }
  303. }
  304. }
  305. </style>