stepAppeal.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <div class="f-main">
  3. <div class="content-top">
  4. <p>密码重置</p>
  5. <a href="javascript:void(0)" class="back" @click="jump('select')"><i class="el-icon-back"></i></a>
  6. </div>
  7. <div class="f-form">
  8. <div class="page-part">
  9. <mt-field placeholder="新手机号码"
  10. v-model="valid.mobile"
  11. :state="state.mobile"
  12. type="tel"
  13. @blur.native.capture="validateMobile"
  14. ></mt-field>
  15. </div>
  16. <div class="page-part">
  17. <mt-field auto-complete="off"
  18. placeholder="短信验证码"
  19. v-model="valid.token"
  20. :state="state.token"
  21. @blur.native.capture="validateCode">
  22. <span class="token" @click="getCheckCode" v-text="tokenText">获取验证码</span>
  23. </mt-field>
  24. </div>
  25. <div class="page-part">
  26. <mt-field placeholder="新密码"
  27. v-model="valid.password"
  28. :attr="{maxlength: 20}"
  29. :state="state.password"
  30. @input.native="validatePassword"
  31. @blur.native.capture="validatePasswordTip"></mt-field>
  32. <template v-if="valid.password">
  33. <p class="pwd">密码强度 <em :class="{sm:progress === '弱', md: progress === '中', ld:progress === '强'}"></em> <em :class="{md: progress === '中', ld:progress === '强'}"></em> <em :class="{ld:progress === '强'}"></em> <span :class="{smstep:progress === '弱', mdstep: progress === '中', ldstep:progress === '强'}" v-text="progress">强</span></p>
  34. <p class="pwd">密码须为8-20字符的英文、数字混合</p>
  35. </template>
  36. </div>
  37. <div class="page-part">
  38. <mt-field placeholder="确认密码"
  39. v-model="valid.confirm"
  40. auto-complete="off"
  41. :state="state.confirm"
  42. @blur.native.capture="validateConfirm"
  43. ></mt-field>
  44. </div>
  45. <div class="page-part">
  46. <mt-field placeholder="申诉说明"
  47. type="textarea"
  48. rows="4"
  49. v-model="valid.description"></mt-field>
  50. <p class="pwd">请描述您申诉的原因,并尽可能多地列举出证明此 账号为您所有的证据</p>
  51. </div>
  52. <div class="page-part">
  53. <mt-field placeholder="姓名"
  54. v-model="valid.contactName"
  55. :state="state.contactName"
  56. @blur.native.capture="validateContactName"
  57. ></mt-field>
  58. </div>
  59. <div class="page-part">
  60. <mt-field placeholder="联系电话"
  61. v-model="valid.contactTel"
  62. :state="state.contactTel"
  63. type="tel"
  64. @blur.native.capture="validateContactTel"
  65. ></mt-field>
  66. </div>
  67. <div class="page-part">
  68. <mt-field placeholder="电子邮箱"
  69. v-model="valid.contactEmail"
  70. :state="state.contactEmail"
  71. type="email"
  72. @blur.native.capture="validateContactEmail"
  73. ></mt-field>
  74. </div>
  75. <div class="page-part">
  76. <mt-button size="large" type="primary" @click="sureAccount('last')">提 交</mt-button>
  77. </div>
  78. </div>
  79. </div>
  80. </template>
  81. <script>
  82. export default {
  83. name: 'step-one',
  84. data () {
  85. return {
  86. state: {
  87. mobile: 'error',
  88. token: 'error',
  89. password: 'error',
  90. confirm: 'error',
  91. contactName: 'error',
  92. contactTel: 'error',
  93. contactEmail: 'error'
  94. },
  95. valid: {
  96. mobile: '',
  97. token: '',
  98. password: '',
  99. confirm: '',
  100. description: '',
  101. contactName: '',
  102. contactTel: '',
  103. contactEmail: ''
  104. },
  105. tokenCode: '',
  106. tokenTime: 60,
  107. tokenText: '获取验证码',
  108. progress: '弱'
  109. }
  110. },
  111. methods: {
  112. jump (type) {
  113. this.$emit('stepEvent', type)
  114. },
  115. // 弹窗处理
  116. downToast (type) {
  117. this.$toast({
  118. message: type,
  119. iconClass: 'el-icon-warning'
  120. })
  121. },
  122. // 验证手机号
  123. validateMobile () {
  124. let reg = /^1[0-9]{10}$/
  125. if (!this.valid.mobile) {
  126. this.downToast('请先填写手机号')
  127. this.state.mobile = 'error'
  128. } else {
  129. if (!reg.test(this.valid.mobile)) {
  130. this.downToast('请填写正确的手机号')
  131. this.state.mobile = 'warning'
  132. } else {
  133. this.state.mobile = 'success'
  134. }
  135. }
  136. },
  137. // 验证正确的验证码
  138. validateCode () {
  139. if (!this.valid.token) {
  140. this.downToast('请先填写验证码')
  141. this.state.token = 'error'
  142. } else {
  143. if (!this.valid.mobile) {
  144. this.downToast('请先填写正确的手机号码')
  145. this.state.token = 'warning'
  146. } else {
  147. if (this.tokenCode) {
  148. let param = new FormData()
  149. param.append('mobile', this.valid.mobile)
  150. param.append('token', this.tokenCode)
  151. param.append('code', this.valid.token)
  152. let config = {
  153. headers: {'Content-Type': 'multipart/form-data'}
  154. }
  155. this.$http.post('/appeal/check/mobile', param, config)
  156. .then(response => {
  157. if (response.data.success) {
  158. this.state.token = 'success'
  159. } else {
  160. this.$toast({
  161. message: response.data.errMsg,
  162. iconClass: 'el-icon-error'
  163. })
  164. }
  165. }).catch(() => {
  166. this.downToast('请检查网络是否正常或联系服务商')
  167. })
  168. } else {
  169. this.downToast('请点击先获取验证码信息')
  170. this.state.token = 'warning'
  171. }
  172. }
  173. }
  174. },
  175. // 获取验证码
  176. getCheckCode () {
  177. if (this.tokenTime > 0 && this.tokenTime < 60) {
  178. this.downToast('请稍后再点击,我在倒计时')
  179. } else {
  180. if (this.state.mobile !== 'success') {
  181. this.downToast('请先输入正确的手机号')
  182. } else {
  183. this.$indicator.open('获取中...')
  184. let _this = this
  185. this.$http.get('/sso/personal/register/checkCode', {params: {mobile: this.valid.mobile}})
  186. .then(response => {
  187. this.$indicator.close()
  188. if (response.data) {
  189. this.tokenCode = response.data.token
  190. this.$toast({
  191. message: '验证码已经发送到您的手机,请注意查收',
  192. iconClass: 'el-icon-success'
  193. })
  194. this.tokenText = '已发送(' + this.tokenTime + 'S)'
  195. let setTime = setInterval(() => {
  196. _this.tokenTime--
  197. this.tokenText = '已发送(' + this.tokenTime + 'S)'
  198. if (this.tokenTime <= 0) {
  199. clearInterval(setTime)
  200. _this.tokenText = '获取验证码'
  201. _this.tokenTime = 60
  202. }
  203. }, 1000)
  204. }
  205. }).catch(() => {
  206. this.$indicator.close()
  207. this.downToast('请检查网络是否正常或联系服务商')
  208. })
  209. }
  210. }
  211. },
  212. // 验证密码强度
  213. validatePassword () {
  214. let reg1 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]))|((?=.*[0-9])((?=.*[a-zA-Z]))(?=.*[^a-zA-Z0-9]))).*$/
  215. let reg2 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$/
  216. let count = this.valid.password.length
  217. if (count >= 20) {
  218. this.downToast('密码须为8-20字符的英文、数字混合')
  219. } else {
  220. if (reg1.test(this.valid.password)) {
  221. this.progress = '强'
  222. } else if (reg2.test(this.valid.password)) {
  223. this.progress = '中'
  224. } else {
  225. this.progress = '弱'
  226. }
  227. }
  228. },
  229. // 验证密码
  230. validatePasswordTip () {
  231. let reg2 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$/
  232. if (!this.valid.password) {
  233. this.downToast('请输入密码')
  234. this.state.password = 'error'
  235. } else {
  236. if (!reg2.test(this.valid.password)) {
  237. this.downToast('密码须为8-20字符的英文、数字混合')
  238. this.state.password = 'warning'
  239. } else {
  240. this.state.password = 'success'
  241. if (this.valid.confirm) {
  242. this.validateConfirm()
  243. }
  244. }
  245. }
  246. },
  247. // 验证二次密码
  248. validateConfirm () {
  249. if (!this.valid.confirm) {
  250. this.downToast('请再次输入密码')
  251. this.state.confirm = 'error'
  252. } else {
  253. if (this.valid.confirm === this.valid.password) {
  254. this.state.confirm = 'success'
  255. } else {
  256. this.state.confirm = 'warning'
  257. this.downToast('两次输入密码不一致,请重新输入')
  258. }
  259. }
  260. },
  261. // 验证姓名
  262. validateContactName () {
  263. if (!this.valid.contactName) {
  264. this.downToast('请填写您的姓名')
  265. this.state.contactName = 'error'
  266. } else {
  267. if (this.valid.contactName.length > 20) {
  268. this.downToast('输入长度过长,限定20个字符以内')
  269. this.state.contactName = 'warning'
  270. } else {
  271. this.state.contactName = 'success'
  272. }
  273. }
  274. },
  275. // 验证电话
  276. validateContactTel () {
  277. let reg = /^1[0-9]{10}$/
  278. if (!this.valid.contactTel) {
  279. this.downToast('请填写联系电话')
  280. this.state.contactTel = 'error'
  281. } else {
  282. if (!reg.test(this.valid.contactTel)) {
  283. this.downToast('请填写正确的联系电话')
  284. this.state.contactTel = 'warning'
  285. } else {
  286. this.state.contactTel = 'success'
  287. }
  288. }
  289. },
  290. // 验证邮箱
  291. validateContactEmail () {
  292. let reg = /^([\w-])+(\.\w+)*@([\w-])+((\.\w{2,3}){1,3})$/
  293. if (!this.valid.contactEmail) {
  294. this.downToast('请填写联系电子邮箱')
  295. this.state.contactEmail = 'error'
  296. } else {
  297. if (!reg.test(this.valid.contactEmail)) {
  298. this.downToast('请输入正确的邮箱地址格式')
  299. this.state.contactEmail = 'warning'
  300. } else {
  301. this.state.contactEmail = 'success'
  302. }
  303. }
  304. },
  305. sureAccount (type) {
  306. if (this.state.mobile !== 'success' &&
  307. this.state.token !== 'success' &&
  308. this.state.password !== 'success' &&
  309. this.state.confirm !== 'success' &&
  310. this.state.contactName !== 'success' &&
  311. this.state.contactTel !== 'success' &&
  312. this.state.contactEmail !== 'success') {
  313. this.downToast('请确认填写部分是否有误')
  314. } else {
  315. this.$indicator.open('验证过程中...')
  316. let param = new FormData()
  317. param.append('mobile', this.valid.mobile)
  318. param.append('code', this.valid.token)
  319. param.append('password', this.valid.password)
  320. param.append('description', this.valid.description)
  321. param.append('contactName', this.valid.contactName)
  322. param.append('contactTel', this.valid.contactTel)
  323. param.append('contactEmail', this.valid.contactEmail)
  324. param.append('token', this.tokenCode)
  325. let config = {
  326. headers: {'Content-Type': 'multipart/form-data'}
  327. }
  328. this.$http.post('/appeal/resetPwd', param, config)
  329. .then(response => {
  330. this.$indicator.close()
  331. if (response.data.success) {
  332. this.$emit('stepEvent', type)
  333. this.$emit('lastEvent', 'appeal')
  334. } else {
  335. this.downToast(response.data.errMsg)
  336. }
  337. }).catch(() => {
  338. this.$indicator.close()
  339. this.downToast('请检查网络是否正常或联系服务商')
  340. })
  341. }
  342. }
  343. }
  344. }
  345. </script>