PasswordRestAppeal.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  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. console.log(this.passwordChecked)
  190. } else {
  191. if (this.passwordRest.password !== '') {
  192. if (value.length <= 20 && value.length >= 8) {
  193. var reg1 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]))|((?=.*[0-9])((?=.*[a-zA-Z]))(?=.*[^a-zA-Z0-9]))).*$/
  194. var reg2 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$/
  195. if (reg1.test(value)) {
  196. this.passwordChecked = true
  197. } else if (reg2.test(value)) {
  198. this.passwordChecked = true
  199. } else {
  200. callback(new Error('密码须为8-20字符的英文、数字混合'))
  201. this.passwordChecked = false
  202. }
  203. } else {
  204. callback(new Error('密码须为8-20字符的英文、数字混合'))
  205. this.passwordChecked = false
  206. }
  207. if (this.passwordRest.confirm) {
  208. console.log(this.passwordRest.confirm)
  209. if (value !== this.passwordRest.confirm) {
  210. this.showPasswordError = true
  211. // callback(new Error('两次输入密码不一致!'))
  212. this.confirmChecked = false
  213. } else {
  214. this.confirmChecked = true
  215. this.showPasswordError = false
  216. callback()
  217. }
  218. }
  219. }
  220. callback()
  221. }
  222. }
  223. var validateConfirm = (rule, value, callback) => {
  224. if (value === '') {
  225. callback(new Error('请再次输入密码'))
  226. this.showPasswordError = false
  227. this.confirmChecked = false
  228. } else if (value !== this.passwordRest.password) {
  229. // callback(new Error('两次输入密码不一致!'))
  230. this.showPasswordError = true
  231. this.confirmChecked = false
  232. } else {
  233. this.confirmChecked = true
  234. this.showPasswordError = false
  235. callback()
  236. }
  237. }
  238. var validateDescription = (rule, value, callback) => {
  239. if (value === '') {
  240. callback(new Error('请填写申诉说明'))
  241. this.descriptionChecked = false
  242. this.descriptionTip = false
  243. } else {
  244. if (this.passwordRest.description !== '') {
  245. if (value.length >= 100) {
  246. callback(new Error('输入长度过长,100个字符以内'))
  247. this.descriptionChecked = false
  248. this.descriptionTip = false
  249. } else {
  250. this.descriptionChecked = true
  251. this.descriptionTip = false
  252. }
  253. }
  254. callback()
  255. }
  256. }
  257. var validateContactName = (rule, value, callback) => {
  258. if (value === '') {
  259. callback(new Error('请填写您的姓名'))
  260. this.contactNameChecked = false
  261. } else {
  262. if (this.passwordRest.contactName !== '') {
  263. if (value.length >= 20) {
  264. callback(new Error('输入长度过长,20个字符以内'))
  265. this.contactNameChecked = false
  266. } else {
  267. this.contactNameChecked = true
  268. }
  269. }
  270. callback()
  271. }
  272. }
  273. var validateContactTel = (rule, value, callback) => {
  274. if (value === '') {
  275. callback(new Error('请填写正确的联系电话'))
  276. this.contactTelChecked = false
  277. } else {
  278. if (this.passwordRest.contactTel !== '') {
  279. var reg = /^1[0-9]{10}$/
  280. if (!reg.test(value)) {
  281. callback(new Error('请填写正确的联系电话'))
  282. this.contactTelChecked = false
  283. } else {
  284. this.contactTelChecked = true
  285. }
  286. }
  287. callback()
  288. }
  289. }
  290. var validateContactEmail = (rule, value, callback) => {
  291. if (value === '') {
  292. callback(new Error('请填写正确的电子邮箱'))
  293. this.contactEmailChecked = false
  294. } else {
  295. if (this.passwordRest.contactEmail !== '') {
  296. var reg = /^([\w-])+(\.\w+)*@([\w-])+((\.\w{2,3}){1,3})$/
  297. if (!reg.test(value)) {
  298. callback(new Error('请输入正确的邮箱地址格式'))
  299. this.contactEmailChecked = false
  300. } else {
  301. this.contactEmailChecked = true
  302. }
  303. }
  304. callback()
  305. }
  306. }
  307. return {
  308. isShowLoading: false,
  309. showPasswordError: false,
  310. codeErrorMsg: '',
  311. goNextStep: true,
  312. passwordRest: {
  313. mobile: '',
  314. code: '',
  315. password: '',
  316. conform: '',
  317. description: '',
  318. contactName: '',
  319. contactTel: '',
  320. contactEmail: ''
  321. },
  322. checked: true,
  323. sendAccountCode: true,
  324. account_time: 0,
  325. getCodeBtnIsDisabled: true,
  326. codeErrorChecked: false,
  327. descriptionTip: true,
  328. showMsgTip1: false,
  329. showMsgTip2: false,
  330. showMsgTip3: false,
  331. showMsgTip4: false,
  332. mobileChecked: false,
  333. codeChecked: false,
  334. passwordChecked: false,
  335. confirmChecked: false,
  336. descriptionChecked: false,
  337. contactNameChecked: false,
  338. contactTelChecked: false,
  339. contactEmailChecked: false,
  340. rules: {
  341. mobile: [
  342. {validator: validateMobile, trigger: 'blur'}
  343. ],
  344. code: [
  345. {validator: validateCode, trigger: 'blur'}
  346. ],
  347. password: [
  348. {validator: validatePassword, trigger: 'change'},
  349. {validator: validatePasswordTip, trigger: 'blur'}
  350. ],
  351. confirm: [
  352. {validator: validateConfirm, trigger: 'blur'}
  353. ],
  354. description: [
  355. {validator: validateDescription, trigger: 'blur'}
  356. ],
  357. contactName: [
  358. {validator: validateContactName, trigger: 'blur'}
  359. ],
  360. contactTel: [
  361. {validator: validateContactTel, trigger: 'blur'}
  362. ],
  363. contactEmail: [
  364. {validator: validateContactEmail, trigger: 'blur'}
  365. ]
  366. }
  367. }
  368. },
  369. methods: {
  370. // 判断我同意是否被选中
  371. checkboxChecked () {
  372. this.checked = !this.checked
  373. },
  374. // 获取校验码
  375. getCheckCode () {
  376. this.isShowLoading = true
  377. this.$http.get(`/appeal/check/mobile`, {params: {mobile: this.passwordRest.mobile}})
  378. .then(response => {
  379. this.isShowLoading = false
  380. if (response.data.success) {
  381. this.token = response.data.content.token
  382. if (this.token !== '') {
  383. this.$message({
  384. message: '验证码已经发送到您的手机,请注意查收',
  385. type: 'success'
  386. })
  387. this.sendAccountCode = false
  388. this.account_time = 60
  389. var accountTime = setInterval(() => {
  390. this.account_time--
  391. if (this.account_time <= 0) {
  392. this.sendAccountCode = true
  393. clearInterval(accountTime)
  394. }
  395. }, 1000)
  396. }
  397. } else {
  398. return Promise.reject(response.data)
  399. }
  400. }).catch(err => {
  401. this.isShowLoading = false
  402. this.$message.error(err.errMsg)
  403. })
  404. },
  405. // 提交表单
  406. submit () {
  407. if (this.mobileChecked && this.codeChecked && this.passwordChecked && this.confirmChecked && this.descriptionChecked && this.contactNameChecked && this.contactTelChecked && this.contactEmailChecked && this.checked) {
  408. this.isShowLoading = true
  409. let param = new FormData()
  410. param.append('mobile', this.passwordRest.mobile)
  411. param.append('code', this.passwordRest.code)
  412. param.append('password', this.passwordRest.password)
  413. param.append('description', this.passwordRest.description)
  414. param.append('contactName', this.passwordRest.contactName)
  415. param.append('contactTel', this.passwordRest.contactTel)
  416. param.append('contactEmail', this.passwordRest.contactEmail)
  417. param.append('token', this.token)
  418. let config = {
  419. headers: {'Content-Type': 'multipart/form-data'}
  420. }
  421. this.$http.post('/appeal/resetPwd', param, config)
  422. .then(response => {
  423. this.isShowLoading = false
  424. if (response.data.success) {
  425. this.goNextStep = false
  426. // 待跳转到设置页面
  427. // window.loaction.href = ''
  428. } else {
  429. this.goNextStep = true
  430. return Promise.reject(response.data)
  431. }
  432. }).catch(err => {
  433. this.$message.error(err.errMsg)
  434. this.isShowLoading = false
  435. // this.codeErrorChecked = true
  436. // this.codeChecked = false
  437. this.account_time = 0
  438. })
  439. }
  440. },
  441. // 跳转至个人中心页面
  442. goCloudCenter () {
  443. window.location.href = '/cloudcenter'
  444. }
  445. }
  446. }
  447. </script>
  448. <style lang="scss" scoped>
  449. .certification {
  450. margin: 0 auto;
  451. width: 100%;
  452. background: #eee;
  453. .container{
  454. padding-top: 50px;
  455. margin: 0 auto;
  456. width: 980px;
  457. text-align: center;
  458. .content{
  459. padding: 0 50px;
  460. margin: 50px auto 0;
  461. width: 100%;
  462. text-align: center;
  463. background: #fff;
  464. .content-top{
  465. height: 80px;
  466. line-height: 80px;
  467. h3{
  468. margin-bottom: 0;
  469. font-size: 24px;
  470. color: #000;
  471. border-bottom: 1px solid #dcdcdc;
  472. }
  473. .step{
  474. position: relative;
  475. margin-top: 10px;
  476. img{
  477. width: 315px;
  478. height: 46px;
  479. }
  480. .step-item{
  481. position: absolute;
  482. top: 45px;
  483. left: 265px;
  484. span{
  485. margin-right: 85px;
  486. font-size: 14px;
  487. color: #b4b4b4;
  488. }
  489. span.active {
  490. color: #0076ad;
  491. }
  492. }
  493. }
  494. }
  495. form {
  496. padding-bottom: 44px;
  497. margin-top: 36px;
  498. input{
  499. padding: 0 0 0 18px;
  500. width: 360px;
  501. height: 44px;
  502. line-height: 44px;
  503. font-size: 14px;
  504. color: #000;
  505. border-radius: 0;
  506. }
  507. .pwd {
  508. margin: 6px 0 -15px 0;
  509. text-align: left;
  510. font-size: 13px;
  511. em{
  512. display: inline-block;
  513. margin: 0 8px 2px 0;
  514. width: 24px;
  515. height: 6px;
  516. &:first-child{
  517. margin-left: 10px;
  518. }
  519. }
  520. span{
  521. margin-left: 10px;
  522. font-size: 13px;
  523. }
  524. }
  525. .pwd.sm{
  526. color: #8c8c8c;
  527. em {
  528. background: #bfbfbf;
  529. &:first-child{
  530. background: #ff4e00;
  531. }
  532. }
  533. span{
  534. color: #ff4e00;
  535. }
  536. }
  537. .pwd.md{
  538. color: #8c8c8c;
  539. em {
  540. background: #22ac38;
  541. &:nth-child(3){
  542. background: #bfbfbf;
  543. }
  544. }
  545. span{
  546. color: #22ac38;
  547. }
  548. }
  549. .pwd.lar{
  550. color: #8c8c8c;
  551. em {
  552. background: #00a0e9;
  553. }
  554. span{
  555. color: #00a0e9;
  556. }
  557. }
  558. .pwd.low{
  559. color: #8c8c8c;
  560. em{
  561. background: #bfbfbf;
  562. }
  563. }
  564. span.tip{
  565. position: absolute;
  566. top: 0;
  567. right: -238px;
  568. font-size: 13px;
  569. color: #8c8c8c;
  570. a{
  571. font-size: 13px;
  572. color: #0076ad;
  573. }
  574. }
  575. span.tip.description {
  576. top: 10px;
  577. right: -266px;
  578. width: 245px;
  579. line-height: 18px;
  580. text-align: left;
  581. }
  582. span.tip.codeError-tip {
  583. position: absolute;
  584. top: 3px;
  585. left: 378px;
  586. width: 200px;
  587. text-align: left;
  588. color: #ff4949;
  589. font-size: 12px;
  590. }
  591. span.tip.passwordError{
  592. position: absolute;
  593. top: 3px;
  594. left: 380px;
  595. width: 200px;
  596. text-align: left;
  597. color: #ff4949;
  598. font-size: 12px;
  599. }
  600. i{
  601. position: absolute;
  602. top: 13px;
  603. left: 20px;
  604. font-size: 20px;
  605. color: #a0a0a0;
  606. }
  607. input[type='checkbox']{
  608. margin: 0 14px 0 55px;
  609. float: left;
  610. width: 16px;
  611. height: 16px;
  612. }
  613. span.agree{
  614. float: left;
  615. margin: 1px 0 0 10px;
  616. font-size: 14px;
  617. color: #8b8b8b;
  618. a{
  619. color: #0076ad;
  620. }
  621. }
  622. .form-group.agree{
  623. margin: 20px auto 0 !important;
  624. }
  625. .btn {
  626. margin: 34px 0 16px 0;
  627. width: 360px;
  628. height: 44px;
  629. line-height: 44px;
  630. font-size: 16px;
  631. color: #fff;
  632. background: #0076AD;
  633. border-radius: 3px;
  634. }
  635. }
  636. .content-bottom{
  637. margin-top: 35px;
  638. padding-bottom: 50px;
  639. p{
  640. font-size: 24px;
  641. color: #323232;
  642. img{
  643. margin-right: 20px;
  644. width: 30px;
  645. height: 28px;
  646. }
  647. }
  648. p.pass{
  649. font-size: 24px;
  650. color: #e77405;
  651. img{
  652. height: 30px;
  653. }
  654. }
  655. p.passed {
  656. color: #2ab300;
  657. img{
  658. height: 30px;
  659. }
  660. }
  661. span{
  662. display: inline-block;
  663. margin: 15px 0 140px 0;
  664. font-size: 14px;
  665. color: #8b8b8b;
  666. }
  667. .close-btn{
  668. margin: 0 auto;
  669. width: 200px;
  670. height: 36px;
  671. line-height: 36px;
  672. font-size: 14px;
  673. text-align: center;
  674. color: #323232;
  675. border: 1px solid #d2d2d2;
  676. border-radius: 3px;
  677. cursor: pointer ;
  678. }
  679. }
  680. }
  681. }
  682. }
  683. </style>