StepAppeal.vue 18 KB

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