mrr.sj.front/pages/recruit/recruit.vue

202 lines
6.0 KiB
Vue
Raw Permalink Normal View History

2026-03-24 11:45:13 +08:00
<template>
<view class="container">
<custom-navbar title="招募" :showBack="true" backgroundColor="#fff" @onHeadleClick="goInvite" headleSrc="https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/3b04f0c1-a55e-4658-9de5-22175cce9bbc.png" :show-headle="info.state_other==1"></custom-navbar>
<view class="content">
<image :src="bjSrc" mode="widthFix" class="bjImg"></image>
<image class="imgCard" :src="info.promotion_img" mode="aspectFill">
</image>
<image src="/static/images/recruit/btn.gif" v-if="info.state_other==1" mode="widthFix" class="btnImg" @click="goRecruit2"></image>
</view>
</view>
</template>
<script>
import request from "../../utils/request";
import {
handleImgSize,
handleImgSizeUni
} from '@/utils/service.js'
export default {
data() {
return {
bjSrc: "/static/images/recruit/bj1.png",
info: {}
}
},
onLoad() {
this.getrecruit();
},
methods: {
async goInvite() {
let _that = this;
let imageUrl =
"https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/yh/1756713709528-717.png?x-oss-process=image/resize,p_40";
var pages = getCurrentPages();
var page = pages[pages.length - 1];
var bitmap = null;
// 获取当前页面 webview 的对象实例
var currentWebview = await page.$getAppWebview();
bitmap = await new plus.nativeObj.Bitmap("store-detail");
// 将webview内容绘制到Bitmap对象中
currentWebview.draw(
bitmap,
function () {
console.log("截屏绘制图片成功", bitmap);
bitmap.save(
"_doc/a.jpg",
{},
async function (i) {
imageUrl = i.target;
try {
// 直接调用导入的函数,不要加 this
const processedUrl = await handleImgSizeUni(i.target);
console.log("处理后的图片地址:", processedUrl);
// 赋值给组件数据
imageUrl = processedUrl;
} catch (err) {
console.error("处理失败:", err);
}
_that.setShare(imageUrl);
bitmap.clear();
},
function (e) {
_that.setShare(imageUrl);
console.log("保存图片失败:" + JSON.stringify(e));
}
);
},
function (e) {
_that.setShare(imageUrl);
console.log("截屏绘制图片失败:" + JSON.stringify(e));
}
);
},
setShare(imageUrl) {
let _that = this;
uni.share({
provider: "weixin",
scene: "WXSceneSession",
type: 5,
title: "「美融融」招商通道开启,期待您加入!",
miniProgram: {
id: "gh_89c92e18b70b", // 小程序原始ID
path: `/subPackages/recruit/recruit`, //小程序路径
type: _that.$store.state.wxShareType, // 正式版:0测试版:1体验版:2
webUrl: "https://www.baidu.com/",
},
// href:"https://www.baidu.com/",
imageUrl: imageUrl, // 分享主图建议300*300以上
success: function (res) {
console.log("success:" + JSON.stringify(res));
},
fail: function (err) {
uni.share({
provider: "weixin",
scene: "WXSceneSession",
type: 5,
title: "「美融融」招商通道开启,期待您加入!",
miniProgram: {
id: "gh_89c92e18b70b", // 小程序原始ID
path: `/subPackages/recruit/recruit`, //小程序路径
type: _that.$store.state.wxShareType, // 正式版:0测试版:1体验版:2
webUrl: "https://www.baidu.com/",
},
// href:"https://www.baidu.com/",
imageUrl:
"https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/yh/1756713709528-717.png?x-oss-process=image/resize,p_40", // 分享主图建议300*300以上
success: function (res) {
console.log("success:" + JSON.stringify(res));
},
fail: function (err) {
console.log("fail:" + JSON.stringify(err));
},
});
},
});
},
getrecruit() {
// 加载一级类目
request.post("/user/getRecruitment").then((res) => {
this.info = res.data;
});
},
goRecruit2(){
this.jumpToWeixinMiniProgram()
// uni.navigateTo({
// url: `/pages/recruit/recruit2`,
// });
},
// 点击“跳转小程序”按钮时触发
jumpToWeixinMiniProgram() {
// #ifdef APP-PLUS
plus.share.getServices((services) => {
let weixin = null;
// 遍历所有分享服务,找到微信
services.forEach((item) => {
if (item.id === "weixin") {
weixin = item;
}
});
if (weixin) {
// 调用微信小程序跳转接口
weixin.launchMiniProgram({
id: "gh_89c92e18b70b", // 必须填微信小程序的原始AppID
path: "/subPackages/recruit/recruit2", // 要打开的页面路径(可带参数)
type: 0, // 版本类型0-正式版1-测试版2-体验版默认0
success: () => {
uni.showToast({
title: "跳转成功",
icon: "success",
});
},
fail: (err) => {
uni.showToast({
title: "跳转失败:" + err.message,
icon: "none",
});
},
});
} else {
uni.showToast({
title: "未安装微信,请先安装",
icon: "none",
});
}
});
// #endif
},
}
}
</script>
<style lang="less">
.container {
.content {
position: relative;
.bjImg {
width: 750rpx;
}
.imgCard {
position: absolute;
left: 50%;
transform: translateX(-50%);
width: 690rpx;
height: 770rpx;
// background: #fff;
border-radius: 40rpx;
top: 690rpx;
}
.btnImg {
position: absolute;
width: 566rpx;
left: 50%;
transform: translateX(-50%);
bottom: 31rpx;
}
}
}
</style>