attachment.vue 14 KB

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