resumeUpload.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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. <!-- #ifdef APP-PLUS -->
  16. <view
  17. class="upload-card"
  18. :is-shadow="true"
  19. @click="handleWeChatMiniApp"
  20. >
  21. <view class="card-icon"></view>
  22. <view class="card-text">微信小程序上传</view>
  23. <view class="card-badge"></view>
  24. </view>
  25. <!-- #endif -->
  26. <view
  27. class="upload-card"
  28. :is-shadow="true"
  29. >
  30. <view class="card-icon-phone"></view>
  31. <view class="card-text">手机文件上传</view>
  32. <fileSelector
  33. class="upload-file-selector"
  34. :isShowStyle="false"
  35. title=""
  36. allowType=".doc,.docx,.xls,.xlsx,.pdf"
  37. @fileSelected="uploadResumes"
  38. />
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import fileSelector from '@/uni_modules/zhouquan-fileSelector/components/zhouquan-fileSelector/file-selector.vue';
  45. export default {
  46. components: {
  47. fileSelector
  48. },
  49. data() {
  50. return {
  51. statusBarHeight: 0, // 状态栏高度
  52. content: [],
  53. showLoadCard: false,
  54. showResumesAnalysis: false,
  55. validInfoCount: 0, // 有效信息数量
  56. loading: false,
  57. showTipPopup: false
  58. };
  59. },
  60. onLoad(e) {
  61. // 获取状态栏高度
  62. let systemInfo = uni.getSystemInfoSync();
  63. this.statusBarHeight = systemInfo.statusBarHeight || 0;
  64. this.getUserInfo()
  65. // this.avatar = uni.getStorageSync('avatar')
  66. },
  67. methods: {
  68. // 返回上一页
  69. goBack() {
  70. uni.navigateBack();
  71. },
  72. getUserInfo() {
  73. this.$Request.get("/app/resumes/getAttachment").then(res => {
  74. if (res.code == 0) {
  75. res.data.forEach(function (item) {
  76. const ext = item.attachmentName.split('.').pop().toLowerCase();
  77. item.fileType = ext
  78. })
  79. this.content = res.data
  80. }
  81. uni.hideLoading();
  82. });
  83. },
  84. // 保存
  85. uploadResumes(e) {
  86. var that = this
  87. console.log(e.path)
  88. const validExtensions = ['pdf', 'doc', 'docx'];
  89. const ext = e.name.split('.').pop().toLowerCase();
  90. if (!validExtensions.includes(ext)) {
  91. this.$queue.showToast('仅支持PDF/DOC/DOCX格式')
  92. return;
  93. }
  94. uni.getFileInfo({
  95. filePath: e.path,
  96. success: (info) => {
  97. let attachment_size = (info.size / 1024).toFixed(1)
  98. that.$queue.uploadFile(e.path, function (path) {
  99. uni.showLoading({ title: '上传中' })
  100. if (path)
  101. that.$Request.postJson("/app/resumes/saveAttachment", {
  102. attachmentAddress: path,
  103. attachmentName: e.name,
  104. attachmentSize: attachment_size
  105. }).then(res => {
  106. uni.hideLoading()
  107. if (res.code === 0) {
  108. uni.showToast({
  109. title: '上传成功',
  110. icon: "none"
  111. })
  112. uni.navigateBack({
  113. delta: 1
  114. })
  115. } else {
  116. uni.showToast({
  117. title: res.msg,
  118. icon: "none"
  119. })
  120. }
  121. })
  122. else {
  123. uni.hideLoading()
  124. that.$queue.showToast('文件上传失败')
  125. }
  126. })
  127. },
  128. fail: (err) => {
  129. uni.hideLoading()
  130. console.error('获取失败', err);
  131. }
  132. });
  133. },
  134. // 微信小程序上传
  135. handleWeChatUpload() {
  136. plus.share.getServices(res => {
  137. let weixinService = null;
  138. for (let i in res) {
  139. if (res[i].id === 'weixin') {
  140. weixinService = res[i];
  141. break;
  142. }
  143. }
  144. const userId = uni.getStorageSync('userId')
  145. if (weixinService) {
  146. weixinService.launchMiniProgram({
  147. id: 'gh_854ab5288c2d',
  148. path: `/pages/index/index?userId=${userId}`,
  149. type: 0 // 小程序版本类型:0-正式版;1-测试版;2-体验版
  150. });
  151. } else {
  152. console.log('未安装微信或获取微信服务失败');
  153. }
  154. });
  155. },
  156. // 打开微信小程序
  157. handleWeChatMiniApp() {
  158. uni.showModal({
  159. title: '提示',
  160. content: '即将离开亿职赞打开微信小程序,请选择是否打开',
  161. success: (res) => {
  162. if (res.confirm) {
  163. this.handleWeChatUpload()
  164. }
  165. }
  166. })
  167. }
  168. },
  169. };
  170. </script>
  171. <style lang="scss" scoped>
  172. .navbar {
  173. padding: 24rpx 32rpx 20rpx 32rpx;
  174. background: #fff;
  175. .navbar-content {
  176. display: flex;
  177. align-items: center;
  178. justify-content: space-between;
  179. height: 60rpx;
  180. .navbar-left {
  181. width: 60rpx;
  182. height: 60rpx;
  183. display: flex;
  184. align-items: center;
  185. justify-content: center;
  186. }
  187. .navbar-title {
  188. color: rgba(23, 23, 37, 1);
  189. font-family: DM Sans;
  190. font-size: 36rpx;
  191. font-weight: 700;
  192. line-height: 52rpx;
  193. letter-spacing: 0%;
  194. text-align: center;
  195. }
  196. .navbar-right {
  197. width: 60rpx;
  198. height: 60rpx;
  199. }
  200. }
  201. }
  202. .contain {
  203. flex: 1;
  204. padding: 30rpx;
  205. background: #f1f5f8;
  206. .upload-card {
  207. position: relative;
  208. display: flex;
  209. height: 100rpx;
  210. padding: 0 30rpx;
  211. background: #fff;
  212. align-items: center;
  213. line-height: 100rpx;
  214. border-radius: 10rpx;
  215. margin-bottom: 20rpx;
  216. .card-icon {
  217. width: 44rpx;
  218. height: 44rpx;
  219. background: url('@/static/images/resumeUpload/miniApp.png') no-repeat center center;
  220. background-size: 100% 100%;
  221. margin-right: 10rpx;
  222. }
  223. .card-icon-phone {
  224. width: 44rpx;
  225. height: 44rpx;
  226. background: url('@/static/images/resumeUpload/phone.png') no-repeat center center;
  227. background-size: 100% 100%;
  228. margin-right: 10rpx;
  229. }
  230. .card-badge {
  231. width: 44rpx;
  232. height: 44rpx;
  233. background: url('@/static/images/resumeUpload/recommendation.png') no-repeat center center;
  234. background-size: 100% 100%;
  235. margin-right: 10rpx;
  236. }
  237. .card-text {
  238. margin: 0 10rpx;
  239. font-size: 30rpx;
  240. color: #666666;
  241. }
  242. }
  243. .upload-file-selector {
  244. position: absolute;
  245. left: 0;
  246. top: 0;
  247. width: 100%;
  248. height: 100%;
  249. opacity: 0;
  250. z-index: 5;
  251. }
  252. .upload-button {
  253. width: 100%;
  254. display: flex;
  255. height: 100rpx;
  256. position: relative;
  257. background: #fff;
  258. .upload-button-content {
  259. display: flex;
  260. z-index: 2;
  261. position: absolute;
  262. top: 0;
  263. left: 0;
  264. }
  265. }
  266. }
  267. </style>