Forget.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <home-base :show="false"><view class="div container">
  3. <view class="div common-header-wrap">
  4. <view :style="'height:'+navHeight+'px'"></view>
  5. <view class="common-header-holder"></view>
  6. <view class="common-header-fixed">
  7. <title-header />
  8. <uni-nav-bar title="密码找回" class="common-header" left-icon="back" @clickLeft="goBack()">
  9. </uni-nav-bar>
  10. </view>
  11. </view>
  12. <view class="div main-content">
  13. <view class="div topList">
  14. <view class="div list">
  15. <view class="div item">
  16. <label class="title active">忘记密码</label>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="div top-wrapper">
  21. <flex-line class="field-line input-wrapper" :show-border="true"><view class="div field-line-right" slot="right"><input class="field-input" type="number" v-model="username" placeholder="请输入手机号" :attr="{ oninput: 'if(value.length>11)value=value.slice(0,11)' }" /></view></flex-line>
  22. <flex-line class="field-line input-wrapper" :show-border="true"><view class="div field-line-right" slot="right"><input class="field-input" type="number" v-model="verifyCodeMobile" placeholder="验证码" :attr="{ oninput: 'if(value.length>6)value=value.slice(0,6)' }" /><view @click="sendVerifyCodeMobile" class="div common-btn send-btn">{{sendStateTextMobile}}</view></view></flex-line>
  23. <flex-line class="field-line input-wrapper" :show-border="true"><view class="div field-line-right" slot="right"><input class="field-input" type="password" v-model="password" placeholder="设置密码" maxlength="20" /></view></flex-line>
  24. <flex-line class="field-line input-wrapper" :show-border="true"><view class="div field-line-right" slot="right"><input class="field-input" type="password" v-model="confirmPassword" placeholder="确认密码" maxlength="20" /><label v-if="!confirmPassword" class="tips">6-20位数字/字母/符号</label></view></flex-line>
  25. </view>
  26. <view class="div find_the_password_help">如果账号还没有绑定手机号,请联系平台管理员找回密码</view>
  27. <view class="div common-btn ds-button-large mt-10" @click="onSubmit">确定</view>
  28. </view>
  29. </view></home-base>
  30. </template>
  31. <script>
  32. import {getFontSize} from '@/util/common'
  33. import TitleHeader from '../../TitleHeader'
  34. import HomeBase from '../HomeBase'
  35. import { forget } from '../../../api/memberForget'
  36. import { getSmsCaptcha } from '../../../api/common'
  37. import { mapMutations, mapActions, mapState } from 'vuex'
  38. import flexLine from '../../flexLine'
  39. export default {
  40. name:'HomeMemberForget',
  41. components:{
  42. TitleHeader,
  43. HomeBase,
  44. flexLine
  45. },
  46. mounted(){
  47. // #ifdef MP-WEIXIN
  48. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  49. // #endif
  50. },
  51. computed:{
  52. fontSize(){
  53. return getFontSize()
  54. },
  55. },
  56. data(){
  57. return {
  58. navHeight: 0,
  59. username: '',
  60. password: '',
  61. confirmPassword: '',
  62. verifyCodeMobile: '',
  63. canSendMobile: true,
  64. timeIntervalMobile: false,
  65. sendStateTextMobile: '发送'
  66. }
  67. },
  68. beforeDestroy: function () {
  69. clearInterval(this.timeIntervalMobile)
  70. },
  71. methods:{
  72. goBack(){uni.navigateBack({delta:1})},
  73. ...mapMutations({
  74. saveAuthInfo: 'memberLogin'
  75. }),
  76. onSubmit () {
  77. forget(this.username, this.verifyCodeMobile, this.password, this.confirmPassword).then(
  78. response => {
  79. this.saveAuthInfo({ token: response.result.token, info: response.result.info })
  80. uni.navigateTo({url:'/pages/member/index/Index'})
  81. },
  82. error => {
  83. uni.showToast({icon:'none',title: error.message})
  84. }
  85. )
  86. },
  87. sendVerifyCodeMobile () {
  88. if (!this.canSendMobile) {
  89. return
  90. }
  91. getSmsCaptcha(3, this.username).then(res => {
  92. this.canSendMobile = false
  93. let second = 60
  94. uni.showToast({icon:'none',title: res.message})
  95. let _this = this
  96. this.timeIntervalMobile = setInterval(function () {
  97. if (second <= 0) {
  98. _this.canSendMobile = true
  99. _this.sendStateTextMobile = '发送'
  100. clearInterval(_this.timeIntervalMobile)
  101. } else {
  102. _this.sendStateTextMobile = second + 's'
  103. }
  104. second--
  105. }, 1000)
  106. }).catch(function (error) {
  107. uni.showToast({icon:'none',title: error.message})
  108. })
  109. }
  110. }
  111. }
  112. </script>
  113. <style scoped lang="scss">
  114. .ds-button-large{margin:0 $pageSpace}
  115. .container {
  116. display: flex;
  117. flex-direction: column;
  118. justify-content: flex-start;
  119. align-items: stretch;
  120. .main-content{background: #fff;padding:1rem 0;}
  121. .input-wrapper {
  122. display: flex;
  123. flex-direction: row;
  124. align-content: flex-start;
  125. align-items: center;
  126. background-color: #fff;
  127. height:2.2rem;
  128. padding-left:0.5rem;
  129. input {
  130. flex: 1;
  131. font-size:$subFontSize
  132. }
  133. .bottom-input {
  134. border-bottom-width: 0;
  135. }
  136. }
  137. }
  138. .top-wrapper {
  139. margin:0 $pageSpace;
  140. }
  141. .bottom-wrapper {
  142. margin-top: 0.5rem;
  143. }
  144. .tips {
  145. color: $descTextColor;
  146. font-size:$fontSize;
  147. white-space: nowrap;
  148. position: absolute;
  149. right: 0;
  150. top:50%;
  151. margin-top:-.3rem;
  152. }
  153. .field-line-right{position: relative;
  154. .field-input{
  155. text-align: left !important;
  156. }
  157. }
  158. .send-btn{border:1px solid $primaryColor;color:$primaryColor;min-width: 2rem}
  159. .topList {
  160. height:2rem;
  161. padding:1rem $pageSpace;
  162. .list {
  163. height: 100%;
  164. display: flex;
  165. flex-direction: row;
  166. justify-content: flex-start;
  167. align-content: center;
  168. align-items: stretch;
  169. background-color: #fff;
  170. }
  171. .item {
  172. padding:0 .5rem;
  173. position: relative;
  174. display: flex;
  175. flex-direction: column;
  176. justify-content: center;
  177. align-items: center;
  178. }
  179. .title {
  180. text-align: center;
  181. font-size:$h2;
  182. color: $formInputColor;
  183. }
  184. .active {
  185. color: $primaryColor;
  186. font-size:1.1rem;
  187. }
  188. .normal {
  189. color: #404245;
  190. }
  191. }
  192. .find_the_password_help{margin: 0 .6rem;font-size:$subFontSize;padding-top: .5rem;color: $descTextColor }
  193. </style>