login.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <template>
  2. <view class="container">
  3. <u-icon class="back-btn" name="arrow-left" color="black" size="20" @click="navBack"></u-icon>
  4. <view class="wrapper">
  5. <image style='width:38px;height:38px;margin:223rpx 0 20px 0;' src='@/static/logo.png'></image>
  6. <h2 class="title Semibold">欢迎使用智运</h2>
  7. <view
  8. style='position:relative;width:100%;margin-top:50px;border-bottom:1px solid #E8E9ED;padding:10px;align-items: center;'
  9. class="flex">
  10. <view class="phone-before-num NumberMedium">+86</view>
  11. <view style='width:85%;'>
  12. <!-- <u--input class="phone-number" border="none" maxlength='11' v-model='phone'
  13. placeholder="请输入手机号码" type="number"></u--input>
  14. <u-input /> -->
  15. <u--input v-model="phone" border="none" type='number' placeholder="请输入手机号码" class="phone-number"
  16. maxlength='11' :clearable='true'></u--input>
  17. </view>
  18. </view>
  19. <view style='margin-top:20px;border-bottom:1px solid #E8E9ED;position:relative;height:40px'>
  20. <!-- <u--input class='password' border="none" v-model='password'
  21. placeholder="请输入密码,6-16位字符" :type="type" value="">
  22. </u--input> -->
  23. <u-input v-if="isShowPassword=='password'" class='password' border="none" v-model='password' placeholder="请输入密码,6-16位字符"
  24. type="password" :clearable='true'>
  25. <template slot="suffix">
  26. <u-icon name="eye-fill" color="rgb(192, 196, 204)" size="24" @click="passWordStatus(1)"
  27. v-if="isShowPassword=='password'"></u-icon>
  28. <u-icon name="eye-off" color="rgb(192, 196, 204)" size="24" @click="passWordStatus(2)" v-else>
  29. </u-icon>
  30. </template>
  31. </u-input>
  32. <u-input v-else class='password' border="none" v-model='password' placeholder="请输入密码,6-16位字符"
  33. type="text" :clearable='true'>
  34. <template slot="suffix">
  35. <u-icon name="eye-fill" color="rgb(192, 196, 204)" size="24" @click="passWordStatus(1)"
  36. v-if="isShowPassword=='password'"></u-icon>
  37. <u-icon name="eye-off" color="rgb(192, 196, 204)" size="24" @click="passWordStatus(2)" v-else>
  38. </u-icon>
  39. </template>
  40. </u-input>
  41. </view>
  42. <button :class='phone!=""&&password!=""?"active":""' @click='passlogin'
  43. class='Regular verificationCode'>登录</button>
  44. <button @click='goregister' class='verificationCode active Regular'>手机号一键注册</button>
  45. <view class='flex' style='color:#6A6A6A;margin-top:10px;'>
  46. <view style='flex:1;text-align:center;border-right:1px solid #E8E9ED;' class="Regular"
  47. @click="forgetpass()">忘记密码</view>
  48. <view @click='gocode' style='flex:1;text-align:center;' class="Regular">验证码登录</view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import {
  56. mapMutations
  57. } from 'vuex';
  58. import {
  59. openFSqlite,
  60. createFSQL,
  61. selectFSQL,
  62. addFSQL
  63. } from '../../util/f.js'
  64. import helper from '@/common/helper.js';
  65. import {
  66. queryData,
  67. upData,
  68. initData
  69. } from '../../util/dbUtil.js'
  70. import {
  71. mapState
  72. } from 'vuex';
  73. export default {
  74. data() {
  75. return {
  76. isShowPassword: 'password',
  77. inputContent: null,
  78. loginType: "wechat",
  79. phone: '',
  80. password: '',
  81. logining: false,
  82. isPhone: false,
  83. isApple: true,
  84. accessToken: '',
  85. params: {
  86. encryptedData: '',
  87. session_key: '',
  88. iv: '',
  89. },
  90. userInfo: {
  91. nickName: '',
  92. avatarUrl: '',
  93. gender: '',
  94. phone: ''
  95. },
  96. type: 'password',
  97. inputStatus: 'none',
  98. verifyCode: null,
  99. sendText: '获取验证码',
  100. sendDisabled: false,
  101. system: '',
  102. platform: '',
  103. userData: undefined,
  104. canIUseProfile: false
  105. }
  106. },
  107. computed: {
  108. ...mapState(['clientId'])
  109. },
  110. onShow() {
  111. // this.loginType = "wechat"
  112. this.$api.logout()
  113. },
  114. onLoad(options) {
  115. if (wx.getUserProfile) {
  116. console.log('--check getUserProfile--OK');
  117. this.canIUseProfile = true;
  118. }
  119. console.log("login on load")
  120. // var that = this
  121. // that.$request.baseRequest('user', 'sendIsApple', {
  122. // }).then(res => {
  123. // that.isApple = res.data
  124. // })
  125. // uni.getSystemInfo({
  126. // success:(res) => {
  127. // // console.log(res)
  128. // this.system = res.system // ios
  129. // this.platform = res.platform // 14.3
  130. // }
  131. // })
  132. },
  133. methods: {
  134. passWordStatus(type) {
  135. if (type == 1) {
  136. this.isShowPassword = 'text'
  137. } else {
  138. this.isShowPassword = 'password'
  139. }
  140. },
  141. passlogin(e) {
  142. var that = this
  143. uni.showLoading({
  144. title: '登录中',
  145. mask: true
  146. })
  147. console.log("clinetId", this.clientId)
  148. that.$request.baseRequest('get', '/commonUser/login', {
  149. phone: this.phone,
  150. password: this.password,
  151. loginFlag: 2
  152. }).then(res => {
  153. if (res.code == 200) {
  154. console.log("userInfo", res.data)
  155. uni.setStorageSync('userInfo', res.data)
  156. that.$request.baseRequest('get', '/newsInfo/unreadMessage', {
  157. reCommonId: this.userInfo.id,
  158. }).then(res3 => {
  159. if (res3.data) {
  160. let name = 'myTip';
  161. let value = res3.data
  162. if (value == 0) {
  163. uni.removeTabBarBadge({
  164. index: 2
  165. })
  166. }
  167. that.$store.commit('$uStore', {
  168. name,
  169. value
  170. });
  171. if (value != 0 && value) {
  172. uni.setTabBarBadge({
  173. index: 2,
  174. text: value + ""
  175. })
  176. }
  177. }
  178. })
  179. that.$request.baseRequest('get', '/driverInfo/firstAuthentication', {
  180. driverPhone: this.phone,
  181. }).then(res2 => {
  182. uni.setStorageSync('pcuserInfo', res.data)
  183. uni.setStorageSync('userInfo', res.data)
  184. uni.setStorageSync('firstAuthentication', res2.data)
  185. helper.getListByUserId()
  186. that.$store.commit('login', res.data)
  187. // that.liangxinLogin()
  188. uni.switchTab({
  189. url: '/pages/goodSource/index'
  190. });
  191. uni.hideLoading()
  192. //
  193. //
  194. })
  195. // that.$request.baseRequest('post', '/commonUser/api/loginQuickly', {
  196. // mobilePhone: this.phone,
  197. // veriCode: "123456",
  198. // loginFlag: 2
  199. // }).then(res1 => {
  200. // console.log("loginQuickly", res)
  201. // if (res1.code == 200) {
  202. // uni.setStorageSync('pcuserInfo', res1.data)
  203. // that.$request.baseRequest('get', '/newsInfo/unreadMessage', {
  204. // reCommonId: this.userInfo.id,
  205. // }).then(res3 => {
  206. // if (res3.data) {
  207. // let name = 'myTip';
  208. // let value = res3.data
  209. // if (value == 0) {
  210. // uni.removeTabBarBadge({
  211. // index: 2
  212. // })
  213. // }
  214. // that.$store.commit('$uStore', {
  215. // name,
  216. // value
  217. // });
  218. // if (value != 0 && value) {
  219. // uni.setTabBarBadge({
  220. // index: 2,
  221. // text: value + ""
  222. // })
  223. // }
  224. // }
  225. // })
  226. // helper.getListByUserId()
  227. // } else {
  228. // that.$request.baseRequest('post', '/commonUser/api/loginQuickly', {
  229. // mobilePhone: '14444444444',
  230. // veriCode: "123456",
  231. // loginFlag: 2
  232. // }).then(res2 => {
  233. // that.$request.baseRequest('get', '/newsInfo/unreadMessage', {
  234. // reCommonId: this.userInfo.id,
  235. // }).then(res3 => {
  236. // if (res3.data) {
  237. // let name = 'myTip';
  238. // let value = res3.data
  239. // if (value == 0) {
  240. // uni.removeTabBarBadge({
  241. // index: 2
  242. // })
  243. // }
  244. // that.$store.commit('$uStore', {
  245. // name,
  246. // value
  247. // });
  248. // if (value != 0 && value) {
  249. // uni.setTabBarBadge({
  250. // index: 2,
  251. // text: value + ""
  252. // })
  253. // }
  254. // }
  255. // })
  256. // uni.setStorageSync('pcuserInfo', res2.data)
  257. // helper.getListByUserId()
  258. // })
  259. // }
  260. // })
  261. that.$store.commit('login', res.data)
  262. var name = 'userInfo';
  263. var value = res.data;
  264. that.$store.commit('$uStore', {
  265. name,
  266. value
  267. });
  268. // that.liangxinLogin()
  269. uni.switchTab({
  270. url: '/pages/goodSource/index'
  271. });
  272. uni.hideLoading()
  273. } else {
  274. uni.hideLoading()
  275. uni.showToast({
  276. title: res.message,
  277. icon: 'none',
  278. duration: 2000
  279. })
  280. }
  281. })
  282. .catch(res => {
  283. uni.$u.toast(res.message);
  284. });
  285. },
  286. gocode() {
  287. uni.navigateTo({
  288. url: '/pages/public/loginOther'
  289. })
  290. },
  291. forgetpass() {
  292. uni.navigateTo({
  293. url: '/pages/mine/settings/editPassword'
  294. })
  295. },
  296. goregister() {
  297. uni.navigateTo({
  298. url: '/pages/public/register'
  299. })
  300. },
  301. ...mapMutations(['login']),
  302. navBack() {
  303. uni.navigateBack();
  304. },
  305. },
  306. }
  307. </script>
  308. <style lang='scss' scoped>
  309. .apple {
  310. background: #000;
  311. width: 35px;
  312. height: 35px;
  313. padding: 8px;
  314. border-radius: 50%;
  315. vertical-align: middle;
  316. }
  317. page {
  318. background: #fff;
  319. }
  320. .close {
  321. width: 20px;
  322. height: 20px;
  323. position: absolute;
  324. right: 0px;
  325. }
  326. .close1 {
  327. width: 20px;
  328. height: 20px;
  329. position: absolute;
  330. right: 10px;
  331. top: 0;
  332. }
  333. .close2 {
  334. width: 15px;
  335. height: 15px;
  336. position: absolute;
  337. right: 19px;
  338. top: 50%;
  339. transform: translateY(-45%);
  340. }
  341. .password {
  342. border: none;
  343. outline: none;
  344. }
  345. .cuIcon-weixin {
  346. background: #2772FB;
  347. color: #fff;
  348. font-size: 18px;
  349. padding: 9px;
  350. border-radius: 50%;
  351. vertical-align: middle;
  352. margin-right: 5px;
  353. }
  354. .container {
  355. /* padding-top: 85px; */
  356. position: relative;
  357. width: 100vw;
  358. height: 100vh;
  359. overflow: hidden;
  360. background: url('~@/static/images/mine/bg@2x.png');
  361. background-size: cover;
  362. }
  363. .wrapper {
  364. position: relative;
  365. z-index: 90;
  366. padding-bottom: 40upx;
  367. height: 100%;
  368. padding: 0 30px;
  369. }
  370. .back-btn {
  371. position: absolute;
  372. left: 40upx;
  373. z-index: 9999;
  374. padding-top: var(--status-bar-height);
  375. top: 40upx;
  376. font-size: 40upx;
  377. color: red;
  378. }
  379. .verificationCode {
  380. margin-top: 20px;
  381. background: #F5F6F9;
  382. color: #AFB3BF;
  383. }
  384. .verificationCode:after {
  385. border: none;
  386. }
  387. .verificationCode.active {
  388. background: #2772FB;
  389. color: #fff;
  390. }
  391. .register {
  392. /* position:absolute; */
  393. bottom: 20px;
  394. left: 50%;
  395. transform: translateX(-50%);
  396. color: #333333;
  397. height: 50px;
  398. line-height: 50px;
  399. border-radius: 30px;
  400. border: 1px solid #444444;
  401. }
  402. .register:after {
  403. border: none;
  404. }
  405. .phone-before-num {
  406. font-size: 34rpx;
  407. color: #333333;
  408. border-right: 1px solid #E8E9ED;
  409. padding-right: 20rpx;
  410. }
  411. .phone-number {
  412. margin-left: 20rpx;
  413. font-size: 34rpx;
  414. font-family: DINPro-Medium, DINPro;
  415. font-weight: 500;
  416. color: #333333;
  417. }
  418. </style>