login.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  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'
  18. placeholder="请输入手机号码" class="phone-number" 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'
  24. v-if="isShowPassword=='password'" placeholder="请输入密码" type="password">
  25. <input maxlength='16' placeholder-style="color:#AFB3BF" class='password' v-model='password' v-else
  26. type="text" placeholder="请输入密码">
  27. <!-- <u-icon name="eye-off" color="rgb(192, 196, 204)" size="24" @click="passWordStatus(2)" v-else>
  28. </u-icon> -->
  29. <image class='yanjingicon' style='width:22px;height:22px;' @click="passWordStatus(1)"
  30. v-if="isShowPassword=='password'" src="../../static/yioncang.png" mode=""></image>
  31. <image class='yanjingicon' style='width:22px;height:22px;' @click="passWordStatus(2)" v-else
  32. src="../../static/xianshi.png" mode=""></image>
  33. </view>
  34. </view>
  35. <button :class='phone!=""&&password!=""?"active":""' @click='passlogin'
  36. class='Regular verificationCode'>登录</button>
  37. <button @click='goregister' class='verificationCode active Regular'>手机号一键注册</button>
  38. <view class='flex' style='color:#6A6A6A;margin-top:10px;'>
  39. <view style='flex:1;text-align:center;border-right:1px solid #E8E9ED;' class="Regular"
  40. @click="forgetpass()">忘记密码</view>
  41. <view @click='gocode' style='flex:1;text-align:center;' class="Regular">验证码登录</view>
  42. </view>
  43. </view>
  44. <u-toast ref="uToast"></u-toast>
  45. <u-modal :show="isShowAlert" :title="alertTitle" :closeOnClickOverlay='true' confirmText='退出登录'
  46. :showCancelButton='true' confirmColor='#2772FB' @confirm="confirmClick" @close="cancelClick"
  47. @cancel="cancelClick"></u-modal>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import {
  53. mapMutations
  54. } from 'vuex';
  55. import {
  56. openFSqlite,
  57. createFSQL,
  58. selectFSQL,
  59. addFSQL
  60. } from '../../util/f.js'
  61. import helper from '@/common/helper.js';
  62. import {
  63. queryData,
  64. upData,
  65. initData
  66. } from '../../util/dbUtil.js'
  67. import {
  68. mapState
  69. } from 'vuex';
  70. //插件对象
  71. var sdkwx = uni.requireNativePlugin('Hdgq-LocSdkWX');
  72. export default {
  73. data() {
  74. return {
  75. isShowAlert: false,
  76. alertTitle: '当前账号已禁用',
  77. isShowPassword: 'password',
  78. inputContent: null,
  79. loginType: "wechat",
  80. phone: '',
  81. password: '',
  82. logining: false,
  83. isPhone: false,
  84. isApple: true,
  85. accessToken: '',
  86. params: {
  87. encryptedData: '',
  88. session_key: '',
  89. iv: '',
  90. },
  91. userInfo: {
  92. nickName: '',
  93. avatarUrl: '',
  94. gender: '',
  95. phone: ''
  96. },
  97. type: 'password',
  98. inputStatus: 'none',
  99. verifyCode: null,
  100. sendText: '获取验证码',
  101. sendDisabled: false,
  102. system: '',
  103. platform: '',
  104. userData: undefined,
  105. canIUseProfile: false,
  106. //定位
  107. shippingNoteInfos: [{
  108. shippingNoteNumber: '',
  109. serialNumber: "",
  110. startCountrySubdivisionCode: "",
  111. endCountrySubdivisionCode: "",
  112. startLongitude: "",
  113. startLatitude: "",
  114. endLongitude: "",
  115. endLatitude: "",
  116. startLocationText: "",
  117. endLocationText: "",
  118. vehicleNumber: "",
  119. driverName: "",
  120. interval: "",
  121. }],
  122. //网络货运信息定位
  123. appId: "", //网络货运企业APP的唯一标识
  124. appSecurity: "", //网络货运企业在省平台申请的接入安全码
  125. enterpriseSenderCode: "23106960", //网络货运企业在省平台申请的企业发送代码
  126. environment: "debug", //环境:“debug”接入测试环境,“release”接入正式环境。
  127. }
  128. },
  129. computed: {
  130. ...mapState(['clientId'])
  131. },
  132. onShow() {
  133. // console.log(uni.$u.test.date('2020-02-29'))
  134. // this.loginType = "wechat"
  135. this.$api.logout()
  136. },
  137. onLoad(options) {
  138. if (wx.getUserProfile) {
  139. console.log('--check getUserProfile--OK');
  140. this.canIUseProfile = true;
  141. }
  142. console.log("login on load")
  143. // var that = this
  144. // that.$request.baseRequest('user', 'sendIsApple', {
  145. // }).then(res => {
  146. // that.isApple = res.data
  147. // })
  148. // uni.getSystemInfo({
  149. // success:(res) => {
  150. // // console.log(res)
  151. // this.system = res.system // ios
  152. // this.platform = res.platform // 14.3
  153. // }
  154. // })
  155. },
  156. methods: {
  157. restart() { //开启定位
  158. var remark = "测试"; //备注
  159. let that = this
  160. sdkwx.restart(this.shippingNoteInfos[0].vehicleNumber, this.shippingNoteInfos[0].driverName, remark, this
  161. .shippingNoteInfos,
  162. function(res) {
  163. if (res.type == "onSuccess") {
  164. //成功
  165. console.log("开启定位成功!!!",res)
  166. var shippingNoteInfos = res.data[0]; //运单信息列表
  167. if (shippingNoteInfos) {
  168. let dateTtime = Number(shippingNoteInfos.interval + 60000)
  169. console.log("开始定时", dateTtime)
  170. that.timer = setInterval(() => {
  171. console.log("定时")
  172. that.send()
  173. }, dateTtime);
  174. }
  175. } else if (res.type == "onFailure") {
  176. //失败
  177. console.log("开启定位失败!!!",res)
  178. var errorCode = res.data.errorCode; //错误码
  179. var errorMsg = res.data.errorMsg; //错误描述
  180. that.timer = setInterval(() => { //失败也需要定时发送定位
  181. console.log("定时")
  182. that.send()
  183. }, 975204); //15分钟
  184. }
  185. });
  186. },
  187. send() { //发送定位
  188. var remark = ""
  189. var that = this
  190. console.log("send参数", this.shippingNoteInfos)
  191. sdkwx.send(this.shippingNoteInfos[0].vehicleNumber, this.shippingNoteInfos[0].driverName, remark, this
  192. .shippingNoteInfos,
  193. function(res) {
  194. if (res.type == "onSuccess") {
  195. console.log("App.vue发送定位成功",res)
  196. var shippingNoteInfos = res.data[0]; //运单信息列表
  197. if (shippingNoteInfos) {
  198. let dateTime = Number(shippingNoteInfos.interval + 60000)
  199. console.log("定时开始", dateTime)
  200. that.timer = setInterval(() => {
  201. that.send()
  202. }, dateTime);
  203. }
  204. } else if (res.type == "onFailure") {
  205. console.log("App.vue发送定位失败", res)
  206. //失败
  207. var errorCode = res.data.errorCode; //错误码
  208. var errorMsg = res.data.errorMsg; //错误描述
  209. that.timer = setInterval(() => { //失败也需要定时上传定位(为了解决频繁调用接口问题)
  210. that.send()
  211. }, 975204);
  212. }
  213. });
  214. },
  215. auth() { //授权
  216. let phoneType = uni.getSystemInfoSync().platform //判断手机类型
  217. if (phoneType == "android") {
  218. this.appId = "uni.UNI9C76CB6"
  219. this.appSecurity = "24c593b7037347e08857a6ab05fd231b0509f5bb7cb741078f524f506ad32db8"
  220. } else if (phoneType == "ios") {
  221. this.appId = "uni.UNIDCD13AC"
  222. this.appSecurity = "b01e4805276646eeb25f0fad91de97a4f32e8c2c0e0d42e5b24cc4737e9f040f"
  223. }
  224. console.log("授权")
  225. let that = this
  226. sdkwx.auth(this.appId, this.appSecurity, this.enterpriseSenderCode, this.environment, function(res) {
  227. if (res.type == "onSuccess") {
  228. //成功
  229. if (res.data.length > 0) {
  230. that.restart()
  231. }
  232. console.log("授权成功",res)
  233. } else if (res.type == "onFailure") {
  234. //失败
  235. var errorCode = res.data.errorCode; //错误码
  236. var errorMsg = res.data.errorMsg; //错误描述
  237. console.log("授权失败","没有可定位的订单")
  238. console.log(res)
  239. }
  240. // uni.showModal({
  241. // content: JSON.stringify(res)
  242. // });
  243. });
  244. },
  245. passWordStatus(type) {
  246. if (type == 1) {
  247. this.isShowPassword = 'text'
  248. } else {
  249. this.isShowPassword = 'password'
  250. }
  251. },
  252. cancelClick() {
  253. this.isShowAlert = false
  254. },
  255. confirmClick() {
  256. if (uni.getSystemInfoSync().platform == 'ios') {
  257. plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
  258. } else if (uni.getSystemInfoSync().platform == 'android') {
  259. plus.runtime.quit();
  260. }
  261. },
  262. passlogin(e) {
  263. var that = this
  264. if (this.phone == '') {
  265. that.$refs.uToast.show({
  266. type: 'error',
  267. message: "请输入手机号!"
  268. })
  269. return
  270. }
  271. if (this.password == '') {
  272. that.$refs.uToast.show({
  273. type: 'error',
  274. message: "请输入密码!"
  275. })
  276. return
  277. }
  278. that.$request.baseRequest('get', '/driverInfo/firstAuthentication', {
  279. driverPhone: this.phone,
  280. }).then(res => {
  281. if (res.data.authenticationStatus == '已禁用') {
  282. that.$refs.uToast.show({
  283. type: 'error',
  284. message: "账号审核中!"
  285. })
  286. } else {
  287. uni.showLoading({
  288. title: '登录中',
  289. mask: true
  290. })
  291. console.log("clinetId", this.clientId)
  292. that.$request.baseRequest('get', '/commonUser/login', {
  293. phone: that.phone,
  294. password: that.password,
  295. loginFlag: 2,
  296. identification: 1
  297. }, 'application/x-www-form-urlencoded').then(res => {
  298. if (res.code == 200) {
  299. // uni.setStorageSync("shiro",encodeURIComponent(`ws_login_companyShortName=
  300. // '黑龙江中天昊元贸易有限公司'; ws_login_rememberMe=1; ws_login_account=${that.phone}; ws_login_pwd=${that.password}; shiro.session=65500189-7bb5-457f-9ff6-0db069150e78`)
  301. uni.setStorageSync('userInfo', res.data)
  302. // uni.setStorageSync("shiro",res.header['Set-Cookie'])
  303. that.$request.baseRequest('get', '/newsInfo/unreadMessage', {
  304. reCommonId: that.userInfo.id,
  305. }).then(res3 => {
  306. if (res3.data) {
  307. let name = 'myTip';
  308. let value = res3.data
  309. if (value == 0) {
  310. uni.removeTabBarBadge({
  311. index: 2
  312. })
  313. }
  314. that.$store.commit('$uStore', {
  315. name,
  316. value
  317. });
  318. if (value != 0 && value) {
  319. uni.setTabBarBadge({
  320. index: 2,
  321. text: value + ""
  322. })
  323. }
  324. }
  325. })
  326. that.$request.baseRequest('get', '/orderInfo/getData', {
  327. commonId: uni.getStorageSync('userInfo').id,
  328. }).then(res1 => {
  329. if (res1.data.length > 0) {
  330. that.shippingNoteInfos[0].shippingNoteNumber = res1.data[0].orderNo //运单号
  331. that.shippingNoteInfos[0].serialNumber = "0000" //分单号
  332. that.shippingNoteInfos[0].startCountrySubdivisionCode = res1.data[0]
  333. .sendAdCode //起点位置行政区划代码,调 用 start/stop/pause/restart 时 必填,调用 send 非必填
  334. that.shippingNoteInfos[0].endCountrySubdivisionCode = res1.data[0]
  335. .unsendAdCode //到达位置行政区划代码,调 用 start/stop/pause/restart 时 必填,调用 send 非必填
  336. that.shippingNoteInfos[0].startLongitude = res1.data[0]
  337. .sendLongitude //起点位置经度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  338. that.shippingNoteInfos[0].startLatitude = res1.data[0]
  339. .sendLatitude //起点位置纬度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  340. that.shippingNoteInfos[0].endLongitude = res1.data[0]
  341. .unsendLongitude //到达位置经度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  342. that.shippingNoteInfos[0].endLatitude = res1.data[0]
  343. .unsendLatitude //到达位置纬度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  344. that.shippingNoteInfos[0].driverName = res1.data[0]
  345. .driverName //司机姓名,SDK 回调返回, 调用 start/stop/pause/restart/ 必填,send 时非必填
  346. that.shippingNoteInfos[0].vehicleNumber = res1.data[0]
  347. .carNumber //车牌号,SDK 回调返回,调 用 start/stop/pause/restart/必 填,send 时非必填
  348. that.shippingNoteInfos[0].startLocationText = res1.data[0]
  349. .sendCity //起点地址文字描述,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  350. that.shippingNoteInfos[0].endLocationText = res1.data[0]
  351. .unloadCity //到达地址文字描述,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  352. that.shippingNoteInfos[0].interval = "5000"
  353. console.log("查看参数", that.shippingNoteInfos)
  354. that.auth()
  355. that.$helper.fUN_AmapLocation.start({
  356. intervalTime: 5000,
  357. isReport: false
  358. },
  359. res => {
  360. // console.log('====确认装车开启连续定位====');
  361. // console.log(res)
  362. let _data = {
  363. orderId: res1.data[0].id,
  364. longitude: res.longitude,
  365. latitude: res.latitude,
  366. province: res.province,
  367. city: res.city,
  368. area: res.district
  369. }
  370. that.$helper.gjList.push(_data)
  371. uni.setStorageSync('mapGJ', that.$helper
  372. .gjList);
  373. // console.log('this.$helper.gjList')
  374. // console.log(this.$helper.gjList)
  375. // console.log("条数", uni.getStorageSync('mapGJ').length)
  376. if (uni.getStorageSync('mapGJ').length > 100) {
  377. // console.log(JSON.stringify(uni
  378. // .getStorageSync('mapGJ')))
  379. that.$request.baseRequest('post',
  380. '/hyOrderTravelPath/api/addInfo', {
  381. orderId: "cdae6ec34c2349768c490a9fefa03fb3",
  382. longitudeLatitude: JSON
  383. .stringify(uni
  384. .getStorageSync(
  385. 'mapGJ'))
  386. }).then(res => {
  387. uni.removeStorageSync('mapGJ');
  388. that.$helper.gjList = []
  389. })
  390. .catch(res => {
  391. uni.$u.toast(res.message);
  392. });
  393. }
  394. //判断缓存数据条数,超过reportInterval时清空缓存,重新存入缓存
  395. }
  396. );
  397. }
  398. })
  399. that.$request.baseRequest('get', '/driverInfo/firstAuthentication', {
  400. driverPhone: this.phone,
  401. }).then(res2 => {
  402. if (res.data.statusFlag == '已禁用') {
  403. this.isShowAlert = true
  404. uni.hideLoading()
  405. return
  406. }
  407. uni.setStorageSync('pcuserInfo', res.data)
  408. uni.setStorageSync('userInfo', res.data)
  409. uni.setStorageSync('firstAuthentication', res2.data)
  410. helper.getListByUserId()
  411. that.$store.commit('login', res.data)
  412. var name = 'userInfo';
  413. var value = res.data;
  414. that.$store.commit('$uStore', {
  415. name,
  416. value
  417. });
  418. uni.switchTab({
  419. url: '/pages/goodSource/index'
  420. });
  421. uni.hideLoading()
  422. uni.switchTab({
  423. url: '/pages/goodSource/index'
  424. });
  425. uni.hideLoading()
  426. })
  427. } else {
  428. uni.hideLoading()
  429. uni.showToast({
  430. title: res.message,
  431. icon: 'none',
  432. duration: 2000
  433. })
  434. }
  435. })
  436. .catch(res => {
  437. uni.$u.toast(res.message);
  438. });
  439. }
  440. })
  441. },
  442. gocode() {
  443. uni.navigateTo({
  444. url: '/pages/public/loginOther'
  445. })
  446. },
  447. forgetpass() {
  448. uni.navigateTo({
  449. url: '/pages/mine/settings/editPassword'
  450. })
  451. },
  452. goregister() {
  453. uni.navigateTo({
  454. url: '/pages/public/register'
  455. })
  456. },
  457. ...mapMutations(['login']),
  458. navBack() {
  459. uni.navigateBack();
  460. },
  461. },
  462. }
  463. </script>
  464. <style lang='scss' scoped>
  465. .apple {
  466. background: #000;
  467. width: 35px;
  468. height: 35px;
  469. padding: 8px;
  470. border-radius: 50%;
  471. vertical-align: middle;
  472. }
  473. page {
  474. background: #fff;
  475. }
  476. .yanjingicon {
  477. position: absolute;
  478. right: 0;
  479. top: 50%;
  480. transform: translate(-50%, -50%);
  481. }
  482. .close {
  483. width: 20px;
  484. height: 20px;
  485. position: absolute;
  486. right: 0px;
  487. }
  488. .close1 {
  489. width: 20px;
  490. height: 20px;
  491. position: absolute;
  492. right: 10px;
  493. top: 0;
  494. }
  495. .close2 {
  496. width: 15px;
  497. height: 15px;
  498. position: absolute;
  499. right: 19px;
  500. top: 50%;
  501. transform: translateY(-45%);
  502. }
  503. .password {
  504. border: none;
  505. outline: none;
  506. }
  507. .cuIcon-weixin {
  508. background: #2772FB;
  509. color: #fff;
  510. font-size: 18px;
  511. padding: 9px;
  512. border-radius: 50%;
  513. vertical-align: middle;
  514. margin-right: 5px;
  515. }
  516. .container {
  517. /* padding-top: 85px; */
  518. position: relative;
  519. width: 100vw;
  520. height: 100vh;
  521. overflow: hidden;
  522. background: url('~@/static/images/mine/bg@2x.png');
  523. background-size: cover;
  524. }
  525. .wrapper {
  526. position: relative;
  527. z-index: 90;
  528. padding-bottom: 40upx;
  529. height: 100%;
  530. padding: 0 30px;
  531. }
  532. .back-btn {
  533. position: absolute;
  534. left: 40upx;
  535. z-index: 9999;
  536. padding-top: var(--status-bar-height);
  537. top: 40upx;
  538. font-size: 40upx;
  539. color: red;
  540. }
  541. .verificationCode {
  542. margin-top: 20px;
  543. background: #F5F6F9;
  544. color: #AFB3BF;
  545. }
  546. .verificationCode:after {
  547. border: none;
  548. }
  549. .verificationCode.active {
  550. background: #2772FB;
  551. color: #fff;
  552. }
  553. .register {
  554. /* position:absolute; */
  555. bottom: 20px;
  556. left: 50%;
  557. transform: translateX(-50%);
  558. color: #333333;
  559. height: 50px;
  560. line-height: 50px;
  561. border-radius: 30px;
  562. border: 1px solid #444444;
  563. }
  564. .register:after {
  565. border: none;
  566. }
  567. .phone-before-num {
  568. font-size: 34rpx;
  569. color: #333333;
  570. border-right: 1px solid #E8E9ED;
  571. padding-right: 20rpx;
  572. }
  573. .phone-number {
  574. margin-left: 20rpx;
  575. font-size: 34rpx;
  576. font-family: DINPro-Medium, DINPro;
  577. font-weight: 500;
  578. color: #333333;
  579. }
  580. </style>