login.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  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].orderNo //运单号
  347. that.shippingNoteInfos[0].serialNumber = "0000" //分单号
  348. that.shippingNoteInfos[0].startCountrySubdivisionCode = res1.data[0]
  349. .sendAdCode //起点位置行政区划代码,调 用 start/stop/pause/restart 时 必填,调用 send 非必填
  350. that.shippingNoteInfos[0].endCountrySubdivisionCode = res1.data[0]
  351. .unsendAdCode //到达位置行政区划代码,调 用 start/stop/pause/restart 时 必填,调用 send 非必填
  352. that.shippingNoteInfos[0].startLongitude = res1.data[0]
  353. .sendLongitude //起点位置经度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  354. that.shippingNoteInfos[0].startLatitude = res1.data[0]
  355. .sendLatitude //起点位置纬度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  356. that.shippingNoteInfos[0].endLongitude = res1.data[0]
  357. .unsendLongitude //到达位置经度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  358. that.shippingNoteInfos[0].endLatitude = res1.data[0]
  359. .unsendLatitude //到达位置纬度,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  360. that.shippingNoteInfos[0].driverName = res1.data[0]
  361. .driverName //司机姓名,SDK 回调返回, 调用 start/stop/pause/restart/ 必填,send 时非必填
  362. that.shippingNoteInfos[0].vehicleNumber = res1.data[0]
  363. .carNumber //车牌号,SDK 回调返回,调 用 start/stop/pause/restart/必 填,send 时非必填
  364. that.shippingNoteInfos[0].startLocationText = res1.data[0]
  365. .sendCity //起点地址文字描述,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  366. that.shippingNoteInfos[0].endLocationText = res1.data[0]
  367. .unloadCity //到达地址文字描述,调用 start/stop/pause/restart 时必 填,调用 send 非必填
  368. that.shippingNoteInfos[0].interval = "5000"
  369. console.log("查看参数", that.shippingNoteInfos)
  370. that.auth()
  371. that.$helper.fUN_AmapLocation.start({
  372. intervalTime: 5000,
  373. isReport: false
  374. },
  375. res => {
  376. // console.log('====确认装车开启连续定位====');
  377. // console.log(res)
  378. let _data = {
  379. orderId: res1.data[0].id,
  380. longitude: res.longitude,
  381. latitude: res.latitude,
  382. province: res.province,
  383. city: res.city,
  384. area: res.district
  385. }
  386. that.$helper.gjList.push(_data)
  387. uni.setStorageSync('mapGJ', that.$helper
  388. .gjList);
  389. // console.log('this.$helper.gjList')
  390. // console.log(this.$helper.gjList)
  391. // console.log("条数", uni.getStorageSync('mapGJ').length)
  392. if (uni.getStorageSync('mapGJ').length > 100) {
  393. // console.log(JSON.stringify(uni
  394. // .getStorageSync('mapGJ')))
  395. that.$request.baseRequest('post',
  396. '/hyOrderTravelPath/api/addInfo', {
  397. orderId: "cdae6ec34c2349768c490a9fefa03fb3",
  398. longitudeLatitude: JSON
  399. .stringify(uni
  400. .getStorageSync(
  401. 'mapGJ'))
  402. }).then(res => {
  403. uni.removeStorageSync('mapGJ');
  404. that.$helper.gjList = []
  405. })
  406. .catch(res => {
  407. uni.$u.toast(res.message);
  408. });
  409. }
  410. //判断缓存数据条数,超过reportInterval时清空缓存,重新存入缓存
  411. }
  412. );
  413. }
  414. })
  415. that.$request.baseRequest('get', '/driverInfo/firstAuthentication', {
  416. driverPhone: this.phone,
  417. }).then(res2 => {
  418. if (res.data.statusFlag == '已禁用') {
  419. this.isShowAlert = true
  420. uni.hideLoading()
  421. return
  422. }
  423. uni.setStorageSync('pcuserInfo', res.data)
  424. uni.setStorageSync('userInfo', res.data)
  425. uni.setStorageSync('firstAuthentication', res2.data)
  426. helper.getListByUserId()
  427. that.$store.commit('login', res.data)
  428. var name = 'userInfo';
  429. var value = res.data;
  430. that.$store.commit('$uStore', {
  431. name,
  432. value
  433. });
  434. uni.switchTab({
  435. url: '/pages/goodSource/index'
  436. });
  437. uni.hideLoading()
  438. uni.switchTab({
  439. url: '/pages/goodSource/index'
  440. });
  441. uni.hideLoading()
  442. })
  443. } else {
  444. uni.hideLoading()
  445. uni.showToast({
  446. title: res.message,
  447. icon: 'none',
  448. duration: 2000
  449. })
  450. }
  451. })
  452. .catch(res => {
  453. uni.$u.toast(res.message);
  454. });
  455. }
  456. })
  457. },
  458. gocode() {
  459. uni.navigateTo({
  460. url: '/pages/public/loginOther'
  461. })
  462. },
  463. forgetpass() {
  464. uni.navigateTo({
  465. url: '/pages/mine/settings/editPassword'
  466. })
  467. },
  468. goregister() {
  469. uni.navigateTo({
  470. url: '/pages/public/register'
  471. })
  472. },
  473. ...mapMutations(['login']),
  474. navBack() {
  475. uni.navigateBack();
  476. },
  477. },
  478. }
  479. </script>
  480. <style lang='scss' scoped>
  481. .apple {
  482. background: #000;
  483. width: 35px;
  484. height: 35px;
  485. padding: 8px;
  486. border-radius: 50%;
  487. vertical-align: middle;
  488. }
  489. page {
  490. background: #fff;
  491. }
  492. .yanjingicon {
  493. position: absolute;
  494. right: 0;
  495. top: 50%;
  496. transform: translate(-50%, -50%);
  497. }
  498. .close {
  499. width: 20px;
  500. height: 20px;
  501. position: absolute;
  502. right: 0px;
  503. }
  504. .close1 {
  505. width: 20px;
  506. height: 20px;
  507. position: absolute;
  508. right: 10px;
  509. top: 0;
  510. }
  511. .close2 {
  512. width: 15px;
  513. height: 15px;
  514. position: absolute;
  515. right: 19px;
  516. top: 50%;
  517. transform: translateY(-45%);
  518. }
  519. .password {
  520. border: none;
  521. outline: none;
  522. }
  523. .cuIcon-weixin {
  524. background: #2772FB;
  525. color: #fff;
  526. font-size: 18px;
  527. padding: 9px;
  528. border-radius: 50%;
  529. vertical-align: middle;
  530. margin-right: 5px;
  531. }
  532. .container {
  533. /* padding-top: 85px; */
  534. position: relative;
  535. width: 100vw;
  536. height: 100vh;
  537. overflow: hidden;
  538. background: url('~@/static/images/mine/bg@2x.png');
  539. background-size: cover;
  540. }
  541. .wrapper {
  542. position: relative;
  543. z-index: 90;
  544. padding-bottom: 40upx;
  545. height: 100%;
  546. padding: 0 30px;
  547. }
  548. .back-btn {
  549. position: absolute;
  550. left: 40upx;
  551. z-index: 9999;
  552. padding-top: var(--status-bar-height);
  553. top: 40upx;
  554. font-size: 40upx;
  555. color: red;
  556. }
  557. .verificationCode {
  558. margin-top: 20px;
  559. background: #F5F6F9;
  560. color: #AFB3BF;
  561. }
  562. .verificationCode:after {
  563. border: none;
  564. }
  565. .verificationCode.active {
  566. background: #2772FB;
  567. color: #fff;
  568. }
  569. .register {
  570. /* position:absolute; */
  571. bottom: 20px;
  572. left: 50%;
  573. transform: translateX(-50%);
  574. color: #333333;
  575. height: 50px;
  576. line-height: 50px;
  577. border-radius: 30px;
  578. border: 1px solid #444444;
  579. }
  580. .register:after {
  581. border: none;
  582. }
  583. .phone-before-num {
  584. font-size: 34rpx;
  585. color: #333333;
  586. border-right: 1px solid #E8E9ED;
  587. padding-right: 20rpx;
  588. }
  589. .phone-number {
  590. margin-left: 20rpx;
  591. font-size: 34rpx;
  592. font-family: DINPro-Medium, DINPro;
  593. font-weight: 500;
  594. color: #333333;
  595. }
  596. </style>