login.vue 19 KB

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