index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <template>
  2. <view class="reg" :style="{ 'height': setHeight + 'px' }">
  3. <view class="title">重置密码</view>
  4. <div class="form" v-if="step === 1">
  5. <form @submit="submit1" report-submit='true'>
  6. <view class="verify">
  7. <view class="list">
  8. <view class="item">
  9. <input type='number' placeholder='填写手机号码' placeholder-class='placeholder' v-model="phone"></input>
  10. </view>
  11. <view class="item acea-row row-between-wrapper">
  12. <input type='number' placeholder='填写验证码' placeholder-class='placeholder' class="codeIput" v-model="yzm"></input>
  13. <button class="code font-color" :class="disabled === true ? 'on' : ''" :disabled='disabled' @click="code">
  14. {{ text }}
  15. </button>
  16. </view>
  17. </view>
  18. <button form-type="submit" class="confirmBnt">立即找回</button>
  19. </view>
  20. </form>
  21. <view class="login">已有账号,<navigator hover-class="none" url="/pages/users/login/index">立即登录?</navigator></view>
  22. </div>
  23. <div class="form2" v-else>
  24. <div class="item">
  25. <div class="acea-row row-middle">
  26. <input type="password" placeholder="请输入新密码" placeholder-class="placeholder" v-model="password" required />
  27. </div>
  28. </div>
  29. <div class="item">
  30. <div class="acea-row row-middle">
  31. <input type="password" placeholder="再次确认密码" placeholder-class="placeholder" v-model="qrPassword" required />
  32. </div>
  33. </div>
  34. <button class="btn" @click="submit2">确认修改</button>
  35. <button class="back" @click="back">返回</button>
  36. <view class="login">已有账号,<navigator hover-class="none" url="/pages/users/login/index">立即登录?</navigator></view>
  37. </div>
  38. </view>
  39. </template>
  40. <script>
  41. import {
  42. ApiForgetYzm,
  43. ApiForget1,
  44. ApiForget2
  45. } from '@/api/api.js';
  46. import CryptoJS from "@/libs/CryptoJS";
  47. import sendVerifyCode from "@/mixins/SendVerifyCode";
  48. export default {
  49. mixins: [sendVerifyCode],
  50. data() {
  51. return {
  52. setHeight: 0,
  53. phone:'',
  54. yzm:'',
  55. step:1,
  56. token: '',
  57. password: '',
  58. qrPassword: ''
  59. }
  60. },
  61. mounted() {
  62. let that = this
  63. uni.getSystemInfo({
  64. success: function (res) {
  65. that.setHeight = res.windowHeight
  66. }
  67. })
  68. },
  69. methods: {
  70. async code() {
  71. let that = this;
  72. if (!that.phone) return that.$util.Tips({
  73. title: '请填写手机号码!'
  74. });
  75. if (!(/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.phone))) return that.$util.Tips({
  76. title: '请输入正确的手机号码!'
  77. });
  78. var secret_key = "b1bd7a4b8da3e47ce58e73b9e5f656c4";
  79. var AES = new CryptoJS.AES(secret_key);
  80. await ApiForgetYzm({
  81. mobile: that.phone,
  82. token: AES.encrypt(that.phone),
  83. time: new Date().getTime()
  84. }).then(res => {
  85. that.$util.Tips({
  86. title: res.msg
  87. });
  88. that.sendCode();
  89. }).catch(err => {
  90. return that.$util.Tips({
  91. title: err
  92. });
  93. });
  94. },
  95. async submit1() {
  96. let that = this;
  97. if (!that.phone) return that.$util.Tips({
  98. title: '请填写手机号码'
  99. });
  100. if (!(/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.phone))) return that.$util.Tips({
  101. title: '请输入正确的手机号码'
  102. });
  103. if (!that.yzm) return that.$util.Tips({
  104. title: '请填写验证码'
  105. });
  106. if (!/^[\w\d]+$/i.test(that.yzm)) return that.$util.Tips({
  107. title: '请输入正确的验证码'
  108. });
  109. ApiForget1({
  110. mobile: that.phone,
  111. yzm: that.yzm
  112. }).then(res => {
  113. that.token = res.data.token;
  114. that.step = 2;
  115. }).catch(res => {
  116. that.$util.Tips({
  117. title: res
  118. });
  119. });
  120. },
  121. submit2 () {
  122. let that = this;
  123. if (!that.password) return that.$util.Tips({
  124. title: '请输入新密码'
  125. });
  126. if (that.password.length < 6) return that.$util.Tips({
  127. title: '密码不能少于6位'
  128. });
  129. if (!that.qrPassword) return that.$util.Tips({
  130. title: '请输入确认密码'
  131. });
  132. if (that.qrPassword !== that.password) return that.$util.Tips({
  133. title: '二次密码不相等'
  134. });
  135. ApiForget2({
  136. token: that.token,
  137. password: that.password,
  138. qrPassword: that.qrPassword
  139. }).then(res => {
  140. return that.$util.Tips({
  141. title: '找回密码成功!',
  142. icon: 'success'
  143. }, {
  144. tab: 2,
  145. url: '/pages/users/login/index'
  146. });
  147. }).catch(err => {
  148. that.$util.Tips({
  149. title: err
  150. });
  151. });
  152. },
  153. back(){
  154. this.step = 1;
  155. }
  156. }
  157. }
  158. </script>
  159. <style scoped lang="scss">
  160. .reg{
  161. background: #fff;
  162. }
  163. .title{
  164. font-size: 42rpx;
  165. text-align: center;
  166. padding-top: 60rpx;
  167. }
  168. .verify .phone {
  169. font-size: 32rpx;
  170. font-weight: bold;
  171. text-align: center;
  172. margin-top: 55rpx;
  173. }
  174. .verify .list {
  175. width: 580rpx;
  176. margin: 53rpx auto 0 auto;
  177. }
  178. .verify .list .item {
  179. width: 100%;
  180. height: 110rpx;
  181. border-bottom: 2rpx solid #f0f0f0;
  182. }
  183. .verify .list .item input {
  184. width: 100%;
  185. height: 100%;
  186. font-size: 32rpx;
  187. }
  188. .verify .list .item .placeholder {
  189. color: #b9b9bc;
  190. }
  191. .verify .list .item input.codeIput {
  192. width: 340rpx;
  193. }
  194. .verify .list .item .code {
  195. font-size: 32rpx;
  196. background-color: #fff;
  197. }
  198. .verify .list .item .code.on {
  199. color: #b9b9bc !important;
  200. }
  201. .verify .confirmBnt {
  202. font-size: 32rpx;
  203. width: 580rpx;
  204. height: 90rpx;
  205. border-radius: 45rpx;
  206. color: #fff;
  207. margin: 92rpx auto 0 auto;
  208. text-align: center;
  209. line-height: 90rpx;
  210. background: #ff5c00;
  211. }
  212. .form .login{
  213. display: flex;
  214. justify-content: center;
  215. margin-top: 30rpx;
  216. navigator{
  217. color:#ff5c00;
  218. }
  219. }
  220. .form2{
  221. padding: 40rpx;
  222. .avatar{
  223. width:140rpx;
  224. height:140rpx;
  225. font-size:22rpx;
  226. color:#bbb;
  227. border:1rpx dashed #ddd;
  228. margin: 20rpx auto;
  229. text-align: center;
  230. .iconfont{
  231. font-size: 50rpx;
  232. }
  233. image{
  234. width:140rpx;
  235. height:140rpx;
  236. }
  237. }
  238. .item {
  239. border-bottom: 1rpx solid #ededed;
  240. padding: 45rpx 0 20rpx 0;
  241. image{
  242. width:40rpx;
  243. height:40rpx;
  244. margin-right: 20rpx;
  245. }
  246. input{
  247. flex-grow: 1;
  248. font-size: 28rpx;
  249. }
  250. .placeholder{
  251. color:#ccc;
  252. }
  253. }
  254. .btn {
  255. font-size: 32rpx;
  256. width: 580rpx;
  257. height: 85rpx;
  258. border-radius: 45rpx;
  259. color: #fff;
  260. margin: 80rpx auto 0 auto;
  261. text-align: center;
  262. line-height: 85rpx;
  263. background: #ff5c00;
  264. }
  265. .back{
  266. font-size: 32rpx;
  267. width: 580rpx;
  268. height: 85rpx;
  269. border-radius: 45rpx;
  270. margin: 20rpx auto 0 auto;
  271. text-align: center;
  272. line-height: 85rpx;
  273. border: 1rpx solid #dcdee2;
  274. color:#515a6e;
  275. }
  276. .login{
  277. display: flex;
  278. justify-content: center;
  279. margin-top: 30rpx;
  280. navigator{
  281. color:#ff5c00;
  282. }
  283. }
  284. }
  285. </style>