forget.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <view class="content">
  3. <view class="list">
  4. <view class="tishi">若您忘记了密码,可在此重新设置新密码。</view>
  5. <view class="list-call">
  6. <image class="img" src="/static/shilu-login/1.png"></image>
  7. <input class="sl-input" type="number" v-model="phone" maxlength="11" placeholder="请输入手机号" />
  8. </view>
  9. <view class="list-call">
  10. <image class="img" src="/static/shilu-login/2.png"></image>
  11. <input class="sl-input" type="text" v-model="password" maxlength="32" placeholder="请输入新密码" :password="!showPassword" />
  12. <image class="img" :src="showPassword?'/static/shilu-login/op.png':'/static/shilu-login/cl.png'" @tap="display"></image>
  13. </view>
  14. <view class="list-call">
  15. <image class="img" src="/static/shilu-login/3.png"></image>
  16. <input class="sl-input" type="number" v-model="code" maxlength="4" placeholder="验证码" />
  17. <view class="yzm" :class="{ yzms: second>0 }" @tap="getcode">{{yanzhengma}}</view>
  18. </view>
  19. </view>
  20. <view class="button-login" hover-class="button-hover" @tap="bindLogin()">
  21. <text>修改密码</text>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. var _this, js;
  27. export default {
  28. data() {
  29. return {
  30. phone: '',
  31. second: 0,
  32. code: "",
  33. showPassword: false,
  34. password: ''
  35. }
  36. },
  37. onLoad() {
  38. _this = this;
  39. },
  40. computed: {
  41. yanzhengma() {
  42. if (this.second == 0) {
  43. return '获取验证码';
  44. } else {
  45. if (this.second < 10) {
  46. return '重新获取0' + this.second;
  47. } else {
  48. return '重新获取' + this.second;
  49. }
  50. }
  51. }
  52. },
  53. onUnload() {
  54. this.clear()
  55. },
  56. methods: {
  57. display() {
  58. this.showPassword = !this.showPassword
  59. },
  60. clear(){
  61. clearInterval(js)
  62. js = null
  63. this.second = 0
  64. },
  65. getcode() {
  66. if (this.phone.length != 11) {
  67. uni.showToast({
  68. icon: 'none',
  69. title: '手机号不正确'
  70. });
  71. return;
  72. }
  73. if (this.second > 0) {
  74. return;
  75. }
  76. _this.second = 60;
  77. js = setInterval(function() {
  78. _this.second--;
  79. if (_this.second == 0) {
  80. _this.clear()
  81. }
  82. }, 1000)
  83. uni.request({
  84. url: 'http://***/getcode.html', //仅为示例,并非真实接口地址。
  85. data: {
  86. phone: this.phone,
  87. type: 'forget'
  88. },
  89. method: 'POST',
  90. dataType: 'json',
  91. success: (res) => {
  92. if (res.data.code != 200) {
  93. uni.showToast({
  94. title: res.data.msg,
  95. icon: 'none'
  96. });
  97. _this.second = 0;
  98. } else {
  99. uni.showToast({
  100. title: res.data.msg
  101. });
  102. _this.second = 60;
  103. js = setInterval(function() {
  104. _this.second--;
  105. if (_this.second == 0) {
  106. _this.clear()
  107. }
  108. }, 1000)
  109. }
  110. },fail() {
  111. this.clear()
  112. }
  113. });
  114. },
  115. bindLogin() {
  116. if (this.phone.length != 11) {
  117. uni.showToast({
  118. icon: 'none',
  119. title: '手机号不正确'
  120. });
  121. return;
  122. }
  123. if (this.password.length < 6) {
  124. uni.showToast({
  125. icon: 'none',
  126. title: '密码不正确'
  127. });
  128. return;
  129. }
  130. if (this.code.length != 4) {
  131. uni.showToast({
  132. icon: 'none',
  133. title: '验证码不正确'
  134. });
  135. return;
  136. }
  137. uni.request({
  138. url: 'http://***/forget.html',
  139. data: {
  140. phone: this.phone,
  141. password: this.password,
  142. code: this.code
  143. },
  144. method: 'POST',
  145. dataType: 'json',
  146. success: (res) => {
  147. if (res.data.code != 200) {
  148. uni.showToast({
  149. title: res.data.msg,
  150. icon: 'none'
  151. });
  152. } else {
  153. uni.showToast({
  154. title: res.data.msg
  155. });
  156. setTimeout(function() {
  157. uni.navigateBack();
  158. }, 1500)
  159. }
  160. }
  161. });
  162. }
  163. }
  164. }
  165. </script>
  166. <style>
  167. .content {
  168. display: flex;
  169. flex-direction: column;
  170. justify-content: center;
  171. }
  172. .tishi {
  173. color: #999999;
  174. font-size: 28rpx;
  175. line-height: 50rpx;
  176. margin-bottom: 50rpx;
  177. }
  178. .list {
  179. display: flex;
  180. flex-direction: column;
  181. padding-top: 50rpx;
  182. padding-left: 70rpx;
  183. padding-right: 70rpx;
  184. }
  185. .list-call {
  186. display: flex;
  187. flex-direction: row;
  188. justify-content: space-between;
  189. align-items: center;
  190. height: 100rpx;
  191. color: #333333;
  192. border-bottom: 0.5px solid #e2e2e2;
  193. }
  194. .list-call .img {
  195. width: 40rpx;
  196. height: 40rpx;
  197. }
  198. .list-call .sl-input {
  199. flex: 1;
  200. text-align: left;
  201. font-size: 32rpx;
  202. margin-left: 16rpx;
  203. }
  204. .button-login {
  205. color: #FFFFFF;
  206. font-size: 34rpx;
  207. width: 470rpx;
  208. height: 100rpx;
  209. background: linear-gradient(-90deg, rgba(63, 205, 235, 1), rgba(188, 226, 158, 1));
  210. box-shadow: 0rpx 0rpx 13rpx 0rpx rgba(164, 217, 228, 0.2);
  211. border-radius: 50rpx;
  212. line-height: 100rpx;
  213. text-align: center;
  214. margin-left: auto;
  215. margin-right: auto;
  216. margin-top: 100rpx;
  217. }
  218. .button-hover {
  219. background: linear-gradient(-90deg, rgba(63, 205, 235, 0.8), rgba(188, 226, 158, 0.8));
  220. }
  221. .yzm {
  222. color: #FF7D13;
  223. font-size: 24rpx;
  224. line-height: 64rpx;
  225. padding-left: 10rpx;
  226. padding-right: 10rpx;
  227. width: auto;
  228. height: 64rpx;
  229. border: 1rpx solid rgba(255, 131, 30, 1);
  230. border-radius: 50rpx;
  231. }
  232. .yzms {
  233. color: #999999 !important;
  234. border: 1rpx solid #999999;
  235. }
  236. </style>