login.vue 12 KB

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