password.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <view class="container">
  3. <view class="logo-img"><image src="../../static/img/log.png" mode=""></image></view>
  4. <view class="logo">LALA</view>
  5. <view class="login_text">
  6. <view class="login_input flex_item">
  7. <view class="login_img"><image class="phone" src="/static/img/phone.png"></image></view>
  8. <view class="login_name"><input class="uni-input" type="text" disabled="true" v-model="phone" focus placeholder="请输入邮箱" /></view>
  9. </view>
  10. <view class="login_input flex_item">
  11. <view class="login_img"><image src="/static/img/password.png"></image></view>
  12. <view class="login_name"><input class="uni-input" type="password" v-model="password" focus placeholder=" 请输入新的密码" /></view>
  13. </view>
  14. <view class="login_input flex_item">
  15. <view class="login_img"><image src="/static/img/password.png"></image></view>
  16. <view class="login_name"><input class="uni-input" type="password" v-model="password2" focus placeholder="请重复输入新密码" /></view>
  17. </view>
  18. <view class="login_input flex">
  19. <view class="login_img"><image class="codeimg" src="/static/img/yan.png"></image></view>
  20. <view class="login_name flex">
  21. <input class="uni-input width" v-model="code" type="number" focus placeholder="请输入验证码" />
  22. <view class="code" @click="verification">{{ countDown == 0 ? '发送验证码' : countDown }}</view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="login" @click="updatalogin">确认修改</view>
  27. </view>
  28. </template>
  29. <script>
  30. import { registerReset } from '@/api/set.js';
  31. import { verify } from '@/api/login.js';
  32. export default {
  33. data() {
  34. return {
  35. phone: '', //用户
  36. code: '', //验证码
  37. password2: '',
  38. password: '',
  39. time: '', //保存倒计时对象
  40. countDown: 0 //倒计时
  41. };
  42. },
  43. onLoad() {
  44. let userInfo = uni.getStorageSync('userInfo') || '';
  45. this.phone = userInfo.account
  46. },
  47. watch: {
  48. // 监听倒计时
  49. countDown(i) {
  50. if (i == 0) {
  51. clearInterval(this.time);
  52. }
  53. }
  54. },
  55. methods: {
  56. updatalogin() {
  57. let obj = this;
  58. // if (obj.phone == '') {
  59. // obj.$api.msg('请输入邮箱');
  60. // return;
  61. // }
  62. // if (!/^([a-zA-Z]|[0-9])(\w|\-|\.)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(obj.phone)) {
  63. // obj.$api.msg('请输入正确的邮箱');
  64. // return;
  65. // }
  66. if (obj.password == '') {
  67. obj.$api.msg('请输入密码');
  68. return;
  69. }
  70. if (obj.password2 == '') {
  71. obj.$api.msg('请再次输入密码');
  72. return;
  73. }
  74. if (obj.password2 != obj.password) {
  75. obj.$api.msg('两次密码不正确');
  76. return;
  77. }
  78. if (obj.code == '') {
  79. obj.$api.msg('请输入验证码');
  80. return;
  81. }
  82. registerReset({
  83. account: obj.phone, //账号
  84. password: obj.password,
  85. password2: obj.password2,
  86. type: 1,
  87. captcha: obj.code
  88. })
  89. .then(function(e) {
  90. obj.$api.msg(e.msg);
  91. uni.navigateTo({
  92. url: '/pages/public/login'
  93. });
  94. })
  95. .catch(e => {
  96. console.log(e);
  97. });
  98. },
  99. //发送验证码
  100. verification() {
  101. let obj = this;
  102. if (this.phone == '') {
  103. this.$api.msg('请输入电话号码');
  104. return;
  105. }
  106. if (this.phone.length < 11) {
  107. this.$api.msg('请输入正确的手机号');
  108. return;
  109. }
  110. // 判断是否在倒计时
  111. if (obj.countDown > 0) {
  112. return false;
  113. } else {
  114. obj.countDown = 60;
  115. obj.time = setInterval(() => {
  116. obj.countDown--;
  117. }, 1000);
  118. //调用验证码接口
  119. verify({
  120. phone: obj.phone,
  121. type: 'login'
  122. })
  123. .then(({ data }) => {
  124. uni.showToast({
  125. title: '验证码已发送',
  126. duration: 2000,
  127. position: 'top',
  128. icon: 'none'
  129. });
  130. })
  131. .catch(err => {
  132. console.log(err);
  133. });
  134. }
  135. }
  136. }
  137. };
  138. </script>
  139. <style lang="scss">
  140. page {
  141. min-height: 100%;
  142. background-color: #ffffff;
  143. .container {
  144. width: 100%;
  145. padding: 60rpx 70rpx;
  146. }
  147. }
  148. .logo-img {
  149. width: 161rpx;
  150. height: 161rpx;
  151. margin:auto;
  152. margin-top: 52rpx !important;
  153. margin-bottom: 15rpx !important;
  154. box-shadow: 0px 12rpx 13rpx 0px rgba(68, 150, 157, 0.47);
  155. border-radius: 50%;
  156. image {
  157. width: 161rpx;
  158. height: 161rpx;
  159. border-radius: 50%;
  160. }
  161. }
  162. .logo {
  163. font-size: 36rpx;
  164. font-weight: 400;
  165. color: #44969d;
  166. text-align: center;
  167. }
  168. .phone {
  169. height: 43rpx !important;
  170. width: 27rpx !important;
  171. }
  172. .codeimg {
  173. height: 39rpx !important;
  174. width: 31rpx !important;
  175. }
  176. .login_text {
  177. border-radius: 20rpx;
  178. margin-top: 80rpx;
  179. .login_input {
  180. // border-bottom: 1px solid #C5CEE0;
  181. margin-bottom: 35rpx;
  182. padding-bottom: 60rpx;
  183. .login_img {
  184. height: 35rpx;
  185. width: 31rpx;
  186. margin-right: 20rpx;
  187. image {
  188. width: 100%;
  189. height: 100%;
  190. }
  191. }
  192. .uni-input {
  193. text-align: left;
  194. width: 400rpx;
  195. font-size: 32rpx !important;
  196. }
  197. .login_name {
  198. color: #333333;
  199. .code {
  200. color: #60bab0;
  201. font-size: 23rpx;
  202. border-left: 1px solid #eeeeee;
  203. width: 150rpx;
  204. flex-shrink: 0;
  205. text-align: center;
  206. }
  207. }
  208. }
  209. }
  210. .login {
  211. background: linear-gradient(90deg, #60bab0, #60bab0, #45969b);
  212. margin-top: 96rpx;
  213. color: #ffffff;
  214. text-align: center;
  215. padding: 26rpx 0rpx;
  216. border-radius: 20rpx;
  217. }
  218. </style>