updateCertificates.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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. confirmSelection() {
  104. const certificates = this.certificates.map(certificate => {
  105. return {
  106. userId: '',
  107. certificateId: '',
  108. certificateName: certificate,
  109. isuse: 1
  110. }
  111. })
  112. uni.showLoading({ title: "保存中..." })
  113. this.$Request
  114. .postJson('/app/userFirst/updateCertificate', certificates)
  115. .then((res) => {
  116. if (res.code == 0) {
  117. uni.showToast({ title: '保存成功', icon: 'none' })
  118. // 实际开发中可以在这里添加跳转逻辑
  119. uni.$emit('updateResume')
  120. setTimeout(() => {
  121. uni.navigateBack()
  122. }, 1000)
  123. } else {
  124. uni.showToast({
  125. title: res.msg,
  126. icon: 'none',
  127. })
  128. }
  129. })
  130. .finally(() => {
  131. uni.hideLoading()
  132. })
  133. }
  134. }
  135. }
  136. </script>
  137. <style lang="scss" scoped>
  138. @import '@/common.scss';
  139. .certificates {
  140. height: 100vh;
  141. background: #fff;
  142. display: flex;
  143. flex-direction: column;
  144. padding: 0 40rpx 200rpx;
  145. }
  146. .navbar-content {
  147. display: flex;
  148. align-items: center;
  149. justify-content: space-between;
  150. height: 88rpx;
  151. }
  152. .nav-left,
  153. .nav-right {
  154. width: 60rpx;
  155. height: 60rpx;
  156. display: flex;
  157. align-items: center;
  158. justify-content: center;
  159. }
  160. .nav-title {
  161. color: rgba(51, 51, 51, 1);
  162. font-family: DM Sans;
  163. font-size: 36rpx;
  164. font-weight: 700;
  165. line-height: 26px;
  166. letter-spacing: 0px;
  167. text-align: center;
  168. }
  169. .main-content {
  170. margin-top: 20rpx;
  171. flex: 1;
  172. overflow: auto;
  173. .tip {
  174. padding: 72rpx 0 32rpx;
  175. color: #666;
  176. }
  177. }
  178. .skills-section {
  179. margin-bottom: 50rpx;
  180. }
  181. .section-title {
  182. color: rgba(34, 37, 42, 1);
  183. font-family: DM Sans;
  184. font-size: 36rpx;
  185. font-weight: 500;
  186. line-height: 24px;
  187. letter-spacing: 0px;
  188. text-align: left;
  189. margin-bottom: 24rpx;
  190. padding-left: 4rpx;
  191. }
  192. .skills-grid {
  193. display: flex;
  194. flex-wrap: wrap;
  195. gap: 20rpx;
  196. }
  197. .skill-tag {
  198. padding: 16rpx 24rpx;
  199. background: #F7F8FA;
  200. border: 1rpx solid #E5E5EA;
  201. border-radius: 16rpx;
  202. transition: all 0.2s ease;
  203. display: flex;
  204. align-items: center;
  205. justify-content: center;
  206. cursor: pointer;
  207. text {
  208. font-size: 26rpx;
  209. color: rgba(102, 102, 102, 1);
  210. font-weight: 400;
  211. text-align: center;
  212. line-height: 1.2;
  213. }
  214. &:hover {
  215. background: rgba(153, 196, 250, 0.2);
  216. border-color: rgba(1, 107, 246, 0.3);
  217. }
  218. &.active {
  219. background: rgba(1, 107, 246, 0.1);
  220. border: 1rpx solid rgba(1, 107, 246, 1);
  221. box-shadow: 0 4rpx 12rpx rgba(1, 107, 246, 0.15);
  222. text {
  223. color: rgba(1, 107, 246, 1);
  224. font-weight: 500;
  225. }
  226. }
  227. &:active {
  228. transform: scale(0.96);
  229. }
  230. }
  231. .custom-tags {
  232. display: flex;
  233. flex-wrap: wrap;
  234. gap: 20rpx;
  235. }
  236. .custom-tag {
  237. padding: 14rpx 20rpx;
  238. background: rgba(153, 196, 250, 0.4);
  239. border: 1rpx solid rgba(1, 107, 246, 1);
  240. border-radius: 16rpx;
  241. display: flex;
  242. align-items: center;
  243. gap: 10rpx;
  244. cursor: pointer;
  245. transition: all 0.2s ease;
  246. text {
  247. font-size: 24rpx;
  248. color: rgba(1, 107, 246, 1);
  249. font-weight: 400;
  250. }
  251. &:hover {
  252. background: rgba(153, 196, 250, 0.6);
  253. }
  254. &:active {
  255. transform: scale(0.96);
  256. }
  257. }
  258. .add-tag {
  259. padding: 14rpx 20rpx;
  260. background: #F7F8FA;
  261. border: 1rpx dashed #E5E5EA;
  262. border-radius: 16rpx;
  263. display: flex;
  264. align-items: center;
  265. gap: 10rpx;
  266. cursor: pointer;
  267. transition: all 0.2s ease;
  268. text {
  269. font-size: 24rpx;
  270. color: rgba(102, 102, 102, 1);
  271. font-weight: 400;
  272. }
  273. &:hover {
  274. background: #f0f0f0;
  275. border-color: #d9d9d9;
  276. }
  277. &:active {
  278. transform: scale(0.96);
  279. }
  280. }
  281. // 添加标签弹窗样式
  282. .add-tag-popup {
  283. background: #fff;
  284. border-radius: 24rpx;
  285. padding: 48rpx 40rpx;
  286. width: 100%;
  287. .popup-title {
  288. color: rgba(34, 37, 42, 1);
  289. font-family: DM Sans;
  290. font-size: 36rpx;
  291. font-weight: 500;
  292. line-height: 24px;
  293. text-align: center;
  294. margin-bottom: 36rpx;
  295. }
  296. .popup-content {
  297. margin-bottom: 40rpx;
  298. .tag-input {
  299. width: 100%;
  300. height: 90rpx;
  301. padding: 0 24rpx;
  302. border: 1rpx solid #E5E5EA;
  303. border-radius: 16rpx;
  304. font-size: 28rpx;
  305. color: rgba(34, 37, 42, 1);
  306. background: #F7F8FA;
  307. box-sizing: border-box;
  308. }
  309. .tag-input::placeholder {
  310. color: #C9CDD4;
  311. }
  312. }
  313. .popup-buttons {
  314. display: flex;
  315. gap: 24rpx;
  316. .popup-btn {
  317. flex: 1;
  318. height: 88rpx;
  319. border-radius: 16rpx;
  320. display: flex;
  321. align-items: center;
  322. justify-content: center;
  323. font-size: 30rpx;
  324. font-weight: 500;
  325. transition: all 0.2s ease;
  326. cursor: pointer;
  327. }
  328. .cancel-btn {
  329. background: #F7F8FA;
  330. color: rgba(102, 102, 102, 1);
  331. &:active {
  332. background: #eaeaea;
  333. }
  334. }
  335. .confirm-btn {
  336. background: #007AFF;
  337. color: #fff;
  338. &:active {
  339. background: #0056CC;
  340. }
  341. }
  342. }
  343. }
  344. </style>