newlogin.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <view class="newlogin">
  3. <view class="status_bar"></view>
  4. <view class="newlogin_img_area">
  5. <image class="newlogin_img" src="../../static/newlogin.png" mode="widthFix"></image>
  6. </view>
  7. <view class="mt-50 mlr-60 card_area">
  8. <view class="flex-n fac card_area_item">
  9. <view class="card_icon iconfont iconren"></view>
  10. <view class="flex-n fac ml-19 card_content flex-1">
  11. <z-input class="card_input flex-1" align="left" v-model="loginName" placeholder="请输入手机号码">
  12. </z-input>
  13. </view>
  14. </view>
  15. <view class="flex-n fac card_area_item mt-20">
  16. <view class="card_icon iconfont iconsuotou"></view>
  17. <view class="flex-n fac ml-19 card_content flex-1">
  18. <z-input :type="switchSave?'':'password'" align="left" class="card_input flex-1 mr-20"
  19. v-model="passWord" placeholder="请输入密码"></z-input>
  20. <switch :checked="switchSave" @change="changeswitchSave" />
  21. </view>
  22. </view>
  23. </view>
  24. <z-button width="630" class="mt-70" @click="login">登 录</z-button>
  25. <view class="forget_pass mt-60" @click="gotoForgetPage">
  26. 忘记登录密码
  27. </view>
  28. <z-message></z-message>
  29. </view>
  30. </template>
  31. <script>
  32. const app = getApp({
  33. allowDefault: true
  34. });
  35. export default {
  36. data() {
  37. return {
  38. switchSave: false,
  39. loginName: '',
  40. passWord: ''
  41. };
  42. },
  43. methods: {
  44. login() {
  45. var that = this;
  46. this.$axios.post('app/account/login', {
  47. loginName: this.loginName,
  48. passWord: this.passWord
  49. }).then(res => {
  50. console.log(res.data)
  51. console.log(app.globalData)
  52. app.globalData.authorization = res.data.Authorization;
  53. uni.setStorage({
  54. key: 'roleId',
  55. data: res.data.roleId
  56. })
  57. console.warn(uni.getStorageSync('storeId'))
  58. app.globalData.userId = res.data.userId;
  59. uni.setStorage({
  60. key: 'userInfo',
  61. data: res.data
  62. })
  63. uni.setStorage({
  64. key: 'loginName',
  65. data: that.loginName
  66. })
  67. uni.setStorage({
  68. key: 'passWord',
  69. data: that.passWord
  70. })
  71. this.$store.state.dicChange = true;
  72. this.getData(res.data.userId);
  73. }).catch(err => {
  74. console.log(err)
  75. uni.showToast({
  76. title: err.msg,
  77. icon: 'none',
  78. duration: 2000
  79. })
  80. })
  81. },
  82. getData(id) {
  83. console.log(id)
  84. this.$axios.get('app/user/userInfo/' + id).then(res => {
  85. let storeId = '';
  86. if (uni.getStorageSync('userInfo').storeId) {
  87. storeId = uni.getStorageSync('userInfo').storeId;
  88. } else {
  89. storeId = res.data.store[0].storeId || ''
  90. }
  91. uni.setStorage({
  92. key: 'storeId',
  93. data: storeId
  94. })
  95. console.log(res)
  96. uni.setStorage({
  97. key: 'storeInfo',
  98. data: res.data
  99. })
  100. uni.switchTab({
  101. url: '../book/index/index',
  102. success: res => {},
  103. fail: () => {},
  104. complete: () => {}
  105. });
  106. }).catch(err => {
  107. this.$refs.uToast.error(err.msg)
  108. })
  109. },
  110. changeswitchSave(e) {
  111. this.switchSave = e.detail.value;
  112. },
  113. gotoForgetPage() {
  114. uni.navigateTo({
  115. url: '../center/setting/forgetpass',
  116. success: res => {},
  117. fail: () => {},
  118. complete: () => {}
  119. });
  120. }
  121. }
  122. }
  123. </script>
  124. <style scoped lang="scss">
  125. .newlogin {
  126. width: 100%;
  127. height: 100vh;
  128. overflow: hidden;
  129. background: url(../../static/login_bg.png);
  130. background-size: 100% auto;
  131. background-repeat: no-repeat;
  132. background-position: left bottom;
  133. .status_bar {
  134. height: var(--status-bar-height);
  135. }
  136. .newlogin_img_area {
  137. text-align: center;
  138. .newlogin_img {
  139. width: 453rpx;
  140. margin-top: 100rpx;
  141. }
  142. }
  143. }
  144. .card_area {
  145. .card_area_item {
  146. height: 100rpx;
  147. }
  148. .card_icon {
  149. min-width: 40rpx;
  150. font-size: 40rpx;
  151. color: #2481EE;
  152. }
  153. .card_content {
  154. border-bottom: 1px solid #B8B8B8;
  155. }
  156. .card_input {
  157. padding: 20rpx 0;
  158. }
  159. }
  160. .forget_pass {
  161. font-size: 24rpx;
  162. color: #2481EE;
  163. text-align: center;
  164. }
  165. </style>