index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <view >
  3. <tm-message ref="toast"></tm-message>
  4. <tm-menubars title="找回密码" color="bg-gradient-primary-lighten" :showback="true"></tm-menubars>
  5. <tm-sheet :shadow="24">
  6. <tm-steps model="number" color="bg-gradient-blue-accent" activeFontColor="blue" line-color="bg-gradient-blue-accent" v-model="active" :list="list"></tm-steps>
  7. <view v-if="active==1">
  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. <view class="px-24">
  17. <tm-button @click="xia()" theme="bg-gradient-blue-accent" block>下一步</tm-button>
  18. </view>
  19. </tm-form>
  20. </view>
  21. <view v-else>
  22. <tm-form>
  23. <tm-input name="title" password title="密码" v-model="reqData.password"></tm-input>
  24. <tm-input name="title" password title="确认密码" v-model="reqData.password1"></tm-input>
  25. <view class="px-24">
  26. <tm-button @click="tijiao()" theme="bg-gradient-blue-accent" block>提交</tm-button>
  27. </view>
  28. </tm-form>
  29. </view>
  30. </tm-sheet>
  31. </view>
  32. </template>
  33. <script>
  34. import{myRequest} from '@/api/request.js'
  35. export default {
  36. data() {
  37. return {
  38. active:1,
  39. list:['1.验证手机号码','2.设置新密码'],
  40. reqData:{
  41. mobile:'',
  42. sms_code:'',
  43. password:'',
  44. password1:''
  45. },
  46. yzmvar:{
  47. colorvar:'primary',
  48. text:'发送验证码'
  49. }
  50. };
  51. },
  52. onLoad() {
  53. },
  54. created() {
  55. },
  56. methods: {
  57. tijiao(){
  58. var that=this;
  59. if(that.reqData.password==""){
  60. that.$refs.toast.show({model:'warn',label:'请输入密码'})
  61. return
  62. }else if(that.reqData.password1==""){
  63. that.$refs.toast.show({model:'warn',label:'请输入确认密码'})
  64. return
  65. }else if(that.reqData.password != that.reqData.password1){
  66. that.$refs.toast.show({model:'warn',label:'密码不一致'})
  67. return
  68. }
  69. myRequest({
  70. url: "/api/login/retrievePassword",
  71. method:'post',
  72. data:that.reqData
  73. }).then(res => {
  74. console.log(res)
  75. if (res.data.code == 200) {
  76. that.$refs.toast.show({model:'success',label:res.data.msg})
  77. setTimeout(function(){
  78. uni.navigateTo({
  79. url: "/pages/login/index",
  80. })
  81. },2000)
  82. }else{
  83. that.$refs.toast.show({model:'error',label:res.data.msg})
  84. }
  85. })
  86. },
  87. xia(){
  88. var that=this;
  89. if(that.reqData.mobile==""){
  90. that.$refs.toast.show({model:'warn',label:'请输入手机号'})
  91. return
  92. }else if(that.reqData.sms_code==""){
  93. that.$refs.toast.show({model:'warn',label:'请输入验证码'})
  94. return
  95. }
  96. that.active=2
  97. },
  98. sendyzm(){
  99. var that=this;
  100. if(that.reqData.mobile==""){
  101. that.$refs.toast.show({model:'warn',label:'请输入手机号'})
  102. return
  103. }
  104. that.yzmvar.colorvar="gray";
  105. that.yzmvar.text="已发送";
  106. setTimeout(function(){
  107. that.yzmvar.colorvar="primary";
  108. that.yzmvar.text="发送验证码";
  109. },5000)
  110. },
  111. },
  112. }
  113. </script>
  114. <style lang="scss">
  115. </style>