login.vue 12 KB

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