PasswordRestAppeal.vue 21 KB

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