login-account.vue 8.0 KB

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