index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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" title="验证码" v-model="reqData.sms_code"></tm-input>
  12. <view>
  13. <tm-button @click="sendyzm" :theme="yzmvar.colorvar" size="m">{{yzmvar.text}}</tm-button>
  14. </view>
  15. </view>
  16. <tm-input name="title" password title="密码" v-model="reqData.password"></tm-input>
  17. <tm-input name="title" password title="确认密码" v-model="reqData.password1"></tm-input>
  18. <view class="px-24">
  19. <view class="py-10 text-size-s text-grey text-align-left">
  20. <tm-checkbox :size="32" color="bg-gradient-primary-accent" v-model="checked" round="rounded"></tm-checkbox>同意<text class="text-primary" @click="xieyi()">《用户服务协议》</text></view>
  21. <tm-button @click="tijiao()" theme="bg-gradient-blue-accent" block>注册</tm-button>
  22. <view class="py-10 text-size-s text-grey text-align-center ma-10">
  23. <text class="text-primary text-size-s text-align-center" @click="login()">已有账号,立即登录</text>
  24. </view>
  25. </view>
  26. </tm-form>
  27. </view>
  28. </tm-sheet>
  29. </view>
  30. </template>
  31. <script>
  32. import{myRequest} from '@/api/request.js'
  33. export default {
  34. data() {
  35. return {
  36. checked:false,
  37. reqData:{
  38. mobile:'',
  39. sms_code:'',
  40. password:'',
  41. password1:''
  42. },
  43. yzmvar:{
  44. colorvar:'primary',
  45. text:'发送验证码'
  46. }
  47. };
  48. },
  49. onLoad() {
  50. },
  51. created() {
  52. this.sys = uni.getSystemInfoSync();
  53. },
  54. methods: {
  55. tijiao(){
  56. var that=this;
  57. if(that.reqData.mobile==""){
  58. that.$refs.toast.show({model:'warn',label:'请输入手机号'})
  59. return
  60. }else if(that.reqData.sms_code==""){
  61. that.$refs.toast.show({model:'warn',label:'请输入验证码'})
  62. return
  63. }else if(that.reqData.password==""){
  64. that.$refs.toast.show({model:'warn',label:'请输入密码'})
  65. return
  66. }else if(that.reqData.password1==""){
  67. that.$refs.toast.show({model:'warn',label:'请输入确认密码'})
  68. return
  69. }else if(that.reqData.password != that.reqData.password1){
  70. that.$refs.toast.show({model:'warn',label:'密码不一致'})
  71. return
  72. }else if(! that.checked){
  73. that.$refs.toast.show({model:'warn',label:'请勾选用户协议'})
  74. return
  75. }
  76. myRequest({
  77. url: "/api/login/register",
  78. method:'post',
  79. data:that.reqData
  80. }).then(res => {
  81. console.log(res)
  82. if (res.data.code == 200) {
  83. that.$refs.toast.show({model:'success',label:res.data.msg})
  84. setTimeout(function(){
  85. uni.navigateTo({
  86. url: "/pages/login/index",
  87. })
  88. },2000)
  89. }else{
  90. that.$refs.toast.show({model:'error',label:res.data.msg})
  91. }
  92. })
  93. },
  94. sendyzm(){
  95. var that=this;
  96. if(that.reqData.mobile==""){
  97. that.$refs.toast.show({model:'warn',label:'请输入手机号'})
  98. return
  99. }
  100. that.yzmvar.colorvar="gray";
  101. that.yzmvar.text="已发送";
  102. setTimeout(function(){
  103. that.yzmvar.colorvar="primary";
  104. that.yzmvar.text="发送验证码";
  105. },5000)
  106. },
  107. login(){
  108. uni.navigateTo({
  109. url: "/pages/login/index",
  110. })
  111. },
  112. xieyi(){
  113. uni.navigateTo({
  114. url: "/pages/xieyi/index",
  115. })
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang="scss">
  121. /deep/ .tm-menubars .body{
  122. background-color: #1b1b1b !important;
  123. }
  124. </style>