index.vue 4.7 KB

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