password.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <view>
  3. <view class="info-line">
  4. <view class="il-top">
  5. <text>手机账号</text>
  6. </view>
  7. <view class="il-code" style="color: #ccc;">
  8. {{ getHideMobile(user.mobile) }}
  9. </view>
  10. </view>
  11. <view class="info-line">
  12. <view class="il-top">
  13. <text>验证码</text>
  14. </view>
  15. <view class="il-code">
  16. <input placeholder="验证码" type="number" v-model="verify_code" />
  17. <view class="ilc-btn" v-if="verifyCount == 0" @click="getverifyPhone">获取验证码</view>
  18. <view class="ilc-no-show" v-else>{{verifyCount}} s</view>
  19. </view>
  20. </view>
  21. <view class="info-line" >
  22. <view class="il-top">
  23. <text>输入密码</text>
  24. </view>
  25. <view class="il-bot">
  26. <input placeholder="输入密码" v-model="new_password" password />
  27. </view>
  28. </view>
  29. <view class="info-line">
  30. <view class="il-top">
  31. <text>再次输入密码</text>
  32. </view>
  33. <view class="il-bot">
  34. <input placeholder="再次输入密码" v-model="two_password" password />
  35. </view>
  36. </view>
  37. <view class="update-btn" @click="tapSubmit">
  38. <text>修改</text>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import {
  44. mapState,
  45. mapMutations
  46. } from 'vuex'
  47. export default {
  48. computed: mapState(['user']),
  49. data() {
  50. return {
  51. verify_code: "",
  52. verifyCount: 0,
  53. new_password: "",
  54. two_password : ""
  55. }
  56. },
  57. onLoad(options) {
  58. },
  59. methods: {
  60. getverifyPhone: function() {
  61. if (this.verifyCount > 0) return;
  62. uni.showLoading({
  63. title: "获取中..."
  64. });
  65. this
  66. .request
  67. .post("userYzm", {
  68. type: "mobile"
  69. })
  70. .then(res => {
  71. console.log(res);
  72. uni.hideLoading();
  73. if (res.code == 200) {
  74. if (res.data.status == 2) {
  75. this.utils.CountDowm(res.data.time, (e, s) => {
  76. this.verifyCount = e;
  77. });
  78. }
  79. if (res.data.status == 1) {
  80. this.utils.CountDowm(120, (e, s) => {
  81. this.verifyCount = e;
  82. });
  83. }
  84. } else {
  85. uni.showToast({
  86. title: res.msg,
  87. mask: true,
  88. icon: 'none'
  89. });
  90. }
  91. })
  92. .catch(err => {
  93. uni.showToast({
  94. title: '获取失败',
  95. mask: true,
  96. icon: 'none'
  97. });
  98. uni.hideLoading();
  99. });
  100. },
  101. /**
  102. * 提交数据
  103. */
  104. tapSubmit:function(){
  105. if(this.verify_code == ''){
  106. this.utils.Tip("请输入验证码");
  107. return;
  108. }
  109. if(this.new_password == ''){
  110. this.utils.Tip("请输入新密码");
  111. return;
  112. }
  113. if(this.new_password.length < 5){
  114. this.utils.Tip("新密码不能少于5位");
  115. return;
  116. }
  117. if(this.new_password != this.two_password){
  118. this.utils.Tip("两次密码不相等");
  119. return;
  120. }
  121. this.utils.loadIng("提交中..");
  122. this
  123. .request
  124. .post("updatePassword",{new_password:this.new_password,verify_code:this.verify_code})
  125. .then(res=>{
  126. uni.hideLoading();
  127. if(res.code == 200) {
  128. this.utils.Tip(res.msg,()=>{
  129. uni.navigateBack();
  130. });
  131. }else{
  132. this.utils.Tip(res.msg);
  133. }
  134. }).catch(function(){
  135. uni.hideLoading();
  136. this.utils.Tip("网络错误,请稍后尝试");
  137. });
  138. },
  139. getHideMobile:function(text){
  140. if(!this.utils.isDefine(text)) {
  141. return "";
  142. }
  143. return text.substr(0,3) + "******" + text.substr(text.length - 3,3);
  144. },
  145. },
  146. }
  147. </script>
  148. <style>
  149. page {
  150. background: #F5F5F5;
  151. }
  152. #box {
  153. padding-top: 90px;
  154. z-index: -1;
  155. }
  156. .info-line {
  157. height: 80px;
  158. padding: 0 15px;
  159. background-color: #fff;
  160. border-top: 1px #f5f5f5 solid;
  161. }
  162. .il-top {
  163. color: #333;
  164. font-size: 14px;
  165. margin-top: 10px;
  166. }
  167. .il-bot {
  168. margin-top: 10px;
  169. }
  170. .il-bot input {
  171. width: 100%;
  172. height: 100%;
  173. font-size: 13px;
  174. }
  175. .update-btn {
  176. width: 90%;
  177. height: 40px;
  178. text-align: center;
  179. line-height: 40px;
  180. margin: 30px auto;
  181. background: #db292b;
  182. color: #fff;
  183. border-radius: 100px;
  184. font-size: 16px;
  185. }
  186. .il-code {
  187. display: flex;
  188. align-items: center;
  189. margin-top: 10px;
  190. }
  191. .il-code input {
  192. width: 50%;
  193. height: 100%;
  194. font-size: 13px;
  195. }
  196. .ilc-btn {
  197. width: 90px;
  198. height: 30px;
  199. text-align: center;
  200. line-height: 30px;
  201. margin-left: auto;
  202. font-size: 12px;
  203. background: #db292b;
  204. color: #fff;
  205. border-radius: 100px;
  206. }
  207. .ilc-no-show {
  208. width: 90px;
  209. height: 30px;
  210. text-align: center;
  211. line-height: 30px;
  212. margin-left: auto;
  213. font-size: 12px;
  214. background: #eee;
  215. color: #999;
  216. border-radius: 100px;
  217. }
  218. </style>