tab-center-publish.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. const LOGIN_PAGE = '/pages/passport/lobby'
  2. const LABELS = {
  3. 'zh-Hant': ['發動態', '發視頻', '開始直播'],
  4. 'zh-cn': ['发圈子', '上传视频', '开始直播'],
  5. default: ['Send Mood', 'Send Video', 'Send Live']
  6. }
  7. const ROUTES = [
  8. '/pages/dynamics/publish',
  9. '/pages/dynamics/publish?type=video',
  10. '/pages/shop/live/live'
  11. ]
  12. function resolveLabels(locale) {
  13. if (locale === 'zh-Hant' || locale === 'zh-cn') return LABELS[locale]
  14. return LABELS.default
  15. }
  16. function openPublishRoute(index) {
  17. const url = ROUTES[index]
  18. if (index === 2) {
  19. // #ifdef APP-PLUS || MP-WEIXIN
  20. uni.navigateTo({ url })
  21. // #endif
  22. // #ifndef APP-PLUS || MP-WEIXIN
  23. uni.showToast({ title: '目前只开放App和微信小程序直播', icon: 'none' })
  24. // #endif
  25. return
  26. }
  27. uni.navigateTo({ url })
  28. }
  29. export function bindTabCenterPublisher(vm) {
  30. uni.onTabBarMidButtonTap(() => {
  31. const loggedIn = vm.$store?.state?.user?.isLogin
  32. if (!loggedIn) {
  33. uni.navigateTo({ url: LOGIN_PAGE })
  34. return
  35. }
  36. const locale = uni.getLocale()
  37. uni.showActionSheet({
  38. itemList: resolveLabels(locale),
  39. success: ({ tapIndex }) => openPublishRoute(tapIndex)
  40. })
  41. })
  42. }