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