mainWorkIntro.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. <template>
  2. <view class="switch-roles">
  3. <nav-bar title="公司信息" color="#000"></nav-bar>
  4. <view class="roles-content">
  5. <view class="content">
  6. <view class="progress-num"> <text>8</text>/8 </view>
  7. <view class="title">
  8. <view>主营业务介绍</view>
  9. </view>
  10. <view class="desc">
  11. 介绍公司主营业务及旗下的产品信息,可有效提升求职者对公司及品牌的认知
  12. </view>
  13. <view class="content-index">
  14. <view class="content-item">
  15. <view class="content-item-title">主营产品</view>
  16. <view class="check-box">
  17. <view class="check-item" :class="{ 'check-active': selectedProducts.includes(item) }"
  18. v-for="(item, index) in productList" :key="index" @click="toggleProduct(item)">
  19. {{ item }}</view>
  20. </view>
  21. </view>
  22. <view class="content-item">
  23. <view class="content-item-title">自定义</view>
  24. <!-- 自定义标签显示区域 -->
  25. <view class="custom-tags-box">
  26. <view class="check-item custom-tag"
  27. :class="{ 'check-active': selectedCustomTags.includes(tag) }"
  28. v-for="(tag, index) in customTags" :key="'custom-' + index"
  29. @click="toggleCustomTag(tag)">
  30. {{ tag }}
  31. <text class="delete-tag" @click.stop="deleteCustomTag(index)">×</text>
  32. </view>
  33. <!-- 添加按钮 -->
  34. <view class="add-tag-btn" @click="showAddDialog">
  35. <text class="add-text">添加</text>
  36. <image class="add-icon" src="@/static/images/my/my/add.svg" mode="aspectFix" />
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="submit-btn" @click="goJobPostingSecond">下一步</view>
  44. <!-- 添加标签弹框 -->
  45. <u-modal v-model="showDialog" :show-cancel-button="true" confirm-text="确定" cancel-text="取消" title="添加标签"
  46. @confirm="confirmAddTag" @cancel="cancelAddTag">
  47. <view class="dialog-content">
  48. <u-input v-model="tempTag" type="text" :border="true" :clearable="true" input-align="left"
  49. placeholder="请输入标签内容" maxlength="20" @confirm="confirmAddTag" />
  50. <view class="input-tips">最多输入20个字符</view>
  51. </view>
  52. </u-modal>
  53. </view>
  54. </template>
  55. <script>
  56. import navBar from "@/components/nav-bar/index.vue";
  57. export default {
  58. data() {
  59. return {
  60. // 主营产品列表
  61. productList: [
  62. "3C数码",
  63. "美妆日化",
  64. "智能家居",
  65. "宠物相机",
  66. "监控摄像头",
  67. "家装产品",
  68. "耗材",
  69. "装修材料",
  70. "卫浴产品",
  71. ],
  72. // 选中的产品
  73. selectedProducts: [],
  74. // 自定义标签列表
  75. customTags: [],
  76. // 选中的自定义标签
  77. selectedCustomTags: [],
  78. // 弹框显示控制
  79. showDialog: false,
  80. // 临时标签输入
  81. tempTag: ""
  82. };
  83. },
  84. components: {
  85. navBar,
  86. },
  87. onLoad(options) {
  88. this.loadSavedCompanyScope();
  89. },
  90. methods: {
  91. // 加载已保存的业务范围数据(从缓存)
  92. loadSavedCompanyScope() {
  93. try {
  94. let companyInfo = uni.getStorageSync('companyInfo');
  95. console.log('从缓存获取的公司信息:', companyInfo);
  96. if (companyInfo?.companyScope) {
  97. this.processCompanyScope(companyInfo.companyScope);
  98. console.log('已加载保存的业务范围数据');
  99. } else {
  100. console.log('缓存中没有业务范围数据');
  101. }
  102. } catch (error) {
  103. console.error('加载业务范围数据失败:', error);
  104. }
  105. },
  106. // 处理业务范围数据
  107. processCompanyScope(scopeString) {
  108. if (!scopeString) return;
  109. // 处理字符串:替换中文逗号,分割,过滤空值
  110. const scopeItems = scopeString
  111. .replace(/,/g, ',')
  112. .split(',')
  113. .map(item => item.trim())
  114. .filter(item => item);
  115. console.log('解析后的业务范围:', scopeItems);
  116. // 清空当前选择
  117. this.selectedProducts = [];
  118. this.customTags = [];
  119. this.selectedCustomTags = [];
  120. // 分离标准产品和自定义标签
  121. scopeItems.forEach(item => {
  122. if (this.productList.includes(item)) {
  123. // 是标准产品
  124. this.selectedProducts.push(item);
  125. } else {
  126. // 是自定义标签
  127. this.customTags.push(item);
  128. this.selectedCustomTags.push(item); // 自定义标签默认都是选中的
  129. }
  130. });
  131. },
  132. // 切换产品选择
  133. toggleProduct(product) {
  134. const index = this.selectedProducts.indexOf(product);
  135. if (index > -1) {
  136. this.selectedProducts.splice(index, 1);
  137. } else {
  138. this.selectedProducts.push(product);
  139. }
  140. },
  141. // 显示添加标签弹框
  142. showAddDialog() {
  143. this.tempTag = "";
  144. this.showDialog = true;
  145. },
  146. // 确认添加标签
  147. confirmAddTag() {
  148. if (this.tempTag.trim() === "") {
  149. uni.showToast({
  150. title: "请输入标签内容",
  151. icon: "none",
  152. });
  153. return;
  154. }
  155. if (this.customTags.includes(this.tempTag.trim())) {
  156. uni.showToast({
  157. title: "标签已存在",
  158. icon: "none",
  159. });
  160. return;
  161. }
  162. // 检查是否与标准产品重复
  163. if (this.productList.includes(this.tempTag.trim())) {
  164. uni.showToast({
  165. title: "该标签已存在于主营产品列表中",
  166. icon: "none",
  167. });
  168. return;
  169. }
  170. const newTag = this.tempTag.trim();
  171. this.customTags.push(newTag);
  172. this.selectedCustomTags.push(newTag); // 新增的自定义标签默认选中
  173. this.showDialog = false;
  174. this.tempTag = "";
  175. },
  176. // 取消添加标签
  177. cancelAddTag() {
  178. this.showDialog = false;
  179. this.tempTag = "";
  180. },
  181. // 切换自定义标签选择
  182. toggleCustomTag(tag) {
  183. const index = this.selectedCustomTags.indexOf(tag);
  184. if (index > -1) {
  185. this.selectedCustomTags.splice(index, 1);
  186. } else {
  187. this.selectedCustomTags.push(tag);
  188. }
  189. },
  190. // 删除自定义标签
  191. deleteCustomTag(index) {
  192. const tag = this.customTags[index];
  193. // 如果这个标签被选中了,先从选中列表中移除
  194. const selectedIndex = this.selectedCustomTags.indexOf(tag);
  195. if (selectedIndex > -1) {
  196. this.selectedCustomTags.splice(selectedIndex, 1);
  197. }
  198. // 删除标签
  199. this.customTags.splice(index, 1);
  200. },
  201. goJobPostingSecond() {
  202. // 获取所有选中的标签
  203. const allSelectedTags = [...this.selectedProducts, ...this.selectedCustomTags];
  204. if (allSelectedTags.length === 0) {
  205. uni.showToast({
  206. title: "请至少选择一个业务标签",
  207. icon: "none",
  208. });
  209. return;
  210. }
  211. console.log("选中的业务标签:", allSelectedTags);
  212. let companyData = {
  213. companyId: this.$queue.getData('companyId'),
  214. companyScope: allSelectedTags.join(',')
  215. }
  216. this.$Request.postJson('/app/company/updateCompany', companyData).then(res => {
  217. if (res.code == 0) {
  218. uni.showToast({
  219. title: '提交成功',
  220. duration: 1500,
  221. });
  222. setTimeout(() => {
  223. uni.switchTab({
  224. url: '/pages/my/index'
  225. });
  226. }, 500)
  227. }
  228. })
  229. },
  230. },
  231. };
  232. </script>
  233. <style lang="scss" scoped>
  234. .switch-roles {
  235. background-color: #fff;
  236. position: absolute;
  237. left: 0;
  238. right: 0;
  239. top: 0;
  240. bottom: 0;
  241. display: flex;
  242. flex-direction: column;
  243. .roles-content {
  244. width: 100%;
  245. flex: 1;
  246. overflow: hidden;
  247. overflow-y: auto;
  248. .content {
  249. padding: 40rpx;
  250. box-sizing: border-box;
  251. display: flex;
  252. flex-direction: column;
  253. align-items: center;
  254. justify-content: center;
  255. .progress-num {
  256. color: #016bf6;
  257. font-family: DM Sans;
  258. font-size: 24rpx;
  259. font-weight: 500;
  260. width: 100%;
  261. padding-bottom: 20rpx;
  262. box-sizing: border-box;
  263. text {
  264. font-size: 48rpx;
  265. font-weight: 700;
  266. }
  267. }
  268. .title {
  269. color: #333;
  270. width: 100%;
  271. font-family: DM Sans;
  272. font-size: 48rpx;
  273. font-weight: 700;
  274. display: flex;
  275. justify-content: space-between;
  276. align-items: center;
  277. margin-bottom: 20rpx;
  278. }
  279. .desc {
  280. color: rgba(102, 102, 102, 1);
  281. width: 100%;
  282. font-family: DM Sans;
  283. font-size: 24rpx;
  284. font-weight: 400;
  285. line-height: 32rpx;
  286. letter-spacing: 0.5%;
  287. text-align: left;
  288. padding: 20rpx 0;
  289. box-sizing: border-box;
  290. margin-bottom: 20rpx;
  291. }
  292. .content-index {
  293. width: 100%;
  294. .content-item {
  295. margin-bottom: 40rpx;
  296. .content-item-title {
  297. color: rgba(34, 37, 42, 1);
  298. font-family: DM Sans;
  299. font-size: 32rpx;
  300. font-weight: 400;
  301. line-height: 48rpx;
  302. padding-bottom: 12rpx;
  303. box-sizing: border-box;
  304. }
  305. .check-box {
  306. display: flex;
  307. gap: 12rpx;
  308. flex-wrap: wrap;
  309. align-items: center;
  310. }
  311. // 自定义标签区域
  312. .custom-tags-box {
  313. display: flex;
  314. gap: 12rpx;
  315. flex-wrap: wrap;
  316. align-items: center;
  317. .custom-tag {
  318. position: relative;
  319. padding-right: 30rpx;
  320. .delete-tag {
  321. position: absolute;
  322. right: 8rpx;
  323. top: 50%;
  324. transform: translateY(-50%);
  325. font-size: 18rpx;
  326. color: #999;
  327. width: 20rpx;
  328. height: 20rpx;
  329. display: flex;
  330. align-items: center;
  331. justify-content: center;
  332. }
  333. }
  334. .add-tag-btn {
  335. flex-shrink: 0;
  336. padding: 8rpx 16rpx;
  337. border-radius: 8rpx;
  338. background: #9999991a;
  339. border: 1rpx solid #9999991a;
  340. box-sizing: border-box;
  341. color: rgba(102, 102, 102, 1);
  342. font-family: DM Sans;
  343. font-size: 16rpx;
  344. font-weight: 400;
  345. display: flex;
  346. align-items: center;
  347. gap: 4rpx;
  348. .add-text {
  349. color: #016bf6;
  350. }
  351. .add-icon {
  352. width: 16rpx;
  353. height: 16rpx;
  354. }
  355. }
  356. }
  357. }
  358. }
  359. .check-item {
  360. flex-shrink: 0;
  361. padding: 8rpx 16rpx;
  362. border-radius: 8rpx;
  363. background: #9999991a;
  364. border: 1rpx solid #9999991a;
  365. box-sizing: border-box;
  366. color: rgba(102, 102, 102, 1);
  367. font-family: DM Sans;
  368. font-size: 16rpx;
  369. font-weight: 400;
  370. }
  371. .check-active {
  372. box-sizing: border-box;
  373. border: 1rpx solid #016bf6;
  374. border-radius: 8rpx;
  375. background: rgba(252, 233, 220, 1);
  376. color: #016bf6;
  377. }
  378. }
  379. }
  380. .submit-btn {
  381. flex-shrink: 0;
  382. border-radius: 999px;
  383. background: #ff6600;
  384. color: rgba(255, 255, 255, 1);
  385. font-family: DM Sans;
  386. font-size: 32rpx;
  387. font-weight: 400;
  388. line-height: 48rpx;
  389. display: flex;
  390. justify-content: center;
  391. align-items: center;
  392. padding: 24rpx 32rpx;
  393. box-sizing: border-box;
  394. margin: 30rpx 40rpx;
  395. margin-top: 20rpx;
  396. }
  397. }
  398. // 弹框内容样式
  399. .dialog-content {
  400. padding: 40rpx;
  401. box-sizing: border-box;
  402. .input-tips {
  403. color: #999;
  404. font-size: 24rpx;
  405. text-align: right;
  406. margin-top: 10rpx;
  407. }
  408. }
  409. // 输入框placeholder样式
  410. .input-placeholder {
  411. color: rgba(153, 153, 153, 1);
  412. font-family: DM Sans;
  413. font-size: 16rpx;
  414. font-weight: 400;
  415. }
  416. </style>