123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394 |
- <template>
- <layout-page>
- <view class="pb-150">
- <view class="text-center" :class="vip ? 'vipBox' : 'avatarBox'" @tap="handleTap">
- <img :src="getUserAvatar(baseInfo?.avatar, baseInfo?.sex)" alt="" class="img-box">
- <image v-if="vip" src="/static/svg/vip.svg" class="vipIcon" @click.stop="handleToLink({path: '/pagesA/vip/index'})"></image>
- <view v-if="!useUserStore.isLogin" class="font-weight-bold font-size-20">点击登录</view>
- <view v-else class="font-weight-bold font-size-20">{{ baseInfo?.name || userInfo?.phone }}</view>
- </view>
- <view style="padding: 40rpx 0 0 0;">
- <resume-status></resume-status>
- </view>
-
- <view class="d-flex">
- <view v-for="(item, index) in itemList" :key="index" @tap="handleToLink(item)" class="parent">
- <view class="d-flex justify-space-around align-center">
- <uni-icons color="#00B760" :type="item.icon" size="30"/>
- <text class="itemText">{{ item.title }}</text>
- </view>
- </view>
- </view>
-
- <view style="height: 20rpx; background-color: #f8f8fa;"></view>
-
- <view class="card">
- <uni-list>
- <uni-list-item
- v-for="item in list"
- :clickable="true"
- :key="item.title"
- :title="item.title"
- showArrow
- :rightText="item.rightTex || ''"
- @click="handleToLink(item)"
- >
- </uni-list-item>
- </uni-list>
- </view>
-
- <button v-if="useUserStore.isLogin" class="send-button" style="margin-bottom: 50px;" @tap="handleLogout">退出登录</button>
-
- <uni-popup ref="popup" type="dialog">
- <uni-popup-dialog type="warn" cancelText="取消" confirmText="确定" title="系统提示" content="确认退出账号?" @confirm="handleLogoutConfirm"
- @close="handleLogoutClose"></uni-popup-dialog>
- </uni-popup>
- <!-- 我的分享码 -->
- <uni-popup ref="shareQrCodePopup" type="dialog">
- <view class="shareQrCodePopupContent">
- <view class="color-primary text">邀请用户注册领50积分</view>
- <view class="qrCode">
- <image
- v-if="!!shareUrl"
- :src="shareUrl"
- :show-menu-by-longpress="true"
- style="width: 200px;height: 200px; padding: 20rpx;"
- ></image>
- </view>
- <view v-if="shareUrl" class="saveImg">长按二维码保存图片</view>
- </view>
- </uni-popup>
- <uni-popup ref="inputDialog" type="dialog">
- <view class="shareQrCodePopupContent">
- <view>请前往网页版{{ dialogType ? '门墩儿招聘' : '门墩儿商城' }}</view>
- <uni-link class="ss-m-t-10" :href="dialogType ? 'https://www.menduner.com' : 'https://www.menduner.com/mall'" text="点击复制网页地址" color="#00B760" fontSize="16" copyTips="已复制,请在电脑端打开"></uni-link>
- </view>
- </uni-popup>
- </view>
- </layout-page>
- </template>
- <script setup>
- import { ref, computed, watch } from 'vue'
- import ResumeStatus from '@/components/ResumeStatus'
- import { userStore } from '@/store/user'
- import { getUserAvatar } from '@/utils/avatar'
- import { getAccessToken, showNecessaryInfoPopup } from '@/utils/request'
- import layoutPage from '@/layout'
- import { showAuthModal } from '@/hooks/useModal'
- import { onShow, onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
- import { getJobAdvertisedShareQrcode } from '@/api/user'
- // 设置自定义tabbar选中值
- onShow(() => {
- const currentPage = getCurrentPages()[0]; // 获取当前页面实例
- const currentTabBar = currentPage?.getTabBar?.();
- // 设置当前tab页的下标index
- currentTabBar?.setData({ selected: 4 });
- })
- // showAuthModal('') //测试 selectUserType
- const inputDialog = ref()
- const useUserStore = userStore()
- const baseInfo = computed(() => useUserStore?.baseInfo)
- const userInfo = computed(() => useUserStore?.userInfo)
- const vip = computed(() => new Date().getTime() < useUserStore?.userInfo?.vipExpireDate)
- const popup = ref()
- const shareQrCodePopup = ref()
- const itemList = [
- { title: "我的关注", path: "/pagesA/collect/index", icon: "list" },
- { title:'关注我的', path:'/pagesA/seenMe/index', icon:'staff' }
- ]
- const defaultList = [
- { title: '在线简历', path: '/pagesA/resumeOnline/index' },
- { title: '附件简历', path: '/pagesA/resume/index' },
- { title: '学生专区', path: '/pagesA/student/index', key: 'student', defaultHide: true },
- { title: '面试管理', path: '/pagesA/interview/index' },
- { title: '会员套餐', path: '/pagesA/vipPackage/index' },
- { title: '我的分享码', path: '/pagesB/sharePoster/index' },
- { title: '新用户邀请记录', path: '/pagesB/inviteRecord/index' },
- { title: '门墩儿商城', appId: 'wx6decdf12f9e7a061' },
- { title: '我要招聘', key: 'recruit' },
- { title: '联系我们', path: '/pagesB/contactUs/index' },
- { title: '协议中心', path: '/pagesB/agreement/index', open: true }
- ]
- const list = ref(defaultList.filter(e => !e.defaultHide))
- watch(
- () => baseInfo.value,
- (newVal) => {
- if (newVal) {
- list.value = defaultList.map(e => { // 不改变原数组,退出登录需要重置菜单
- let hide = e.defaultHide
- if (e?.key === 'student' && newVal.type === '1') hide = false // 学生信息管理。 type:0是求职者,1是学生
- return hide ? null : e
- }).filter(Boolean)
- }
- },
- { immediate: true },
- // { deep: true }
- )
- watch(
- () => vip.value,
- (newVal) => {
- if (newVal) list.value.splice(3, 0, { title: 'vip权益', key: 'vip', path: '/pagesA/vip/index' })
- else list.value = list.value.filter(e => !e.key || e.key !== 'vip')
- },
- { immediate: true },
- // { deep: true }
- )
- onLoad(() => {
- wx.showShareMenu({
- withShareTicket: true,
- menus: ['shareAppMessage', 'shareTimeline']
- })
- onShareAppMessage(() => {
- return {
- title: '门墩儿 专注顶尖招聘',
- path: '/pages/index/position',
- imageUrl: '../../static/img/share-poster.jpg'
- }
- })
- onShareTimeline(() => {
- return {
- title: '门墩儿 专注顶尖招聘',
- path: '/pages/index/position',
- imageUrl: '../../static/img/share-poster.jpg'
- }
- })
- })
- const openSubscribe = (path) => {
- wx.requestSubscribeMessage({
- tmplIds: ['2dByiI4wf6D3ZmxDH1QywH264F3N-9ysnvsS7xQm4PE'],
- success:(res)=>{
- console.log(res, 'uni.requestSubscribeMessage-res')
- uni.navigateTo({
- url: path
- })
- },
- fail:(err)=>{
- console.log('订阅失败', err)
- uni.navigateTo({
- url: path
- })
- }
- })
- }
- // 列表跳转
- const dialogType = ref('')
- const handleToLink = (item) => {
- if (item.open && item.path) return uni.navigateTo({ url: item.path })
- if (item.appId) {
- // uni.navigateToMiniProgram({
- // appId: item.appId,
- // })
- // return
- // uni.showToast({
- // title: '请前往网页版门墩儿商城',
- // icon: 'none'
- // })
- dialogType.value = 0
- inputDialog.value.open()
- }
- if (item.key === 'recruit') {
- dialogType.value = 1
- inputDialog.value.open()
- }
- if (!item.path) return
- if (!getAccessToken()) {
- uni.showToast({
- title: '请先登录',
- icon: 'none'
- })
- showAuthModal()
- return
- }
- if (showNecessaryInfoPopup()) {
- uni.showToast({
- title: '请先完善基本信息',
- icon: 'none'
- })
- showAuthModal('necessaryInfo')
- return
- }
- if (item.path === 'shareQrCode') {
- handleShareCode()
- return
- }
- // 点击在线简历需调起订阅消息
- if (item.title === '在线简历'){
- openSubscribe(item.path)
- return
- }
- uni.navigateTo({
- url: item.path
- })
- }
- const shareUrl = ref()
- // 生成分享二维码
- const handleShareCode = async () => {
- const userId = useUserStore?.accountInfo?.userId || ''
- if (!userId) {
- uni.showToast({
- title: '请先登录',
- icon: 'none'
- })
- showAuthModal()
- return
- }
- if (showNecessaryInfoPopup()) {
- uni.showToast({
- title: '请先完善基本信息',
- icon: 'none'
- })
- showAuthModal('necessaryInfo')
- return
- }
- const query = {
- scene: 'shareId=' + userId,
- path: 'pages/login/index',
- width: 200,
- autoColor: false,
- checkPath: true,
- hyaline: true
- }
- const res = await getJobAdvertisedShareQrcode(query)
- shareUrl.value = res?.data ? 'data:image/png;base64,' + res.data : ''
- shareQrCodePopup.value.open()
- }
- // 保存到本地
- // const handleSaveShareUrl = async () => {
- // const fsm = wx.getFileSystemManager()
- // const data = shareUrl.value
- // if (!data) return
- // fsm.writeFile({
- // filePath:wx.env.USER_DATA_PATH+'/MySharingCode.png',
- // data: data.slice(22),
- // encoding:'base64',
- // success: res => {
- // wx.saveImageToPhotosAlbum({
- // filePath: wx.env.USER_DATA_PATH + '/MySharingCode.png',
- // success: function (res) {
- // wx.showToast({
- // title: '保存成功',
- // })
- // },
- // fail: function (err) {
- // console.log(err)
- // }
- // })
- // }, fail: err => {
- // console.log(err)
- // }
- // })
- // }
- // 登录
- const handleTap = () => {
- if (!useUserStore.isLogin) {
- showAuthModal()
- return
- }
- uni.navigateTo({
- url: '/pagesA/resumeOnline/index'
- })
- }
- // 退出登录
- const handleLogout = () => {
- popup.value.open()
- }
- const handleLogoutClose = () => {
- popup.value.close()
- }
- const handleLogoutConfirm = () => {
- list.value = defaultList.filter(e => !e.hide) // 重置菜单
- useUserStore.handleLogout()
- }
- </script>
- <style scoped lang="scss">
- .pb-150 {
- padding-bottom: 100px;
- }
- .img-box {
- width: 150rpx;
- height: 150rpx;
- border: 2rpx solid #ccc;
- border-radius: 50%;
- }
- .vipBox {
- color: #a18a0f;
- position: relative;
- .img-box {
- border: 1px solid gold;
- }
- .vipIcon {
- position: absolute;
- width: 45px;
- height: 24px;
- bottom: 34px;
- left: 50%;
- }
- }
- :deep(.uni-list-item) {
- height: 120rpx !important;
- line-height: 120rpx !important;
- }
- :deep(.uni-list-item__content-title) {
- font-size: 32rpx !important;
- font-weight: 500;
- }
- .colors{
- font-size: 24rpx;
- color: #606266;
- }
- .size-16{
- color: #3f424f;
- font-size: 32rpx;
- margin: 13rpx 0 5rpx 0;
- }
- .itemText {
- color: #3f424f;
- font-size: 36rpx;
- }
- .parent{
- width: 50%;
- border: 1px solid #f4f4f4;
- border-radius: 10rpx;
- margin: 0 30rpx 20rpx 30rpx;
- padding: 20rpx;
- }
- .parent:first-child{
- margin: 0 0 20rpx 30rpx;
- }
- .shareQrCodePopupContent {
- width: 75vw;
- padding: 40rpx;
- margin-bottom: 20rpx;
- text-align: center;
- background-color: #fff;
- .text {
- margin-bottom: 20px;
- }
- .qrCode {
- margin-left: 4px;
- }
- .saveImg {
- text-align: center;
- margin-top: 10px;
- color: #999;
- }
- }
- </style>
|