StepAppeal.vue 11 KB

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