C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

157 lines
4.4 KiB

  1. const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px'
  2. let config = require("../../../config/config.js");
  3. let Http = require("../../../utils/HttpBasics");
  4. const util = require("../../../utils/util");
  5. let app = getApp();
  6. const imgurl = require("../../../utils/imgurl");
  7. const format = require("../../../utils/util.js");
  8. Page({
  9. data: {
  10. navigationBarHeight,
  11. noOrdersUrl: imgurl.noOrders.url,
  12. loadingUrl: imgurl.loading.url,
  13. wmhome: imgurl.wmhome.url,
  14. wmdiscount: imgurl.wmdiscount.url,
  15. wmgive: imgurl.wmgive.url,
  16. tabs: [{
  17. key: "all",
  18. name: "全部"
  19. },
  20. {
  21. key: 0,
  22. name: "待付款"
  23. },
  24. {
  25. key: 1,
  26. name: "已完成"
  27. }
  28. ],
  29. liveStatusList:[
  30. {
  31. name:'直播中',
  32. value:101
  33. },
  34. {
  35. name:'未开始',
  36. value:102
  37. },
  38. {
  39. name:'已结束',
  40. value:103
  41. },
  42. {
  43. name:'禁播',
  44. value:104
  45. },
  46. {
  47. name:' 暂停中',
  48. value:105
  49. },
  50. {
  51. name:' 异常',
  52. value:106
  53. },
  54. {
  55. name:'已过期',
  56. value:107
  57. },
  58. ],
  59. list: [],
  60. current: "",
  61. loading: true, //"上拉加载"的变量,默认false,隐藏
  62. current_scroll: "1",
  63. allow_load: true,
  64. page: 1,
  65. content: "",
  66. roomInfos:[],
  67. customParams:''
  68. },
  69. onLoad(e) {
  70. // this.getList(e.id, 1);
  71. this.getRoomList(1);
  72. let customParams = encodeURIComponent(JSON.stringify({ path: 'pages/index/index', pid: 1 }))
  73. this.setData({
  74. customParams
  75. })
  76. },
  77. goDetail(e){
  78. console.log(e.currentTarget.dataset.data)
  79. let customParams = encodeURIComponent(JSON.stringify({ path: '/pages2live/livelist/index', pid: e.currentTarget.dataset.data.roomid })) // 开发者在直播间页面路径上携带自定义参数(如示例中的path和pid参数),后续可以在分享卡片链接和跳转至商详页时获取,详见【获取自定义参数】、【直播间到商详页面携带参数】章节(上限600个字符,超过部分会被截断)
  80. wx.navigateTo({
  81. url: `plugin-private://wx2b03c6e691cd7370/pages2/live-player-plugin?room_id=${e.currentTarget.dataset.data.roomid}&type=10&custom_params=${customParams}`,
  82. })
  83. },
  84. //获取房间列表
  85. getRoomList(pageNum){
  86. let that=this;
  87. if (this.data.allow_load) {
  88. this.setData({
  89. loading: true,
  90. content: '小主,我在玩命加载中...'
  91. })
  92. Http.get({
  93. url: config.api.getRoomList,
  94. data: {
  95. start:pageNum*5-5,
  96. limit:5,
  97. token: app.globalData.token,
  98. appId:config.weapp.AppId
  99. }
  100. }).then(res => {
  101. console.log(res)
  102. this.setData({
  103. loading: false,
  104. })
  105. res.data.roomInfos.map((item,index)=>{
  106. console.log(parseInt(item.startTime))
  107. item.startTimeStr = format.formatTime(
  108. parseInt(item.startTime+"000"),
  109. "MM-dd hh:mm"
  110. );
  111. item.endTimeStr = format.formatTime(
  112. parseInt(item.endTime+"000"),
  113. "MM-dd hh:mm"
  114. );
  115. this.data.liveStatusList.map((item02,index02)=>{
  116. if(item.liveStatus==item02.value){
  117. item.statusName=item02.name
  118. }
  119. })
  120. })
  121. var tmpArr = this.data.roomInfos;
  122. tmpArr.push.apply(tmpArr, res.data.roomInfos);
  123. if(tmpArr.length==res.data.total){
  124. this.setData({
  125. allow_load:false
  126. })
  127. }
  128. this.setData({
  129. roomInfos:tmpArr
  130. })
  131. }).catch(err=>{
  132. that.setData({
  133. loading: false,
  134. })
  135. })
  136. }else{
  137. this.setData({
  138. loading: true,
  139. content: "——— 再拉裤子就掉了啦 ———"
  140. })
  141. setTimeout(function () {
  142. that.setData({
  143. loading: false,
  144. })
  145. }, 1400)
  146. }
  147. },
  148. onReachBottom: function () {
  149. var that = this;
  150. that.data.page++;
  151. that.setData({
  152. page: that.data.page
  153. });
  154. this.getRoomList(that.data.page);
  155. }
  156. });