mixin.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { getCanvasSelectLiveListApi } from '@/api/anotherTFInterface'
  2. import { funMixin } from '../../config/mixin'
  3. export const commonMixin = {
  4. mixins: [ funMixin ],
  5. data() {
  6. return {
  7. appid: 'wxc0aec85efc6b05e5',
  8. roomId: [], // 填写具体的房间号
  9. roomList: [],
  10. page: {
  11. page: 1,
  12. pageSize: 6
  13. }
  14. }
  15. },
  16. props: {
  17. terminal: {
  18. type: Number,
  19. default: 4
  20. },
  21. typeId: {
  22. type: Number,
  23. default: 1
  24. },
  25. shopId: {
  26. type: Number,
  27. default: 0
  28. },
  29. componentContent: {
  30. type: Object
  31. }
  32. },
  33. created() {
  34. this.getLiveRooms()
  35. },
  36. methods: {
  37. // 获取直播间列表
  38. getLiveRooms() {
  39. getCanvasSelectLiveListApi(this.page).then((res) => {
  40. this.roomList = res.data.list
  41. })
  42. },
  43. toLiveRoom(item) {
  44. this.roomId.push(item.roomid)
  45. if (!this.appid || !this.roomId.length) {
  46. return
  47. }
  48. // 路由参数
  49. const customParams = encodeURIComponent(JSON.stringify({ path: 'livePage/index', pid: 1 }))
  50. // let customParams
  51. // 开发者在直播间页面路径上携带自定义参数(如示例中的path和pid参数),后续可以在分享卡片链接和跳转至商详页时获取,详见【获取自定义参数】、【直播间到商详页面携带参数】章节(上限600个字符,超过部分会被截断)
  52. // #ifdef MP-WEIXIN
  53. wx.navigateTo({
  54. url: `plugin-private://${this.appid}/pages/live-player-plugin?room_id=${this.roomId}&custom_params=${customParams}`
  55. })
  56. // #endif
  57. }
  58. }
  59. }