my.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <layout-page>
  3. <view class="pb-120">
  4. <view class="text-center" @tap="handleTap">
  5. <img :src="getUserAvatar(baseInfo?.avatar, baseInfo?.sex)" alt="" class="img-box">
  6. <view v-if="!useUserStore.isLogin" class="font-weight-bold font-size-20">点击登录</view>
  7. <view v-else class="font-weight-bold font-size-20">{{ baseInfo?.name || userInfo?.phone }}</view>
  8. </view>
  9. <view style="padding: 40rpx 0 0 0;">
  10. <resume-status></resume-status>
  11. </view>
  12. <view class="d-flex">
  13. <view v-for="(item, index) in itemList" :key="index" @tap="handleToLink(item)" class="parent">
  14. <view class="d-flex justify-space-around align-center">
  15. <uni-icons color="#00897B" :type="item.icon" size="30"/>
  16. <text class="itemText">{{ item.title }}</text>
  17. </view>
  18. </view>
  19. </view>
  20. <view style="height: 20rpx; background-color: #f8f8fa;"></view>
  21. <view class="card">
  22. <uni-list>
  23. <uni-list-item
  24. v-for="item in list"
  25. :clickable="true"
  26. :key="item.title"
  27. :title="item.title"
  28. showArrow
  29. :rightText="item.rightTex || ''"
  30. @click="handleToLink(item)"
  31. >
  32. </uni-list-item>
  33. </uni-list>
  34. </view>
  35. <button v-if="useUserStore.isLogin" class="send-button ss-m-b-30" @tap="handleLogout">退出登录</button>
  36. <uni-popup ref="popup" type="dialog">
  37. <uni-popup-dialog type="warn" cancelText="取消" confirmText="确定" title="系统提示" content="确认退出账号?" @confirm="handleLogoutConfirm"
  38. @close="handleLogoutClose"></uni-popup-dialog>
  39. </uni-popup>
  40. <uni-popup ref="shareQrCodePopup" type="dialog">
  41. <view class="shareQrCodePopupContent">
  42. <view class="color-primary text">邀请用户注册领50积分</view>
  43. <view class="qrCode">
  44. <image
  45. v-if="!!shareUrl"
  46. :src="shareUrl"
  47. :show-menu-by-longpress="true"
  48. style="width: 200px;height: 200px; padding: 20rpx;"
  49. ></image>
  50. </view>
  51. <view v-if="shareUrl" class="saveImg">长按二维码保存图片</view>
  52. </view>
  53. </uni-popup>
  54. </view>
  55. </layout-page>
  56. </template>
  57. <script setup>
  58. import { ref, computed } from 'vue'
  59. import ResumeStatus from '@/components/ResumeStatus'
  60. import { userStore } from '@/store/user'
  61. import { getUserAvatar } from '@/utils/avatar'
  62. import { getAccessToken } from '@/utils/request'
  63. import layoutPage from '@/layout'
  64. import { showAuthModal } from '@/hooks/useModal'
  65. import { onShow } from '@dcloudio/uni-app'
  66. import { getJobAdvertisedShareQrcode } from '@/api/user'
  67. // import { base64src } from '@/utils/base64src.js'
  68. // 设置自定义tabbar选中值
  69. onShow(() => {
  70. const currentPage = getCurrentPages()[0]; // 获取当前页面实例
  71. const currentTabBar = currentPage?.getTabBar?.();
  72. // 设置当前tab页的下标index
  73. currentTabBar?.setData({ selected: 4 });
  74. })
  75. const useUserStore = userStore()
  76. const baseInfo = computed(() => useUserStore?.baseInfo)
  77. const userInfo = computed(() => useUserStore?.userInfo)
  78. const popup = ref()
  79. const shareQrCodePopup = ref()
  80. const itemList = [
  81. { title: "我的关注", path: "/pagesA/collect/index", icon: "list" },
  82. { title:'关注我的', path:'/pagesA/seenMe/index', icon:'staff' }
  83. ]
  84. const list = [
  85. { title: '我的分享码', path: 'shareQrCode' },
  86. { title: '在线简历', path: '/pagesA/resumeOnline/index' },
  87. { title: '附件简历', path: '/pagesA/resume/index' },
  88. { title: '面试管理', path: '/pagesA/interview/index' },
  89. { title: '门墩儿商城', appId: 'wx6decdf12f9e7a061' },
  90. { title: '我要招聘', key: 'recruit' }
  91. ]
  92. // 列表跳转
  93. const handleToLink = (item) => {
  94. if (item.appId) {
  95. // uni.navigateToMiniProgram({
  96. // appId: item.appId,
  97. // })
  98. // return
  99. uni.showToast({
  100. title: '请前往网页版门墩儿商城',
  101. icon: 'none'
  102. })
  103. }
  104. if (item.key === 'recruit') {
  105. uni.showToast({
  106. title: '请前往网页版门墩儿招聘',
  107. icon: 'none'
  108. })
  109. }
  110. if (!item.path) return
  111. if (!getAccessToken()) {
  112. uni.showToast({
  113. title: '请先登录',
  114. icon: 'none'
  115. })
  116. showAuthModal()
  117. return
  118. }
  119. if (item.path === 'shareQrCode') {
  120. handleShareCode()
  121. return
  122. }
  123. uni.navigateTo({
  124. url: item.path
  125. })
  126. }
  127. const shareUrl = ref()
  128. // 生成分享二维码
  129. const handleShareCode = async () => {
  130. const userId = useUserStore?.accountInfo?.userId || ''
  131. console.log(1, 'userId', userId)
  132. if (!userId) {
  133. uni.showToast({
  134. title: '请先登录',
  135. icon: 'none'
  136. })
  137. showAuthModal()
  138. return
  139. }
  140. // if (!getAccessToken())
  141. const query = {
  142. scene: 'shareId=' + userId,
  143. path: 'pages/login/index',
  144. width: 200,
  145. autoColor: false,
  146. checkPath: true,
  147. hyaline: true
  148. }
  149. const res = await getJobAdvertisedShareQrcode(query)
  150. shareUrl.value = res?.data ? 'data:image/png;base64,' + res.data : ''
  151. shareQrCodePopup.value.open()
  152. }
  153. // 保存到本地
  154. const handleSaveShareUrl = async () => {
  155. // base64src(shareUrl.value, '我的分享码')
  156. const fsm = wx.getFileSystemManager()
  157. const data = shareUrl.value
  158. // console.log('data:', data)
  159. if (!data) return
  160. fsm.writeFile({
  161. filePath:wx.env.USER_DATA_PATH+'/MySharingCode.png',
  162. data: data.slice(22),
  163. encoding:'base64',
  164. success: res => {
  165. wx.saveImageToPhotosAlbum({
  166. filePath: wx.env.USER_DATA_PATH + '/MySharingCode.png',
  167. success: function (res) {
  168. wx.showToast({
  169. title: '保存成功',
  170. })
  171. },
  172. fail: function (err) {
  173. console.log(err)
  174. }
  175. })
  176. // console.log(res)
  177. }, fail: err => {
  178. console.log(err)
  179. }
  180. })
  181. }
  182. // 登录
  183. const handleTap = () => {
  184. if (!useUserStore.isLogin) {
  185. showAuthModal()
  186. return
  187. }
  188. uni.navigateTo({
  189. url: '/pagesA/resumeOnline/index'
  190. })
  191. }
  192. // 退出登录
  193. const handleLogout = () => {
  194. popup.value.open()
  195. }
  196. const handleLogoutClose = () => {
  197. popup.value.close()
  198. }
  199. const handleLogoutConfirm = () => {
  200. useUserStore.handleLogout()
  201. }
  202. </script>
  203. <style scoped lang="scss">
  204. .pb-120 {
  205. padding-bottom: 120rpx;
  206. }
  207. .img-box {
  208. width: 150rpx;
  209. height: 150rpx;
  210. border: 2rpx solid #ccc;
  211. border-radius: 50%;
  212. }
  213. :deep(.uni-list-item) {
  214. height: 120rpx !important;
  215. line-height: 120rpx !important;
  216. }
  217. :deep(.uni-list-item__content-title) {
  218. font-size: 32rpx !important;
  219. font-weight: 500;
  220. }
  221. .colors{
  222. font-size: 24rpx;
  223. color: #606266;
  224. }
  225. .size-16{
  226. color: #3f424f;
  227. font-size: 32rpx;
  228. margin: 13rpx 0 5rpx 0;
  229. }
  230. .itemText {
  231. color: #3f424f;
  232. font-size: 36rpx;
  233. }
  234. .parent{
  235. width: 50%;
  236. border: 1px solid #f4f4f4;
  237. border-radius: 10rpx;
  238. margin: 0 30rpx 20rpx 30rpx;
  239. padding: 20rpx;
  240. }
  241. .parent:first-child{
  242. margin: 0 0 20rpx 30rpx;
  243. }
  244. .shareQrCodePopupContent {
  245. width: 80vw;
  246. padding: 30rpx;
  247. margin-bottom: 20rpx;
  248. text-align: center;
  249. background-color: #fff;
  250. .text {
  251. margin-bottom: 20px;
  252. }
  253. .qrCode {
  254. margin-left: 4px;
  255. }
  256. .saveImg {
  257. text-align: center;
  258. margin-top: 10px;
  259. color: #999;
  260. }
  261. }
  262. </style>