PasswordRestAppeal.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. <template>
  2. <div class="certification">
  3. <div class="container">
  4. <div class="content" v-show="goNextStep">
  5. <div class="content-top">
  6. <h3>密码重置</h3>
  7. </div>
  8. <div>
  9. <el-form :model="passwordRest" :rules="rules" ref="passwordRest" label-width="100px" class="demo-ruleForm">
  10. <el-form-item prop="mobile">
  11. <el-input v-model="passwordRest.mobile" placeholder="新手机号码"></el-input>
  12. </el-form-item>
  13. <el-form-item prop="code">
  14. <el-input type="text" v-model="passwordRest.code"
  15. v-bind:class="{ active: codeErrorChecked }"
  16. auto-complete="off" class="msg"
  17. placeholder="短信验证码"></el-input>
  18. <el-button type="primary" class="code"
  19. v-show="sendAccountCode"
  20. @click="getCheckCode"
  21. :disabled="getCodeBtnIsDisabled">获取验证码</el-button>
  22. <el-button type="primary" v-show="!sendAccountCode" class="code code-send">已发送({{account_time}}s)</el-button>
  23. <span v-show="codeErrorChecked" class="tip codeError-tip" >{{codeErrorMsg}}</span>
  24. </el-form-item>
  25. <el-form-item prop="password">
  26. <el-input type="password" v-model="passwordRest.password" auto-complete="off" placeholder="新密码"></el-input>
  27. <div class="pwd sm" v-show="showMsgTip1">密码强度 <em></em><em></em><em></em><span>弱</span></div>
  28. <div class="pwd md" v-show="showMsgTip2">密码强度 <em></em><em></em><em></em><span>中</span></div>
  29. <div class="pwd lar" v-show="showMsgTip3">密码强度 <em></em><em></em><em></em><span>强</span></div>
  30. <div class="pwd low" v-show="showMsgTip4">密码强度 <em></em><em></em><em></em></div>
  31. </el-form-item>
  32. <el-form-item prop="confirm">
  33. <el-input type="password"
  34. v-model="passwordRest.confirm"
  35. v-bind:class="{active: showPasswordError}"
  36. auto-complete="off"
  37. placeholder="密码确认"></el-input>
  38. <span class="tip passwordError" v-show="showPasswordError">两次输入密码不一致</span>
  39. </el-form-item>
  40. <el-form-item prop="description">
  41. <el-input type="textarea" v-model="passwordRest.description" placeholder="申诉说明"></el-input>
  42. <span class="tip description" v-show="descriptionTip">请描述您申诉的原因,并尽可能多地列举出证明此账号为您所有的证据</span>
  43. </el-form-item>
  44. <el-form-item prop="contactName">
  45. <el-input type="text" v-model="passwordRest.contactName" auto-complete="off" placeholder="姓名"></el-input>
  46. </el-form-item>
  47. <el-form-item prop="contactTel">
  48. <el-input type="text" v-model="passwordRest.contactTel" auto-complete="off" placeholder="联系电话"></el-input>
  49. </el-form-item>
  50. <el-form-item prop="contactEmail">
  51. <el-input type="text" v-model="passwordRest.contactEmail" auto-complete="off" placeholder="电子邮箱"></el-input>
  52. </el-form-item>
  53. <el-form-item>
  54. <a class="btn finish"
  55. @click="submit"
  56. :disabled="!checked || !mobileChecked || !codeChecked || !passwordChecked || !confirmChecked || !descriptionChecked || !contactNameChecked || !contactTelChecked || !contactEmailChecked">提交</a>
  57. </el-form-item>
  58. <el-form-item>
  59. <el-checkbox name="type" v-model="checked" @click="checkboxChecked"></el-checkbox>
  60. <span class="agree">我已阅读并同意 <a href="/common/agreement">《优软云服务条款》</a></span>
  61. </el-form-item>
  62. </el-form>
  63. </div>
  64. </div>
  65. <div class="content" v-show="!goNextStep">
  66. <div class="content-top">
  67. <h3>密码重置</h3>
  68. </div>
  69. <div class="content-bottom">
  70. <p class="passed"><img src="/images/all/pass.png" alt=""/>申诉已提交</p>
  71. <span>申诉内容已提交,请耐心等待审核</span>
  72. <div class="close-btn" @click="goCloudCenter">关闭</div>
  73. </div>
  74. </div>
  75. <loading v-show="isShowLoading"/>
  76. </div>
  77. </div>
  78. </template>
  79. <script>
  80. import Loading from '~components/common/loading/Loading.vue'
  81. export default {
  82. name: 'AccountAppeal',
  83. components: {
  84. Loading
  85. },
  86. data () {
  87. var validateMobile = (rule, value, callback) => {
  88. if (value === '') {
  89. callback(new Error('请填写正确的手机号'))
  90. this.getCodeBtnIsDisabled = true
  91. this.mobileChecked = false
  92. } else {
  93. if (this.passwordRest.mobile !== '') {
  94. var reg = /^1[0-9]{10}$/
  95. if (!reg.test(value)) {
  96. callback(new Error('请填写正确的手机号'))
  97. this.getCodeBtnIsDisabled = true
  98. this.mobileChecked = false
  99. } else {
  100. this.getCodeBtnIsDisabled = false
  101. this.mobileChecked = true
  102. }
  103. }
  104. callback()
  105. }
  106. }
  107. var validateCode = (rule, value, callback) => {
  108. if (value === '') {
  109. callback(new Error('请填写正确的验证码'))
  110. this.codeErrorChecked = false
  111. this.codeChecked = false
  112. } else {
  113. if (this.passwordRest.code !== '') {
  114. if (this.passwordRest.mobile === '') {
  115. callback(new Error('请先填写正确的手机号'))
  116. } else {
  117. if (this.token) {
  118. let param = new FormData()
  119. param.append('mobile', this.passwordRest.mobile)
  120. param.append('code', this.passwordRest.code)
  121. param.append('token', this.token)
  122. let config = {
  123. headers: {'Content-Type': 'multipart/form-data'}
  124. }
  125. this.$http.post(`/appeal/check/mobile`, param, config)
  126. .then(response => {
  127. if (response.data.success) {
  128. this.codeChecked = true
  129. this.codeErrorChecked = false
  130. } else {
  131. this.codeErrorChecked = true
  132. this.codeChecked = false
  133. return Promise.reject(response.data)
  134. }
  135. }).catch(err => {
  136. this.codeErrorMsg = err.errMsg
  137. // this.$message.error(err.errMsg)
  138. })
  139. } else {
  140. this.codeChecked = false
  141. this.codeErrorChecked = false
  142. callback(new Error('请先获取验证码'))
  143. }
  144. }
  145. }
  146. callback()
  147. }
  148. }
  149. var validatePassword = (rule, value, callback) => {
  150. if (this.passwordRest.password !== '') {
  151. if (value.length <= 20 && value.length >= 8) {
  152. var reg1 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]))|((?=.*[0-9])((?=.*[a-zA-Z]))(?=.*[^a-zA-Z0-9]))).*$/
  153. var reg2 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$/
  154. if (reg1.test(value)) {
  155. // callback(new Error('密码强度强'))
  156. this.showMsgTip3 = true
  157. this.showMsgTip2 = false
  158. this.showMsgTip1 = false
  159. this.showMsgTip4 = false
  160. this.passwordChecked = true
  161. } else if (reg2.test(value)) {
  162. // callback(new Error('密码强度中'))
  163. this.showMsgTip2 = true
  164. this.showMsgTip3 = false
  165. this.showMsgTip1 = false
  166. this.showMsgTip4 = false
  167. this.passwordChecked = true
  168. } else {
  169. this.showMsgTip1 = true
  170. this.showMsgTip3 = false
  171. this.showMsgTip2 = false
  172. this.showMsgTip4 = false
  173. this.passwordChecked = false
  174. }
  175. } else {
  176. this.showMsgTip3 = false
  177. this.showMsgTip2 = false
  178. this.showMsgTip1 = false
  179. this.showMsgTip4 = true
  180. this.passwordChecked = false
  181. }
  182. }
  183. callback()
  184. }
  185. var validatePasswordTip = (rule, value, callback) => {
  186. if (value === '') {
  187. callback(new Error('请输入密码'))
  188. this.passwordChecked = false
  189. } else {
  190. if (this.passwordRest.password !== '') {
  191. if (value.length <= 20 && value.length >= 8) {
  192. var reg1 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]))|((?=.*[0-9])((?=.*[a-zA-Z]))(?=.*[^a-zA-Z0-9]))).*$/
  193. var reg2 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$/
  194. if (reg1.test(value)) {
  195. this.passwordChecked = true
  196. } else if (reg2.test(value)) {
  197. this.passwordChecked = true
  198. } else {
  199. callback(new Error('密码须为8-20字符的英文、数字混合'))
  200. this.passwordChecked = false
  201. }
  202. } else {
  203. callback(new Error('密码须为8-20字符的英文、数字混合'))
  204. this.passwordChecked = false
  205. }
  206. if (this.passwordRest.confirm !== '') {
  207. if (value !== this.passwordRest.confirm) {
  208. this.showPasswordError = true
  209. // callback(new Error('两次输入密码不一致!'))
  210. this.confirmChecked = false
  211. } else {
  212. this.confirmChecked = true
  213. this.showPasswordError = false
  214. callback()
  215. }
  216. }
  217. }
  218. callback()
  219. }
  220. }
  221. var validateConfirm = (rule, value, callback) => {
  222. if (value === '') {
  223. callback(new Error('请再次输入密码'))
  224. this.showPasswordError = false
  225. this.confirmChecked = false
  226. } else if (value !== this.passwordRest.password) {
  227. // callback(new Error('两次输入密码不一致!'))
  228. this.showPasswordError = true
  229. this.confirmChecked = false
  230. } else {
  231. this.confirmChecked = true
  232. this.showPasswordError = false
  233. callback()
  234. }
  235. }
  236. var validateDescription = (rule, value, callback) => {
  237. if (value === '') {
  238. callback(new Error('请填写申诉说明'))
  239. this.descriptionChecked = false
  240. this.descriptionTip = false
  241. } else {
  242. if (this.passwordRest.description !== '') {
  243. if (value.length >= 100) {
  244. callback(new Error('输入长度过长,100个字符以内'))
  245. this.descriptionChecked = false
  246. this.descriptionTip = false
  247. } else {
  248. this.descriptionChecked = true
  249. this.descriptionTip = false
  250. }
  251. }
  252. callback()
  253. }
  254. }
  255. var validateContactName = (rule, value, callback) => {
  256. if (value === '') {
  257. callback(new Error('请填写您的姓名'))
  258. this.contactNameChecked = false
  259. } else {
  260. if (this.passwordRest.contactName !== '') {
  261. if (value.length >= 20) {
  262. callback(new Error('输入长度过长,20个字符以内'))
  263. this.contactNameChecked = false
  264. } else {
  265. this.contactNameChecked = true
  266. }
  267. }
  268. callback()
  269. }
  270. }
  271. var validateContactTel = (rule, value, callback) => {
  272. if (value === '') {
  273. callback(new Error('请填写正确的联系电话'))
  274. this.contactTelChecked = false
  275. } else {
  276. if (this.passwordRest.contactTel !== '') {
  277. var reg = /^1[0-9]{10}$/
  278. if (!reg.test(value)) {
  279. callback(new Error('请填写正确的联系电话'))
  280. this.contactTelChecked = false
  281. } else {
  282. this.contactTelChecked = true
  283. }
  284. }
  285. callback()
  286. }
  287. }
  288. var validateContactEmail = (rule, value, callback) => {
  289. if (value === '') {
  290. callback(new Error('请填写正确的电子邮箱'))
  291. this.contactEmailChecked = false
  292. } else {
  293. if (this.passwordRest.contactEmail !== '') {
  294. var reg = /^([\w-])+(\.\w+)*@([\w-])+((\.\w{2,3}){1,3})$/
  295. if (!reg.test(value)) {
  296. callback(new Error('请输入正确的邮箱地址格式'))
  297. this.contactEmailChecked = false
  298. } else {
  299. this.contactEmailChecked = true
  300. }
  301. }
  302. callback()
  303. }
  304. }
  305. return {
  306. isShowLoading: false,
  307. showPasswordError: false,
  308. codeErrorMsg: false,
  309. goNextStep: true,
  310. passwordRest: {
  311. mobile: '',
  312. code: '',
  313. password: '',
  314. conform: '',
  315. description: '',
  316. contactName: '',
  317. contactTel: '',
  318. contactEmail: ''
  319. },
  320. checked: true,
  321. sendAccountCode: true,
  322. account_time: 0,
  323. getCodeBtnIsDisabled: true,
  324. codeErrorChecked: false,
  325. descriptionTip: true,
  326. showMsgTip1: false,
  327. showMsgTip2: false,
  328. showMsgTip3: false,
  329. showMsgTip4: false,
  330. mobileChecked: false,
  331. codeChecked: false,
  332. passwordChecked: false,
  333. confirmChecked: false,
  334. descriptionChecked: false,
  335. contactNameChecked: false,
  336. contactTelChecked: false,
  337. contactEmailChecked: false,
  338. rules: {
  339. mobile: [
  340. {validator: validateMobile, trigger: 'blur'}
  341. ],
  342. code: [
  343. {validator: validateCode, trigger: 'blur'}
  344. ],
  345. password: [
  346. {validator: validatePassword, trigger: 'change'},
  347. {validator: validatePasswordTip, trigger: 'blur'}
  348. ],
  349. confirm: [
  350. {validator: validateConfirm, trigger: 'blur'}
  351. ],
  352. description: [
  353. {validator: validateDescription, trigger: 'blur'}
  354. ],
  355. contactName: [
  356. {validator: validateContactName, trigger: 'blur'}
  357. ],
  358. contactTel: [
  359. {validator: validateContactTel, trigger: 'blur'}
  360. ],
  361. contactEmail: [
  362. {validator: validateContactEmail, trigger: 'blur'}
  363. ]
  364. }
  365. }
  366. },
  367. methods: {
  368. // 判断我同意是否被选中
  369. checkboxChecked () {
  370. this.checked = !this.checked
  371. },
  372. // 获取校验码
  373. getCheckCode () {
  374. this.isShowLoading = true
  375. this.$http.get(`/appeal/check/mobile`, {params: {mobile: this.passwordRest.mobile}})
  376. .then(response => {
  377. this.isShowLoading = false
  378. this.token = response.data.content.token
  379. if (this.token !== '') {
  380. this.$message({
  381. message: '验证码已经发送到您的手机,请注意查收',
  382. type: 'success'
  383. })
  384. this.sendAccountCode = false
  385. this.account_time = 60
  386. var accountTime = setInterval(() => {
  387. this.account_time--
  388. if (this.account_time <= 0) {
  389. this.sendAccountCode = true
  390. clearInterval(accountTime)
  391. }
  392. }, 1000)
  393. }
  394. }).catch(err => {
  395. this.isShowLoading = false
  396. this.$message.error(err.errMsg)
  397. })
  398. },
  399. // 提交表单
  400. submit () {
  401. if (this.mobileChecked && this.codeChecked && this.passwordChecked && this.confirmChecked && this.descriptionChecked && this.contactNameChecked && this.contactTelChecked && this.contactEmailChecked && this.checked) {
  402. this.isShowLoading = true
  403. let param = new FormData()
  404. param.append('mobile', this.passwordRest.mobile)
  405. param.append('code', this.passwordRest.code)
  406. param.append('password', this.passwordRest.password)
  407. param.append('description', this.passwordRest.description)
  408. param.append('contactName', this.passwordRest.contactName)
  409. param.append('contactTel', this.passwordRest.contactTel)
  410. param.append('contactEmail', this.passwordRest.contactEmail)
  411. param.append('token', this.token)
  412. let config = {
  413. headers: {'Content-Type': 'multipart/form-data'}
  414. }
  415. this.$http.post('/appeal/resetPwd', param, config)
  416. .then(response => {
  417. if (response.data.success) {
  418. this.isShowLoading = false
  419. this.goNextStep = false
  420. // 待跳转到设置页面
  421. // window.loaction.href = ''
  422. } else {
  423. this.goNextStep = true
  424. return Promise.reject(response.data)
  425. }
  426. }).catch(err => {
  427. this.isShowLoading = false
  428. this.$message.error(err.errMsg)
  429. })
  430. }
  431. },
  432. // 跳转至个人中心页面
  433. goCloudCenter () {
  434. window.location.href = '/cloudcenter'
  435. }
  436. }
  437. }
  438. </script>
  439. <style lang="scss" scoped>
  440. .certification {
  441. margin: 0 auto;
  442. width: 100%;
  443. background: #eee;
  444. .container{
  445. padding-top: 50px;
  446. margin: 0 auto;
  447. width: 980px;
  448. text-align: center;
  449. .content{
  450. padding: 0 50px;
  451. margin: 50px auto 0;
  452. width: 100%;
  453. text-align: center;
  454. background: #fff;
  455. .content-top{
  456. height: 80px;
  457. line-height: 80px;
  458. h3{
  459. margin-bottom: 0;
  460. font-size: 24px;
  461. color: #000;
  462. border-bottom: 1px solid #dcdcdc;
  463. }
  464. .step{
  465. position: relative;
  466. margin-top: 10px;
  467. img{
  468. width: 315px;
  469. height: 46px;
  470. }
  471. .step-item{
  472. position: absolute;
  473. top: 45px;
  474. left: 265px;
  475. span{
  476. margin-right: 85px;
  477. font-size: 14px;
  478. color: #b4b4b4;
  479. }
  480. span.active {
  481. color: #0076ad;
  482. }
  483. }
  484. }
  485. }
  486. form {
  487. padding-bottom: 44px;
  488. margin-top: 36px;
  489. input{
  490. padding: 0 0 0 18px;
  491. width: 360px;
  492. height: 44px;
  493. line-height: 44px;
  494. font-size: 14px;
  495. color: #000;
  496. border-radius: 0;
  497. }
  498. .pwd {
  499. margin: 6px 0 -15px 0;
  500. text-align: left;
  501. font-size: 13px;
  502. em{
  503. display: inline-block;
  504. margin: 0 8px 2px 0;
  505. width: 24px;
  506. height: 6px;
  507. &:first-child{
  508. margin-left: 10px;
  509. }
  510. }
  511. span{
  512. margin-left: 10px;
  513. font-size: 13px;
  514. }
  515. }
  516. .pwd.sm{
  517. color: #8c8c8c;
  518. em {
  519. background: #bfbfbf;
  520. &:first-child{
  521. background: #ff4e00;
  522. }
  523. }
  524. span{
  525. color: #ff4e00;
  526. }
  527. }
  528. .pwd.md{
  529. color: #8c8c8c;
  530. em {
  531. background: #22ac38;
  532. &:nth-child(3){
  533. background: #bfbfbf;
  534. }
  535. }
  536. span{
  537. color: #22ac38;
  538. }
  539. }
  540. .pwd.lar{
  541. color: #8c8c8c;
  542. em {
  543. background: #00a0e9;
  544. }
  545. span{
  546. color: #00a0e9;
  547. }
  548. }
  549. .pwd.low{
  550. color: #8c8c8c;
  551. em{
  552. background: #bfbfbf;
  553. }
  554. }
  555. span.tip{
  556. position: absolute;
  557. top: 0;
  558. right: -238px;
  559. font-size: 13px;
  560. color: #8c8c8c;
  561. a{
  562. font-size: 13px;
  563. color: #0076ad;
  564. }
  565. }
  566. span.tip.description {
  567. top: 10px;
  568. right: -266px;
  569. width: 245px;
  570. line-height: 18px;
  571. text-align: left;
  572. }
  573. span.tip.codeError-tip {
  574. position: absolute;
  575. top: 3px;
  576. left: 378px;
  577. width: 200px;
  578. text-align: left;
  579. color: #ff4949;
  580. font-size: 12px;
  581. }
  582. span.tip.passwordError{
  583. position: absolute;
  584. top: 3px;
  585. left: 380px;
  586. width: 200px;
  587. text-align: left;
  588. color: #ff4949;
  589. font-size: 12px;
  590. }
  591. i{
  592. position: absolute;
  593. top: 13px;
  594. left: 20px;
  595. font-size: 20px;
  596. color: #a0a0a0;
  597. }
  598. input[type='checkbox']{
  599. margin: 0 14px 0 55px;
  600. float: left;
  601. width: 16px;
  602. height: 16px;
  603. }
  604. span.agree{
  605. float: left;
  606. margin: 1px 0 0 10px;
  607. font-size: 14px;
  608. color: #8b8b8b;
  609. a{
  610. color: #0076ad;
  611. }
  612. }
  613. .form-group.agree{
  614. margin: 20px auto 0 !important;
  615. }
  616. .btn {
  617. margin: 34px 0 16px 0;
  618. width: 360px;
  619. height: 44px;
  620. line-height: 44px;
  621. font-size: 16px;
  622. color: #fff;
  623. background: #0076AD;
  624. border-radius: 3px;
  625. }
  626. }
  627. .content-bottom{
  628. margin-top: 35px;
  629. padding-bottom: 50px;
  630. p{
  631. font-size: 24px;
  632. color: #323232;
  633. img{
  634. margin-right: 20px;
  635. width: 30px;
  636. height: 28px;
  637. }
  638. }
  639. p.pass{
  640. font-size: 24px;
  641. color: #e77405;
  642. img{
  643. height: 30px;
  644. }
  645. }
  646. p.passed {
  647. color: #2ab300;
  648. img{
  649. height: 30px;
  650. }
  651. }
  652. span{
  653. display: inline-block;
  654. margin: 15px 0 140px 0;
  655. font-size: 14px;
  656. color: #8b8b8b;
  657. }
  658. .close-btn{
  659. margin: 0 auto;
  660. width: 200px;
  661. height: 36px;
  662. line-height: 36px;
  663. font-size: 14px;
  664. text-align: center;
  665. color: #323232;
  666. border: 1px solid #d2d2d2;
  667. border-radius: 3px;
  668. cursor: pointer ;
  669. }
  670. }
  671. }
  672. }
  673. }
  674. </style>