login.vue 19 KB

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