index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <view>
  3. <view style="background: #fff;margin: auto;border-radius: 5%;padding: 50rpx 80rpx;">
  4. <view>
  5. <input class="text_2" placeholder="请输入手机号码" v-model="data.mobilephone" />
  6. </view>
  7. <view>
  8. <input class="text_2" password="true" type="safe-password" placeholder="请输入登录密码" v-model="data.mobilepwd" />
  9. </view>
  10. <view class="input_2 flex-row" style="display: none;">
  11. <input class="text_4" placeholder="请输入验证码" v-model="data.inputcode" />
  12. <text class="text_5" @click="getCode">{{ data.code }}</text>
  13. </view>
  14. <button @click="onClick_1" class="text_6">确认登录</button>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. data() {
  21. return {
  22. constants: {},
  23. data: {
  24. mobilephone: '',
  25. mobilepwd: '',
  26. code: '2589',
  27. inputcode: '2589'
  28. }
  29. };
  30. },
  31. onLoad(option) {
  32. // // console.log(option);
  33. // this.getCode();
  34. },
  35. methods: {
  36. onClick_1() {
  37. if(!this.data.mobilephone){
  38. uni.showToast({
  39. title:"手机号不能为空",
  40. icon:"none",
  41. })
  42. return;
  43. }
  44. if(!this.data.mobilepwd){
  45. uni.showToast({
  46. title:"密码不能为空",
  47. icon:"none",
  48. })
  49. return;
  50. }
  51. if(!this.data.inputcode){
  52. uni.showToast({
  53. title:"验证码不能为空",
  54. icon:"none",
  55. })
  56. return;
  57. }
  58. if(this.data.inputcode!=this.data.code){
  59. uni.showToast({
  60. title:"验证码错误",
  61. icon:"none",
  62. })
  63. this.getCode();
  64. return;
  65. }
  66. var data = new Object();
  67. data.sjh=this.data.mobilephone;
  68. data.mm=this.data.mobilepwd;
  69. this.$api
  70. .MhPostModel(data, 'user/login')
  71. .then(res => {
  72. // console.log('MhUserLogin信息', JSON.stringify(res));
  73. if (res.data.code != 1) {
  74. uni.showToast({
  75. title: res.data.msg,
  76. icon: 'none'
  77. });
  78. this.getCode();
  79. return;
  80. } else {
  81. uni.showToast({
  82. title: res.data.msg,
  83. icon: 'none'
  84. });
  85. this.$api.setUserinfo(res.data.data);
  86. uni.switchTab({
  87. url:"/pages/my/index"
  88. })
  89. }
  90. })
  91. .catch(err => {
  92. // console.log('request fail', JSON.stringify(err));
  93. });
  94. },
  95. getCode() {
  96. var data = new Object();
  97. this.$api
  98. .MhUserModel(data, 'MhUserCheckCode')
  99. .then(res => {
  100. // console.log('MhUserCheckCode信息', JSON.stringify(res));
  101. if (res.data.code != 0) {
  102. uni.showToast({
  103. title: res.data.msg,
  104. icon: 'none'
  105. });
  106. return;
  107. } else {
  108. this.data.code = res.data.info;
  109. }
  110. })
  111. .catch(err => {
  112. // console.log('request fail', JSON.stringify(err));
  113. });
  114. }
  115. }
  116. };
  117. </script>
  118. <style lang="css">
  119. page {
  120. background: url(../../static/loginbg.png) #fff no-repeat;background-size:100% auto;background-position: top;
  121. padding: 0;height: auto;
  122. margin: 0;padding-top: 480rpx;
  123. }
  124. .text_2{background: #f5f5f8;font-size: 28rpx;height: 90rpx;line-height: 90rpx;padding-left: 20rpx;margin-bottom:30rpx;border-radius: 10rpx;}
  125. .text_6{background-image: linear-gradient(#829c52, #59723b);color: #fff;border: 0;font-size: 28rpx;height: 90rpx;line-height: 90rpx;}
  126. </style>