index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view>
  3. <view class="status_bar">
  4. <!-- 这里是状态栏 -->
  5. </view>
  6. <u-image src="../../static/sailun/login_bg.png" mode="widthFix"></u-image>
  7. <view class="content">
  8. <u-card padding="50" :head-border-bottom="false" :show-head="false" :show-foot="false" :border="false" box-shadow="0px 1px 10px rgba(0,0,0,0.2)"
  9. border-radius="20" margin="50rpx">
  10. <view slot="body">
  11. <view style="margin-top: 20rpx;">
  12. <u-field v-model="tel" placeholder="请填写手机号" label-width="50">
  13. <u-icon slot="icon" name="account" size="36" color="#666666"></u-icon>
  14. </u-field>
  15. </view>
  16. <view style="margin-top: 30rpx;">
  17. <u-field v-model="code" placeholder="请填写验证码" label-width="50">
  18. <u-icon slot="icon" name="lock" size="36" color="#666666"></u-icon>
  19. <u-button size="mini" slot="right" type="primary" @click="getCode" shape="circle" :loading="codeLoading">{{codeText}}</u-button>
  20. </u-field>
  21. </view>
  22. <u-verification-code ref="uCode" @change="codeChange"></u-verification-code>
  23. <view style="margin-top: 80rpx;">
  24. <u-button type="primary" :ripple="true" ripple-bg-color="#99d4ff" shape="circle" @tap="$u.debounce(submit, 2000,immediate = true)"
  25. :loading="loading">登录</u-button>
  26. </view>
  27. <view style="margin-top: 80rpx;display: flex;justify-content: center;">
  28. <view class="u-flex" @click="inregister">
  29. <view style="color: rgba(0,160,234,0.5)">
  30. 还没有账号?
  31. </view>
  32. <view style="color: #00A0EA">
  33. 立即注册
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </u-card>
  39. </view>
  40. <view class="foot">
  41. <view class="u-flex u-row-center u-col-center">
  42. <u-divider color="#0095FF" border-color="#0095FF" bg-color="#F4F4F4" fontSize="30">赛轮店管家</u-divider>
  43. </view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import {mapState,mapMutations} from 'vuex'
  49. import {
  50. request
  51. } from '../../common/request/request'
  52. require("promise.prototype.finally").shim()
  53. export default {
  54. data() {
  55. return {
  56. tel: '',
  57. code: '',
  58. codeText: '',
  59. pact: false,
  60. loading: false,
  61. codeLoading:false,
  62. SystemInfo:'',
  63. networkType:''
  64. }
  65. },
  66. computed: {
  67. ...mapState(['hasLogin'])
  68. },
  69. created() {
  70. uni.getSystemInfo({
  71. success:(res)=>{
  72. this.SystemInfo=res
  73. }
  74. });
  75. uni.getNetworkType({
  76. success:(res)=>{
  77. this.networkType=res.networkType
  78. }
  79. });
  80. },
  81. methods: {
  82. ...mapMutations(['login']),
  83. toUser(provider){
  84. this.login(provider);
  85. if(this.hasLogin){
  86. this.$u.route({
  87. url: 'pages/home/index',
  88. type: 'switchTab',
  89. })
  90. }else{
  91. uni.navigateBack();
  92. }
  93. },
  94. submit() {
  95. if (this.$u.test.mobile(this.tel)) {
  96. this.loading = true
  97. request({
  98. url: '/sailun/appLogin/storeLogin',
  99. method: 'post',
  100. data: {
  101. "account": "",
  102. "loginType": "1",
  103. "mobileCode": this.code,
  104. "password": "",
  105. "phoneNumber": this.tel,
  106. "osType":this.SystemInfo.platform,
  107. "osVersion":this.SystemInfo.system,
  108. "phoneBrand":this.SystemInfo.brand,
  109. "phoneModel":this.SystemInfo.model,
  110. "appVersion":"1.00",
  111. "networkType":this.networkType,
  112. }
  113. }).then(res => {
  114. if (res.data.code == 0) {
  115. this.toUser(res.data.data)
  116. uni.$emit('login', {
  117. msg: '登录成功'
  118. })
  119. }else {
  120. this.$u.toast(res.data.msg);
  121. }
  122. }).catch(err => {
  123. console.log(err)
  124. this.$u.toast('登录失败');
  125. }).finally(() => {
  126. this.loading = false
  127. })
  128. }
  129. },
  130. inregister() {
  131. this.$u.route({
  132. url: 'pages/login/register',
  133. })
  134. },
  135. codeChange(text) {
  136. this.codeText = text;
  137. },
  138. getCode() {
  139. if (this.tel) {
  140. this.codeLoading=true
  141. request({
  142. url: '/sailun/appStoreBasicInfo/sendCode',
  143. method: 'post',
  144. data: {
  145. "phoneNumber": this.tel,
  146. "opreaType":"1"
  147. },
  148. }).then(res => {
  149. console.log(res)
  150. if (res.data.code == 0) {
  151. if (this.$refs.uCode.canGetCode) {
  152. this.$refs.uCode.start();
  153. } else {
  154. this.$u.toast('倒计时结束后再发送');
  155. }
  156. }
  157. if (res.data.code == 500) {
  158. this.$u.toast(res.data.msg);
  159. }
  160. }).catch(err => {
  161. console.log(err)
  162. }).finally(() => {
  163. this.codeLoading=false
  164. })
  165. } else {
  166. this.$u.toast('请输入手机号');
  167. }
  168. },
  169. }
  170. };
  171. </script>
  172. <style lang="scss" scoped>
  173. .status_bar {
  174. height: var(--status-bar-height);
  175. width: 100%;
  176. background-color: #0095FF;
  177. }
  178. .content {
  179. position: relative;
  180. top: -350rpx;
  181. }
  182. .foot {
  183. position: fixed;
  184. bottom: 10rpx;
  185. width: 100%;
  186. }
  187. </style>