login.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <view class="login-content">
  3. <view class="login-content-info">
  4. <view class="login-bgm":style="{backgroundImage:`url(${staticUrl}/img/tuan-index-bg.png)`}">
  5. <image class="login-logo" :src="staticUrl+'/img/logo.png'" mode="scaleToFill"></image>
  6. <text>{{ title }}</text>
  7. </view>
  8. <view class="login-info">
  9. <view class="login-info-box">
  10. <text class="login-info-title">账号密码登陆</text>
  11. <view class="login-info-form">
  12. <u--form
  13. labelWidth="0"
  14. :borderBottom="false"
  15. :model="form"
  16. :rules="rules"
  17. ref="uForm">
  18. <u-form-item prop="mobile">
  19. <u--input
  20. v-model="form.mobile"
  21. placeholder="请输入账号"
  22. border="surround"
  23. shape="circle"
  24. prefixIcon="account-fill"
  25. prefixIconStyle="font-size: 22px;color: #909399"
  26. ></u--input>
  27. </u-form-item>
  28. <u-form-item prop="password">
  29. <u--input
  30. v-model="form.password"
  31. placeholder="请输入账密码"
  32. border="surround"
  33. shape="circle"
  34. prefixIcon="lock-fill"
  35. :password="true"
  36. prefixIconStyle="font-size: 22px;color: #909399"
  37. ></u--input>
  38. </u-form-item>
  39. </u--form>
  40. </view>
  41. <view class="login-info-submit">
  42. <u-button
  43. class="login-info-submit-but"
  44. @click="submit()"
  45. :loading="loading"
  46. loadingText="登录中..."
  47. >登录</u-button>
  48. </view>
  49. <view class="login-info-tip">暂不支持自行注册</view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. export default {
  57. data() {
  58. return {
  59. staticUrl:this.$commonConfig.staticUrl,
  60. title: '《伟大转折》剧目团购系统',
  61. logoUrl: this.$commonConfig.staticUrl + "login/logo.png",
  62. loading: false,
  63. backUrl:null,
  64. form: {
  65. mobile: '',
  66. password: '',
  67. },
  68. rules: {
  69. 'mobile': {
  70. type: 'string',
  71. required: true,
  72. message: '请填写账号',
  73. trigger: ['blur', 'change']
  74. },
  75. 'password': {
  76. type: 'string',
  77. required: true,
  78. message: '请填写密码',
  79. trigger: ['blur', 'change']
  80. },
  81. },
  82. }
  83. },
  84. onReady() {
  85. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  86. this.$refs.uForm.setRules(this.rules)
  87. },
  88. onLoad() {
  89. let that = this;
  90. // 测试环境填充用户名密码
  91. if(process.env.NODE_ENV=='development'){
  92. this.form.mobile = '13682277062';
  93. this.form.password = '123456';
  94. }
  95. uni.getStorage({
  96. key: 'backUrl',
  97. success: function (res) {
  98. // console.log('getStorage',res);
  99. },
  100. complete(res) {
  101. if(res.data){
  102. that.backUrl = '/'+res.data;
  103. }else{
  104. that.backUrl = '/pages/index/index';
  105. }
  106. console.log('backUrl',that.backUrl);
  107. }
  108. });
  109. },
  110. onShow() {
  111. },
  112. methods: {
  113. /**
  114. *
  115. * 提交登录
  116. *
  117. */
  118. submit() {
  119. this.loading = true
  120. this.$refs.uForm.validate().then(res => {
  121. this.$u.toast('校验通过')
  122. this.$u.api.teamLogin(this.form).then(res=>{
  123. this.loading = false
  124. // console.log('res',res.data);
  125. this.$u.vuex('vuex_user_info', res.data);
  126. uni.reLaunch({url: this.backUrl});
  127. }).catch(err=>{
  128. console.log('login',err);
  129. this.loading = false
  130. })
  131. }).catch(errors => {
  132. this.$u.toast('校验失败')
  133. this.loading = false
  134. })
  135. }
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. .login-content {
  141. width: 100%;
  142. height: 100vh;
  143. position: relative;
  144. box-sizing: border-box;
  145. --bgm-height: 630rpx;
  146. }
  147. /** 背景 */
  148. .login-content-box {
  149. width: 100%;
  150. height: 100%;
  151. box-sizing: border-box;
  152. }
  153. .login-bgm {
  154. width: 100%;
  155. height: 630rpx;
  156. // background-image: url("#{$image-beas-url}login/bgm.png");
  157. background-size: 100% auto;
  158. background-repeat: no-repeat;
  159. box-sizing: border-box;
  160. display: flex;
  161. flex-direction: column;
  162. justify-content: center;
  163. align-items: center;
  164. .login-logo {
  165. width: 240rpx;
  166. height: 172rpx;
  167. padding: 50rpx 0;
  168. }
  169. >text {
  170. font-size: 32rpx;
  171. font-family: SourceHanSansCN, SourceHanSansCN;
  172. font-weight: bold;
  173. color: #FFFFFF;
  174. }
  175. }
  176. .login-info {
  177. width: 100%;
  178. height: calc(100% - var(--bgm-height) + 40rpx);
  179. background-color: #fff;
  180. border-radius: 28rpx 28rpx 0rpx 0rpx;
  181. position: absolute;
  182. bottom: 0;
  183. left: 0;
  184. z-index: 22;
  185. box-sizing: border-box;
  186. padding: 80rpx;
  187. .login-info-box {
  188. width: 100%;
  189. height: 100%;
  190. display: flex;
  191. flex-direction: column;
  192. box-sizing: border-box;
  193. .login-info-title {
  194. font-size: 32rpx;
  195. font-family: SourceHanSansCN, SourceHanSansCN;
  196. font-weight: bold;
  197. color: #2D2D2D;
  198. padding-bottom: 40rpx;
  199. }
  200. .login-info-form {
  201. }
  202. .login-info-submit {
  203. width: 100%;
  204. height: 80rpx;
  205. padding: 40rpx 0 20rpx;
  206. flex-shrink: 0;
  207. .login-info-submit-but {
  208. display: flex;
  209. justify-content: center;
  210. align-items: center;
  211. border-radius: 40rpx;
  212. width: 100% !important;
  213. height: 100% !important;
  214. background-color: #ed0000;
  215. color: #fff;
  216. }
  217. }
  218. .login-info-tip {
  219. width: 100%;
  220. text-align: center;
  221. font-size: 24rpx;
  222. font-family: SourceHanSansCN, SourceHanSansCN;
  223. font-weight: 400;
  224. color: #C2C2C2;
  225. }
  226. }
  227. }
  228. </style>