index.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. import {
  2. ApiModel
  3. } from "../../utils/api";
  4. const _Http = new ApiModel;
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. dataTypes: 0, //0-全部数据 1-单独数据
  11. tabsList: ["私域直播", "展会直播"], //tabs列表
  12. tabsIndex: 0, //tabs下标
  13. accountStatus: null, //直播账号状态 1-账号正常 2-账号审核中 3-没有账号
  14. liveDataCount: {}, //实时数据统计
  15. liveDataCountForSession: {}, //单场次数据统计
  16. liveSessionList: [], //直播场次列表
  17. liveUserList: [], //直播用户观看记录
  18. pageNumber: 1, //当前页码
  19. pageTotal: 1, //列表总页数
  20. userPageNumber: 1, //用户当前页码
  21. userPageTotal: 1, //用户总列表
  22. optionRow: -1, //列表选中项
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad: function (options) {
  28. //获取直播账号
  29. this.getLiveInfo()
  30. },
  31. /* 获取直播账号详情 */
  32. getLiveInfo() {
  33. const method = (this.data.tabsIndex == 0) ? 'getSYLiveInfo' : 'getLiveInfo';
  34. _Http.basic({
  35. "accesstoken": wx.getStorageSync('userData').token,
  36. "classname": "customer.live.live",
  37. "method": method,
  38. "content": {}
  39. }).then(res => {
  40. this.setData({
  41. accountStatus: res.code,
  42. accountMsg: res.data[0]
  43. })
  44. /* 直播数据统计 */
  45. this.getLiveDataCount()
  46. /* 直播场次列表查询 */
  47. this.getLiveSessionList()
  48. })
  49. },
  50. /* 直播数据统计 */
  51. getLiveDataCount() {
  52. //判断私域还是展会
  53. const method = (this.data.tabsIndex == 0) ? 'getSYLiveDataCount' : 'getLiveDataCount'
  54. _Http.basic({
  55. "accesstoken": wx.getStorageSync('userData').token,
  56. "classname": "customer.live.live",
  57. "method": method,
  58. "content": {
  59. "channelid": this.data.accountMsg.channelid
  60. }
  61. }).then(res => {
  62. if (res.msg != '成功') return wx.showToast({
  63. title: res.data,
  64. icon: "none"
  65. });
  66. this.setData({
  67. liveDataCount: res.data
  68. })
  69. })
  70. },
  71. /* 直播场次列表查询 */
  72. getLiveSessionList() {
  73. const method = (this.data.tabsIndex == 0) ? "getSYLiveSessionList" : "getLiveSessionList"
  74. _Http.basic({
  75. "accesstoken": wx.getStorageSync('userData').token,
  76. "classname": "customer.live.live",
  77. "method": method,
  78. "content": {
  79. "getdatafromdbanyway": true,
  80. "pageNumber": this.data.pageNumber,
  81. "pageSize": 10,
  82. "channelid": this.data.accountMsg.channelid
  83. }
  84. }).then(res => {
  85. console.log(res)
  86. if (res.msg != '成功') return wx.showToast({
  87. title: res.data,
  88. icon: "none"
  89. });
  90. for (let i = 0; i < res.data.length; i++) {
  91. let checkdate = res.data[i].starttime;
  92. res.data[i].starttime = checkdate.slice(0, checkdate.lastIndexOf('.'));
  93. }
  94. this.setData({
  95. liveSessionList: res.data,
  96. pageTotal: res.pageTotal
  97. })
  98. })
  99. },
  100. /* 查看场次详情 */
  101. viewDetails(e) {
  102. const {
  103. index
  104. } = e.currentTarget.dataset;
  105. const sessionid = this.data.liveSessionList[index].sessionid;
  106. this.setData({
  107. showStartTime: this.data.liveSessionList[index].starttime,
  108. sessionid
  109. })
  110. /* 场次详情统计 */
  111. _Http.basic({
  112. "accesstoken": wx.getStorageSync('userData').token,
  113. "classname": "customer.live.live",
  114. "method": "getSYLiveDataCountForSession",
  115. "content": {
  116. "sessionid": sessionid
  117. }
  118. }).then(res => {
  119. console.log(res)
  120. if (res.msg != '成功') wx.showToast({
  121. title: '数据统计获取失败,请稍后再试',
  122. icon: "none"
  123. })
  124. this.setData({
  125. liveDataCountForSession: res.data
  126. })
  127. });
  128. this.LiveUserList();
  129. this.setData({
  130. dataTypes: 1
  131. })
  132. },
  133. /* 观看用户列表 */
  134. LiveUserList() {
  135. /* 用户观看列表 */
  136. const method = (this.data.tabsIndex == 0) ? "getSYLiveUserList" : "getLiveUserList";
  137. _Http.basic({
  138. "accesstoken": wx.getStorageSync('userData').token,
  139. "classname": "customer.live.live",
  140. "method": method,
  141. "content": {
  142. "getdatafromdbanyway": true,
  143. "pageNumber": this.data.userPageNumber,
  144. "pageSize": 10,
  145. "sessionid": this.data.sessionid,
  146. "channelid": this.data.accountMsg.channelid
  147. }
  148. }).then(res => {
  149. console.log(res)
  150. if (res.msg != '成功') wx.showToast({
  151. title: '观看列表获取失败,请稍后再试',
  152. icon: "none"
  153. })
  154. for (let i = 0; i < res.data.length; i++) {
  155. const index = res.data[i].datetime.lastIndexOf('.');
  156. res.data[i].datetime = res.data[i].datetime.slice(0, index)
  157. }
  158. this.setData({
  159. userPageTotal: res.pageTotal,
  160. liveUserList: res.data
  161. })
  162. });
  163. },
  164. /* 返回场次列表 */
  165. returnLiveData() {
  166. this.setData({
  167. dataTypes: 0,
  168. userPageNumber: 1,
  169. userPageTotal: 1
  170. })
  171. },
  172. /* 场次列表选中 */
  173. optionItemIndex(e) {
  174. const {
  175. index
  176. } = e.currentTarget.dataset;
  177. if (index == this.data.optionRow) return this.setData({
  178. optionRow: -1
  179. });
  180. this.setData({
  181. optionRow: index
  182. })
  183. },
  184. /* 下一页 */
  185. buttonRightClick() {
  186. if (this.data.dataTypes == 0) {
  187. if (this.data.pageNumber == this.data.pageTotal) return wx.showToast({
  188. title: '已经到达最后一页',
  189. icon: "none"
  190. });
  191. this.setData({
  192. pageNumber: this.data.pageNumber + 1
  193. })
  194. this.getSYLiveSessionList()
  195. } else {
  196. if (this.data.userPageNumber == this.data.userPageTotal) return wx.showToast({
  197. title: '已经到达最后一页',
  198. icon: "none"
  199. });
  200. this.setData({
  201. userPageNumber: this.data.userPageNumber + 1
  202. })
  203. this.LiveUserList()
  204. }
  205. },
  206. /* 上一页 */
  207. buttonLifeClick() {
  208. if (this.data.dataTypes == 0) {
  209. if (this.data.pageNumber == 1) return wx.showToast({
  210. title: '已经在第一页了哦',
  211. icon: "none"
  212. });
  213. this.setData({
  214. pageNumber: this.data.pageNumber - 1
  215. })
  216. this.getSYLiveSessionList()
  217. } else {
  218. if (this.data.userPageNumber == 1) return wx.showToast({
  219. title: '已经在第一页了哦',
  220. icon: "none"
  221. });
  222. this.setData({
  223. userPageNumber: this.data.userPageNumber - 1
  224. })
  225. this.LiveUserList()
  226. }
  227. },
  228. /* tabs回调 */
  229. setIndex({
  230. detail
  231. }) {
  232. this.setData({
  233. tabsIndex: detail,
  234. pageNumber: 1,
  235. pageTotal: 1,
  236. userPageNumber: 1,
  237. userPageTotal: 1
  238. })
  239. this.getLiveInfo();
  240. },
  241. /**
  242. * 生命周期函数--监听页面初次渲染完成
  243. */
  244. onReady: function () {
  245. },
  246. /**
  247. * 生命周期函数--监听页面显示
  248. */
  249. onShow: function () {
  250. },
  251. /**
  252. * 生命周期函数--监听页面隐藏
  253. */
  254. onHide: function () {
  255. },
  256. /**
  257. * 生命周期函数--监听页面卸载
  258. */
  259. onUnload: function () {
  260. },
  261. /**
  262. * 页面相关事件处理函数--监听用户下拉动作
  263. */
  264. onPullDownRefresh: function () {
  265. },
  266. /**
  267. * 页面上拉触底事件的处理函数
  268. */
  269. onReachBottom: function () {
  270. },
  271. /**
  272. * 用户点击右上角分享
  273. */
  274. onShareAppMessage: function () {
  275. }
  276. })