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.

168 rivejä
4.9 KiB

  1. const app = getApp()
  2. const config = require("../../config/config")
  3. const Http = require("../../utils/HttpBasics.js")
  4. const navigationBarHeight = (getApp().statusBarHeight + 44)+"px"
  5. Page({
  6. data:{
  7. imgHttps:app.globalData.imgHttps,
  8. navigationBarHeight,
  9. id:"",//upid
  10. name:'',//upName
  11. indexFlog:2,//选着类别
  12. upData:{},//作者信息
  13. pageNum:1,
  14. classList:[],//课程列表
  15. dNum:"",//但课程数
  16. zNum:"",//专栏数
  17. addFlag: true,
  18. },
  19. hieaddCheck() {
  20. let animation = tt.createAnimation({
  21. duration: 1000,
  22. timingFunction: "ease",
  23. });
  24. animation.translateX(400).step()
  25. this.setData({
  26. // extraClasses: 'addBox-transition',
  27. showAddBox: animation.export(),
  28. addFlag: true
  29. })
  30. },
  31. showAddCheck: function () {
  32. this.setData({
  33. addFlag: false
  34. })
  35. let animation = tt.createAnimation({
  36. duration: 1000,
  37. timingFunction: "ease",
  38. });
  39. animation.translateX(0).step()
  40. this.setData({
  41. showAddBox: animation.export(),
  42. })
  43. },
  44. getClass(){//课程list
  45. Http.get({
  46. url:config.api.columnLsit,
  47. data:{
  48. merchantId:this.data.id,
  49. type:this.data.indexFlog,
  50. pageNum:this.data.pageNum,
  51. pageSize: 6
  52. }
  53. }).then(res=>{
  54. if(this.data.pageNum>1){
  55. let temp = this.data.classList
  56. temp.push(...res.data.list)
  57. this.setData({
  58. classList:temp
  59. })
  60. }else{
  61. this.setData({
  62. classList:res.data.list
  63. })
  64. }
  65. })
  66. },
  67. setIndex(e){
  68. let index = e.currentTarget.dataset.index
  69. console.log(index);
  70. this.setData({
  71. indexFlog:index,
  72. pageNum:1,
  73. classList:[]
  74. })
  75. this.getClass()
  76. },
  77. getUpData(){
  78. Http.get({
  79. url:config.api.getUpUser,
  80. data:{
  81. id:this.data.id
  82. }
  83. }).then(res=>{
  84. let temp = res.data
  85. let arr = JSON.parse(res.data.businessTypes)
  86. let sring = ""
  87. arr.map(item=>{
  88. sring += ' '+item.title
  89. })
  90. temp.sring = sring
  91. console.log(temp);
  92. this.setData({
  93. upData:temp
  94. })
  95. }).catch(err=>{
  96. tt.showToast({
  97. title: err.message, // 内容
  98. icon:"none"
  99. });
  100. })
  101. },
  102. onLoad(options){
  103. if(app.globalData.token){
  104. this.setData({
  105. id:options.id,
  106. name:options.name
  107. })
  108. this.getUpData()
  109. this.getClass()
  110. }else{
  111. app.tokenCallback = token =>{
  112. this.setData({
  113. id:options.id,
  114. name:options.name
  115. })
  116. this.getUpData()
  117. this.getClass()
  118. }
  119. }
  120. },
  121. onReachBottom() {
  122. console.log("到底了");
  123. this.setData({
  124. pageNum:this.data.pageNum+1
  125. })
  126. this.getClass()
  127. },
  128. onShow() {
  129. let animation = tt.createAnimation({
  130. duration: 0,
  131. // timingFunction: "ease",
  132. });
  133. animation.translateX(400).step()
  134. this.setData({
  135. showAddBox: animation.export(),
  136. screenFlag:false,//初始化防录屏弹框
  137. })
  138. // this.itiRecording()
  139. },
  140. onShareAppMessage: function (shareOption) {
  141. let that = this
  142. if (shareOption.channel == 'video') { // 判断是是不是分享视频
  143. return {
  144. channel: 'video', // 必写 video
  145. //     templateId: '',   // 分享的模版 id (如果未设置就是默认,下面会说如何设置)
  146. title: `知播堂-${that.data.upData.name}`,     // 分享的标题
  147. //     desc: '我是简介',     // 分享的内容介绍目前没有用
  148.     path: `/pages/UpHome/UpHome?id=${that.data.id}&name=${that.data.name}`,  // 分享的路径
  149. extra: {
  150. videoTopics: ["知播堂",] // 只有抖音才会有的属性
  151. },
  152. }
  153. } else { // 右上角分享
  154. return {
  155. templateId: '',         //分享的模版 id
  156. title: '',            //分享的标题
  157. desc: '',           // 分享的内容
  158. //      path: ``, // 分享的路径
  159. }
  160. }
  161. },
  162. })