attachment.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. <template>
  2. <view>
  3. <!-- 顶部导航栏 -->
  4. <view class="navbar" :style="{ paddingTop: (12 + statusBarHeight) + 'px' }">
  5. <view class="navbar-content">
  6. <view class="navbar-left" @click="goBack">
  7. <u-icon name="arrow-leftward" size="36" color="#333"></u-icon>
  8. </view>
  9. <view class="navbar-title">附件管理</view>
  10. <view class="navbar-right"></view>
  11. </view>
  12. </view>
  13. <!-- <nav-bar title="基本信息"></nav-bar> -->
  14. <view class="contain flex flex-direction">
  15. <view class="usermain">
  16. <scroll-view scroll-with-animation scroll-y>
  17. <!-- 我的公司 -->
  18. <view class="usermain-item item-padding" v-for="item in content">
  19. <view class="usermain-item-title c-flex-center">
  20. <image
  21. :src="item.fileType == 'pdf' ? '../../static/images/pdf.svg' : '../../static/images/docx.svg'"
  22. class="header-icon" mode="aspectFill" />
  23. </view>
  24. <view @click="seekDoc(item)" class="fileContent c-flex-center">
  25. <view class="fileName m-ellipsis">{{ item.attachmentName }}</view>
  26. <view class="filedesc">{{ item.attachmentSize }}kb 更新于{{ item.createTime }}</view>
  27. </view>
  28. <view @click.stop="more(item.resumesAttachmentId)" class="c-flex-center">
  29. <u-icon name="more-dot-fill"></u-icon>
  30. </view>
  31. </view>
  32. <empty :isShow="false" v-if="content.length == 0" />
  33. </scroll-view>
  34. </view>
  35. <view class="footer-btn">
  36. <fileSelector title="上传简历" allowType=".doc,.docx,.xls,.xlsx,.pdf" @fileSelected="uploadResumes"
  37. @filesChanged="onFilesChanged" />
  38. </view>
  39. </view>
  40. <!-- 权限说明弹窗 -->
  41. <u-popup mode="top" ref="permission">
  42. <view class="popup-content">
  43. <view class="popup-text-permission">选择/拍摄照片需要相机/相册权限,用于上传用户头像</view>
  44. </view>
  45. </u-popup>
  46. </view>
  47. </template>
  48. <script>
  49. import configdata from '../../common/config.js';
  50. import navBar from "@/components/nav-bar/index.vue";
  51. // 引入组件
  52. import fileSelector from '@/uni_modules/zhouquan-fileSelector/components/zhouquan-fileSelector/file-selector.vue';
  53. import empty from '../../components/empty.vue'
  54. export default {
  55. components: {
  56. navBar,
  57. fileSelector,
  58. empty
  59. },
  60. data() {
  61. return {
  62. statusBarHeight: 0, // 状态栏高度
  63. phone: '',
  64. weChatNum: '',//微信号
  65. email: '',//接收简历邮箱
  66. selectedCompany: '深圳市汉瑞国际猎头服务有限公司', // 我的公司
  67. selectedPosition: '人事总监', // 我的职务
  68. avatar: '../../static/logo.png',
  69. userName: '',
  70. nickName: '',
  71. userId: '',
  72. realName: '',
  73. weChatId: "",
  74. password: '',
  75. platform: '',
  76. createTime: '',
  77. money: '',
  78. jiFen: '',
  79. status: '',
  80. zhiFuBao: '',
  81. zhiFuBaoName: '',
  82. sex: 1,
  83. age: 0,
  84. content: []
  85. };
  86. },
  87. computed: {
  88. phoneWithMask() {
  89. if (this.phone && this.phone.length >= 11) {
  90. return this.phone.substring(0, 3) + '******' + this.phone.substring(9);
  91. }
  92. return this.phone || '请设置手机号';
  93. }
  94. },
  95. onLoad(e) {
  96. // 获取状态栏高度
  97. let systemInfo = uni.getSystemInfoSync();
  98. this.statusBarHeight = systemInfo.statusBarHeight || 0;
  99. this.getUserInfo()
  100. // this.avatar = uni.getStorageSync('avatar')
  101. },
  102. methods: {
  103. // 返回上一页
  104. goBack() {
  105. uni.navigateBack();
  106. },
  107. // 修改手机号
  108. modifyPhone() {
  109. console.log('点击修改手机号,当前手机号:', this.phone);
  110. const url = `/pages/my/userphone?currentPhone=${this.phone}`;
  111. console.log('跳转路径:', url);
  112. uni.navigateTo({
  113. url: url,
  114. });
  115. },
  116. // 选择公司
  117. selectCompany() {
  118. uni.navigateTo({
  119. url: '/pages/my/myCompany'
  120. });
  121. },
  122. // 选择职务
  123. selectPosition() {
  124. // 这里可以跳转到职务选择页面或显示职务选择弹窗
  125. console.log('选择职务');
  126. },
  127. onChooseAvatar(e) {
  128. let that = this;
  129. let token = uni.getStorageSync('token');
  130. uni.uploadFile({
  131. url: that.config("APIHOST1") +
  132. '/alioss/upload', //真实的接口地址
  133. filePath: e.detail.avatarUrl,
  134. header: {
  135. token: token
  136. },
  137. name: 'file',
  138. success: uploadFileRes => {
  139. let url = JSON.parse(uploadFileRes.data);
  140. that.avatar = url.data
  141. uni.hideLoading();
  142. }
  143. });
  144. },
  145. goMyAddress() {
  146. uni.navigateTo({
  147. url: '../jifen/myaddress'
  148. });
  149. },
  150. uploadImg() {
  151. let token = uni.getStorageSync('token')
  152. if (!token) {
  153. this.goLoginInfo();
  154. return;
  155. }
  156. let that = this;
  157. var url = null;
  158. uni.showActionSheet({
  159. // itemList按钮的文字接受的是数组
  160. itemList: ["查看头像", "从相册选择图片"],
  161. async success(e) {
  162. var index = e.tapIndex
  163. if (index === 0) {
  164. // 用户点击了预览当前图片
  165. // 可以自己实现当前头像链接的读取
  166. let url = that.avatar;
  167. let arr = []
  168. arr.push(url)
  169. uni.previewImage({
  170. // 预览功能图片也必须是数组的
  171. urls: arr
  172. })
  173. } else if (index === 1) {
  174. // 1. 检查权限状态
  175. const hasPermission = await this.$queue.checkPermission(
  176. 'camera',
  177. '选择/拍摄照片需要相机/相册权限,用于上传用户头像',
  178. this
  179. );
  180. // 2. 如果未授权或者用户拒绝,显示提示
  181. if (!hasPermission) {
  182. return;
  183. }
  184. uni.chooseImage({
  185. count: 1, //默认9
  186. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  187. sourceType: ['album'], //从相册选择
  188. success: function (res) {
  189. uni.showLoading({
  190. title: '上传中...'
  191. });
  192. let token = uni.getStorageSync('token');
  193. let userId = uni.getStorageSync('userId');
  194. uni.uploadFile({
  195. url: that.config("APIHOST1") +
  196. '/alioss/upload', //真实的接口地址
  197. filePath: res.tempFilePaths[0],
  198. header: {
  199. token: token
  200. },
  201. name: 'file',
  202. success: uploadFileRes => {
  203. url = JSON.parse(uploadFileRes.data);
  204. that.avatar = url.data
  205. uni.hideLoading();
  206. }
  207. });
  208. }
  209. });
  210. }
  211. }
  212. })
  213. },
  214. config: function (name) {
  215. var info = null;
  216. if (name) {
  217. var name2 = name.split("."); //字符分割
  218. if (name2.length > 1) {
  219. info = configdata[name2[0]][name2[1]] || null;
  220. } else {
  221. info = configdata[name] || null;
  222. }
  223. if (info == null) {
  224. let web_config = cache.get("web_config");
  225. if (web_config) {
  226. if (name2.length > 1) {
  227. info = web_config[name2[0]][name2[1]] || null;
  228. } else {
  229. info = web_config[name] || null;
  230. }
  231. }
  232. }
  233. }
  234. return info;
  235. },
  236. getUserInfo() {
  237. this.$Request.get("/app/resumes/getAttachment").then(res => {
  238. if (res.code == 0) {
  239. res.data.forEach(function (item) {
  240. const ext = item.attachmentName.split('.').pop().toLowerCase();
  241. item.fileType = ext
  242. })
  243. this.content = res.data
  244. }
  245. uni.hideLoading();
  246. });
  247. },
  248. // 保存
  249. uploadResumes(e) {
  250. var that = this
  251. console.log(e.path)
  252. const validExtensions = ['pdf', 'doc', 'docx'];
  253. const ext = e.name.split('.').pop().toLowerCase();
  254. if (!validExtensions.includes(ext)) {
  255. this.$queue.showToast('仅支持PDF/DOC/DOCX格式')
  256. return;
  257. }
  258. uni.getFileInfo({
  259. filePath: e.path,
  260. success: (info) => {
  261. console.log('文件大小:', info.size); // 单位:字节
  262. let attachment_size = (info.size / 1024).toFixed(1)
  263. that.$queue.uploadFile(e.path, function (path) {
  264. if (path)
  265. that.$Request.postJson("/app/resumes/saveAttachment", {
  266. attachmentAddress: path,
  267. attachmentName: e.name,
  268. attachmentSize: attachment_size
  269. }).then(res => {
  270. if (res.code === 0) {
  271. that.getUserInfo()
  272. uni.$emit('updateAttachmentList')
  273. } else {
  274. uni.showToast({
  275. title: res.msg,
  276. icon: "none"
  277. })
  278. }
  279. })
  280. else
  281. that.$queue.showToast('文件上传失败')
  282. })
  283. },
  284. fail: (err) => {
  285. console.error('获取失败', err);
  286. }
  287. });
  288. },
  289. more(id) {
  290. var that = this
  291. uni.showActionSheet({
  292. itemList: ["删除"],
  293. itemColor: "#3273db",
  294. success(res) {
  295. if (res.tapIndex == 0)
  296. that.deleteAttachment(id)
  297. },
  298. fail(res) {
  299. console.log(res.errMsg);
  300. },
  301. });
  302. },
  303. deleteAttachment(id) {
  304. var that = this;
  305. uni.showModal({
  306. title: '提示',
  307. content: '确定删除?',
  308. success(res) {
  309. if (res.confirm) {
  310. that.$Request.postJson("/app/resumes/deleteAttachment", {
  311. resumesAttachmentId: id
  312. }).then(res => {
  313. if (res.code === 0) {
  314. var info = that.content.filter(function (item) {
  315. return item.resumesAttachmentId != id;
  316. });
  317. that.content = info
  318. uni.$emit('updateAttachmentList')
  319. } else {
  320. uni.showToast({
  321. title: res.msg,
  322. icon: "none"
  323. })
  324. }
  325. })
  326. } else if (res.cancel) {
  327. console.log('用户点击取消')
  328. }
  329. }
  330. })
  331. },
  332. onFilesChanged(e) {
  333. console.log(e)
  334. },
  335. seekDoc(it) {
  336. //#ifdef APP-PLUS
  337. uni.downloadFile({
  338. url: it.attachmentAddress,
  339. success: function (res) {
  340. var filePath = res.tempFilePath;
  341. uni.openDocument({
  342. filePath: filePath,
  343. showMenu: true,
  344. success: function (res) {
  345. console.log('打开文档成功');
  346. }
  347. });
  348. }
  349. });
  350. return;
  351. //#endif
  352. uni.navigateTo({
  353. url: '/pages/index/webView?url=' + it.attachmentAddress + '&title=' + it.attachmentName
  354. });
  355. }
  356. },
  357. // userphone(){
  358. // uni.navigateTo({
  359. // url:'/pages/my/userphone'
  360. // })
  361. // }
  362. };
  363. </script>
  364. <style lang="scss" scoped>
  365. page {
  366. /* background: #f6f6f6; */
  367. }
  368. .navbar {
  369. position: fixed;
  370. top: 0;
  371. left: 0;
  372. right: 0;
  373. z-index: 999;
  374. background: #fff;
  375. padding: 0 0 40rpx 20rpx;
  376. .navbar-content {
  377. display: flex;
  378. align-items: center;
  379. justify-content: space-between;
  380. padding: 0 30rpx;
  381. height: 60rpx;
  382. .navbar-left {
  383. width: 60rpx;
  384. height: 60rpx;
  385. display: flex;
  386. align-items: center;
  387. justify-content: center;
  388. }
  389. .navbar-title {
  390. color: rgba(23, 23, 37, 1);
  391. font-family: DM Sans;
  392. font-size: 36rpx;
  393. font-weight: 700;
  394. line-height: 52rpx;
  395. letter-spacing: 0%;
  396. text-align: center;
  397. }
  398. .navbar-right {
  399. width: 60rpx;
  400. height: 60rpx;
  401. }
  402. }
  403. }
  404. button::after {
  405. border: none;
  406. background-color: none;
  407. }
  408. button {
  409. position: relative;
  410. display: block;
  411. margin-left: auto;
  412. margin-right: auto;
  413. padding-left: 0px;
  414. padding-right: 0px;
  415. box-sizing: border-box;
  416. text-decoration: none;
  417. line-height: 1.35;
  418. overflow: hidden;
  419. color: #666666;
  420. /* background-color: #fff; */
  421. background-color: rgba(255, 255, 255, 0) !important;
  422. width: 100%;
  423. height: 100%;
  424. }
  425. .contain {
  426. padding-top: 120rpx;
  427. /* 为固定导航栏留出空间 */
  428. /* #ifdef APP*/
  429. padding-top: calc(120rpx + var(--status-bar-height));
  430. /* #endif*/
  431. height: 100vh;
  432. }
  433. .usermain {
  434. background: #ffffff;
  435. /* color: #fff; */
  436. height: 100vh;
  437. scroll-view {
  438. height: 100%;
  439. }
  440. }
  441. .usermain-item {
  442. display: flex;
  443. justify-content: space-between;
  444. margin: 0 40rpx;
  445. padding: 30rpx 0;
  446. // border-bottom: 1rpx solid rgba(229, 229, 229, 0.3);
  447. background: #fff;
  448. .fileContent {
  449. width: 85%;
  450. margin: 0 20rpx;
  451. }
  452. .fileName {
  453. color: #222;
  454. font-size: 32rpx;
  455. }
  456. .filedesc {
  457. margin-top: 10rpx;
  458. font-size: 24rpx;
  459. }
  460. .c-flex-center {
  461. align-self: center;
  462. color: #aaa;
  463. flex-shrink: 0;
  464. }
  465. }
  466. .usermain-item-title {
  467. color: rgba(31, 44, 55, 1);
  468. font-family: DM Sans;
  469. font-size: 28rpx;
  470. font-weight: 500;
  471. line-height: 44rpx;
  472. text-align: left;
  473. .header-icon {
  474. width: 50rpx;
  475. height: 50rpx;
  476. display: block;
  477. }
  478. }
  479. .usermain-item.item-padding {
  480. /* padding: 0; */
  481. }
  482. .cu-form-group {
  483. padding: 0;
  484. background: #ffffff;
  485. text-align: right;
  486. }
  487. .cu-form-group input {
  488. background: #ffffff;
  489. font-size: 28rpx;
  490. /* color: #fff; */
  491. }
  492. /* 姓名字段样式 - 参考basicInfo.vue */
  493. .usermain-item .form-label {
  494. color: rgba(31, 44, 55, 1);
  495. font-family: DM Sans;
  496. font-size: 32rpx;
  497. font-weight: 500;
  498. line-height: 44rpx;
  499. letter-spacing: 0.5%;
  500. text-align: left;
  501. display: flex;
  502. align-items: center;
  503. margin-bottom: 16rpx;
  504. }
  505. .usermain-item .required-mark {
  506. color: #FF3B30;
  507. font-size: 36rpx;
  508. font-weight: 600;
  509. margin-right: 8rpx;
  510. }
  511. .usermain-item .cu-form-group {
  512. background: transparent;
  513. text-align: left;
  514. padding: 0;
  515. }
  516. .usermain-item .cu-form-group input {
  517. width: 100%;
  518. height: 68rpx;
  519. font-size: 28rpx;
  520. border: 1rpx solid rgba(227, 231, 236, 1);
  521. border-radius: 44rpx;
  522. color: rgba(23, 23, 37, 1);
  523. padding: 0 32rpx;
  524. background: #ffffff;
  525. font-family: DM Sans;
  526. font-weight: 400;
  527. }
  528. .usermain-item .cu-form-group input::placeholder {
  529. color: rgba(155, 155, 155, 1);
  530. font-size: 28rpx;
  531. }
  532. /* 联系方式样式 */
  533. .contact-structure {
  534. border-bottom: none !important;
  535. }
  536. .contact-wrapper {
  537. display: flex;
  538. align-items: center;
  539. justify-content: space-between;
  540. padding: 0;
  541. margin-top: 8rpx;
  542. }
  543. .phone-display {
  544. color: rgba(23, 23, 37, 1);
  545. font-family: DM Sans;
  546. font-size: 28rpx;
  547. font-weight: 400;
  548. line-height: 40rpx;
  549. letter-spacing: 0.5%;
  550. }
  551. .modify-link {
  552. color: rgba(24, 144, 255, 1);
  553. font-family: DM Sans;
  554. font-size: 28rpx;
  555. font-weight: 400;
  556. line-height: 40rpx;
  557. letter-spacing: 0.5%;
  558. cursor: pointer;
  559. text-decoration: none;
  560. }
  561. .modify-link:active {
  562. opacity: 0.7;
  563. }
  564. /* 头像编辑图标样式 */
  565. .avatar-wrapper {
  566. position: relative;
  567. display: inline-block;
  568. }
  569. .edit-avatar-icon {
  570. position: absolute;
  571. bottom: 10rpx;
  572. right: 2rpx;
  573. width: 24rpx;
  574. height: 24rpx;
  575. // background: #fff;
  576. border-radius: 50%;
  577. display: flex;
  578. align-items: center;
  579. justify-content: center;
  580. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  581. }
  582. .avatar-button {
  583. position: relative;
  584. padding: 0;
  585. margin: 0;
  586. background: transparent;
  587. border: none;
  588. }
  589. .footer-btn {
  590. margin-top: 40rpx;
  591. padding-bottom: 40rpx;
  592. }
  593. .footer-btn .usermain-btn {
  594. color: rgba(255, 255, 255, 1);
  595. background: rgba(1, 107, 246, 1);
  596. text-align: center;
  597. width: 90%;
  598. height: 80rpx;
  599. font-size: 32rpx;
  600. line-height: 80rpx;
  601. margin: 20rpx auto;
  602. border-radius: 40rpx;
  603. }
  604. /* 选择器样式 - 参考workExperience页面 */
  605. .form-input-selector {
  606. width: 100%;
  607. height: 68rpx;
  608. padding: 0 40rpx;
  609. border: 1px solid rgba(227, 231, 236, 1);
  610. border-radius: 24px;
  611. background: rgba(255, 255, 255, 1);
  612. display: flex;
  613. align-items: center;
  614. justify-content: space-between;
  615. cursor: pointer;
  616. transition: all 0.2s ease;
  617. .placeholder {
  618. color: #999999;
  619. font-family: DM Sans;
  620. font-size: 28rpx;
  621. font-weight: 400;
  622. line-height: 40rpx;
  623. }
  624. text {
  625. color: rgba(23, 23, 37, 1);
  626. font-family: DM Sans;
  627. font-size: 28rpx;
  628. font-weight: 400;
  629. line-height: 40rpx;
  630. }
  631. }
  632. .arrow-down {
  633. color: rgba(96, 98, 102, 1);
  634. font-size: 24rpx;
  635. font-weight: 400;
  636. transform: scale(1.5);
  637. }
  638. .selector-group:active {
  639. background: #f5f7fa !important;
  640. transform: scale(0.99);
  641. }
  642. </style>