login.vue 9.1 KB

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