forget-password.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <view class="content">
  3. <view class="status_bar"></view>
  4. <view class="logo">
  5. <image src="~@/static/logo.png" mode="aspectFit"></image>
  6. </view>
  7. <view class="title">
  8. <text v-if="mine_code == 'ningdongyunying'">E信管理</text>
  9. <text v-if="mine_code == 'zaoquan'">枣泉煤矿</text>
  10. </view>
  11. <view class="change_box">
  12. <view class="item">
  13. <view class="name">手机号</view>
  14. <view class="input">
  15. <input type="text" value="" v-model="mobile"/>
  16. </view>
  17. </view>
  18. <view class="send_box">
  19. <view class="send_code">
  20. <view class="name">验证码</view>
  21. <view class="input">
  22. <input type="text" value="" v-model="vcode"/>
  23. </view>
  24. </view>
  25. <view class="send_btn" @click="send_vcode()">
  26. <text>{{send_text}}</text>
  27. </view>
  28. </view>
  29. <view class="item">
  30. <view class="name">修改密码</view>
  31. <view class="input">
  32. <input type="password" value="" v-model="password"/>
  33. </view>
  34. </view>
  35. <view class="item">
  36. <view class="name">确认密码</view>
  37. <view class="input">
  38. <input type="password" value="" v-model="copypassword"/>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="tips">
  43. <text @click="back()">记起来了?请点击这登陆</text>
  44. </view>
  45. <view class="change_btn" @click="changeBtn()">
  46. <text>确认修改</text>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. var testPassword =/^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_!@#$%^&*`~()-+=]+$)(?![a-z0-9]+$)(?![a-z\W_!@#$%^&*`~()-+=]+$)(?![0-9\W_!@#$%^&*`~()-+=]+$)[a-zA-Z0-9\W_!@#$%^&*`~()-+=]{8,15}$/
  52. export default {
  53. data() {
  54. return {
  55. mine_code:"",
  56. mobile:'',
  57. vcode:'',
  58. password:'',
  59. copypassword:'',
  60. send_text:'发送验证码'
  61. };
  62. },
  63. onLoad() {
  64. this.mine_code = uni.getStorageSync('mine_code')
  65. },
  66. methods: {
  67. changeBtn() {
  68. },
  69. back(){
  70. uni.navigateTo({
  71. url:"../login/login"
  72. })
  73. },
  74. send_vcode(){
  75. if(this.mobile.length < 11){
  76. uni.showToast({
  77. icon:'none',
  78. title:'请填写正确的手机号'
  79. })
  80. return
  81. }
  82. if(this.send_text == "发送验证码"){
  83. this.$api.sms_send_v_code({
  84. mobile:this.mobile
  85. }).then((res)=>{
  86. console.log(res.data)
  87. if(res.data.code == 3001){
  88. uni.showToast({
  89. icon:"none",
  90. title:"电话号码错误"
  91. })
  92. this.send_text = "发送验证码"
  93. }else if(res.data.code == 3002){
  94. uni.showToast({
  95. icon:"none",
  96. title:"发送失败"
  97. })
  98. this.send_text = "发送验证码"
  99. }else if(res.data.code == 3003){
  100. uni.showToast({
  101. icon:"none",
  102. title:"请填写绑定的手机号"
  103. })
  104. this.send_text = "发送验证码"
  105. }else if(res.data.code == 0){
  106. uni.showToast({
  107. icon:"none",
  108. title:"验证码发送成功"
  109. })
  110. }
  111. })
  112. }
  113. this.send_text = "已发送"
  114. if(this.send_text = "已发送"){
  115. uni.showToast({
  116. icon:"none",
  117. title:"请勿重复发送"
  118. })
  119. }
  120. },
  121. changeBtn(){
  122. if(this.vcode == ''){
  123. uni.showToast({
  124. icon:'none',
  125. title:'请填写验证码'
  126. })
  127. return
  128. }
  129. if(this.password == '' || this.copypassword == ''){
  130. uni.showToast({
  131. icon:'none',
  132. title:'请填写完整信息'
  133. })
  134. return
  135. }
  136. if(this.password !== this.copypassword){
  137. uni.showToast({
  138. icon:'none',
  139. title:'两次密码输入不一致'
  140. })
  141. return
  142. }
  143. if( !testPassword.test(this.password) ){
  144. uni.showToast({
  145. icon:'none',
  146. title:'密码必须包含大写字母、小写字母、数字和特殊符号且长度在8位至16位之间'
  147. })
  148. return
  149. }
  150. this.$api.user_forget_password({
  151. mobile:this.mobile,
  152. vcode:this.vcode,
  153. password:this.password
  154. }).then((res)=>{
  155. console.log(res)
  156. if(res.data.code == 4002){
  157. uni.showToast({
  158. icon:'none',
  159. title:"验证码超时或者错误"
  160. })
  161. return
  162. }else{
  163. uni.setStorageSync('login_password',this.password)
  164. uni.showToast({
  165. icon:'none',
  166. title:'密码修改成功、返回登陆'
  167. })
  168. this.send_text = "发送验证码"
  169. }
  170. setTimeout(function(){
  171. uni.navigateTo({
  172. url:"../login/login"
  173. })
  174. },1000)
  175. })
  176. }
  177. }
  178. }
  179. </script>
  180. <style lang="scss">
  181. page {}
  182. .content {
  183. width: 750rpx;
  184. min-height: 100vh;
  185. height: 100%;
  186. background-image: url(~@/static/login.png);
  187. background-size: cover;
  188. background-position: center center;
  189. background-repeat: no-repeat;
  190. .logo {
  191. width: 344rpx;
  192. height: 350rpx;
  193. margin: 0 auto;
  194. padding-top: 100rpx;
  195. image {
  196. width: 100%;
  197. height: 100%;
  198. }
  199. }
  200. .title {
  201. margin: 0 auto;
  202. margin-top: 32rpx;
  203. width: 288rpx;
  204. height: 47rpx;
  205. font-size: 36rpx;
  206. color: #FFFFFF;
  207. line-height: 47rpx;
  208. text-align: center;
  209. }
  210. .change_box {
  211. padding-top: 40px;
  212. .item {
  213. margin: 0 auto;
  214. margin-bottom: 20px;
  215. width: 600rpx;
  216. height: 45px;
  217. background: #FFFFFF;
  218. border-radius: 25px;
  219. box-sizing: border-box;
  220. padding: 0 20px;
  221. display: flex;
  222. align-items: center;
  223. .name {
  224. width: 150rpx;
  225. font-size: 16px;
  226. color: #009FE8;
  227. line-height: 45px;
  228. }
  229. .input {
  230. input {
  231. height: 45px;
  232. color: #666;
  233. }
  234. }
  235. }
  236. .send_box{
  237. margin: 0 auto;
  238. margin-bottom: 20px;
  239. width: 600rpx;
  240. display: flex;
  241. justify-content: space-between;
  242. align-items: center;
  243. .send_code{
  244. background: #FFFFFF;
  245. border-radius: 25px;
  246. box-sizing: border-box;
  247. padding: 0 20px;
  248. height: 45px;
  249. display: flex;
  250. justify-content: space-between;
  251. align-items: center;
  252. .name{
  253. width: 120rpx;
  254. font-size: 16px;
  255. font-family: MicrosoftYaHei;
  256. color: #009FE8;
  257. line-height: 45px;
  258. }
  259. .input{
  260. width: 140rpx;
  261. }
  262. }
  263. .send_btn{
  264. width: 220rpx;
  265. height: 50px;
  266. background: rgba(100, 220, 255, 0.8);
  267. border-radius: 25px;
  268. text-align: center;
  269. line-height: 50px;
  270. text {
  271. font-size: 34rpx;
  272. color: #FFFFFF;
  273. }
  274. }
  275. }
  276. }
  277. .tips {
  278. margin: 0 auto;
  279. margin-top: 25px;
  280. text-align: center;
  281. font-size: 14px;
  282. color: #ECF0F1;
  283. line-height: 40px;
  284. text-align: center;
  285. }
  286. .change_btn {
  287. margin: 40px auto;
  288. width: 200px;
  289. height: 50px;
  290. background: rgba(100, 220, 255, 0.8);
  291. border-radius: 25px;
  292. text-align: center;
  293. line-height: 50px;
  294. text {
  295. font-size: 18px;
  296. color: #FFFFFF;
  297. letter-spacing: 4px;
  298. }
  299. }
  300. }
  301. </style>