index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <view class="login" :style="{ 'height': setHeight + 'px' }">
  3. <view class="logo">
  4. <image src="../../../static/images/logo.png"></image>
  5. <view>登录巴巴礼品网</view>
  6. </view>
  7. <div class="form">
  8. <form @submit.prevent="submit">
  9. <div class="item">
  10. <div class="acea-row row-middle">
  11. <image src="../../../static/images/phone_1.png"></image>
  12. <input type="text" placeholder="请输入绑定的手机号" placeholder-class="placeholder" v-model="userName" required />
  13. </div>
  14. </div>
  15. <div class="item">
  16. <div class="acea-row row-middle">
  17. <image src="../../../static/images/code_2.png"></image>
  18. <input type="password" placeholder="请输入登录密码" placeholder-class="placeholder" v-model="password" required />
  19. </div>
  20. </div>
  21. </form>
  22. <view class="goto">
  23. <navigator hover-class="none" url="/pages/users/retrievePassword/index">
  24. 忘记密码?
  25. </navigator>
  26. <navigator class="zhuce" hover-class="none" url="/pages/users/register/index">
  27. 注册账号
  28. </navigator>
  29. </view>
  30. <view class="btn" @click="submit">登录</view>
  31. <navigator class="return" hover-class="none" url="/pages/index/index" open-type='switchTab'>继续浏览<text class="iconfont icon-jiantou"></text></navigator>
  32. </div>
  33. </view>
  34. </template>
  35. <script>
  36. import {
  37. loginApi
  38. } from '@/api/api.js';
  39. const BACK_URL = "login_back_url";
  40. export default {
  41. data() {
  42. return {
  43. setHeight: 0,
  44. userName: '',
  45. password: ''
  46. }
  47. },
  48. mounted() {
  49. let that = this
  50. uni.getSystemInfo({
  51. success: function (res) {
  52. that.setHeight = res.windowHeight
  53. }
  54. })
  55. },
  56. methods: {
  57. async submit() {
  58. let that = this;
  59. if (!that.userName) return that.$util.Tips({
  60. title: '请填写账号'
  61. });
  62. if (!/^[\w\d]{5,16}$/i.test(that.userName)) return that.$util.Tips({
  63. title: '请输入正确的账号'
  64. });
  65. if (!that.password) return that.$util.Tips({
  66. title: '请填写密码'
  67. });
  68. loginApi({
  69. check: true,
  70. userName: that.userName,
  71. passWord: that.password
  72. }).then(res => {
  73. that.$store.commit("LOGIN", {
  74. 'token': res.data.token,
  75. 'time': 2592000
  76. });
  77. that.$store.commit("UPDATE_USERINFO", res.data.user_info);
  78. const backUrl = that.$Cache.get(BACK_URL) || "/pages/index/index";
  79. that.$Cache.clear(BACK_URL);
  80. if (backUrl === '/pages/index/index' || backUrl === '/pages/users/purchase/index' || backUrl ===
  81. '/pages/my/index') {
  82. uni.switchTab({
  83. url: backUrl
  84. });
  85. } else {
  86. uni.switchTab({
  87. url: '/pages/index/index'
  88. });
  89. }
  90. }).catch(err => {
  91. that.$util.Tips({
  92. title: err
  93. });
  94. });
  95. }
  96. }
  97. }
  98. </script>
  99. <style scoped lang="scss">
  100. .login{
  101. padding-top: 200rpx;
  102. background: #fff;
  103. }
  104. .logo{
  105. text-align: center;
  106. image{
  107. width:140rpx;
  108. height:140rpx;
  109. }
  110. view{
  111. font-size: 32rpx;
  112. font-weight: 700;
  113. letter-spacing: 10rpx;
  114. color:#262626;
  115. }
  116. }
  117. .form{
  118. padding: 40rpx;
  119. .item {
  120. border-bottom: 1rpx solid #ededed;
  121. padding: 45rpx 0 20rpx 0;
  122. image{
  123. width:40rpx;
  124. height:40rpx;
  125. margin-right: 20rpx;
  126. }
  127. input{
  128. flex-grow: 1;
  129. }
  130. .placeholder{
  131. color:#ccc;
  132. }
  133. }
  134. .goto{
  135. display: flex;
  136. justify-content: space-between;
  137. margin-top: 45rpx;
  138. color:#666;
  139. .zhuce{
  140. color:#ff5c00;
  141. }
  142. }
  143. .btn{
  144. font-size: 35rpx;
  145. color: #fff;
  146. height: 86rpx;
  147. border-radius: 40rpx;
  148. background: linear-gradient(90deg,#f35447 0,#ff8e3c);
  149. text-align: center;
  150. line-height: 86rpx;
  151. margin-top: 70rpx;
  152. }
  153. .return{
  154. color:#666;
  155. text-align: right;
  156. margin-top: 30rpx;
  157. .iconfont{
  158. font-size: 23rpx;
  159. }
  160. }
  161. }
  162. </style>