StepAppeal.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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="off"
  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('appeal')">提 交</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. console.log('tokenCode', this.tokenCode)
  137. if (!this.valid.token) {
  138. this.downToast('请先填写验证码')
  139. this.state.token = 'error'
  140. } else {
  141. if (!this.valid.mobile) {
  142. this.downToast('请先填写正确的手机号码')
  143. this.state.token = 'warning'
  144. } else {
  145. if (this.tokenCode) {
  146. let param = new FormData()
  147. param.append('mobile', this.valid.mobile)
  148. param.append('token', this.tokenCode)
  149. param.append('code', this.valid.token)
  150. let config = {
  151. headers: {'Content-Type': 'multipart/form-data'}
  152. }
  153. this.$http.post('/appeal/check/mobile', param, config)
  154. .then(response => {
  155. if (response.data.success) {
  156. this.state.token = 'success'
  157. } else {
  158. this.$toast({
  159. message: response.data.errMsg,
  160. iconClass: 'el-icon-error'
  161. })
  162. return Promise.reject(response.data)
  163. }
  164. }).catch(() => {
  165. this.downToast('请检查网络是否正常或联系服务商')
  166. })
  167. } else {
  168. this.downToast('请点击先获取验证码信息')
  169. this.state.token = 'warning'
  170. }
  171. }
  172. }
  173. },
  174. // 获取验证码
  175. getCheckCode () {
  176. if (this.tokenTime > 0 && this.tokenTime < 60) {
  177. this.downToast('请稍后再点击,我在倒计时')
  178. } else {
  179. if (this.state.mobile === 'success') {
  180. this.$indicator.open('获取中...')
  181. let _this = this
  182. this.$http.get('/appeal/check/mobile', {params: {mobile: this.valid.mobile}})
  183. .then(response => {
  184. this.$indicator.close()
  185. if (response.data) {
  186. console.log('res', response.data)
  187. this.tokenCode = response.data.content.token
  188. this.$toast({
  189. message: '验证码已经发送到您的手机,请注意查收',
  190. iconClass: 'el-icon-success'
  191. })
  192. this.tokenText = '已发送(' + this.tokenTime + 'S)'
  193. let setTime = setInterval(() => {
  194. _this.tokenTime--
  195. this.tokenText = '已发送(' + this.tokenTime + 'S)'
  196. if (this.tokenTime <= 0) {
  197. clearInterval(setTime)
  198. _this.tokenText = '获取验证码'
  199. _this.tokenTime = 60
  200. }
  201. }, 1000)
  202. }
  203. }).catch(() => {
  204. this.$indicator.close()
  205. this.downToast('请检查网络是否正常或联系服务商')
  206. })
  207. }
  208. }
  209. },
  210. // 验证密码
  211. validatePassword () {
  212. if (!this.valid.password) {
  213. this.downToast('请填写密码')
  214. this.state.password = 'error'
  215. } else {
  216. this.state.password = 'success'
  217. }
  218. },
  219. // 申诉
  220. validateDescription () {
  221. if (!this.valid.description) {
  222. this.downToast('请填写申诉说明')
  223. this.state.description = 'error'
  224. } else {
  225. if (this.valid.description.length >= 100) {
  226. this.downToast('输入长度过长,100个字符以内')
  227. this.state.description = 'warning'
  228. } else {
  229. this.state.description = 'success'
  230. }
  231. }
  232. },
  233. // 验证姓名
  234. validateContactName () {
  235. if (!this.valid.contactName) {
  236. this.downToast('请填写您的姓名')
  237. this.state.contactName = 'error'
  238. } else {
  239. if (this.valid.contactName.length > 20) {
  240. this.downToast('输入长度过长,限定20个字符以内')
  241. this.state.contactName = 'warning'
  242. } else {
  243. this.state.contactName = 'success'
  244. }
  245. }
  246. },
  247. // 验证电话
  248. validateContactTel () {
  249. let reg = /^1[0-9]{10}$/
  250. if (!this.valid.contactTel) {
  251. this.downToast('请填写联系电话')
  252. this.state.contactTel = 'error'
  253. } else {
  254. if (!reg.test(this.valid.contactTel)) {
  255. this.downToast('请填写正确的联系电话')
  256. this.state.contactTel = 'warning'
  257. } else {
  258. this.state.contactTel = 'success'
  259. }
  260. }
  261. },
  262. // 验证邮箱
  263. validateContactEmail () {
  264. let reg = /^([\w-])+(\.\w+)*@([\w-])+((\.\w{2,3}){1,3})$/
  265. if (!this.valid.contactEmail) {
  266. this.downToast('请填写联系电子邮箱')
  267. this.state.contactEmail = 'error'
  268. } else {
  269. if (!reg.test(this.valid.contactEmail)) {
  270. this.downToast('请输入正确的邮箱地址格式')
  271. this.state.contactEmail = 'warning'
  272. } else {
  273. this.state.contactEmail = 'success'
  274. }
  275. }
  276. },
  277. sureAccount (type) {
  278. if (this.state.mobile !== 'success' ||
  279. this.state.token !== 'success' ||
  280. this.state.password !== 'success' ||
  281. this.state.description !== 'success' ||
  282. this.state.contactName !== 'success' ||
  283. this.state.contactTel !== 'success' ||
  284. this.state.contactEmail !== 'success') {
  285. this.downToast('请确认填写部分是否有误')
  286. } else {
  287. this.$indicator.open('验证过程中...')
  288. let param = new FormData()
  289. param.append('mobile', this.valid.mobile)
  290. param.append('code', this.valid.token)
  291. param.append('password', this.valid.password)
  292. param.append('description', this.valid.description)
  293. param.append('contactName', this.valid.contactName)
  294. param.append('contactTel', this.valid.contactTel)
  295. param.append('contactEmail', this.valid.contactEmail)
  296. param.append('token', this.tokenCode)
  297. param.append('appId', this.$store.state.option.appId)
  298. let config = {
  299. headers: {'Content-Type': 'multipart/form-data'}
  300. }
  301. this.$http.post('/appeal/account', param, config)
  302. .then(response => {
  303. this.$indicator.close()
  304. if (response.data.success) {
  305. this.$emit('stepEvent', type)
  306. this.$emit('lastEvent', 'appeal')
  307. } else {
  308. this.downToast(response.data.errMsg)
  309. }
  310. }).catch(() => {
  311. this.$indicator.close()
  312. this.downToast('请检查网络是否正常或联系服务商')
  313. })
  314. }
  315. }
  316. }
  317. }
  318. </script>