login.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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) {debugger
  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. }).then(res => {
  166. if (res.code == 200) {
  167. console.log("userInfo", res.data)
  168. uni.setStorageSync('userInfo', res.data)
  169. that.$request.baseRequest('get', '/newsInfo/unreadMessage', {
  170. reCommonId: this.userInfo.id,
  171. }).then(res3 => {
  172. if (res3.data) {
  173. let name = 'myTip';
  174. let value = res3.data
  175. if (value == 0) {
  176. uni.removeTabBarBadge({
  177. index: 2
  178. })
  179. }
  180. that.$store.commit('$uStore', {
  181. name,
  182. value
  183. });
  184. if (value != 0 && value) {
  185. uni.setTabBarBadge({
  186. index: 2,
  187. text: value + ""
  188. })
  189. }
  190. }
  191. })
  192. that.$request.baseRequest('get', '/driverInfo/firstAuthentication', {
  193. driverPhone: this.phone,
  194. }).then(res2 => {
  195. if(res.data.statusFlag=='已禁用'){
  196. this.isShowAlert = true
  197. uni.hideLoading()
  198. return
  199. }
  200. uni.setStorageSync('pcuserInfo', res.data)
  201. uni.setStorageSync('userInfo', res.data)
  202. uni.setStorageSync('firstAuthentication', res2.data)
  203. helper.getListByUserId()
  204. that.$store.commit('login', res.data)
  205. var name = 'userInfo';
  206. var value = res.data;
  207. that.$store.commit('$uStore', {
  208. name,
  209. value
  210. });
  211. uni.switchTab({
  212. url: '/pages/goodSource/index'
  213. });
  214. uni.hideLoading()
  215. uni.switchTab({
  216. url: '/pages/goodSource/index'
  217. });
  218. uni.hideLoading()
  219. })
  220. } else {
  221. uni.hideLoading()
  222. uni.showToast({
  223. title: res.message,
  224. icon: 'none',
  225. duration: 2000
  226. })
  227. }
  228. })
  229. .catch(res => {
  230. uni.$u.toast(res.message);
  231. });
  232. },
  233. gocode() {
  234. uni.navigateTo({
  235. url: '/pages/public/loginOther'
  236. })
  237. },
  238. forgetpass() {
  239. uni.navigateTo({
  240. url: '/pages/mine/settings/editPassword'
  241. })
  242. },
  243. goregister() {
  244. uni.navigateTo({
  245. url: '/pages/public/register'
  246. })
  247. },
  248. ...mapMutations(['login']),
  249. navBack() {
  250. uni.navigateBack();
  251. },
  252. },
  253. }
  254. </script>
  255. <style lang='scss' scoped>
  256. .apple {
  257. background: #000;
  258. width: 35px;
  259. height: 35px;
  260. padding: 8px;
  261. border-radius: 50%;
  262. vertical-align: middle;
  263. }
  264. page {
  265. background: #fff;
  266. }
  267. .close {
  268. width: 20px;
  269. height: 20px;
  270. position: absolute;
  271. right: 0px;
  272. }
  273. .close1 {
  274. width: 20px;
  275. height: 20px;
  276. position: absolute;
  277. right: 10px;
  278. top: 0;
  279. }
  280. .close2 {
  281. width: 15px;
  282. height: 15px;
  283. position: absolute;
  284. right: 19px;
  285. top: 50%;
  286. transform: translateY(-45%);
  287. }
  288. .password {
  289. border: none;
  290. outline: none;
  291. }
  292. .cuIcon-weixin {
  293. background: #2772FB;
  294. color: #fff;
  295. font-size: 18px;
  296. padding: 9px;
  297. border-radius: 50%;
  298. vertical-align: middle;
  299. margin-right: 5px;
  300. }
  301. .container {
  302. /* padding-top: 85px; */
  303. position: relative;
  304. width: 100vw;
  305. height: 100vh;
  306. overflow: hidden;
  307. background: url('~@/static/images/mine/bg@2x.png');
  308. background-size: cover;
  309. }
  310. .wrapper {
  311. position: relative;
  312. z-index: 90;
  313. padding-bottom: 40upx;
  314. height: 100%;
  315. padding: 0 30px;
  316. }
  317. .back-btn {
  318. position: absolute;
  319. left: 40upx;
  320. z-index: 9999;
  321. padding-top: var(--status-bar-height);
  322. top: 40upx;
  323. font-size: 40upx;
  324. color: red;
  325. }
  326. .verificationCode {
  327. margin-top: 20px;
  328. background: #F5F6F9;
  329. color: #AFB3BF;
  330. }
  331. .verificationCode:after {
  332. border: none;
  333. }
  334. .verificationCode.active {
  335. background: #2772FB;
  336. color: #fff;
  337. }
  338. .register {
  339. /* position:absolute; */
  340. bottom: 20px;
  341. left: 50%;
  342. transform: translateX(-50%);
  343. color: #333333;
  344. height: 50px;
  345. line-height: 50px;
  346. border-radius: 30px;
  347. border: 1px solid #444444;
  348. }
  349. .register:after {
  350. border: none;
  351. }
  352. .phone-before-num {
  353. font-size: 34rpx;
  354. color: #333333;
  355. border-right: 1px solid #E8E9ED;
  356. padding-right: 20rpx;
  357. }
  358. .phone-number {
  359. margin-left: 20rpx;
  360. font-size: 34rpx;
  361. font-family: DINPro-Medium, DINPro;
  362. font-weight: 500;
  363. color: #333333;
  364. }
  365. </style>