index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view :style="{ minHeight: sys.windowHeight + 'px' }"
  3. :class="[$tm.vx.state().tmVuetify.black ? 'black' : ' ']">
  4. <tm-menubars title="" :shadow="0" :showback="false"></tm-menubars>
  5. <tm-message ref="toast"></tm-message>
  6. <tm-sheet :shadow="24" :padding="[12,24]" :margin="[24,24]">
  7. <view>
  8. <tm-form>
  9. <tm-input name="title" title="手机号码" v-model="reqData.mobile"></tm-input>
  10. <view class="flex-between" :class="$tm.vx.state().tmVuetify.black ? 'bk' : ''">
  11. <tm-input name="title" :password="! on" title="登录密码" v-model="reqData.password"></tm-input>
  12. <view>
  13. <tm-switch v-model="on" :text="['','...']"></tm-switch>
  14. </view>
  15. </view>
  16. <view class="px-24">
  17. <tm-button @click="tijiao()" theme="bg-gradient-blue-accent" block>登陆</tm-button>
  18. <tm-row class="mt-40 mb-20">
  19. <tm-col color="text-size-xs" :grid="6">
  20. <view class="py-10"><text class="text-primary text-size-s text-align-center" @click="zhuce()">注册新用户</text></view>
  21. </tm-col>
  22. <tm-col color="text-size-xs" :grid="6">
  23. <view class="py-10"><text class="text-primary text-size-s text-align-center" @click="zhaohui()">找回密码</text></view>
  24. </tm-col>
  25. </tm-row>
  26. </view>
  27. </tm-form>
  28. </view>
  29. </tm-sheet>
  30. </view>
  31. </template>
  32. <script>
  33. import{myRequest} from '@/api/request.js'
  34. export default {
  35. data() {
  36. return {
  37. on:false,
  38. reqData:{
  39. mobile:'',
  40. password:'',
  41. }
  42. };
  43. },
  44. onLoad() {
  45. },
  46. created() {
  47. this.sys = uni.getSystemInfoSync();
  48. },
  49. methods: {
  50. tijiao(){
  51. var that=this;
  52. if(that.reqData.mobile==""){
  53. that.$refs.toast.show({model:'warn',label:'请输入手机号'})
  54. return
  55. }else if(that.reqData.password==""){
  56. that.$refs.toast.show({model:'warn',label:'请输入密码'})
  57. return
  58. }
  59. myRequest({
  60. url: "/api/login/login",
  61. method:'post',
  62. data:that.reqData
  63. }).then(res => {
  64. console.log(res.data)
  65. if (res.data.code == 200) {
  66. uni.setStorageSync("token",res.data.data.token)
  67. that.$refs.toast.show({model:'success',label:res.data.msg})
  68. setTimeout(function(){
  69. uni.navigateTo({
  70. url: "/pages/index/index",
  71. })
  72. },2000)
  73. }else{
  74. that.$refs.toast.show({model:'error',label:res.data.msg})
  75. }
  76. })
  77. },
  78. zhuce(){
  79. uni.navigateTo({
  80. url: "/pages/registered/index",
  81. })
  82. },
  83. zhaohui(){
  84. uni.navigateTo({
  85. url: "/pages/zhaohui/index",
  86. })
  87. },
  88. login(){
  89. uni.navigateTo({
  90. url: "/pages/login/index",
  91. })
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss">
  97. /deep/ .tm-menubars .body{
  98. background-color: #1b1b1b !important;
  99. }
  100. </style>