index.vue 2.3 KB

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