login-account.vue 8.7 KB

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