updateCertificates.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <view class="certificates">
  3. <!-- 自定义导航栏 -->
  4. <view class="custom-navbar" :style="{ paddingTop: (12 + statusBarHeight) + 'px' }">
  5. <view class="navbar-content">
  6. <view class="nav-left" @click="goBack">
  7. <u-icon name="close" color="#333" size="32"></u-icon>
  8. </view>
  9. <view class="nav-title">资质证书</view>
  10. <view class="nav-right"></view>
  11. </view>
  12. </view>
  13. <!-- 主要内容 -->
  14. <view class="main-content">
  15. <view class="tip">请您添加您的资质证书</view>
  16. <!-- 资质证书 -->
  17. <view class="skills-section">
  18. <view class="section-title">资质证书</view>
  19. <!-- 资质证书区域 -->
  20. <view class="custom-tags">
  21. <view v-for="(item, index) in certificates" :key="index" class="custom-tag"
  22. @click="removeCustomTag(index)">
  23. <text>{{ item }}</text>
  24. <u-icon name="close" color="#007AFF" size="18"></u-icon>
  25. </view>
  26. <view class="add-tag" @click="showAddCertificatesModal">
  27. <text>添加资质证书</text>
  28. <u-icon name="plus" color="#333" size="18"></u-icon>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 底部确定按钮 -->
  34. <view class="fixed-section">
  35. <u-button type="primary" class="submit-btn" @click="confirmSelection">保存</u-button>
  36. </view>
  37. <!-- 添加证书弹窗 -->
  38. <u-popup v-model="showAddCertificates" mode="center" border-radius="24" width="80%">
  39. <view class="add-tag-popup">
  40. <view class="popup-title">添加资质证书</view>
  41. <view class="popup-content">
  42. <input v-model="newCertificates" placeholder="请输入资质证书(不要带上, ; 这种字符)" class="tag-input" maxlength="10" />
  43. </view>
  44. <view class="popup-buttons">
  45. <view class="popup-btn cancel-btn" @click="cancelAdd">取消</view>
  46. <view class="popup-btn confirm-btn" @click="confirmAdd">确定</view>
  47. </view>
  48. </view>
  49. </u-popup>
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. statusBarHeight: 0, // 状态栏高度
  57. certificates: [],
  58. newCertificates: '',
  59. showAddCertificates: false,
  60. };
  61. },
  62. onLoad(options) {
  63. // 获取状态栏高度
  64. let systemInfo = uni.getSystemInfoSync();
  65. this.statusBarHeight = systemInfo.statusBarHeight || 0;
  66. // 设置资质证书回显
  67. if (options.certificates) {
  68. this.certificates = decodeURIComponent(options.certificates).split(';')
  69. }
  70. },
  71. methods: {
  72. goBack() {
  73. uni.navigateBack()
  74. },
  75. showAddCertificatesModal() {
  76. this.showAddCertificates = true
  77. this.newCertificates = ''
  78. },
  79. cancelAdd() {
  80. this.showAddCertificates = false
  81. this.newCertificates = ''
  82. },
  83. confirmAdd() {
  84. if (this.newCertificates.trim()) {
  85. let realLength = this.certificates.filter(item => item !== '不限').length;
  86. if (realLength < 10) {
  87. this.certificates.push(this.newCertificates.trim())
  88. this.showAddCertificates = false
  89. this.newCertificates = ''
  90. } else {
  91. uni.showToast({
  92. title: '最多添加10个资质证书',
  93. icon: 'none'
  94. })
  95. }
  96. } else {
  97. uni.showToast({
  98. title: '请输入资质证书',
  99. icon: 'none'
  100. })
  101. }
  102. },
  103. removeCustomTag(index) {
  104. this.certificates.splice(index, 1)
  105. },
  106. confirmSelection() {
  107. const certificates = this.certificates.map(certificate => {
  108. return {
  109. userId: '',
  110. certificateId: '',
  111. certificateName: certificate,
  112. isuse: 1
  113. }
  114. })
  115. uni.showLoading({ title: "保存中..." })
  116. this.$Request
  117. .postJson('/app/userFirst/updateCertificate', certificates)
  118. .then((res) => {
  119. if (res.code == 0) {
  120. uni.showToast({ title: '保存成功', icon: 'none' })
  121. // 实际开发中可以在这里添加跳转逻辑
  122. uni.$emit('updateResume')
  123. setTimeout(() => {
  124. uni.navigateBack()
  125. }, 1000)
  126. } else {
  127. uni.showToast({
  128. title: res.msg,
  129. icon: 'none',
  130. })
  131. }
  132. })
  133. .finally(() => {
  134. uni.hideLoading()
  135. })
  136. }
  137. }
  138. }
  139. </script>
  140. <style lang="scss" scoped>
  141. @import '@/common.scss';
  142. .certificates {
  143. height: 100vh;
  144. background: #fff;
  145. display: flex;
  146. flex-direction: column;
  147. padding: 0 40rpx 200rpx;
  148. }
  149. .navbar-content {
  150. display: flex;
  151. align-items: center;
  152. justify-content: space-between;
  153. height: 88rpx;
  154. }
  155. .nav-left,
  156. .nav-right {
  157. width: 60rpx;
  158. height: 60rpx;
  159. display: flex;
  160. align-items: center;
  161. justify-content: center;
  162. }
  163. .nav-title {
  164. color: rgba(51, 51, 51, 1);
  165. font-family: DM Sans;
  166. font-size: 36rpx;
  167. font-weight: 700;
  168. line-height: 26px;
  169. letter-spacing: 0px;
  170. text-align: center;
  171. }
  172. .main-content {
  173. margin-top: 20rpx;
  174. flex: 1;
  175. overflow: auto;
  176. .tip {
  177. padding: 72rpx 0 32rpx;
  178. color: #666;
  179. }
  180. }
  181. .skills-section {
  182. margin-bottom: 50rpx;
  183. }
  184. .section-title {
  185. color: rgba(34, 37, 42, 1);
  186. font-family: DM Sans;
  187. font-size: 36rpx;
  188. font-weight: 500;
  189. line-height: 24px;
  190. letter-spacing: 0px;
  191. text-align: left;
  192. margin-bottom: 24rpx;
  193. padding-left: 4rpx;
  194. }
  195. .skills-grid {
  196. display: flex;
  197. flex-wrap: wrap;
  198. gap: 20rpx;
  199. }
  200. .skill-tag {
  201. padding: 16rpx 24rpx;
  202. background: #F7F8FA;
  203. border: 1rpx solid #E5E5EA;
  204. border-radius: 16rpx;
  205. transition: all 0.2s ease;
  206. display: flex;
  207. align-items: center;
  208. justify-content: center;
  209. cursor: pointer;
  210. text {
  211. font-size: 26rpx;
  212. color: rgba(102, 102, 102, 1);
  213. font-weight: 400;
  214. text-align: center;
  215. line-height: 1.2;
  216. }
  217. &:hover {
  218. background: rgba(153, 196, 250, 0.2);
  219. border-color: rgba(1, 107, 246, 0.3);
  220. }
  221. &.active {
  222. background: rgba(1, 107, 246, 0.1);
  223. border: 1rpx solid rgba(1, 107, 246, 1);
  224. box-shadow: 0 4rpx 12rpx rgba(1, 107, 246, 0.15);
  225. text {
  226. color: rgba(1, 107, 246, 1);
  227. font-weight: 500;
  228. }
  229. }
  230. &:active {
  231. transform: scale(0.96);
  232. }
  233. }
  234. .custom-tags {
  235. display: flex;
  236. flex-wrap: wrap;
  237. gap: 20rpx;
  238. }
  239. .custom-tag {
  240. padding: 14rpx 20rpx;
  241. background: rgba(153, 196, 250, 0.4);
  242. border: 1rpx solid rgba(1, 107, 246, 1);
  243. border-radius: 16rpx;
  244. display: flex;
  245. align-items: center;
  246. gap: 10rpx;
  247. cursor: pointer;
  248. transition: all 0.2s ease;
  249. text {
  250. font-size: 24rpx;
  251. color: rgba(1, 107, 246, 1);
  252. font-weight: 400;
  253. }
  254. &:hover {
  255. background: rgba(153, 196, 250, 0.6);
  256. }
  257. &:active {
  258. transform: scale(0.96);
  259. }
  260. }
  261. .add-tag {
  262. padding: 14rpx 20rpx;
  263. background: #F7F8FA;
  264. border: 1rpx dashed #E5E5EA;
  265. border-radius: 16rpx;
  266. display: flex;
  267. align-items: center;
  268. gap: 10rpx;
  269. cursor: pointer;
  270. transition: all 0.2s ease;
  271. text {
  272. font-size: 24rpx;
  273. color: rgba(102, 102, 102, 1);
  274. font-weight: 400;
  275. }
  276. &:hover {
  277. background: #f0f0f0;
  278. border-color: #d9d9d9;
  279. }
  280. &:active {
  281. transform: scale(0.96);
  282. }
  283. }
  284. // 添加标签弹窗样式
  285. .add-tag-popup {
  286. background: #fff;
  287. border-radius: 24rpx;
  288. padding: 48rpx 40rpx;
  289. width: 100%;
  290. .popup-title {
  291. color: rgba(34, 37, 42, 1);
  292. font-family: DM Sans;
  293. font-size: 36rpx;
  294. font-weight: 500;
  295. line-height: 24px;
  296. text-align: center;
  297. margin-bottom: 36rpx;
  298. }
  299. .popup-content {
  300. margin-bottom: 40rpx;
  301. .tag-input {
  302. width: 100%;
  303. height: 90rpx;
  304. padding: 0 24rpx;
  305. border: 1rpx solid #E5E5EA;
  306. border-radius: 16rpx;
  307. font-size: 28rpx;
  308. color: rgba(34, 37, 42, 1);
  309. background: #F7F8FA;
  310. box-sizing: border-box;
  311. }
  312. .tag-input::placeholder {
  313. color: #C9CDD4;
  314. }
  315. }
  316. .popup-buttons {
  317. display: flex;
  318. gap: 24rpx;
  319. .popup-btn {
  320. flex: 1;
  321. height: 88rpx;
  322. border-radius: 16rpx;
  323. display: flex;
  324. align-items: center;
  325. justify-content: center;
  326. font-size: 30rpx;
  327. font-weight: 500;
  328. transition: all 0.2s ease;
  329. cursor: pointer;
  330. }
  331. .cancel-btn {
  332. background: #F7F8FA;
  333. color: rgba(102, 102, 102, 1);
  334. &:active {
  335. background: #eaeaea;
  336. }
  337. }
  338. .confirm-btn {
  339. background: #007AFF;
  340. color: #fff;
  341. &:active {
  342. background: #0056CC;
  343. }
  344. }
  345. }
  346. }
  347. </style>