index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. myRequest({
  101. url: "/api/Login/sendCode?mobile="+that.reqData.mobile,
  102. method:'get',
  103. data:{}
  104. }).then(res => {
  105. if (res.data.code == 200) {
  106. that.$refs.toast.show({model:'success',label:res.data.msg})
  107. that.yzmvar.text="已发送";
  108. setTimeout(function(){
  109. that.yzmvar.text="发送验证码";
  110. },15000)
  111. }else{
  112. that.$refs.toast.show({model:'error',label:res.data.msg})
  113. }
  114. })
  115. },
  116. login(){
  117. uni.navigateTo({
  118. url: "/pages/login/index",
  119. })
  120. },
  121. xieyi(){
  122. uni.navigateTo({
  123. url: "/pages/xieyi/index",
  124. })
  125. }
  126. }
  127. }
  128. </script>
  129. <style lang="scss">
  130. /deep/ .tm-menubars .body{
  131. background-color: #1b1b1b !important;
  132. }
  133. /deep/ .grey-darken-5{
  134. background-color: #0d0d0d!important;
  135. padding: 0px !important;
  136. }
  137. .tou{
  138. font-size: 28px;
  139. padding: 15px 30px 40px 30px;
  140. }
  141. .tel{
  142. margin-left: 5px;
  143. }
  144. .zhuti{
  145. padding: 15px 30px 40px 30px;
  146. }
  147. .mima{
  148. position: relative;
  149. }
  150. .wangji{
  151. position: absolute;
  152. right: 0px;
  153. top: 3px;
  154. }
  155. /deep/ .wangji .primary{
  156. background-color: #303440 !important;
  157. }
  158. </style>