login.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  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' placeholder="请输入手机号码" class="phone-number"
  18. 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' v-if="isShowPassword=='password'" placeholder="请输入密码" type="password">
  24. <input placeholder-style="color:#AFB3BF" class='password' v-model='password' v-else type="text" placeholder="请输入密码">
  25. <u-icon name="eye-fill" color="rgb(192, 196, 204)" size="24" @click="passWordStatus(1)"
  26. v-if="isShowPassword=='password'"></u-icon>
  27. <u-icon name="eye-off" color="rgb(192, 196, 204)" size="24" @click="passWordStatus(2)" v-else>
  28. </u-icon>
  29. </view>
  30. </view>
  31. <button :class='phone!=""&&password!=""?"active":""' @click='passlogin'
  32. class='Regular verificationCode'>登录</button>
  33. <button @click='goregister' class='verificationCode active Regular'>手机号一键注册</button>
  34. <view class='flex' style='color:#6A6A6A;margin-top:10px;'>
  35. <view style='flex:1;text-align:center;border-right:1px solid #E8E9ED;' class="Regular"
  36. @click="forgetpass()">忘记密码</view>
  37. <view @click='gocode' style='flex:1;text-align:center;' class="Regular">验证码登录</view>
  38. </view>
  39. </view>
  40. <u-modal :show="isShowAlert" :title="alertTitle" :closeOnClickOverlay='true' confirmText='退出登录' :showCancelButton='true' confirmColor='#2772FB' @confirm="confirmClick" @close="cancelClick" @cancel="cancelClick"></u-modal>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import {
  46. mapMutations
  47. } from 'vuex';
  48. import {
  49. openFSqlite,
  50. createFSQL,
  51. selectFSQL,
  52. addFSQL
  53. } from '../../util/f.js'
  54. import helper from '@/common/helper.js';
  55. import {
  56. queryData,
  57. upData,
  58. initData
  59. } from '../../util/dbUtil.js'
  60. import {
  61. mapState
  62. } from 'vuex';
  63. export default {
  64. data() {
  65. return {
  66. isShowAlert:false,
  67. alertTitle:'当前账号已禁用',
  68. isShowPassword: 'password',
  69. inputContent: null,
  70. loginType: "wechat",
  71. phone: '',
  72. password: '',
  73. logining: false,
  74. isPhone: false,
  75. isApple: true,
  76. accessToken: '',
  77. params: {
  78. encryptedData: '',
  79. session_key: '',
  80. iv: '',
  81. },
  82. userInfo: {
  83. nickName: '',
  84. avatarUrl: '',
  85. gender: '',
  86. phone: ''
  87. },
  88. type: 'password',
  89. inputStatus: 'none',
  90. verifyCode: null,
  91. sendText: '获取验证码',
  92. sendDisabled: false,
  93. system: '',
  94. platform: '',
  95. userData: undefined,
  96. canIUseProfile: false
  97. }
  98. },
  99. computed: {
  100. ...mapState(['clientId'])
  101. },
  102. onShow() {
  103. // this.loginType = "wechat"
  104. this.$api.logout()
  105. },
  106. onLoad(options) {
  107. if (wx.getUserProfile) {
  108. console.log('--check getUserProfile--OK');
  109. this.canIUseProfile = true;
  110. }
  111. console.log("login on load")
  112. // var that = this
  113. // that.$request.baseRequest('user', 'sendIsApple', {
  114. // }).then(res => {
  115. // that.isApple = res.data
  116. // })
  117. // uni.getSystemInfo({
  118. // success:(res) => {
  119. // // console.log(res)
  120. // this.system = res.system // ios
  121. // this.platform = res.platform // 14.3
  122. // }
  123. // })
  124. },
  125. methods: {
  126. passWordStatus(type) {
  127. if (type == 1) {
  128. this.isShowPassword = 'text'
  129. } else {
  130. this.isShowPassword = 'password'
  131. }
  132. },
  133. cancelClick(){
  134. this.isShowAlert = false
  135. },
  136. confirmClick(){
  137. if (uni.getSystemInfoSync().platform == 'ios'){
  138. plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
  139. } else if (uni.getSystemInfoSync().platform == 'android'){
  140. plus.runtime.quit();
  141. }
  142. },
  143. passlogin(e) {
  144. var that = this
  145. uni.showLoading({
  146. title: '登录中',
  147. mask: true
  148. })
  149. console.log("clinetId", this.clientId)
  150. that.$request.baseRequest('get', '/commonUser/login', {
  151. phone: this.phone,
  152. password: this.password,
  153. loginFlag: 2,
  154. identification: 1
  155. }).then(res => {
  156. if (res.code == 200) {
  157. console.log("userInfo", res.data)
  158. uni.setStorageSync('userInfo', res.data)
  159. that.$request.baseRequest('get', '/newsInfo/unreadMessage', {
  160. reCommonId: this.userInfo.id,
  161. }).then(res3 => {
  162. if (res3.data) {
  163. let name = 'myTip';
  164. let value = res3.data
  165. if (value == 0) {
  166. uni.removeTabBarBadge({
  167. index: 2
  168. })
  169. }
  170. that.$store.commit('$uStore', {
  171. name,
  172. value
  173. });
  174. if (value != 0 && value) {
  175. uni.setTabBarBadge({
  176. index: 2,
  177. text: value + ""
  178. })
  179. }
  180. }
  181. })
  182. that.$request.baseRequest('get', '/orderInfo/getData', {
  183. commonId:uni.getStorageSync('userInfo').id,
  184. }).then(res1 => {
  185. if(res1.data.length>0){
  186. that.$helper.fUN_AmapLocation.start({
  187. intervalTime: 5000,
  188. isReport: false
  189. },
  190. res => {
  191. // console.log('====确认装车开启连续定位====');
  192. // console.log(res)
  193. let _data = {
  194. orderId: res1.data[0].id,
  195. longitude: res.longitude,
  196. latitude: res.latitude,
  197. province: res.province,
  198. city: res.city,
  199. area: res.district
  200. }
  201. this.$helper.gjList.push(_data)
  202. uni.setStorageSync('mapGJ', this.$helper.gjList);
  203. // console.log('this.$helper.gjList')
  204. // console.log(this.$helper.gjList)
  205. console.log("条数", uni.getStorageSync('mapGJ').length)
  206. if (uni.getStorageSync('mapGJ').length > 100) {
  207. console.log(JSON.stringify(uni.getStorageSync('mapGJ')) )
  208. this.$request.baseRequest('post', '/hyOrderTravelPath/api/addInfo', {
  209. orderId:"cdae6ec34c2349768c490a9fefa03fb3",
  210. longitudeLatitude:JSON.stringify(uni.getStorageSync('mapGJ'))
  211. }).then(res => {
  212. uni.removeStorageSync('mapGJ');
  213. this.$helper.gjList = []
  214. })
  215. .catch(res => {
  216. uni.$u.toast(res.message);
  217. });
  218. }
  219. //判断缓存数据条数,超过reportInterval时清空缓存,重新存入缓存
  220. }
  221. );
  222. }
  223. })
  224. that.$request.baseRequest('get', '/driverInfo/firstAuthentication', {
  225. driverPhone: this.phone,
  226. }).then(res2 => {
  227. if(res.data.statusFlag=='已禁用'){
  228. this.isShowAlert = true
  229. uni.hideLoading()
  230. return
  231. }
  232. uni.setStorageSync('pcuserInfo', res.data)
  233. uni.setStorageSync('userInfo', res.data)
  234. uni.setStorageSync('firstAuthentication', res2.data)
  235. helper.getListByUserId()
  236. that.$store.commit('login', res.data)
  237. var name = 'userInfo';
  238. var value = res.data;
  239. that.$store.commit('$uStore', {
  240. name,
  241. value
  242. });
  243. uni.switchTab({
  244. url: '/pages/goodSource/index'
  245. });
  246. uni.hideLoading()
  247. uni.switchTab({
  248. url: '/pages/goodSource/index'
  249. });
  250. uni.hideLoading()
  251. })
  252. } else {
  253. uni.hideLoading()
  254. uni.showToast({
  255. title: res.message,
  256. icon: 'none',
  257. duration: 2000
  258. })
  259. }
  260. })
  261. .catch(res => {
  262. uni.$u.toast(res.message);
  263. });
  264. },
  265. gocode() {
  266. uni.navigateTo({
  267. url: '/pages/public/loginOther'
  268. })
  269. },
  270. forgetpass() {
  271. uni.navigateTo({
  272. url: '/pages/mine/settings/editPassword'
  273. })
  274. },
  275. goregister() {
  276. uni.navigateTo({
  277. url: '/pages/public/register'
  278. })
  279. },
  280. ...mapMutations(['login']),
  281. navBack() {
  282. uni.navigateBack();
  283. },
  284. },
  285. }
  286. </script>
  287. <style lang='scss' scoped>
  288. .apple {
  289. background: #000;
  290. width: 35px;
  291. height: 35px;
  292. padding: 8px;
  293. border-radius: 50%;
  294. vertical-align: middle;
  295. }
  296. page {
  297. background: #fff;
  298. }
  299. .u-icon{
  300. position:absolute;
  301. right:0;
  302. top:50%;
  303. transform: translate(-50%,-50%);
  304. }
  305. .close {
  306. width: 20px;
  307. height: 20px;
  308. position: absolute;
  309. right: 0px;
  310. }
  311. .close1 {
  312. width: 20px;
  313. height: 20px;
  314. position: absolute;
  315. right: 10px;
  316. top: 0;
  317. }
  318. .close2 {
  319. width: 15px;
  320. height: 15px;
  321. position: absolute;
  322. right: 19px;
  323. top: 50%;
  324. transform: translateY(-45%);
  325. }
  326. .password {
  327. border: none;
  328. outline: none;
  329. }
  330. .cuIcon-weixin {
  331. background: #2772FB;
  332. color: #fff;
  333. font-size: 18px;
  334. padding: 9px;
  335. border-radius: 50%;
  336. vertical-align: middle;
  337. margin-right: 5px;
  338. }
  339. .container {
  340. /* padding-top: 85px; */
  341. position: relative;
  342. width: 100vw;
  343. height: 100vh;
  344. overflow: hidden;
  345. background: url('~@/static/images/mine/bg@2x.png');
  346. background-size: cover;
  347. }
  348. .wrapper {
  349. position: relative;
  350. z-index: 90;
  351. padding-bottom: 40upx;
  352. height: 100%;
  353. padding: 0 30px;
  354. }
  355. .back-btn {
  356. position: absolute;
  357. left: 40upx;
  358. z-index: 9999;
  359. padding-top: var(--status-bar-height);
  360. top: 40upx;
  361. font-size: 40upx;
  362. color: red;
  363. }
  364. .verificationCode {
  365. margin-top: 20px;
  366. background: #F5F6F9;
  367. color: #AFB3BF;
  368. }
  369. .verificationCode:after {
  370. border: none;
  371. }
  372. .verificationCode.active {
  373. background: #2772FB;
  374. color: #fff;
  375. }
  376. .register {
  377. /* position:absolute; */
  378. bottom: 20px;
  379. left: 50%;
  380. transform: translateX(-50%);
  381. color: #333333;
  382. height: 50px;
  383. line-height: 50px;
  384. border-radius: 30px;
  385. border: 1px solid #444444;
  386. }
  387. .register:after {
  388. border: none;
  389. }
  390. .phone-before-num {
  391. font-size: 34rpx;
  392. color: #333333;
  393. border-right: 1px solid #E8E9ED;
  394. padding-right: 20rpx;
  395. }
  396. .phone-number {
  397. margin-left: 20rpx;
  398. font-size: 34rpx;
  399. font-family: DINPro-Medium, DINPro;
  400. font-weight: 500;
  401. color: #333333;
  402. }
  403. </style>