login.vue 19 KB

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