index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <view>
  3. <view class="ChangePassword">
  4. <form @submit="editPwd" report-submit='true'>
  5. <view class="phone">当前手机号:{{phone}}</view>
  6. <view class="list">
  7. <view class="item">
  8. <input type='password' placeholder='设置新密码' placeholder-class='placeholder' name="password" :value="password"></input>
  9. </view>
  10. <view class="item">
  11. <input type='password' placeholder='确认新密码' placeholder-class='placeholder' name="qr_password" :value="qr_password"></input>
  12. </view>
  13. <view class="item acea-row row-between-wrapper">
  14. <input type='number' placeholder='填写验证码' placeholder-class='placeholder' class="codeIput" name="captcha" :value="captcha"></input>
  15. <button class="code font-color" :class="disabled === true ? 'on' : ''" :disabled='disabled' @click="handleVerify">
  16. {{ text }}
  17. </button>
  18. </view>
  19. </view>
  20. <button form-type="submit" class="confirmBnt bg-color">确认修改</button>
  21. </form>
  22. </view>
  23. <Verify @success="success" :captchaType="'blockPuzzle'" :imgSize="{ width: '330px', height: '155px' }" ref="verify"></Verify>
  24. </view>
  25. </template>
  26. <script>
  27. // +----------------------------------------------------------------------
  28. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  29. // +----------------------------------------------------------------------
  30. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  31. // +----------------------------------------------------------------------
  32. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  33. // +----------------------------------------------------------------------
  34. // | Author: CRMEB Team <admin@crmeb.com>
  35. // +----------------------------------------------------------------------
  36. import sendVerifyCode from "@/mixins/SendVerifyCode";
  37. import { phoneRegisterReset, registerVerify } from '@/api/api.js';
  38. import { getUserInfo } from '@/api/user.js';
  39. import { mapGetters } from "vuex";
  40. import Verify from '@/components/verify/verify.vue';
  41. import { toLogin } from '@/libs/login.js';
  42. export default {
  43. mixins: [sendVerifyCode],
  44. components: {
  45. Verify
  46. },
  47. data() {
  48. return {
  49. userInfo: {},
  50. phone: '',
  51. password: '',
  52. captcha: '',
  53. qr_password: '',
  54. };
  55. },
  56. computed: mapGetters(['isLogin']),
  57. onLoad() {
  58. if (this.isLogin) {
  59. this.getUserInfo();
  60. } else {
  61. toLogin()
  62. }
  63. },
  64. methods: {
  65. /**
  66. * 获取个人用户信息
  67. */
  68. getUserInfo: function() {
  69. let that = this;
  70. getUserInfo().then(res => {
  71. let tel = res.data.phone;
  72. let phone = tel.substr(0, 3) + "****" + tel.substr(7);
  73. that.$set(that, 'userInfo', res.data);
  74. that.phone = phone;
  75. });
  76. },
  77. /**
  78. * 发送验证码
  79. *
  80. */
  81. async code(data) {
  82. let that = this;
  83. if (!that.userInfo.phone) return that.$util.Tips({
  84. title: '手机号码不存在,无法发送验证码!'
  85. });
  86. await registerVerify(that.userInfo.phone).then(res => {
  87. that.$util.Tips({
  88. title: res.message
  89. });
  90. that.sendCode();
  91. }).catch(err => {
  92. return that.$util.Tips({
  93. title: err
  94. });
  95. });
  96. },
  97. /**
  98. * H5登录 修改密码
  99. *
  100. */
  101. editPwd: function(e) {
  102. let that = this,
  103. password = e.detail.value.password,
  104. qr_password = e.detail.value.qr_password,
  105. captcha = e.detail.value.captcha;
  106. if (!password) return that.$util.Tips({
  107. title: '请输入新密码'
  108. });
  109. if (qr_password != password) return that.$util.Tips({
  110. title: '两次输入的密码不一致!'
  111. });
  112. if (!captcha) return that.$util.Tips({
  113. title: '请输入验证码'
  114. });
  115. phoneRegisterReset({
  116. account: that.userInfo.phone,
  117. captcha: captcha,
  118. password: password
  119. }).then(res => {
  120. return that.$util.Tips({
  121. title: res.message
  122. }, {
  123. tab: 3,
  124. url: 1
  125. });
  126. }).catch(err => {
  127. return that.$util.Tips({
  128. title: err
  129. });
  130. });
  131. },
  132. success(data) {
  133. this.$refs.verify.hide();
  134. this.code(data);
  135. },
  136. handleVerify() {
  137. this.$refs.verify.show();
  138. }
  139. }
  140. }
  141. </script>
  142. <style lang="scss" scoped>
  143. page {
  144. background-color: #fff !important;
  145. }
  146. .ChangePassword .phone {
  147. font-size: 32rpx;
  148. font-weight: bold;
  149. text-align: center;
  150. margin-top: 55rpx;
  151. }
  152. .ChangePassword .list {
  153. width: 580rpx;
  154. margin: 53rpx auto 0 auto;
  155. }
  156. .ChangePassword .list .item {
  157. width: 100%;
  158. height: 110rpx;
  159. border-bottom: 2rpx solid #f0f0f0;
  160. }
  161. .ChangePassword .list .item input {
  162. width: 100%;
  163. height: 100%;
  164. font-size: 32rpx;
  165. }
  166. .ChangePassword .list .item .placeholder {
  167. color: #b9b9bc;
  168. }
  169. .ChangePassword .list .item input.codeIput {
  170. width: 340rpx;
  171. }
  172. .ChangePassword .list .item .code {
  173. font-size: 32rpx;
  174. background-color: #fff;
  175. }
  176. .ChangePassword .list .item .code.on {
  177. color: #b9b9bc !important;
  178. }
  179. .ChangePassword .confirmBnt {
  180. font-size: 32rpx;
  181. width: 580rpx;
  182. height: 90rpx;
  183. border-radius: 45rpx;
  184. color: #fff;
  185. margin: 92rpx auto 0 auto;
  186. text-align: center;
  187. line-height: 90rpx;
  188. }
  189. </style>