stepOne.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <div>
  3. <template v-if="!showChooseAddress">
  4. <div class="f-main">
  5. <div class="content-top">
  6. <p>企业认证</p>
  7. </div>
  8. <div class="f-form">
  9. <div class="page-part">
  10. <mt-field placeholder="企业名称"
  11. v-model="valid.spaceName"
  12. :state="state.spaceName"
  13. @blur.native.capture="validateSpaceName"
  14. ></mt-field>
  15. </div>
  16. <div class="page-part">
  17. <mt-field placeholder="营业执照号"
  18. v-model="valid.businessCode"
  19. auto-complete="off"
  20. :state="state.businessCode"
  21. @blur.native.capture="validateBusinessCode"
  22. ></mt-field>
  23. </div>
  24. <div class="page-part">
  25. <a class="phone-btn-blank" title="上传营业执照扫描件" v-bind:class="{isEmpty: valid.businessCodeImage}">
  26. <i class="fa fa-picture-o fa-p"></i>
  27. <span class="upload">上传营业执照扫描件</span>
  28. <input type="file"
  29. class="form-control file-input"
  30. name="name"
  31. accept="image/jpeg,image/jpg,image/gif,image/bmp,image/png,.pdf"
  32. @change="upload"/>
  33. </a>
  34. <a class="thumbnail" v-if="valid.businessCodeImage !== ''"><img class="previewImg" alt="" :src="isPdf ? '/images/all/timg.png' : valid.businessCodeImage"></a>
  35. </div>
  36. <div class="page-part">
  37. <mt-field placeholder="法定代表人"
  38. v-model="valid.corporation"
  39. auto-complete="off"
  40. :state="state.corporation"
  41. @blur.native.capture="validateCorporation"
  42. ></mt-field>
  43. </div>
  44. <div class="page-part" style="position: relative">
  45. <!--// 注册地址-->
  46. <mt-field readonly aria-haspopup="true" aria-expanded="false"
  47. placeholder="注册地址"
  48. v-model="regAddress"
  49. @click.native="chooseAddress"></mt-field>
  50. <i class="fa fa-map-marker fa-p" v-show="regAddress.length === 0"></i>
  51. </div>
  52. <div class="form-btn">
  53. <div class="page-part">
  54. <el-checkbox v-model="checked">我已阅读并同意 <a href="/common/agreement" class="rgba">《优软云服务条款》</a></el-checkbox>
  55. </div>
  56. <mt-button size="large" type="primary" @click="sureAccount('await')">提 交</mt-button>
  57. </div>
  58. </div>
  59. </div>
  60. </template>
  61. <template v-else>
  62. <address-choose
  63. @getAddress="setAddress"
  64. @getProvince="setProvince"
  65. @getCity="setCity"
  66. @getArea="setArea"
  67. @getDetailAddress="setDetailAddress"
  68. @getPopAddress="setPopAddress"
  69. @showEvent="showAddress"
  70. :popAddress="popAddress"
  71. :regStreet="regStreet"
  72. :regProvince="regProvince"
  73. :regCity="regCity"
  74. :regDistrict="regDistrict"/>
  75. </template>
  76. </div>
  77. </template>
  78. <script>
  79. import addressChoose from '~components/mobile/enterpriseCertification/addressChoose.vue'
  80. export default {
  81. name: 'step-one',
  82. data () {
  83. return {
  84. uploadFileChecked: false,
  85. isPdf: false,
  86. showChooseAddress: false,
  87. checked: true,
  88. state: {
  89. spaceName: 'error',
  90. businessCode: 'error',
  91. corporation: 'error'
  92. },
  93. valid: {
  94. spaceName: '',
  95. businessCode: '',
  96. businessCodeImage: '',
  97. corporation: ''
  98. },
  99. regAddress: '',
  100. regProvince: '',
  101. regCity: '',
  102. regDistrict: '',
  103. popAddress: '',
  104. regStreet: ''
  105. }
  106. },
  107. components: {
  108. addressChoose
  109. },
  110. methods: {
  111. // 弹窗处理
  112. downToast (type) {
  113. this.$toast({
  114. message: type,
  115. iconClass: 'el-icon-warning'
  116. })
  117. },
  118. // 获取地址
  119. chooseAddress () {
  120. this.showChooseAddress = true
  121. },
  122. setAddress (detail) {
  123. this.regAddress = detail
  124. },
  125. setProvince (detail) {
  126. this.regProvince = detail
  127. },
  128. setCity (detail) {
  129. this.regCity = detail
  130. },
  131. setArea (detail) {
  132. this.regDistrict = detail
  133. },
  134. setDetailAddress (detail) {
  135. this.regStreet = detail
  136. },
  137. setPopAddress (detail) {
  138. this.popAddress = detail
  139. },
  140. showAddress (info) {
  141. this.showChooseAddress = info
  142. },
  143. // 验证企业名称
  144. validateSpaceName () {
  145. if (!this.valid.spaceName) {
  146. this.downToast('请填写企业名称')
  147. this.state.spaceName = 'error'
  148. } else {
  149. if (this.valid.spaceName.length >= 20) {
  150. this.state.spaceName = 'warning'
  151. this.downToast('请填写合适的企业名称,20个字符以内')
  152. } else {
  153. this.$http.get(`/api/userspace/name/valid`, {params: {spaceName: this.valid.spaceName}})
  154. .then(response => {
  155. if (response.data.content.isValid) {
  156. this.state.spaceName = 'warning'
  157. this.downToast('该企业已被认证,请确认。')
  158. } else {
  159. this.state.spaceName = 'success'
  160. }
  161. }).catch(err => {
  162. this.downToast(err.errMsg)
  163. })
  164. }
  165. }
  166. },
  167. // 验证营业执照号
  168. validateBusinessCode () {
  169. let reg = /^[A-Za-z0-9]+$/
  170. if (!this.valid.businessCode) {
  171. this.downToast('请填写营业执照号')
  172. this.state.businessCode = 'error'
  173. } else {
  174. if (this.valid.businessCode.length >= 20) {
  175. this.downToast('输入长度过长,20个字符以内')
  176. this.state.businessCode = 'warning'
  177. } else {
  178. if (reg.test(this.valid.businessCode)) {
  179. this.$http.get(`/api/userspace/businessCode/valid`, {params: {businessCode: this.valid.businessCode}})
  180. .then(response => {
  181. if (!response.data.content.isValid) {
  182. this.state.businessCode = 'success'
  183. } else {
  184. this.state.businessCode = 'warning'
  185. this.downToast('该企业已被认证,请确认')
  186. }
  187. }).catch(err => {
  188. this.$message.error(err.errMsg)
  189. })
  190. } else {
  191. this.downToast('营业执照号只能填写字母和数字的组合')
  192. this.state.businessCode = 'error'
  193. }
  194. }
  195. }
  196. },
  197. // 验证法定代表人
  198. validateCorporation () {
  199. if (!this.valid.corporation) {
  200. this.downToast('请填写法定代表人')
  201. this.state.description = 'error'
  202. } else {
  203. if (this.valid.corporation.length >= 20) {
  204. this.downToast('输入长度过长,20个字符以内')
  205. this.state.corporation = 'warning'
  206. } else {
  207. this.state.corporation = 'success'
  208. }
  209. }
  210. },
  211. // 上传营业执照扫描件
  212. upload (e) {
  213. let file = e.target.files[0]
  214. if (file) {
  215. if (file.size > 5 * 1024 * 1024) {
  216. this.uploadFileChecked = false
  217. this.downToast('文件大小不能超过5M')
  218. } else {
  219. this.$indicator.open('上传中...')
  220. let param = new FormData()
  221. param.append('image', file, file.name)
  222. let config = {
  223. headers: {'Content-Type': 'multipart/form-data'}
  224. }
  225. // 图片上传接口
  226. this.$http.post('/api/userspace/upload', param, config)
  227. .then(response => {
  228. this.$indicator.close()
  229. if (response.data.success) {
  230. let path = response.data.content
  231. if (path.slice(path.lastIndexOf('.')).toLowerCase() === '.pdf') {
  232. this.isPdf = true
  233. } else {
  234. this.isPdf = false
  235. }
  236. this.valid.businessCodeImage = response.data.content
  237. this.uploadFileChecked = true
  238. } else {
  239. this.uploadFileChecked = false
  240. return Promise.reject(response.data)
  241. }
  242. }).catch(err => {
  243. this.downToast(err.errMsg)
  244. this.uploadFileChecked = false
  245. })
  246. }
  247. } else {
  248. this.$indicator.close()
  249. }
  250. },
  251. sureAccount (type) {
  252. if (this.state.spaceName !== 'success' ||
  253. this.state.businessCode !== 'success' ||
  254. this.state.corporation !== 'success' ||
  255. this.valid.businessCodeImage === '' ||
  256. this.regAddress === '') {
  257. this.downToast('请确认填写部分是否有误')
  258. } else {
  259. if (!this.checked) {
  260. this.downToast('您对阅读条款未做勾选')
  261. } else {
  262. this.$indicator.open('验证过程中...')
  263. let param = new FormData()
  264. param.append('spaceName', this.valid.spaceName)
  265. param.append('businessCode', this.valid.businessCode)
  266. param.append('corporation', this.valid.corporation)
  267. param.append('businessCodeImage', this.valid.businessCodeImage)
  268. param.append('regAddress', this.regAddress)
  269. param.append('regProvince', this.regProvince)
  270. param.append('regCity', this.regCity)
  271. param.append('regDistrict', this.regDistrict)
  272. param.append('regStreet', this.regStreet)
  273. let config = {
  274. headers: {'Content-Type': 'multipart/form-data'}
  275. }
  276. this.$http.post('/valid/userspace/submit', param, config)
  277. .then(response => {
  278. this.$indicator.close()
  279. if (response.data.success) {
  280. this.$emit('stepEvent', type)
  281. } else {
  282. this.downToast(response.data.errMsg)
  283. }
  284. }).catch(() => {
  285. this.$indicator.close()
  286. this.downToast('请检查网络是否正常或联系服务商')
  287. })
  288. }
  289. }
  290. }
  291. }
  292. }
  293. </script>