forget-password.vue 7.3 KB

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