index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. <view class="tou C1b1b1b">新用户注册</view>
  6. <view class="zhuti">
  7. <tm-form>
  8. <view class="tel text-size-m mt-50">请输入注册手机号码</view>
  9. <tm-input name="title" input-type="number" v-model="reqData.mobile"></tm-input>
  10. <view class="mima">
  11. <tm-input placeholder="请输入短信验证码" name="title" v-model="reqData.sms_code"></tm-input>
  12. <tm-button class="wangji" @click="sendyzm" size="m">{{yzmvar.text}}</tm-button>
  13. </view>
  14. <tm-input name="title" placeholder="请设置6-20位登录密码" password v-model="reqData.password"></tm-input>
  15. <tm-input name="title" placeholder="请再次确认登录密码" password v-model="reqData.password1"></tm-input>
  16. <view class="px-24">
  17. <view class="py-10 text-size-s mt-30">
  18. <tm-checkbox :size="32" color="bg-gradient-primary-accent" v-model="checked" round="rounded"></tm-checkbox>
  19. <text class="text-white" @click="xieyi()" style="vertical-align: middle;">阅读并同意《用户协议》</text>
  20. </view>
  21. <tm-button @click="tijiao()" theme="primary" :round="24" class="mt-50" block>注册</tm-button>
  22. <view class="py-10 text-size-s text-grey text-align-center mt-30">
  23. <text class="text-white text-size-s text-align-center" @click="login()">已有账户,立即登录</text>
  24. </view>
  25. </view>
  26. </tm-form>
  27. </view>
  28. <!-- 弹出层消息 -->
  29. <tm-message ref="toast"></tm-message>
  30. </view>
  31. </template>
  32. <script>
  33. import{myRequest} from '@/api/request.js'
  34. export default {
  35. data() {
  36. return {
  37. checked:false,
  38. reqData:{
  39. mobile:'',
  40. sms_code:'',
  41. password:'',
  42. password1:''
  43. },
  44. yzmvar:{
  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=="" || that.reqData.password.length<6 ||that.reqData.password.length>20){
  64. that.$refs.toast.show({model:'warn',label:'请设置6-20位登录密码'})
  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.text="已发送";
  101. setTimeout(function(){
  102. that.yzmvar.text="发送验证码";
  103. },15000)
  104. },
  105. login(){
  106. uni.navigateTo({
  107. url: "/pages/login/index",
  108. })
  109. },
  110. xieyi(){
  111. uni.navigateTo({
  112. url: "/pages/xieyi/index",
  113. })
  114. }
  115. }
  116. }
  117. </script>
  118. <style lang="scss">
  119. /deep/ .tm-menubars .body{
  120. background-color: #1b1b1b !important;
  121. }
  122. /deep/ .grey-darken-5{
  123. background-color: #0d0d0d!important;
  124. padding: 0px !important;
  125. }
  126. .tou{
  127. font-size: 28px;
  128. padding: 15px 30px 40px 30px;
  129. }
  130. .tel{
  131. margin-left: 5px;
  132. }
  133. .zhuti{
  134. padding: 15px 30px 40px 30px;
  135. }
  136. .mima{
  137. position: relative;
  138. }
  139. .wangji{
  140. position: absolute;
  141. right: 0px;
  142. top: 3px;
  143. }
  144. /deep/ .wangji .primary{
  145. background-color: #303440 !important;
  146. }
  147. </style>