index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <div :class="mobile ? 'companyCompleteMobile' : 'companyComplete'">
  3. <div class="titleArea">
  4. <p class="title">创建企业信息</p>
  5. <p class="smallTitle">
  6. 入驻解决方案,您只需两步
  7. </p>
  8. </div>
  9. <div class="bodyArea">
  10. <div class="selectList">
  11. <div class="topSteps">
  12. <div class="cell" :class="{ok: true}">
  13. <p class="number">1</p>
  14. <p class="word">创建企业信息</p>
  15. </div>
  16. <div class="line"></div>
  17. <div class="cell">
  18. <p class="number">2</p>
  19. <p class="word">新建解决方案</p>
  20. </div>
  21. <div class="line"></div>
  22. <div class="cell">
  23. <p class="number">3</p>
  24. <p class="word">完成</p>
  25. </div>
  26. </div>
  27. <div class="uploadFile">
  28. <p class="name">LOGO</p>
  29. <div class="uploadArea">
  30. <el-upload
  31. v-loading="uploading"
  32. class="avatar-uploader"
  33. action="#"
  34. :show-file-list="false"
  35. :multiple="false"
  36. accept="image/png, image/jpeg"
  37. :before-upload="handleFileChange"
  38. >
  39. <i v-if="imageUrl" class="el-icon-delete avatar-uploader-icon" @click.stop="handleDeleteFile"></i>
  40. <img v-if="imageUrl" :src="imageUrl" class="avatar"/>
  41. <div v-else class="noneImage">
  42. <i class="el-icon-plus avatar-uploader-icon"></i>
  43. </div>
  44. </el-upload>
  45. <p class="tipps">
  46. (图片大小最大2M)
  47. </p>
  48. </div>
  49. </div>
  50. <div class="inputArea">
  51. <div class="inputBox" v-for="item in inputList" :key="item.name">
  52. <p class="name">{{item.title}}</p>
  53. <input type="text" placeholder="请输入" v-model="item.value" v-if="item.type==='text'"/>
  54. <textarea placeholder="请输入" v-model="item.value" v-if="item.type==='textarea'" cols="50" rows="10"/>
  55. </div>
  56. </div>
  57. </div>
  58. <div class="submitButton">
  59. <div class="left"></div>
  60. <div class="right" @click="submitForm">
  61. <p>保存, 去新建解决方案</p>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. </template>
  67. <script>
  68. export default {
  69. name: 'companyComplete',
  70. data() {
  71. return {
  72. typeList: [],
  73. inputList: [
  74. { name: 'name', title: '公司全称', value: '', type: "text" },
  75. { name: 'short_name', title: '公司简称', value: '', type: "text" },
  76. { name: 'website', title: '公司链接', value: '', type: "text" },
  77. { name: 'description', title: '公司简介', value: '', type: "textarea"},
  78. ],
  79. imageUrl: '',
  80. dataInfo: {},
  81. uploading: false,
  82. loadingStatus: null,
  83. getTimes: 30
  84. }
  85. },
  86. asyncData({ app }) {
  87. return {
  88. mobile: app.$deviceType.isMobile(),
  89. }
  90. },
  91. async created() {
  92. },
  93. async mounted() {
  94. await this.needLogin()
  95. this.getInfo()
  96. },
  97. methods: {
  98. /** 获取展示状态 */
  99. getInfo(isRefresh=false) {
  100. this.$axios.post('/api/kaifawu/get_current_step').then(res => {
  101. if (res.data.status === 1) {
  102. this.dataInfo = res.data.data.com_info || {}
  103. // status: "0" 未认证 1认证中 2已成功 3被拒绝
  104. this.inputList.forEach(item => {
  105. let value = this.dataInfo[ item.name ]
  106. if (value) {
  107. item.value = value
  108. }
  109. })
  110. const {step} = this.dataInfo
  111. if (step === 2) {
  112. location.href = "/kaifain/add"
  113. } else if (step === 1) {
  114. }
  115. this.inputList = [ ...this.inputList ]
  116. this.imageUrl = this.dataInfo.logo || ''
  117. console.log('ist', this.inputList)
  118. }
  119. }).finally(()=>{
  120. this.loadingStatus && this.loadingStatus.close()
  121. })
  122. },
  123. /** 提交 **/
  124. submitForm() {
  125. let p = {}
  126. if (this.dataInfo.id) {
  127. p = this.dataInfo
  128. }
  129. this.inputList.forEach(item => {
  130. p[ item.name ] = item.value
  131. })
  132. p.logo = this.imageUrl
  133. if (!p.name) {
  134. this.$message.warning('请输入公司全称');
  135. return;
  136. }
  137. if (!p.short_name) {
  138. this.$message.warning('请输入公司简称');
  139. return;
  140. }
  141. if (!p.website) {
  142. this.$message.warning('请输入公司链接');
  143. return;
  144. }
  145. if (!p.description) {
  146. this.$message.warning('请输入公司简介');
  147. return;
  148. }
  149. if (!p.logo) {
  150. this.$message.warning('请上传logo图片');
  151. return;
  152. }
  153. this.$axios.post('/api/company_info/update_info', p).then(res => {
  154. let data = res.data
  155. if (data.status === 1) {
  156. this.$message.success('您已提交企业信息')
  157. setTimeout(() => {
  158. // if (this.$deviceType.app) {
  159. // history.back()
  160. // } else {
  161. location.href = '/kaifain/add'
  162. // }
  163. }, 1000)
  164. } else {
  165. this.$message.error('提交失败')
  166. }
  167. }).catch(e => {
  168. console.log(e)
  169. this.$message.error('提交失败')
  170. })
  171. },
  172. handleFileChange(file) {
  173. const isLt2M = file.size / 1024 / 1024 < 2;
  174. if (!isLt2M) {
  175. this.$message.error('上传图片大小不能超过 2MB!');
  176. return
  177. }
  178. const formData = new FormData();
  179. formData.append("file", file);
  180. formData.append("original_filename", file.name);
  181. this.uploading = true;
  182. this.$axios
  183. .$post(`/upload_image`, formData, {
  184. headers: { "Content-Type": "multipart/form-data" }
  185. })
  186. .then(res => {
  187. console.log(res)
  188. this.imageUrl = res.filename
  189. }).catch((e)=>{
  190. this.$message.error("上传失败:" + e.message)
  191. })
  192. .finally(() => {
  193. this.uploading = false;
  194. });
  195. },
  196. handleDeleteFile() {
  197. this.imageUrl = ''
  198. },
  199. },
  200. }
  201. </script>
  202. <style lang="scss" scoped>
  203. @import '../../../assets/css/otherpage/companyComplete.scss';
  204. </style>
  205. <style lang="scss">
  206. @import '../../../assets/css/scssCommon.scss';
  207. .el-upload {
  208. width: 80px;
  209. height: 80px;
  210. border: 1px dashed #409eff;
  211. border-radius: 6px;
  212. cursor: pointer;
  213. position: relative;
  214. overflow: hidden;
  215. img {
  216. width: 100%;
  217. height: auto;
  218. object-fit: contain;
  219. object-position: top left;
  220. }
  221. &:hover {
  222. border-color: #409eff;
  223. .el-icon-delete {
  224. display: block;
  225. }
  226. }
  227. }
  228. .companyCompleteMobile {
  229. .el-upload {
  230. width: pxtovw(80);
  231. height: pxtovw(80);
  232. border: pxtovw(1) dashed #409eff;
  233. border-radius: pxtovw(6);
  234. }
  235. }
  236. </style>