index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <view :style="colorStyle">
  3. <view class="ChangePassword">
  4. <form @submit="editPwd">
  5. <view class="phone">{{$t(`当前手机号`)}}:{{phone}}</view>
  6. <view class="list">
  7. <view class="item">
  8. <input type='password' :placeholder='$t(`设置新密码`)' placeholder-class='placeholder' name="password" :value="password"></input>
  9. </view>
  10. <view class="item">
  11. <input type='password' :placeholder='$t(`确认新密码`)' 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='$t(`填写验证码`)' placeholder-class='placeholder' class="codeIput" name="captcha" :value="captcha"></input>
  15. <button class="code font-num" :class="disabled === true ? 'on' : ''" :disabled='disabled' @click="code">
  16. {{ text }}
  17. </button>
  18. </view>
  19. </view>
  20. <button form-type="submit" class="confirmBnt bg-color">{{$t(`确认修改`)}}</button>
  21. </form>
  22. </view>
  23. <!-- #ifdef MP -->
  24. <!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
  25. <!-- #endif -->
  26. </view>
  27. </template>
  28. <script>
  29. import sendVerifyCode from "@/mixins/SendVerifyCode";
  30. import {
  31. phoneRegisterReset,
  32. registerVerify,
  33. verifyCode
  34. } from '@/api/api.js';
  35. import {
  36. getUserInfo
  37. } from '@/api/user.js';
  38. import {
  39. toLogin
  40. } from '@/libs/login.js';
  41. import {
  42. mapGetters
  43. } from "vuex";
  44. // #ifdef MP
  45. import authorize from '@/components/Authorize';
  46. // #endif
  47. import colors from '@/mixins/color.js';
  48. export default {
  49. mixins: [sendVerifyCode,colors],
  50. components: {
  51. // #ifdef MP
  52. authorize
  53. // #endif
  54. },
  55. data() {
  56. return {
  57. userInfo: {},
  58. phone: '',
  59. password: '',
  60. captcha: '',
  61. qr_password: '',
  62. isAuto: false, //没有授权的不会自动授权
  63. isShowAuth: false ,//是否隐藏授权
  64. key: '',
  65. };
  66. },
  67. computed: mapGetters(['isLogin']),
  68. watch:{
  69. isLogin:{
  70. handler:function(newV,oldV){
  71. if(newV){
  72. this.getUserInfo();
  73. }
  74. },
  75. deep:true
  76. }
  77. },
  78. onLoad() {
  79. if (this.isLogin) {
  80. this.getUserInfo();
  81. verifyCode().then(res=>{
  82. this.$set(this, 'key', res.data.key)
  83. });
  84. } else {
  85. toLogin()
  86. }
  87. },
  88. methods: {
  89. /**
  90. * 授权回调
  91. */
  92. onLoadFun: function(e) {
  93. this.getUserInfo();
  94. },
  95. // 授权关闭
  96. authColse: function(e) {
  97. this.isShowAuth = e
  98. },
  99. /**
  100. * 获取个人用户信息
  101. */
  102. getUserInfo: function() {
  103. let that = this;
  104. getUserInfo().then(res => {
  105. let tel = res.data.phone;
  106. let phone = tel.substr(0, 3) + "****" + tel.substr(7);
  107. that.$set(that, 'userInfo', res.data);
  108. that.phone = phone;
  109. });
  110. },
  111. /**
  112. * 发送验证码
  113. *
  114. */
  115. async code() {
  116. let that = this;
  117. if (!that.userInfo.phone) return that.$util.Tips({
  118. title: that.$t(`手机号码不存在,无法发送验证码!`)
  119. });
  120. await registerVerify(that.userInfo.phone,'reset', that.key).then(res => {
  121. that.$util.Tips({
  122. title: res.msg
  123. });
  124. that.sendCode();
  125. }).catch(err => {
  126. return that.$util.Tips({
  127. title: err
  128. });
  129. });
  130. },
  131. /**
  132. * H5登录 修改密码
  133. *
  134. */
  135. editPwd: function(e) {
  136. let that = this,
  137. password = e.detail.value.password,
  138. qr_password = e.detail.value.qr_password,
  139. captcha = e.detail.value.captcha;
  140. if (!password) return that.$util.Tips({
  141. title: that.$t(`请输入新密码`)
  142. });
  143. if (qr_password != password) return that.$util.Tips({
  144. title: that.$t(`两次输入的密码不一致!`)
  145. });
  146. if (!captcha) return that.$util.Tips({
  147. title: that.$t(`请输入验证码`)
  148. });
  149. phoneRegisterReset({
  150. account: that.userInfo.phone,
  151. captcha: captcha,
  152. password: password
  153. }).then(res => {
  154. return that.$util.Tips({
  155. title: res.msg
  156. }, {
  157. tab: 3,
  158. url: 1
  159. });
  160. }).catch(err => {
  161. return that.$util.Tips({
  162. title: err
  163. });
  164. });
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="scss">
  170. page {
  171. background-color: #fff !important;
  172. }
  173. .ChangePassword .phone {
  174. font-size: 32rpx;
  175. font-weight: bold;
  176. text-align: center;
  177. margin-top: 55rpx;
  178. }
  179. .ChangePassword .list {
  180. width: 580rpx;
  181. margin: 53rpx auto 0 auto;
  182. }
  183. .ChangePassword .list .item {
  184. width: 100%;
  185. height: 110rpx;
  186. border-bottom: 2rpx solid #f0f0f0;
  187. }
  188. .ChangePassword .list .item input {
  189. width: 100%;
  190. height: 100%;
  191. font-size: 32rpx;
  192. }
  193. .ChangePassword .list .item .placeholder {
  194. color: #b9b9bc;
  195. }
  196. .ChangePassword .list .item input.codeIput {
  197. width: 340rpx;
  198. }
  199. .ChangePassword .list .item .code {
  200. font-size: 32rpx;
  201. background-color: #fff;
  202. }
  203. .ChangePassword .list .item .code.on {
  204. color: #b9b9bc !important;
  205. }
  206. .ChangePassword .confirmBnt {
  207. font-size: 32rpx;
  208. width: 580rpx;
  209. height: 90rpx;
  210. border-radius: 45rpx;
  211. color: #fff;
  212. margin: 92rpx auto 0 auto;
  213. text-align: center;
  214. line-height: 90rpx;
  215. }
  216. </style>