resumeUpload.vue 5.7 KB

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