login.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  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. }
  92. },
  93. computed: {
  94. ...mapState(['clientId'])
  95. },
  96. onShow() {
  97. // this.loginType = "wechat"
  98. this.$api.logout()
  99. console.log("login onShow")
  100. },
  101. onLoad(options) {
  102. if (wx.getUserProfile) {
  103. console.log('--check getUserProfile--OK');
  104. this.canIUseProfile = true;
  105. }
  106. console.log("login on load")
  107. // var that = this
  108. // that.$request.baseRequest('user', 'sendIsApple', {
  109. // }).then(res => {
  110. // that.isApple = res.data
  111. // })
  112. // uni.getSystemInfo({
  113. // success:(res) => {
  114. // // console.log(res)
  115. // this.system = res.system // ios
  116. // this.platform = res.platform // 14.3
  117. // }
  118. // })
  119. },
  120. methods: {
  121. check(val) {
  122. console.log(val)
  123. if (!uni.$u.test.enOrNum(val.detail.value)) {
  124. this.$refs.uToast.show({
  125. type: 'error',
  126. message: "密码只能是字母或数字!"
  127. })
  128. this.password = ''
  129. return
  130. }
  131. },
  132. passWordStatus(type) {
  133. if (type == 1) {
  134. this.isShowPassword = 'text'
  135. } else {
  136. this.isShowPassword = 'password'
  137. }
  138. },
  139. passlogin(e) {
  140. var that = this
  141. if (this.phone == '') {
  142. that.$refs.uToast.show({
  143. type: 'error',
  144. message: "请输入手机号!"
  145. })
  146. return
  147. }
  148. if (this.password == '') {
  149. that.$refs.uToast.show({
  150. type: 'error',
  151. message: "请输入密码!"
  152. })
  153. return
  154. }
  155. if (!uni.$u.test.enOrNum(this.password)) {
  156. that.$refs.uToast.show({
  157. type: 'error',
  158. message: "密码只能是字母或数字!"
  159. })
  160. return
  161. }
  162. that.$request.baseRequest('get', '/cargoOwnerInfo/firstAuthentication', {
  163. phone: this.phone,
  164. }).then(res => {
  165. if (res.data.authenticationStatus == '已禁用') {
  166. that.$refs.uToast.show({
  167. type: 'error',
  168. message: "账号审核中!"
  169. })
  170. } else {
  171. uni.showLoading({
  172. title: '登录中',
  173. mask: true
  174. })
  175. that.$request.baseRequest('get', '/commonUser/login', {
  176. phone: that.phone,
  177. password: that.password,
  178. loginFlag: 1,
  179. identification: 2
  180. }).then(res => {
  181. if (res.code == 200) {
  182. uni.setStorageSync('userInfo', res.data)
  183. that.$request.baseRequest('get', '/newsInfo/unreadMessage', {
  184. reCommonId: that.userInfo.id,
  185. }).then(res3 => {
  186. if (res3.data || res3.data == 0) {
  187. let name = 'myTip';
  188. let value = res3.data
  189. if (value == 0) {
  190. uni.removeTabBarBadge({
  191. index: 2
  192. })
  193. }
  194. that.$store.commit('$uStore', {
  195. name,
  196. value
  197. });
  198. if (value != 0 && value) {
  199. uni.setTabBarBadge({
  200. index: 2,
  201. text: value + ""
  202. })
  203. }
  204. }
  205. })
  206. that.$store.commit('login', res.data)
  207. var name = 'userInfo';
  208. var value = res.data;
  209. that.$store.commit('$uStore', {
  210. name,
  211. value
  212. });
  213. uni.switchTab({
  214. url: '/pages/order/index'
  215. });
  216. uni.hideLoading()
  217. } else {
  218. uni.hideLoading()
  219. uni.showToast({
  220. title: res.message,
  221. icon: 'none',
  222. duration: 2000
  223. })
  224. }
  225. })
  226. .catch(res => {
  227. uni.hideLoading()
  228. uni.$u.toast(res.message);
  229. });
  230. }
  231. })
  232. },
  233. gocode() {
  234. uni.navigateTo({
  235. url: '/pages/public/loginOther'
  236. })
  237. },
  238. forgetpass() {
  239. uni.navigateTo({
  240. url: '/pages/mine/settings/editPassword'
  241. })
  242. },
  243. goregister() {
  244. uni.navigateTo({
  245. url: '/pages/public/register'
  246. })
  247. },
  248. ...mapMutations(['login']),
  249. navBack() {
  250. uni.navigateBack();
  251. },
  252. },
  253. }
  254. </script>
  255. <style lang='scss' scoped>
  256. .apple {
  257. background: #000;
  258. width: 35px;
  259. height: 35px;
  260. padding: 8px;
  261. border-radius: 50%;
  262. vertical-align: middle;
  263. }
  264. page {
  265. background: #fff;
  266. }
  267. .phone {
  268. padding: 20rpx;
  269. font-size: 28rpx;
  270. }
  271. .close {
  272. width: 20px;
  273. height: 20px;
  274. position: absolute;
  275. right: 0px;
  276. }
  277. .yanjingicon {
  278. position: absolute;
  279. right: 0;
  280. top: 50%;
  281. transform: translate(-50%, -50%);
  282. }
  283. .close1 {
  284. width: 20px;
  285. height: 20px;
  286. position: absolute;
  287. right: 10px;
  288. top: 0;
  289. }
  290. .close2 {
  291. width: 15px;
  292. height: 15px;
  293. position: absolute;
  294. right: 19px;
  295. top: 50%;
  296. transform: translateY(-45%);
  297. }
  298. .password {
  299. border: none;
  300. outline: none;
  301. font-size: 28rpx;
  302. }
  303. .cuIcon-weixin {
  304. background: #2772FB;
  305. color: #fff;
  306. font-size: 18px;
  307. padding: 9px;
  308. border-radius: 50%;
  309. vertical-align: middle;
  310. margin-right: 5px;
  311. }
  312. .container {
  313. /* padding-top: 85px; */
  314. position: relative;
  315. width: 100vw;
  316. height: 100vh;
  317. overflow: hidden;
  318. background: url('~@/static/images/mine/bg@2x.png');
  319. background-size: cover;
  320. }
  321. .wrapper {
  322. position: relative;
  323. z-index: 90;
  324. padding-bottom: 40upx;
  325. height: 100%;
  326. padding: 0 30px;
  327. }
  328. .back-btn {
  329. position: absolute;
  330. left: 40upx;
  331. z-index: 9999;
  332. padding-top: var(--status-bar-height);
  333. top: 40upx;
  334. font-size: 40upx;
  335. color: red;
  336. }
  337. .verificationCode {
  338. margin-top: 20px;
  339. background: #F5F6F9;
  340. color: #AFB3BF;
  341. }
  342. .verificationCode:after {
  343. border: none;
  344. }
  345. .verificationCode.active {
  346. background: #2772FB;
  347. color: #fff;
  348. }
  349. .register {
  350. /* position:absolute; */
  351. bottom: 20px;
  352. left: 50%;
  353. transform: translateX(-50%);
  354. color: #333333;
  355. height: 50px;
  356. line-height: 50px;
  357. border-radius: 30px;
  358. border: 1px solid #444444;
  359. }
  360. .register:after {
  361. border: none;
  362. }
  363. .phone-before-num {
  364. font-size: 34rpx;
  365. color: #333333;
  366. border-right: 1px solid #E8E9ED;
  367. padding-right: 20rpx;
  368. }
  369. .phone-number {
  370. margin-left: 20rpx;
  371. font-size: 34rpx;
  372. font-family: DINPro-Medium, DINPro;
  373. font-weight: 500;
  374. color: #333333;
  375. }
  376. /deep/.uni-input-input:disabled {
  377. background: #fff;
  378. }
  379. </style>