StepNew.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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.contactName"
  11. :state="state.contactName"
  12. @blur.native.capture="validateContactName"
  13. ></mt-field>
  14. </div>
  15. <div class="page-part">
  16. <mt-field placeholder="新管理员手机号"
  17. v-model="valid.mobile"
  18. :state="state.mobile"
  19. type="tel"
  20. @blur.native.capture="validateMobile"
  21. ></mt-field>
  22. </div>
  23. <div class="page-part">
  24. <mt-field auto-complete="off"
  25. placeholder="短信验证码"
  26. v-model="valid.code"
  27. :state="state.code"
  28. @blur.native.capture="validateCode">
  29. <span class="token" @click="getCheckCode" v-text="tokenText" v-if="state.mobile === 'success'">获取验证码</span>
  30. <span class="token-no" v-text="tokenText" v-if="state.mobile !== 'success'">获取验证码</span>
  31. </mt-field>
  32. </div>
  33. <div class="page-part">
  34. <mt-field placeholder="更换原因"
  35. type="textarea"
  36. rows="4"
  37. v-model="valid.description"
  38. @blur.native.capture="validateDescription"></mt-field>
  39. <p class="pwd">请描述您申诉的原因,并尽可能多地列举出证明此企业账号为您所有的证据</p>
  40. </div>
  41. <div class="page-part">
  42. <mt-field placeholder="联系电话"
  43. v-model="valid.contactTel"
  44. :state="state.contactTel"
  45. type="tel"
  46. @blur.native.capture="validateContactTel"
  47. ></mt-field>
  48. </div>
  49. <div class="page-part">
  50. <mt-button size="large" type="primary" @click="sureAccount('last')">提 交</mt-button>
  51. </div>
  52. </div>
  53. </div>
  54. </template>
  55. <script>
  56. export default {
  57. name: 'step-one',
  58. props: ['tokenId'],
  59. data () {
  60. return {
  61. state: {
  62. contactName: 'error',
  63. mobile: 'error',
  64. code: 'error',
  65. description: 'error',
  66. contactTel: 'error'
  67. },
  68. valid: {
  69. contactName: '',
  70. mobile: '',
  71. code: '',
  72. description: '',
  73. contactTel: ''
  74. },
  75. tokenCode: '',
  76. tokenTime: 60,
  77. tokenText: '获取验证码'
  78. }
  79. },
  80. methods: {
  81. jump (type) {
  82. this.$emit('stepEvent', type)
  83. },
  84. // 弹窗处理
  85. downToast (type) {
  86. this.$toast({
  87. message: type,
  88. iconClass: 'el-icon-warning'
  89. })
  90. },
  91. // 验证姓名
  92. validateContactName () {
  93. if (!this.valid.contactName) {
  94. this.downToast('请填写您的姓名')
  95. this.state.contactName = 'error'
  96. } else {
  97. if (this.valid.contactName.length > 20) {
  98. this.downToast('输入长度过长,限定20个字符以内')
  99. this.state.contactName = 'warning'
  100. } else {
  101. this.state.contactName = 'success'
  102. }
  103. }
  104. },
  105. // 验证手机号
  106. validateMobile () {
  107. if (!this.valid.mobile) {
  108. this.downToast('请先填写手机号')
  109. this.state.mobile = 'error'
  110. } else {
  111. let reg = /^1[0-9]{10}$/
  112. if (!reg.test(this.valid.mobile)) {
  113. this.downToast('请填写正确的手机号')
  114. this.state.mobile = 'warning'
  115. } else {
  116. this.state.mobile = 'success'
  117. }
  118. }
  119. },
  120. // 验证正确的验证码
  121. validateCode () {
  122. if (!this.valid.code) {
  123. this.downToast('请先填写验证码')
  124. this.state.code = 'error'
  125. } else {
  126. if (!this.valid.mobile) {
  127. this.downToast('请先填写正确的手机号码')
  128. this.state.code = 'warning'
  129. } else {
  130. if (this.tokenCode) {
  131. let param = new FormData()
  132. param.append('mobile', this.valid.mobile)
  133. param.append('token', this.tokenCode)
  134. param.append('code', this.valid.code)
  135. let config = {
  136. headers: {'Content-Type': 'multipart/form-data'}
  137. }
  138. this.$http.post('/sso/change/admin/check/newMobile', param, config)
  139. .then(response => {
  140. if (response.data.success) {
  141. this.state.code = 'success'
  142. } else {
  143. this.$toast({
  144. message: response.data.errMsg,
  145. iconClass: 'el-icon-error'
  146. })
  147. }
  148. }).catch((err) => {
  149. this.downToast(err.errMsg)
  150. })
  151. } else {
  152. this.downToast('请点击先获取验证码信息')
  153. this.state.code = 'warning'
  154. }
  155. }
  156. }
  157. },
  158. // 获取验证码
  159. getCheckCode () {
  160. if (this.tokenTime > 0 && this.tokenTime < 60) {
  161. this.downToast('请稍后再点击,我在倒计时')
  162. } else {
  163. if (this.state.mobile === 'success') {
  164. this.$indicator.open('获取中...')
  165. let _this = this
  166. this.$http.get('/sso/change/admin/check/newMobile', {params: {mobile: this.valid.mobile, token: this.tokenId ? this.tokenId : this.$route.query.token}})
  167. .then(response => {
  168. this.$indicator.close()
  169. if (response.data) {
  170. this.tokenCode = response.data.content.token
  171. this.$toast({
  172. message: '验证码已经发送到您的手机,请注意查收',
  173. iconClass: 'el-icon-success'
  174. })
  175. this.tokenText = '已发送(' + this.tokenTime + 'S)'
  176. let setTime = setInterval(() => {
  177. _this.tokenTime--
  178. this.tokenText = '已发送(' + this.tokenTime + 'S)'
  179. if (this.tokenTime <= 0) {
  180. clearInterval(setTime)
  181. _this.tokenText = '获取验证码'
  182. _this.tokenTime = 60
  183. }
  184. }, 1000)
  185. }
  186. }).catch((err) => {
  187. this.$indicator.close()
  188. this.downToast(err.errMsg)
  189. })
  190. }
  191. }
  192. },
  193. // 申诉
  194. validateDescription () {
  195. if (!this.valid.description) {
  196. this.downToast('请填写申诉说明')
  197. this.state.description = 'error'
  198. } else {
  199. if (this.valid.description.length >= 100) {
  200. this.downToast('输入长度过长,100个字符以内')
  201. this.state.description = 'warning'
  202. } else {
  203. this.state.description = 'success'
  204. }
  205. }
  206. },
  207. // 验证电话
  208. validateContactTel () {
  209. let reg = /^1[0-9]{10}$/
  210. if (!this.valid.contactTel) {
  211. this.downToast('请填写联系电话')
  212. this.state.contactTel = 'error'
  213. } else {
  214. if (!reg.test(this.valid.contactTel)) {
  215. this.downToast('请填写正确的联系电话')
  216. this.state.contactTel = 'warning'
  217. } else {
  218. this.state.contactTel = 'success'
  219. }
  220. }
  221. },
  222. sureAccount (type) {
  223. console.log('type', this.tokenId)
  224. if (this.state.mobile !== 'success' ||
  225. this.state.contactName !== 'success' ||
  226. this.state.code !== 'success' ||
  227. this.state.description !== 'success' ||
  228. this.state.contactTel !== 'success') {
  229. this.downToast('请确认填写部分是否有误')
  230. } else {
  231. this.$indicator.open('验证过程中...')
  232. let param = new FormData()
  233. param.append('newAdminName', this.valid.contactName)
  234. param.append('mobile', this.valid.mobile)
  235. param.append('code', this.valid.code)
  236. param.append('contactTel', this.valid.contactTel)
  237. param.append('changeReason', this.valid.description)
  238. param.append('token', this.tokenId ? this.tokenId : this.$route.query.token)
  239. param.append('codeToken', this.tokenCode)
  240. let config = {
  241. headers: {'Content-Type': 'multipart/form-data'}
  242. }
  243. this.$http.post('/sso/change/admin', param, config)
  244. .then(response => {
  245. this.$indicator.close()
  246. if (response.data.success) {
  247. this.$emit('stepEvent', type)
  248. this.$emit('lastEvent', 'success')
  249. } else {
  250. this.downToast(response.data.errMsg)
  251. }
  252. }).catch((err) => {
  253. this.$indicator.close()
  254. this.downToast(err.errMsg)
  255. })
  256. }
  257. }
  258. }
  259. }
  260. </script>