forget-password.vue 7.1 KB

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