login.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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. <u-modal :show="isShowAlert" :title="alertTitle" :closeOnClickOverlay='true' confirmText='退出登录' :showCancelButton='true' confirmColor='#2772FB' @confirm="confirmClick" @close="cancelClick" @cancel="cancelClick"></u-modal>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. import {
  57. mapMutations
  58. } from 'vuex';
  59. import {
  60. openFSqlite,
  61. createFSQL,
  62. selectFSQL,
  63. addFSQL
  64. } from '../../util/f.js'
  65. import helper from '@/common/helper.js';
  66. import {
  67. queryData,
  68. upData,
  69. initData
  70. } from '../../util/dbUtil.js'
  71. import {
  72. mapState
  73. } from 'vuex';
  74. export default {
  75. data() {
  76. return {
  77. isShowAlert:false,
  78. alertTitle:'当前账号已禁用',
  79. isShowPassword: 'password',
  80. inputContent: null,
  81. loginType: "wechat",
  82. phone: '',
  83. password: '',
  84. logining: false,
  85. isPhone: false,
  86. isApple: true,
  87. accessToken: '',
  88. params: {
  89. encryptedData: '',
  90. session_key: '',
  91. iv: '',
  92. },
  93. userInfo: {
  94. nickName: '',
  95. avatarUrl: '',
  96. gender: '',
  97. phone: ''
  98. },
  99. type: 'password',
  100. inputStatus: 'none',
  101. verifyCode: null,
  102. sendText: '获取验证码',
  103. sendDisabled: false,
  104. system: '',
  105. platform: '',
  106. userData: undefined,
  107. canIUseProfile: false
  108. }
  109. },
  110. computed: {
  111. ...mapState(['clientId'])
  112. },
  113. onShow() {
  114. // this.loginType = "wechat"
  115. this.$api.logout()
  116. },
  117. onLoad(options) {
  118. if (wx.getUserProfile) {
  119. console.log('--check getUserProfile--OK');
  120. this.canIUseProfile = true;
  121. }
  122. console.log("login on load")
  123. // var that = this
  124. // that.$request.baseRequest('user', 'sendIsApple', {
  125. // }).then(res => {
  126. // that.isApple = res.data
  127. // })
  128. // uni.getSystemInfo({
  129. // success:(res) => {
  130. // // console.log(res)
  131. // this.system = res.system // ios
  132. // this.platform = res.platform // 14.3
  133. // }
  134. // })
  135. },
  136. methods: {
  137. passWordStatus(type) {
  138. if (type == 1) {
  139. this.isShowPassword = 'text'
  140. } else {
  141. this.isShowPassword = 'password'
  142. }
  143. },
  144. cancelClick(){
  145. this.isShowAlert = false
  146. },
  147. confirmClick(){
  148. if (uni.getSystemInfoSync().platform == 'ios'){
  149. plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
  150. } else if (uni.getSystemInfoSync().platform == 'android'){
  151. plus.runtime.quit();
  152. }
  153. },
  154. passlogin(e) {
  155. var that = this
  156. uni.showLoading({
  157. title: '登录中',
  158. mask: true
  159. })
  160. console.log("clinetId", this.clientId)
  161. that.$request.baseRequest('get', '/commonUser/login', {
  162. phone: this.phone,
  163. password: this.password,
  164. loginFlag: 2,
  165. identification: 1
  166. }).then(res => {
  167. if (res.code == 200) {
  168. console.log("userInfo", res.data)
  169. uni.setStorageSync('userInfo', res.data)
  170. that.$request.baseRequest('get', '/newsInfo/unreadMessage', {
  171. reCommonId: this.userInfo.id,
  172. }).then(res3 => {
  173. if (res3.data) {
  174. let name = 'myTip';
  175. let value = res3.data
  176. if (value == 0) {
  177. uni.removeTabBarBadge({
  178. index: 2
  179. })
  180. }
  181. that.$store.commit('$uStore', {
  182. name,
  183. value
  184. });
  185. if (value != 0 && value) {
  186. uni.setTabBarBadge({
  187. index: 2,
  188. text: value + ""
  189. })
  190. }
  191. }
  192. })
  193. that.$request.baseRequest('get', '/driverInfo/firstAuthentication', {
  194. driverPhone: this.phone,
  195. }).then(res2 => {
  196. if(res.data.statusFlag=='已禁用'){
  197. this.isShowAlert = true
  198. uni.hideLoading()
  199. return
  200. }
  201. uni.setStorageSync('pcuserInfo', res.data)
  202. uni.setStorageSync('userInfo', res.data)
  203. uni.setStorageSync('firstAuthentication', res2.data)
  204. helper.getListByUserId()
  205. that.$store.commit('login', res.data)
  206. var name = 'userInfo';
  207. var value = res.data;
  208. that.$store.commit('$uStore', {
  209. name,
  210. value
  211. });
  212. uni.switchTab({
  213. url: '/pages/goodSource/index'
  214. });
  215. uni.hideLoading()
  216. uni.switchTab({
  217. url: '/pages/goodSource/index'
  218. });
  219. uni.hideLoading()
  220. })
  221. } else {
  222. uni.hideLoading()
  223. uni.showToast({
  224. title: res.message,
  225. icon: 'none',
  226. duration: 2000
  227. })
  228. }
  229. })
  230. .catch(res => {
  231. uni.$u.toast(res.message);
  232. });
  233. },
  234. gocode() {
  235. uni.navigateTo({
  236. url: '/pages/public/loginOther'
  237. })
  238. },
  239. forgetpass() {
  240. uni.navigateTo({
  241. url: '/pages/mine/settings/editPassword'
  242. })
  243. },
  244. goregister() {
  245. uni.navigateTo({
  246. url: '/pages/public/register'
  247. })
  248. },
  249. ...mapMutations(['login']),
  250. navBack() {
  251. uni.navigateBack();
  252. },
  253. },
  254. }
  255. </script>
  256. <style lang='scss' scoped>
  257. .apple {
  258. background: #000;
  259. width: 35px;
  260. height: 35px;
  261. padding: 8px;
  262. border-radius: 50%;
  263. vertical-align: middle;
  264. }
  265. page {
  266. background: #fff;
  267. }
  268. .close {
  269. width: 20px;
  270. height: 20px;
  271. position: absolute;
  272. right: 0px;
  273. }
  274. .close1 {
  275. width: 20px;
  276. height: 20px;
  277. position: absolute;
  278. right: 10px;
  279. top: 0;
  280. }
  281. .close2 {
  282. width: 15px;
  283. height: 15px;
  284. position: absolute;
  285. right: 19px;
  286. top: 50%;
  287. transform: translateY(-45%);
  288. }
  289. .password {
  290. border: none;
  291. outline: none;
  292. }
  293. .cuIcon-weixin {
  294. background: #2772FB;
  295. color: #fff;
  296. font-size: 18px;
  297. padding: 9px;
  298. border-radius: 50%;
  299. vertical-align: middle;
  300. margin-right: 5px;
  301. }
  302. .container {
  303. /* padding-top: 85px; */
  304. position: relative;
  305. width: 100vw;
  306. height: 100vh;
  307. overflow: hidden;
  308. background: url('~@/static/images/mine/bg@2x.png');
  309. background-size: cover;
  310. }
  311. .wrapper {
  312. position: relative;
  313. z-index: 90;
  314. padding-bottom: 40upx;
  315. height: 100%;
  316. padding: 0 30px;
  317. }
  318. .back-btn {
  319. position: absolute;
  320. left: 40upx;
  321. z-index: 9999;
  322. padding-top: var(--status-bar-height);
  323. top: 40upx;
  324. font-size: 40upx;
  325. color: red;
  326. }
  327. .verificationCode {
  328. margin-top: 20px;
  329. background: #F5F6F9;
  330. color: #AFB3BF;
  331. }
  332. .verificationCode:after {
  333. border: none;
  334. }
  335. .verificationCode.active {
  336. background: #2772FB;
  337. color: #fff;
  338. }
  339. .register {
  340. /* position:absolute; */
  341. bottom: 20px;
  342. left: 50%;
  343. transform: translateX(-50%);
  344. color: #333333;
  345. height: 50px;
  346. line-height: 50px;
  347. border-radius: 30px;
  348. border: 1px solid #444444;
  349. }
  350. .register:after {
  351. border: none;
  352. }
  353. .phone-before-num {
  354. font-size: 34rpx;
  355. color: #333333;
  356. border-right: 1px solid #E8E9ED;
  357. padding-right: 20rpx;
  358. }
  359. .phone-number {
  360. margin-left: 20rpx;
  361. font-size: 34rpx;
  362. font-family: DINPro-Medium, DINPro;
  363. font-weight: 500;
  364. color: #333333;
  365. }
  366. </style>