index.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. import {
  2. ApiModel
  3. } from "../../utils/api";
  4. const _Http = new ApiModel;
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. tabsList: ["私域直播", "展会直播"], //tabs列表
  11. tabsIndex: 0, //tabs下标
  12. accountStatus: null, //直播账号状态 1-账号正常 2-账号审核中 3-没有账号
  13. liveDataCount: {}, //实时数据统计
  14. liveSessionList: {}, //直播场次列表
  15. pageNumber: 1, //当前页码
  16. pageTotal: 1, //列表总页数
  17. },
  18. /**
  19. * 生命周期函数--监听页面加载
  20. */
  21. onLoad: function (options) {
  22. //获取直播详情
  23. _Http.basic({
  24. "accesstoken": wx.getStorageSync('userData').token,
  25. "classname": "customer.live.live",
  26. "method": "getSYLiveInfo",
  27. "content": {}
  28. }).then(res => {
  29. console.log(res)
  30. this.setData({
  31. accountStatus: res.code
  32. })
  33. switch (res.code) {
  34. case 1:
  35. this.setData({
  36. accountMsg: res.data[0]
  37. })
  38. /* 直播数据统计 */
  39. _Http.basic({
  40. "accesstoken": wx.getStorageSync('userData').token,
  41. "classname": "customer.live.live",
  42. "method": "getSYLiveDataCount",
  43. "content": {
  44. "channelid": res.data[0].channelid
  45. }
  46. }).then(res => {
  47. if (res.msg != '成功') return wx.showToast({
  48. title: res.data,
  49. icon: "none"
  50. });
  51. this.setData({
  52. liveDataCount: res.data
  53. })
  54. })
  55. /* 私域直播场次列表查询 */
  56. this.getSYLiveSessionList()
  57. break;
  58. case 2:
  59. console.log(2)
  60. break;
  61. case 3:
  62. console.log(3)
  63. break;
  64. default:
  65. wx.showToast({
  66. title: res.data,
  67. icon: "none"
  68. })
  69. }
  70. })
  71. },
  72. /* 私域直播场次列表查询 */
  73. getSYLiveSessionList() {
  74. _Http.basic({
  75. "accesstoken": wx.getStorageSync('userData').token,
  76. "classname": "customer.live.live",
  77. "method": "getSYLiveSessionList",
  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. buttonRightClick() {
  102. if (this.data.pageNumber == this.data.pageTotal) return wx.showToast({
  103. title: '已经到达最后一页',
  104. icon: "none"
  105. });
  106. this.setData({
  107. pageNumber: this.data.pageNumber + 1
  108. })
  109. this.getSYLiveSessionList()
  110. },
  111. /* 上一页 */
  112. buttonLifeClick() {
  113. if (this.data.pageNumber == 1) return wx.showToast({
  114. title: '已经在第一页了哦',
  115. icon: "none"
  116. });
  117. this.setData({
  118. pageNumber: this.data.pageNumber - 1
  119. })
  120. this.getSYLiveSessionList()
  121. },
  122. /* 申请直播账号 */
  123. applyForLive() {
  124. _Http.basic({
  125. "accesstoken": wx.getStorageSync('userData').token,
  126. "classname": "customer.live.live",
  127. "method": "applySYLive",
  128. "content": {}
  129. }).then(res => {
  130. console.log(res)
  131. if (res.code == 1) {
  132. wx.showToast({
  133. title: res.msg,
  134. icon: "none"
  135. })
  136. this.setData({
  137. accountStatus: 2
  138. })
  139. } else {
  140. if (res.data == '私域直播已申请') return wx.showModal({
  141. title: "提示",
  142. content: "您的私域直播账号正在申请中"
  143. })
  144. }
  145. })
  146. },
  147. /* tabs回调 */
  148. setIndex({
  149. detail
  150. }) {
  151. this.setData({
  152. tabsIndex: detail
  153. })
  154. },
  155. /* 复制地址 */
  156. copyTheAddress(e) {
  157. console.log(e)
  158. const {
  159. url
  160. } = e.target.dataset
  161. wx.setClipboardData({
  162. data: url,
  163. success(res) {
  164. wx.getClipboardData({
  165. success(res) {
  166. console.log('内容已复制') // data
  167. }
  168. })
  169. }
  170. })
  171. },
  172. /**
  173. * 生命周期函数--监听页面初次渲染完成
  174. */
  175. onReady: function () {
  176. },
  177. /**
  178. * 生命周期函数--监听页面显示
  179. */
  180. onShow: function () {
  181. },
  182. /**
  183. * 生命周期函数--监听页面隐藏
  184. */
  185. onHide: function () {
  186. },
  187. /**
  188. * 生命周期函数--监听页面卸载
  189. */
  190. onUnload: function () {
  191. },
  192. /**
  193. * 页面相关事件处理函数--监听用户下拉动作
  194. */
  195. onPullDownRefresh: function () {
  196. },
  197. /**
  198. * 页面上拉触底事件的处理函数
  199. */
  200. onReachBottom: function () {
  201. },
  202. /**
  203. * 用户点击右上角分享
  204. */
  205. onShareAppMessage: function () {
  206. }
  207. })