StepAppeal.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <template>
  2. <div>
  3. <template v-if="!showChooseAddress">
  4. <div class="f-main">
  5. <div class="content-top">
  6. <p>更换管理员</p>
  7. <!--<a href="javascript:void(0)" class="back" @click="jump('select')"><i class="el-icon-back"></i></a>-->
  8. </div>
  9. <div class="f-form">
  10. <div class="page-part">
  11. <mt-field placeholder="新管理员手机号"
  12. v-model="valid.mobile"
  13. :state="state.mobile"
  14. type="tel"
  15. @blur.native.capture="validateMobile"
  16. ></mt-field>
  17. </div>
  18. <div class="page-part">
  19. <mt-field auto-complete="off"
  20. placeholder="短信验证码"
  21. v-model="valid.code"
  22. :state="state.code"
  23. @blur.native.capture="validateCode">
  24. <span class="token" @click="getCheckCode" v-text="tokenText" v-if="state.mobile === 'success'">获取验证码</span>
  25. <span class="token-no" v-text="tokenText" v-if="state.mobile !== 'success'">获取验证码</span>
  26. </mt-field>
  27. </div>
  28. <div class="page-part">
  29. <mt-field placeholder="企业名称"
  30. v-model="valid.spaceName"
  31. :state="state.spaceName"
  32. @blur.native.capture="validateSpaceName"
  33. ></mt-field>
  34. </div>
  35. <div class="page-part">
  36. <mt-field placeholder="营业执照号"
  37. v-model="valid.businessCode"
  38. auto-complete="off"
  39. :state="state.businessCode"
  40. @blur.native.capture="validateBusinessCode"
  41. ></mt-field>
  42. </div>
  43. <div class="page-part">
  44. <a class="phone-btn-blank" title="上传营业执照扫描件" v-bind:class="{ correct: uploadFileChecked }">
  45. <i class="fa fa-picture-o fa-p"></i>
  46. <span class="upload">上传营业执照扫描件</span>
  47. <input type="file"
  48. class="form-control file-input"
  49. name="name"
  50. accept="image/jpeg,image/jpg,image/gif,image/bmp,image/png,.pdf"
  51. @change="upload"/>
  52. </a>
  53. <a class="thumbnail" v-if="valid.businessCodeImage !== ''"><img class="previewImg" alt="" :src="isPdf ? '/images/all/timg.png' : valid.businessCodeImage"></a>
  54. </div>
  55. <div class="page-part">
  56. <mt-field placeholder="法定代表人"
  57. v-model="valid.corporation"
  58. auto-complete="off"
  59. :state="state.corporation"
  60. @blur.native.capture="validateCorporation"
  61. ></mt-field>
  62. </div>
  63. <div class="page-part" style="position: relative">
  64. <!--// 注册地址-->
  65. <mt-field readonly aria-haspopup="true" aria-expanded="false"
  66. placeholder="注册地址"
  67. v-model="regAddress"
  68. @click.native="chooseAddress"></mt-field>
  69. <i class="fa fa-map-marker fa-p" v-show="regAddress.length === 0"></i>
  70. </div>
  71. <div class="page-part">
  72. <mt-field placeholder="申诉说明"
  73. type="textarea"
  74. rows="4"
  75. v-model="valid.description"
  76. @blur.native.capture="validateDescription"></mt-field>
  77. <p class="pwd">请描述您申诉的原因,并尽可能多地列举出证明此账号为您所有的证据</p>
  78. </div>
  79. <div class="page-part">
  80. <mt-field placeholder="姓名"
  81. v-model="valid.contactName"
  82. :state="state.contactName"
  83. @blur.native.capture="validateContactName"
  84. ></mt-field>
  85. </div>
  86. <div class="page-part">
  87. <mt-field placeholder="联系电话"
  88. v-model="valid.contactTel"
  89. :state="state.contactTel"
  90. type="tel"
  91. @blur.native.capture="validateContactTel"
  92. ></mt-field>
  93. </div>
  94. <div class="page-part">
  95. <mt-field placeholder="电子邮箱"
  96. v-model="valid.contactEmail"
  97. :state="state.contactEmail"
  98. type="email"
  99. @blur.native.capture="validateContactEmail"
  100. ></mt-field>
  101. </div>
  102. <div class="page-part">
  103. <mt-button size="large" type="primary" @click="sureAccount('last')">提 交</mt-button>
  104. </div>
  105. </div>
  106. </div>
  107. </template>
  108. <template v-else>
  109. <address-choose
  110. @getAddress="setAddress"
  111. @getProvince="setProvince"
  112. @getCity="setCity"
  113. @getArea="setArea"
  114. @getDetailAddress="setDetailAddress"
  115. @getPopAddress="setPopAddress"
  116. @showEvent="showAddress"
  117. :popAddress="popAddress"
  118. :regStreet="regStreet"
  119. :regProvince="regProvince"
  120. :regCity="regCity"
  121. :regDistrict="regDistrict"/>
  122. </template>
  123. </div>
  124. </template>
  125. <script>
  126. import addressChoose from '~components/mobile/enterpriseCertification/addressChoose.vue'
  127. export default {
  128. name: 'step-one',
  129. components: {
  130. addressChoose
  131. },
  132. data () {
  133. return {
  134. uploadFileChecked: false,
  135. isPdf: false,
  136. showChooseAddress: false,
  137. state: {
  138. mobile: 'error',
  139. code: 'error',
  140. spaceName: 'error',
  141. businessCode: 'error',
  142. businessCodeImage: 'error',
  143. corporation: 'error',
  144. description: 'error',
  145. contactName: 'error',
  146. contactTel: 'error',
  147. contactEmail: 'error'
  148. },
  149. valid: {
  150. mobile: '',
  151. code: '',
  152. spaceName: '',
  153. businessCode: '',
  154. businessCodeImage: '',
  155. corporation: '',
  156. description: '',
  157. contactName: '',
  158. contactTel: '',
  159. contactEmail: ''
  160. },
  161. tokenCode: '',
  162. tokenTime: 60,
  163. tokenText: '获取验证码',
  164. regAddress: '',
  165. regProvince: '',
  166. regCity: '',
  167. regDistrict: '',
  168. popAddress: '',
  169. regStreet: ''
  170. }
  171. },
  172. methods: {
  173. // 选择注册地址
  174. chooseAddress () {
  175. this.showChooseAddress = true
  176. },
  177. setAddress (detail) {
  178. this.regAddress = detail
  179. },
  180. setProvince (detail) {
  181. this.regProvince = detail
  182. },
  183. setCity (detail) {
  184. this.regCity = detail
  185. },
  186. setArea (detail) {
  187. this.regDistrict = detail
  188. },
  189. setDetailAddress (detail) {
  190. this.regStreet = detail
  191. },
  192. setPopAddress (detail) {
  193. console.log('popAddress', detail)
  194. this.popAddress = detail
  195. },
  196. showAddress (info) {
  197. this.showChooseAddress = info
  198. },
  199. jump (type) {
  200. this.$emit('stepEvent', type)
  201. },
  202. // 弹窗处理
  203. downToast (type) {
  204. this.$toast({
  205. message: type,
  206. iconClass: 'el-icon-warning'
  207. })
  208. },
  209. // 验证手机号
  210. validateMobile () {
  211. if (!this.valid.mobile) {
  212. this.downToast('请先填写手机号')
  213. this.state.mobile = 'error'
  214. } else {
  215. let reg = /^1[0-9]{10}$/
  216. if (!reg.test(this.valid.mobile)) {
  217. this.downToast('请填写正确的手机号')
  218. this.state.mobile = 'warning'
  219. } else {
  220. this.state.mobile = 'success'
  221. }
  222. }
  223. },
  224. // 验证正确的验证码
  225. validateCode () {
  226. if (!this.valid.code) {
  227. this.downToast('请先填写验证码')
  228. this.state.code = 'error'
  229. } else {
  230. if (!this.valid.mobile) {
  231. this.downToast('请先填写正确的手机号码')
  232. this.state.code = 'warning'
  233. } else {
  234. if (this.tokenCode) {
  235. let param = new FormData()
  236. param.append('mobile', this.valid.mobile)
  237. param.append('token', this.tokenCode)
  238. param.append('code', this.valid.code)
  239. let config = {
  240. headers: {'Content-Type': 'multipart/form-data'}
  241. }
  242. this.$http.post('/appeal/check/mobile', param, config)
  243. .then(response => {
  244. if (response.data.success) {
  245. this.state.code = 'success'
  246. } else {
  247. this.$toast({
  248. message: response.data.errMsg,
  249. iconClass: 'el-icon-error'
  250. })
  251. return Promise.reject(response.data)
  252. }
  253. }).catch(() => {
  254. this.downToast('请检查网络是否正常或联系服务商')
  255. })
  256. } else {
  257. this.downToast('请点击先获取验证码信息')
  258. this.state.code = 'warning'
  259. }
  260. }
  261. }
  262. },
  263. // 获取验证码
  264. getCheckCode () {
  265. if (this.tokenTime > 0 && this.tokenTime < 60) {
  266. this.downToast('请稍后再点击,我在倒计时')
  267. } else {
  268. if (this.state.mobile === 'success') {
  269. this.$indicator.open('获取中...')
  270. let _this = this
  271. this.$http.get('/appeal/check/mobile', {params: {mobile: this.valid.mobile}})
  272. .then(response => {
  273. this.$indicator.close()
  274. if (response.data) {
  275. this.tokenCode = response.data.content.token
  276. this.$toast({
  277. message: '验证码已经发送到您的手机,请注意查收',
  278. iconClass: 'el-icon-success'
  279. })
  280. this.tokenText = '已发送(' + this.tokenTime + 'S)'
  281. let setTime = setInterval(() => {
  282. _this.tokenTime--
  283. this.tokenText = '已发送(' + this.tokenTime + 'S)'
  284. if (this.tokenTime <= 0) {
  285. clearInterval(setTime)
  286. _this.tokenText = '获取验证码'
  287. _this.tokenTime = 60
  288. }
  289. }, 1000)
  290. }
  291. }).catch(() => {
  292. this.$indicator.close()
  293. this.downToast('请检查网络是否正常或联系服务商')
  294. })
  295. }
  296. }
  297. },
  298. // 验证企业名称
  299. validateSpaceName () {
  300. if (!this.valid.spaceName) {
  301. this.downToast('请填写企业名称')
  302. this.state.spaceName = 'error'
  303. } else {
  304. if (this.valid.spaceName.length >= 20) {
  305. this.state.spaceName = 'warning'
  306. this.downToast('请填写合适的企业名称,20个字符以内')
  307. } else {
  308. this.$http.get(`/api/userspace/checkSpaceName`, {params: {spaceName: this.valid.spaceName}})
  309. .then(response => {
  310. if (response.data.success) {
  311. console.log('enterpriseName', response.data)
  312. this.state.spaceName = 'warning'
  313. this.downToast('企业不存在,请确认。')
  314. } else {
  315. this.state.spaceName = 'success'
  316. }
  317. }).catch(err => {
  318. this.$indicator.close()
  319. this.downToast(err.errMsg)
  320. })
  321. }
  322. }
  323. },
  324. // 验证营业执照号
  325. validateBusinessCode () {
  326. let reg = /^[A-Za-z0-9]+$/
  327. if (!this.valid.businessCode) {
  328. this.downToast('请填写营业执照号')
  329. this.state.businessCode = 'error'
  330. } else {
  331. if (this.valid.businessCode.length >= 20) {
  332. this.downToast('输入长度过长,20个字符以内')
  333. this.state.businessCode = 'warning'
  334. } else {
  335. if (reg.test(this.valid.businessCode)) {
  336. this.state.businessCode = 'success'
  337. } else {
  338. this.downToast('营业执照号只能填写字母和数字的组合')
  339. this.state.businessCode = 'error'
  340. }
  341. }
  342. }
  343. },
  344. // 验证法定代表人
  345. validateCorporation () {
  346. if (!this.valid.corporation) {
  347. this.downToast('请填写法定代表人')
  348. this.state.description = 'error'
  349. } else {
  350. if (this.valid.corporation.length >= 20) {
  351. this.downToast('输入长度过长,20个字符以内')
  352. this.state.corporation = 'warning'
  353. } else {
  354. this.state.corporation = 'success'
  355. }
  356. }
  357. },
  358. // 上传营业执照扫描件
  359. upload (e) {
  360. let file = e.target.files[0]
  361. if (file) {
  362. if (file.size > 5 * 1024 * 1024) {
  363. this.uploadFileChecked = false
  364. } else {
  365. this.$indicator.open('上传中...')
  366. let param = new FormData()
  367. param.append('image', file, file.name)
  368. let config = {
  369. headers: {'Content-Type': 'multipart/form-data'}
  370. }
  371. // 图片上传接口
  372. this.$http.post('/api/userspace/upload', param, config)
  373. .then(response => {
  374. this.$indicator.close()
  375. if (response.data.success) {
  376. let path = response.data.content
  377. if (path.slice(path.lastIndexOf('.')).toLowerCase() === '.pdf') {
  378. this.isPdf = true
  379. } else {
  380. this.isPdf = false
  381. }
  382. this.valid.businessCodeImage = response.data.content
  383. this.uploadFileChecked = true
  384. } else {
  385. this.uploadFileChecked = false
  386. return Promise.reject(response.data)
  387. }
  388. }).catch(err => {
  389. this.downToast(err.errMsg)
  390. this.uploadFileChecked = false
  391. })
  392. }
  393. } else {
  394. this.$indicator.close()
  395. }
  396. },
  397. // 申诉
  398. validateDescription () {
  399. if (!this.valid.description) {
  400. this.downToast('请填写申诉说明')
  401. this.state.description = 'error'
  402. } else {
  403. if (this.valid.description.length >= 100) {
  404. this.downToast('输入长度过长,100个字符以内')
  405. this.state.description = 'warning'
  406. } else {
  407. this.state.description = 'success'
  408. }
  409. }
  410. },
  411. // 验证姓名
  412. validateContactName () {
  413. if (!this.valid.contactName) {
  414. this.downToast('请填写您的姓名')
  415. this.state.contactName = 'error'
  416. } else {
  417. if (this.valid.contactName.length > 20) {
  418. this.downToast('输入长度过长,限定20个字符以内')
  419. this.state.contactName = 'warning'
  420. } else {
  421. this.state.contactName = 'success'
  422. }
  423. }
  424. },
  425. // 验证电话
  426. validateContactTel () {
  427. let reg = /^1[0-9]{10}$/
  428. if (!this.valid.contactTel) {
  429. this.downToast('请填写联系电话')
  430. this.state.contactTel = 'error'
  431. } else {
  432. if (!reg.test(this.valid.contactTel)) {
  433. this.downToast('请填写正确的联系电话')
  434. this.state.contactTel = 'warning'
  435. } else {
  436. this.state.contactTel = 'success'
  437. }
  438. }
  439. },
  440. // 验证邮箱
  441. validateContactEmail () {
  442. let reg = /^([\w-])+(\.\w+)*@([\w-])+((\.\w{2,3}){1,3})$/
  443. if (!this.valid.contactEmail) {
  444. this.downToast('请填写联系电子邮箱')
  445. this.state.contactEmail = 'error'
  446. } else {
  447. if (!reg.test(this.valid.contactEmail)) {
  448. this.downToast('请输入正确的邮箱地址格式')
  449. this.state.contactEmail = 'warning'
  450. } else {
  451. this.state.contactEmail = 'success'
  452. }
  453. }
  454. },
  455. sureAccount (type) {
  456. if (this.state.mobile !== 'success' ||
  457. this.state.code !== 'success' ||
  458. this.state.spaceName !== 'success' ||
  459. this.state.businessCode !== 'success' ||
  460. this.valid.businessCodeImage === '' ||
  461. this.regAddress === '' ||
  462. this.state.description !== 'success' ||
  463. this.state.contactName !== 'success' ||
  464. this.state.contactTel !== 'success' ||
  465. this.state.contactEmail !== 'success') {
  466. this.downToast('请确认填写部分是否有误')
  467. } else {
  468. this.$indicator.open('验证过程中...')
  469. let param = new FormData()
  470. param.append('mobile', this.valid.mobile)
  471. param.append('code', this.valid.code)
  472. param.append('spaceName', this.valid.spaceName)
  473. param.append('businessCode', this.valid.businessCode)
  474. param.append('businessCodeImage', this.valid.businessCodeImage)
  475. param.append('regAddress', this.regAddress)
  476. param.append('regProvince', this.regProvince)
  477. param.append('regCity', this.regCity)
  478. param.append('regDistrict', this.regDistrict)
  479. param.append('regStreet', this.regStreet)
  480. param.append('description', this.valid.description)
  481. param.append('contactName', this.valid.contactName)
  482. param.append('contactTel', this.valid.contactTel)
  483. param.append('contactEmail', this.valid.contactEmail)
  484. param.append('token', this.tokenCode)
  485. param.append('appId', this.$store.state.option.appId)
  486. let config = {
  487. headers: {'Content-Type': 'multipart/form-data'}
  488. }
  489. this.$http.post('/appeal/changeAdmin', param, config)
  490. .then(response => {
  491. this.$indicator.close()
  492. if (response.data.success) {
  493. this.$emit('stepEvent', type)
  494. this.$emit('lastEvent', 'appeal')
  495. } else {
  496. this.downToast(response.data.errMsg)
  497. }
  498. }).catch(() => {
  499. this.$indicator.close()
  500. this.downToast('请检查网络是否正常或联系服务商')
  501. })
  502. }
  503. }
  504. }
  505. }
  506. </script>