index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <view :data-theme="theme" class="upda_pasd">
  3. <view class="ChangePassword">
  4. <form @submit="editPwd" report-submit='true'>
  5. <view class="phone">当前手机号:{{userInfo.phone}}</view>
  6. <view class="list">
  7. <view class="item">
  8. <input type='password' placeholder='6-8位字母加数字' placeholder-class='placeholder' name="password"
  9. :value="password" maxlength="18" @blur="checkPasd"></input>
  10. </view>
  11. <view class="item">
  12. <input type='password' placeholder='确认新密码' placeholder-class='placeholder' name="qr_password"
  13. :value="qr_password" maxlength="18" @blur="checkPassword"></input>
  14. </view>
  15. <view class="item acea-row row-between-wrapper">
  16. <input type='number' placeholder='填写验证码' placeholder-class='placeholder' class="codeIput"
  17. name="captcha" :value="captcha" maxlength="6"></input>
  18. <button class="code" :class="disabled === true ? 'on' : ''" :disabled='disabled' @click="code">
  19. {{ text }}
  20. </button>
  21. </view>
  22. </view>
  23. <button form-type="submit" class="confirmBnt">确认修改</button>
  24. </form>
  25. </view>
  26. <Verify @success="handlerOnVerSuccess" :captchaType="'clickWord'" :imgSize="{ width: '330px', height: '155px' }"
  27. ref="verify"></Verify>
  28. </view>
  29. </template>
  30. <script>
  31. // +----------------------------------------------------------------------
  32. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  33. // +----------------------------------------------------------------------
  34. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  35. // +----------------------------------------------------------------------
  36. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  37. // +----------------------------------------------------------------------
  38. // | Author: CRMEB Team <admin@crmeb.com>
  39. // +----------------------------------------------------------------------
  40. import sendVerifyCode from "@/mixins/SendVerifyCode";
  41. import {
  42. phoneRegisterReset,
  43. registerVerify
  44. } from '@/api/api.js';
  45. import {
  46. toLogin
  47. } from '@/libs/login.js';
  48. import {
  49. mapGetters
  50. } from "vuex";
  51. import {
  52. setThemeColor
  53. } from '@/utils/setTheme.js'
  54. import {
  55. Debounce
  56. } from '@/utils/validate.js'
  57. import Verify from '../components/verifition/verify.vue';
  58. import {
  59. updatePasswordCodeApi
  60. } from "../../../api/api";
  61. const app = getApp();
  62. export default {
  63. mixins: [sendVerifyCode],
  64. components: {
  65. Verify
  66. },
  67. data() {
  68. return {
  69. password: '',
  70. captcha: '',
  71. qr_password: '',
  72. isAuto: false, //没有授权的不会自动授权
  73. isShowAuth: false, //是否隐藏授权
  74. theme: app.globalData.theme,
  75. bgColor: ''
  76. };
  77. },
  78. computed: mapGetters(['isLogin', 'userInfo']),
  79. onLoad() {
  80. if (!this.isLogin) {
  81. toLogin();
  82. }
  83. this.bgColor = setThemeColor();
  84. uni.setNavigationBarColor({
  85. frontColor: '#ffffff',
  86. backgroundColor: this.bgColor,
  87. });
  88. },
  89. methods: {
  90. /**
  91. * 授权回调
  92. */
  93. onLoadFun: function(e) {
  94. //this.getUserInfo();
  95. },
  96. // 授权关闭
  97. authColse: function(e) {
  98. this.isShowAuth = e
  99. },
  100. //滑块验证成功后调用
  101. handlerOnVerSuccess(data) {
  102. this.$refs.verify.hide();
  103. this.codeSend();
  104. },
  105. codeSend() {
  106. let that = this;
  107. updatePasswordCodeApi().then(res => {
  108. that.$util.Tips({
  109. title: '发送成功'
  110. });
  111. that.sendCode();
  112. }).catch(err => {
  113. return that.$util.Tips({
  114. title: err
  115. });
  116. });
  117. },
  118. /**
  119. * 发送验证码
  120. *
  121. */
  122. code: Debounce(function(e) {
  123. let that = this;
  124. if (!that.userInfo.phone) return that.$util.Tips({
  125. title: '手机号码不存在,无法发送验证码!'
  126. });
  127. if (that.qr_password != that.password) return that.$util.Tips({
  128. title: '两次输入的密码不一致!'
  129. });
  130. that.$refs.verify.show();
  131. }),
  132. /**
  133. * H5登录 修改密码
  134. *
  135. */
  136. checkPasd(e) {
  137. let that = this,
  138. password = e.detail.value;
  139. that.password = password;
  140. // if (!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,8}$/i.test(password)) return that.$util.Tips({
  141. if (!/^[a-zA-Z]\w{5,17}$/i.test(password)) return that.$util.Tips({
  142. title: '密码格式错误,密码必须以字母开头,长度在6~8之间,只能包含字符数字和下划线'
  143. });
  144. },
  145. checkPassword(e) {
  146. let that = this,
  147. qr_password = e.detail.value;
  148. that.qr_password = qr_password;
  149. if (qr_password != that.password) return that.$util.Tips({
  150. title: '两次输入的密码不一致!'
  151. });
  152. },
  153. editPwd: Debounce(function(e) {
  154. let that = this,
  155. password = e.detail.value.password,
  156. qr_password = e.detail.value.qr_password,
  157. captcha = e.detail.value.captcha;
  158. if (!password) return that.$util.Tips({
  159. title: '请输入新密码'
  160. });
  161. if (!qr_password) return that.$util.Tips({
  162. title: '请确认新密码'
  163. });
  164. if (!captcha) return that.$util.Tips({
  165. title: '请输入验证码'
  166. });
  167. uni.showLoading({
  168. title: '加载中',
  169. mask: true
  170. });
  171. phoneRegisterReset({
  172. captcha: captcha,
  173. password: password
  174. }).then(res => {
  175. uni.hideLoading();
  176. return that.$util.Tips({
  177. title: '操作成功'
  178. }, {
  179. tab: 3,
  180. url: 1
  181. });
  182. }).catch(err => {
  183. uni.hideLoading();
  184. return that.$util.Tips({
  185. title: err
  186. });
  187. });
  188. })
  189. }
  190. }
  191. </script>
  192. <style lang="scss">
  193. page {
  194. background-color: #fff !important;
  195. }
  196. .upda_pasd {
  197. background: #FFFFFF;
  198. height: 100vh;
  199. }
  200. .ChangePassword .phone {
  201. font-size: 32rpx;
  202. font-weight: bold;
  203. text-align: center;
  204. padding-top: 100rpx;
  205. }
  206. .ChangePassword .list {
  207. width: 580rpx;
  208. margin: 53rpx auto 0 auto;
  209. }
  210. .ChangePassword .list .item {
  211. width: 100%;
  212. height: 110rpx;
  213. border-bottom: 2rpx solid #f0f0f0;
  214. }
  215. .ChangePassword .list .item input {
  216. width: 100%;
  217. height: 100%;
  218. font-size: 32rpx;
  219. }
  220. .ChangePassword .list .item .placeholder {
  221. color: #b9b9bc;
  222. }
  223. .ChangePassword .list .item input.codeIput {
  224. width: 340rpx;
  225. }
  226. .ChangePassword .list .item .code {
  227. font-size: 32rpx;
  228. // background-color: #fff;
  229. @include main_color(theme);
  230. }
  231. .ChangePassword .list .item .code.on {
  232. color: #b9b9bc !important;
  233. }
  234. .ChangePassword .confirmBnt {
  235. font-size: 32rpx;
  236. width: 580rpx;
  237. height: 90rpx;
  238. border-radius: 45rpx;
  239. color: #fff;
  240. margin: 92rpx auto 0 auto;
  241. text-align: center;
  242. line-height: 90rpx;
  243. @include main_bg_color(theme);
  244. }
  245. </style>