forget.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <template>
  2. <view class="container">
  3. <view class="title-img">
  4. <image class="title-image" src="../../static/img/hlogo.png" mode="widthFix"></image>
  5. </view>
  6. <view class="title-font">
  7. 挺酒商城
  8. </view>
  9. <view class="login_text">
  10. <view class="login_input flex_item">
  11. <image class="login_img" src="../../static/img/user.png" mode="widthFix"></image>
  12. <view class="login_name"><input class="uni-input" type="text" v-model="phone" focus
  13. placeholder="请输入手机" /></view>
  14. </view>
  15. <view class="login_input flex_item">
  16. <image class="login_img" src="../../static/img/pwd.png" mode="widthFix"></image>
  17. <view class="login_name"><input class="uni-input" type="password" v-model="password" focus
  18. placeholder=" 请输入新的不少于6位的密码" /></view>
  19. </view>
  20. <view class="login_input flex_item">
  21. <image class="login_img" src="../../static/img/pwd.png" mode="widthFix"></image>
  22. <view class="login_name"><input class="uni-input" type="password" v-model="password2" focus
  23. placeholder="请重复输入新密码" /></view>
  24. </view>
  25. <view class="login_input flex">
  26. <image class="login_img" src="../../static/img/send.png" mode="widthFix"></image>
  27. <view class="login_name flex">
  28. <input class="uni-input width" v-model="code" type="number" focus placeholder="请输入验证码" />
  29. <view class="code" @click="verification">{{ countDown == 0 ? '发送验证码' : countDown }}</view>
  30. </view>
  31. </view>
  32. <view class="uni-button uni-button-green" @click="updatalogin">确认修改</view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import {
  38. registerReset
  39. } from '@/api/set.js';
  40. import {
  41. verify
  42. } from '@/api/login.js';
  43. export default {
  44. data() {
  45. return {
  46. phone: '', //用户
  47. code: '', //验证码
  48. password2: '',
  49. password: '',
  50. time: '', //保存倒计时对象
  51. countDown: 0 //倒计时
  52. };
  53. },
  54. onLoad() {},
  55. watch: {
  56. // 监听倒计时
  57. countDown(i) {
  58. if (i == 0) {
  59. clearInterval(this.time);
  60. }
  61. }
  62. },
  63. methods: {
  64. updatalogin() {
  65. let obj = this;
  66. if (obj.phone == '') {
  67. obj.$api.msg('请输入手机');
  68. return;
  69. }
  70. if (!/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(obj.phone) && !
  71. /(^1[3|4|5|6|7|8|9][0-9]{9}$)/.test(this.phone)) {
  72. obj.$api.msg('请输入正确的手机');
  73. return;
  74. }
  75. if (obj.password == '') {
  76. obj.$api.msg('请输入密码');
  77. return;
  78. }
  79. if (obj.password2 == '') {
  80. obj.$api.msg('请再次输入密码');
  81. return;
  82. }
  83. if (obj.password2 != obj.password) {
  84. obj.$api.msg('两次密码不正确');
  85. return;
  86. }
  87. if (obj.code == '') {
  88. obj.$api.msg('请输入验证码');
  89. return;
  90. }
  91. registerReset({
  92. account: obj.phone, //账号
  93. password: obj.password,
  94. password2: obj.password2,
  95. type: 1,
  96. captcha: obj.code
  97. })
  98. .then(function(e) {
  99. obj.$api.msg(e.msg);
  100. uni.navigateTo({
  101. url: '/pages/public/login'
  102. });
  103. })
  104. .catch(e => {
  105. console.log(e);
  106. });
  107. },
  108. //发送验证码
  109. verification() {
  110. let obj = this;
  111. if (this.phone == '') {
  112. this.$api.msg('请输入邮箱号码');
  113. return;
  114. }
  115. if (!/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(obj.phone) && !
  116. /(^1[3|4|5|6|7|8|9][0-9]{9}$)/.test(this.phone)) {
  117. obj.$api.msg('请输入正确的邮箱或手机');
  118. return;
  119. }
  120. // 判断是否在倒计时
  121. if (obj.countDown > 0) {
  122. return false;
  123. } else {
  124. obj.countDown = 60;
  125. obj.time = setInterval(() => {
  126. obj.countDown--;
  127. }, 1000);
  128. //调用验证码接口
  129. verify({
  130. phone: obj.phone,
  131. type: 'login'
  132. })
  133. .then(({
  134. data
  135. }) => {
  136. uni.showToast({
  137. title: '验证码已发送',
  138. duration: 2000,
  139. position: 'top',
  140. icon: 'none'
  141. });
  142. })
  143. .catch(err => {
  144. console.log(err);
  145. });
  146. }
  147. }
  148. }
  149. };
  150. </script>
  151. <style lang="scss">
  152. page {
  153. min-height: 100%;
  154. background-color: #ffffff;
  155. .container {
  156. width: 100%;
  157. }
  158. }
  159. .title-img {
  160. margin: 100rpx auto 0;
  161. width: 160rpx;
  162. .title-image {
  163. width: 160rpx;
  164. }
  165. }
  166. .title-font {
  167. margin-top: 10rpx;
  168. text-align: center;
  169. font-size: 32rpx;
  170. font-family: Source Han Sans CN;
  171. font-weight: bold;
  172. color: #333333;
  173. }
  174. .login_text {
  175. position: relative;
  176. padding: 100rpx 102rpx;
  177. background-color: #ffffff;
  178. border-top-left-radius: 40rpx;
  179. border-top-right-radius: 40rpx;
  180. .login_input {
  181. margin-top: 20rpx;
  182. padding: 26rpx;
  183. border-radius: 21rpx;
  184. border-bottom: 1px solid #eeeeee;
  185. .login_img {
  186. width: 30rpx;
  187. flex-shrink: 0;
  188. }
  189. .uni-input {
  190. text-align: left;
  191. width: 470rpx;
  192. font-size: 28rpx !important;
  193. }
  194. .login_name {
  195. margin-left: 20rpx;
  196. color: #333333;
  197. }
  198. }
  199. .other {
  200. margin-top: 60rpx;
  201. .fenge {
  202. width: 30%;
  203. height: 2rpx;
  204. background-color: #eeeeee;
  205. }
  206. .qita {
  207. font-size: 28rpx;
  208. color: #999999;
  209. }
  210. }
  211. .weixin {
  212. width: 75rpx;
  213. height: 75rpx;
  214. margin: 25rpx auto;
  215. }
  216. .weixin image {
  217. width: 100%;
  218. height: 100%;
  219. }
  220. .weixin_text {
  221. text-align: center;
  222. font-size: 28rpx;
  223. color: #999999;
  224. }
  225. .forget {
  226. font-size: 28rpx;
  227. width: 100%;
  228. text-align: right;
  229. color: #999999;
  230. }
  231. .uni-button-green {
  232. text-align: center;
  233. background: linear-gradient(90deg, #CA57DC, #65B2E9);
  234. border-radius: 10rpx;
  235. color: #ffffff;
  236. margin: 40rpx 10rpx;
  237. }
  238. .uni-button-green-plain {
  239. margin: 40rpx 10rpx;
  240. background: linear-gradient(90deg, #CA57DC, #65B2E9);
  241. border-radius: 10rpx;
  242. color: #ffffff;
  243. }
  244. .uni-button {
  245. height: 85rpx;
  246. line-height: 85rpx;
  247. }
  248. }
  249. .code {
  250. padding-right: 30rpx;
  251. font-size: 23rpx;
  252. width: 150rpx;
  253. flex-shrink: 0;
  254. text-align: center;
  255. color: #2E58FF;
  256. background: linear-gradient(0deg, #CA57DC 0%, #65B2E9 100%);
  257. -webkit-background-clip: text;
  258. -webkit-text-fill-color: transparent;
  259. }
  260. .width {
  261. width: 325rpx !important;
  262. }
  263. .login {
  264. background: #db292b;
  265. margin-top: 96rpx;
  266. color: #ffffff;
  267. text-align: center;
  268. padding: 26rpx 0rpx;
  269. border-radius: 20rpx;
  270. }
  271. </style>