浏览代码

优选集团支持转发朋友圈,职位详情-分享海报企业名称距离调整

Xiao_123 3 月之前
父节点
当前提交
6998443074
共有 2 个文件被更改,包括 15 次插入8 次删除
  1. 5 2
      pagesB/positionDetail/index.vue
  2. 10 6
      pagesB/preferredGroup/index.vue

+ 5 - 2
pagesB/positionDetail/index.vue

@@ -304,9 +304,11 @@ const getImageTempRatio = (url) => {
   maxLine:最多绘制的行数
 **/
 //处理文字多出省略号显示
+const enterpriseNameLines = ref(0)
 const dealWords = (ctx, fontSize, text, maxWidth, x, y, maxLine, isEnterpriseName) => {
   ctx.setFontSize(fontSize);//设置字体大小
   var allRow = Math.ceil(ctx.measureText(text).width / maxWidth);//实际总共能分多少行
+  enterpriseNameLines.value = allRow
   var count = allRow >= maxLine ? maxLine : allRow;//实际能分多少行与设置的最大显示行数比,谁小就用谁做循环次数
   var endPos = 0;//当前字符串的截断点
   for (var j = 0; j < count; j++) {
@@ -327,7 +329,7 @@ const dealWords = (ctx, fontSize, text, maxWidth, x, y, maxLine, isEnterpriseNam
       }
     } else {
       //如果当前的字符串宽度小于最大宽度就直接输出
-      ctx.fillText(nowStr.slice(0), x, (isEnterpriseName ? y + 20 : y) + (j + 1) * 30);
+      ctx.fillText(nowStr.slice(0), x, (isEnterpriseName ? y + 2 : y) + (j + 1) * 30);
     }
   }
 }
@@ -380,7 +382,8 @@ const createPoster = async () => {
   // 企业行业类型、规模
   context.setFontSize(20)
   let industry = industryName && industryName.length > 6 ? `${industryName.slice(0, 7)}...` : industryName
-  context.fillText(`${industry || ''}${scaleName ? ' | ' + scaleName : ''}`, 150, 310)
+  context.setFillStyle('#6c6e7b')
+  context.fillText(`${industry || ''}${scaleName ? ' | ' + scaleName : ''}`, 150, enterpriseNameLines.value === 1 ? 280 : 310)
 
   context.draw(false, () =>{
     wx.canvasToTempFilePath({ 

+ 10 - 6
pagesB/preferredGroup/index.vue

@@ -75,7 +75,7 @@
 
 <script setup>
 import { ref } from 'vue'
-import { onLoad, onShareAppMessage } from '@dcloudio/uni-app'
+import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
 import { getJobAdvertisedSearch } from '@/api/position'
 import { dealDictObjData } from '@/utils/position'
 import { getWebContent } from '@/api/common'
@@ -93,8 +93,6 @@ const getSystemWebContent = async () => {
   preferred.value = preferredGroup.value[enterpriseId.value]
   title.value = preferred.value.title
   uni.hideLoading()
-  
-  console.log('======================================')
 }
 
 onLoad(async (options) => {
@@ -105,15 +103,21 @@ onLoad(async (options) => {
 })
 
 onShareAppMessage(() => {
-  if(!title.value){
-		setTimeout(() => {},1000)
-	}
+  if(!title.value) setTimeout(() => {},1000)
   return {
     title: title.value || '门墩儿 专注顶尖招聘',
     path: '/pagesB/preferredGroup/index?id=' + enterpriseId.value
   }
 })
 
+onShareTimeline(() =>{
+	if (!title.value) setTimeout(() => {}, 1000)
+	return {
+	  title: title.value || '门墩儿 专注顶尖招聘',
+	  path: '/pagesB/preferredGroup/index?id=' + enterpriseId.value
+	}
+})
+
 const current = ref(0)
 const swiperDotIndex = ref(0)
 const change = (e) => {