123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940 |
- //index.js
- //获取应用实例
- // 获取授权登录
- import {
- getOpenidSessionKey
- } from '../../utils/httpUtil';
- // 不用获取授权登录
- import {
- getOpenidNoLogin
- } from '../../utils/httpUtilNoLogin';
- import {
- formatDate
- } from '../../utils/util';
- const app = getApp()
- import {
- hotInit
- } from '../../component/hot/hot';
- import {
- groupInit
- } from '../../component/group/group';
- import {
- myInit
- } from '../../component/my/my';
- import httpRequestApi from '../../utils/APIClient';
- import httputil from '../../utils/httpUtil';
- import {
- GetQueryString
- } from '../../utils/util';
- Page({
- data: {
- tab: [{
- name: '推荐',
- templates: 'recommend',
- },
- {
- name: '关注',
- templates: 'follow',
- },
- {
- name: '资源',
- templates: 'courses',
- },
- {
- name: '我的',
- templates: 'my',
- }
- ],
- winH: 568,
- statusBarHeight: getApp().globalData.statusBarHeight,
- myIndex: 0,
- followData: [],
- recommendPageNo: 1,
- recommendPageSize: 3,
- recommendTotalNo: 1,
- myData: {},
- templates: '',
- title: 'index中的title',
- jurisdictionFlag: true,
- hotInput: '12345',
- mineSettingInfo: '528',
- hide: true,
- isIOS: app.globalData.isIOS,
- ifHaveMore: true,
- indexSignDialog: false,
- indexMissionDialog: false,
- unfinishedCount: 0,
- videoList: [],
- nextMargin: '400rpx', // 视频下边距
- commentShow: false,
- commentList: [],
- commentNum: 0,
- followPageNo: 1,
- followPageSize: 6,
- coursePageNo: 1,
- coursesData: [],
- updateId: 0, // 刷新id
- statusbarobj: {
- isshowbtn: true, //是否显示按钮
- title: "小学语文朗读配音", //标题
- },
- grade: wx.getStorageSync('grade')
- },
- jurisdiction: function () {
- //隐藏弹框
- this.setData({
- hide: !this.data.hide
- })
- //登录页信息
- this.updateData(0)
- },
- //tab点击
- switcher: function ({
- currentTarget
- }) {
- if (currentTarget.dataset.index === this.data.myIndex) return;
- this.updateData(currentTarget.dataset.index);
- },
- // 根据index 更新template
- updateData: function (index) {
- let myIndex = index;
- this.setData({
- myIndex,
- });
- // 获取推荐列表
- if (myIndex == 0) {
- this.setData({
- recommendPageNo: 1,
- videoList: [],
- isSwiper: false
- }, () => {
- this.getHotRecommend(this.uid);
- })
- return;
- }
- /* 关注和我的需要登陆后查看 */
- if (!this.data.isLogin) {
- wx.navigateTo({
- url: `../../pages/login/login?index=${myIndex}`
- });
- return;
- }
- console.log('继续')
- // 刷新关注列表
- if (myIndex == 1) {
- this.setData({
- videoList: [],
- isSwiper: false,
- followPageNo: 1
- }, () => {
- this.getFollowData()
- })
- return;
- }
- // 刷新资源
- if (myIndex == 2) {
- this.setData({
- videoList: [],
- coursesData: [],
- templates: 'courses',
- coursePageNo: 1
- }, () => {
- this.getCoursesList();
- })
- return;
- }
- // 刷新我的
- if (myIndex == 3) {
- this.setData({
- videoList: [],
- templates: 'my',
- isSwiper: false
- }, () => {
- myInit(this);
- })
- return;
- }
- },
- showPage: function () {
- let options = this.data.options;
- console.log('this.data.workId', this.data.workId)
- if (this.data.workId) {
- // 需要在推荐第一个上插入一条分享或者刚朗读完数据
- let id = this.data.workId;
- this.setData({
- workId: null,
- myIndex: 0,
- videoList: [],
- isSwiper: false,
- recommendTotalNo: 1
- })
- httpRequestApi.getClassDetail(id).success(res => {
- console.log('有一条数据', res)
- let tempList = [];
- tempList.push(res.data.data);
- this.setData({
- videoList: [],
- isSwiper: false,
- recommendTotalNo: 1
- }, () => {
- this.formatWorksList(tempList, true);
- console.log('插入数据')
- // this.getHotRecommend();
- // return;
- })
- // this.showPage()
- })
- }
- if (options && options.index) {
- this.updateData(options.index)
- } else {
- console.log('又加载一边')
- this.updateData(0)
- }
- setTimeout(() => {
- if (wx.getStorageSync('uid')) {
- httpRequestApi.userLoginRecord().success(res => {
- if (res.data.data && res.data.data.length !== 0) {
- // 有数据弹签到
- if (this.data.unfinishedCount > 0) {
- this.setData({
- indexSignDialog: true
- })
- }
- } else {
- // 没数据弹任务
- let oldDay = wx.getStorageSync('oldDay');
- let newDate = new Date();
- let day = newDate.getDate() < 10 ? '0' + newDate.getDate() : newDate.getDate()
- let timeStep = (newDate.getMonth() + 1).toString() + day
- if (oldDay) {
- let temp = parseInt(timeStep) - parseInt(oldDay)
- if (temp > 0) {
- wx.setStorageSync('oldDay', timeStep);
- this.setData({
- indexMissionDialog: true
- })
- }
- } else {
- wx.setStorageSync('oldDay', timeStep);
- this.setData({
- indexMissionDialog: true
- })
- }
- }
- })
- }
- }, 2800)
- },
- onLoad: function (options) {
- console.log('onload', options);
- if (options.scene) {
- this.setData({
- workId: options.scene
- })
- }
- if (options.readId) {
- this.setData({
- workId: options.readId
- })
- }
- getOpenidNoLogin((res) => {
- console.log('getOpenidNoLogin', res)
- if (!res.data.data.grade) {
- // 没有年级的老用户
- if (res.data.data.wechatName) {
- this.setData({
- isGradeShow: true,
- options,
- isLogin: true,
- oldUser: true
- })
- return;
- }
- this.setData({
- isGradeShow: true,
- options,
- isLogin: false,
- workId: options.scene ? options.scene : options.readId ? options.readId : undefined
- })
- return
- } else {
- if (res.data.data.wechatName) {
- this.setData({
- isLogin: true
- }, () => {
- this.showPage();
- })
- }
- }
- // 登录或注册完成 展示页面
- }, (error) => {
- console.log('获取失败', error)
- });
- this.uid = wx.getStorageSync('uid');
- let grade = wx.getStorageSync('grade');
- // if (!this.uid || !grade) {
- // this.setData({
- // isGradeShow: true,
- // options
- // })
- // console.log('没有uid 也不是游客,需要去授权')
- // return;
- // }
- wx.getSystemInfo({
- success: (res) => {
- console.log('系统', res)
- console.log('nextMargin', res.pixelRatio)
- console.log('windowHeight', res.windowHeight)
- console.log('windowWidth', res.windowWidth)
- // let ratio = res.pixelRatio;
- let ratio = (res.screenHeight / res.screenWidth) * 1.1;
- console.log('比例系数', ratio)
- let winH = res.windowHeight * ratio;
- let x1 = 465 * ratio;
- let x2 = 603 * ratio;
- let minusNumber = (winH * x1) / x2;
- let nextMargin = parseInt(winH - minusNumber);
- app.globalData.nextMargin = nextMargin;
- this.setData({
- winH: winH,
- devicePixelRatio: res.pixelRatio,
- nextMargin: nextMargin + 'rpx'
- });
- }
- });
- },
- onShow: function () {
- if (this.data.myIndex === 3) {
- this.getUserWorksInfo(1)
- }
- wx.setNavigationBarTitle({
- title: '小学语文朗读配音'
- })
- console.log('页面返回页面返回', this.data.fromLoginIndex)
- if (this.data.fromLoginIndex) {
- console.log('页面返回页面返回', this.data.fromLoginIndex)
- let index = this.data.fromLoginIndex;
- let userInfo = wx.getStorageSync('user');
- this.setData({
- fromLoginIndex: null,
- isLogin: userInfo.wechatName ? true : false
- }, () => {
- this.updateData(0)
- })
- }
- if (this.data.fromReading) {
- this.setData({
- fromReading: false
- })
- this.updateData(3)
- }
- // const userInfo = wx.getStorageSync('user')
- // console.log('userInfo',userInfo)
- // if (userInfo.wechatName) {
- // this.setData({
- // isLogin: true
- // })
- // } else {
- // this.setData({
- // isLogin: false
- // })
- // }
- },
- onHide: function () {
- const str = 'hotData.inputFocus'
- this.setData({
- [str]: false
- });
- },
- /* 两个接口维护同一个数组,手动的结束后添加算法的 */
- // 推荐页信息 获取消息和手动推荐内容
- // 获取热门作品 算法出来的
- getHotRecommend: function () {
- let grade = wx.getStorageSync('grade')
- let pageNo = this.data.recommendPageNo;
- let pageSize = this.data.recommendPageSize;
- httpRequestApi.getHotRecommendSecond(grade, pageNo, pageSize).success(res => {
- console.log(res)
- const recommendRes = res.data.data.list;
- if (recommendRes.length === 0) return;
- // const recommendWorks = [];
- this.formatWorksList(recommendRes);
- })
- },
- // 组装list
- formatWorksList(list, notSet) {
- // const tempList = [];
- list.forEach((item, index) => {
- /* if (index === list.length - 2 && list.length > 2) {
- console.log('设置当前id', item.id)
- this.setData({
- updateId: item.userRead.id
- })
- } */
- const temp = {};
- temp.title = item.userRead.title;
- temp.summary = item.userRead.summary;
- temp.img = item.userRead.iconImg;
- temp.plays = item.userRead.playAmount ? item.userRead.playAmount : 0;
- temp.likes = item.userRead.likeAmount ? item.userRead.likeAmount : 0;
- temp.commentAmount = item.userRead.commentAmount ? item.userRead.commentAmount : 0;
- temp.classId = item.userRead.exampleId ? item.userRead.exampleId : 1605097720036046;
- temp.time = formatDate(item.userRead.gmtCreated, 3);
- temp.avatar = item.user.avatar;
- temp.profession = item.user.profession;
- temp.uid = item.user.uid;
- temp.url = item.userRead.videoPath ? item.userRead.videoPath : item.userRead.originVideo;
- temp.id = item.userRead.id;
- temp.type = item.userRead.type;
- temp.nickName = item.user.wechatName;
- temp.isLike = item.isLike;
- temp.isFans = item.isFans ? true : item.user.uid === this.uid ? true : false;
- temp.isFavorite = item.isFavorites;
- temp.isEfun = item.user.profession === '官方' ? true : false;
- temp.hasTag = item.userRead.tag && item.userRead.tag !== 'EXAMPLE' ? true : false;
- temp.tagUrl = item.userRead.tag ? item.userRead.tag === 'HOT' ? '../../static/index/hot_tag.png' : '../../static/index/new_tag.png' : ''
- temp.status = item.userRead.status;
- temp.coverImg = item.userRead.coverImg;
- temp.shareImg = item.userRead.shareImg;
- temp.grade = item.userRead.grade;
- temp.videoShow = false;
- this.data.videoList.push(temp);
- // tempList.push(temp);
- });
- console.log('当前list', this.data.videoList)
- // if (!notSet) {
- this.setData({
- videoList: this.data.videoList
- })
- // }
- },
- // 获取用户信息
- getUserWorksInfo: function (flag) {
- if (flag) {
- httpRequestApi.getUserWorksInfo().success(res => {
- const userInfo = this.formatGrade(res.data.data.user);
- const str = 'myData.userInfo.wechatName';
- const avatarStr = 'myData.userInfo.avatar';
- const gradeTextStr = 'myData.userInfo.gradeText';
- this.setData({
- [str]: userInfo.wechatName,
- [avatarStr]: userInfo.avatar,
- [gradeTextStr]: userInfo.gradeText
- })
- })
- return;
- }
- httpRequestApi.getUserWorksInfo().success(res => {
- this.data.myData.user = res.data.data;
- httpRequestApi.userIntoPage('pages/index/index', '首页我的').success((res) => {})
- if (res.data.data.myRead) {
- res.data.data.myRead.gmtCreated = formatDate(this.data.myData.user.myRead.gmtCreated, 4)
- }
- res.data.data.user = this.formatGrade(res.data.data.user);
- this.setData({
- myData: res.data.data,
- ['myData.userInfo']: res.data.data.user
- }, () => {
- this.getMyRead()
- });
- }).fail(error => {
- console.log(error)
- })
- },
- formatGrade(userInfo) {
- switch (userInfo.grade) {
- case 'PRESCHOOL':
- userInfo.gradeText = '学前班'
- break;
- case 'PRIMARY_FIRST_GRADE':
- userInfo.gradeText = '一年级'
- break;
- case 'PRIMARY_SECOND_GRADE':
- userInfo.gradeText = '二年级'
- break;
- case 'PRIMARY_THREE_GRADE':
- userInfo.gradeText = '三年级'
- break;
- case 'PRIMARY_SENIOR_GRADE':
- userInfo.gradeText = '四年级';
- break;
- }
- return userInfo;
- },
- videoChange: function (e) {
- if (e.detail.activeId === this.data.updateId) {
- console.log('应该刷新')
- if (this.data.myIndex === 1) {
- this.setData({
- followPageNo: this.data.followPageNo + 1
- }, () => {
- this.getFollowData()
- })
- }
- if (this.data.myIndex === 0) {
- console.log('首页加载第二页')
- this.setData({
- recommendPageNo: this.data.recommendPageNo + 1
- }, () => {
- this.getHotRecommend()
- })
- }
- }
- },
- // 触底加载
- onReachBottom: function () {
- if (this.data.myIndex === 2) {
- this.setData({
- coursePageNo: this.data.coursePageNo + 1
- }, () => {
- this.getCoursesList()
- })
- }
- if (this.data.myIndex === 1) {
- this.setData({
- followPageNo: this.data.followPageNo + 1
- }, () => {
- this.getFollowData()
- })
- }
- if (this.data.myIndex === 0) {
- console.log('首页加载第二页')
- this.setData({
- recommendPageNo: this.data.recommendPageNo + 1
- }, () => {
- this.getHotRecommend()
- })
- }
- // // 当前在推荐页面 加载推荐
- // if (this.data.myIndex === 1) {
- // console.log(this.data.recommendPageNo)
- // console.log(this.data.recommendTotalNo)
- // this.setData({
- // recommendPageNo: this.data.recommendPageNo + 1
- // })
- // if (this.data.recommendPageNo <= this.data.recommendTotalNo) {
- // this.getHotRecommendSecond(this.uid, this.data.recommendPageNo, 3);
- // } else {
- // console.log('没有更多')
- // }
- // }
- },
- onPullDownRefresh: function () {
- //当前在团购页下拉加载
- this.updateData(this.data.myIndex)
- wx.showNavigationBarLoading() //在标题栏中显示加载
- //模拟加载
- setTimeout(function () {
- wx.hideNavigationBarLoading() //完成停止加载
- wx.stopPullDownRefresh() //停止下拉刷新
- }, 1000);
- },
- goToMessage: function () {
- wx.navigateTo({
- url: `../../pages/social/insideMessage/insideMessage`
- });
- const str = 'hotData.unReadMessageNum';
- this.setData({
- [str]: 0
- })
- },
- toMyCollage: function (e) {
- if (app.globalData.isIOS) {
- wx.navigateTo({
- url: `../../pages/groupPage/my-group/my-group?title=我的助力`
- });
- } else {
- wx.navigateTo({
- url: `../../pages/groupPage/my-group/my-group?title=我的拼团`
- });
- }
- },
- toMyCourse: function () {
- wx.navigateTo({
- url: `../../pages/user/mycourse/mycourse?title=我的课程`
- });
- },
- goToFlower: function () {
- wx.navigateTo({
- url: `../../pages/social/littleFlower/littleFlower`
- });
- },
- signInBtn: function (e) {
- this.setData({
- indexSignDialog: false
- })
- console.log(e.detail.formId)
- httpRequestApi.postFormId(e.detail.formId).success(res => {
- console.log(res)
- })
- this.goToFlower();
- },
- missionBtn: function () {
- this.setData({
- indexMissionDialog: false
- })
- this.goToFlower();
- },
- getUserAuth: function () {
- httpRequestApi.getUserAuth().success(res => {
- console.log(res)
- const str = 'myData.isVIP'
- if (res.data.data) {
- this.setData({
- [str]: true
- })
- } else {
- this.setData({
- [str]: false
- })
- }
- })
- },
- delHideMyWork: function () {
- this.getMyRead()
- },
- // 获取我的朗读
- getMyRead: function () {
- httpRequestApi.myRead().success(res => {
- console.log(123123, res)
- console.log('mydata', this.data.myData)
- const myList = res.data.data;
- if (myList.length === 0) {
- this.setData({
- videoList: []
- })
- return
- }
- // this.formatWorksList(myList)
- // const recommendWorks = [];
- const myWorks = [];
- myList.forEach(item => {
- const temp = {};
- temp.title = item.userRead.title;
- temp.summary = item.userRead.summary;
- temp.img = item.userRead.iconImg;
- temp.plays = item.userRead.playAmount ? item.userRead.playAmount : 0;
- temp.likes = item.userRead.likeAmount ? item.userRead.likeAmount : 0;
- temp.commentAmount = item.userRead.commentAmount ? item.userRead.commentAmount : 0;
- temp.classId = item.userRead.exampleId ? item.userRead.exampleId : 1605097720036046;
- temp.time = formatDate(item.userRead.gmtCreated, 3);
- temp.avatar = item.user.avatar;
- temp.profession = item.user.profession;
- temp.uid = item.user.uid;
- temp.url = item.userRead.videoPath ? item.userRead.videoPath : item.userRead.originVideo;
- temp.id = item.userRead.id;
- temp.type = item.userRead.type;
- temp.nickName = item.user.wechatName;
- temp.isLike = item.isLike;
- temp.isFavorite = item.isFavorites;
- temp.showMyBtn = true;
- temp.nickName = this.data.myData.userInfo.wechatName;
- temp.status = item.userRead.status;
- temp.ifCheck = item.userRead.status === 'CHECK' ? true : false;
- temp.coverImg = item.userRead.coverImg;
- temp.grade = item.userRead.grade
- temp.isFans = true;
- temp.videoShow = false;
- temp.shareImg = item.userRead.shareImg;
- myWorks.push(temp);
- });
- console.log('myWorks', myWorks)
- if (this.data.myIndex === 3) {
- this.setData({
- videoList: myWorks
- })
- }
- })
- },
- // 评论区点击
- commentTap: function (e) {
- console.log('点击评论区', e)
- if (e.target.dataset.type === 'blank') {
- this.setData({
- commentShow: false
- })
- }
- },
- touchMove: function (e) {
- return
- },
- // 打开评论
- openComment: function (e) {
- //
- console.log('id', e.detail.activeId)
- this.setData({
- commentShow: !this.data.commentShow,
- commentId: e.detail.activeId,
- // commentList: []
- });
- // this.getReply(e.detail.activeId);
- },
- // 获取评论信息
- getReply: function (columnId) {
- // let columnId = this.data.id;
- console.log(123123123, columnId)
- // let pageNo = this.data.pageNo;
- // let pageSize = this.data.pageSize;
- httpRequestApi.getReply(this.uid, columnId, 1, 10).success((res) => {
- console.log('reply', res)
- const commentList = res.data.data.list;
- const commentNum = res.data.data.totalSize;
- console.log('评论数量', commentNum)
- commentList.forEach((item) => {
- const temp = {};
- temp.nickName = item.user.wechatName;
- temp.avatar = item.user.avatar;
- temp.uid = item.user.uid;
- temp.text = item.detailDesc;
- temp.id = item.id;
- temp.replyCount = item.replyCount;
- temp.time = formatDate(item.gmtCreated, 3);
- temp.likes = item.postsAttributeInfo.favors || 0;
- temp.isLike = item.isLike;
- temp.replyList = item.replyVOList;
- this.data.commentList.push(temp);
- });
- this.setData({
- commentList: this.data.commentList,
- commentNum: commentNum
- })
- });
- },
- // 发布回复
- sendReply: function (e) {
- console.log('triger', e.detail.content);
- let data = {
- columnId: this.data.commentId,
- colunmNames: 'what',
- detailDesc: e.detail.content,
- // productId: this.data.productId
- }
- httpRequestApi.postReply(this.uid, data).success(res => {
- console.log(res)
- this.setData({
- pageNo: 1,
- commentList: []
- }, () => {
- this.getReply(this.data.commentId);
- })
- });
- },
- gradeTap: function () {
- // console.log("组件回调,返回上一页");
- this.setData({
- isGradeShow: true
- })
- },
- onShareAppMessage: function (res) {
- console.log('点击分享按钮', res)
- console.log('点击分享按钮', this.data.shareTitle)
- console.log('点击分享按钮', this.data.shareId)
- console.log('点击分享按钮', this.data.shareImg)
- if (res.from === 'button') {
- return {
- title: '请欣赏我的课文朗读作品,点赞+评论。',
- path: `/pages/index/index?readId=${this.data.shareId}`,
- imageUrl: this.data.shareImg
- }
- } else {
- return {
- title: '课文朗读,从未如此有趣。',
- path: '/pages/index/index',
- }
- }
- },
- openShare: function (e) {
- console.log('用户点击分享按钮123', e)
- this.setData({
- shareTitle: e.detail.currentTarget.dataset.title,
- shareId: e.detail.currentTarget.dataset.id,
- shareImg: e.detail.currentTarget.dataset.shareimg
- })
- },
- // 修改年级
- changeGrade: function (e) {
- const grade = e.target.dataset.code;
- wx.setStorageSync('grade', grade)
- this.setData({
- isGradeShow: false,
- grade
- })
- if (this.data.oldUser) {
- let data = {
- grade: e.target.dataset.code
- };
- httpRequestApi.settingUserInfo(data).success(res => {
- })
- return;
- };
- getOpenidNoLogin((res) => {
- console.log('getOpenidNoLogin', res)
- // 登录或注册完成 展示页面
- if (res.data.data.wechatName) {
- this.setData({
- isLogin: true
- })
- } else {
- this.setData({
- isLogin: false
- })
- }
- this.showPage()
- }, (error) => {
- console.log('获取失败')
- wx.setStorageSync('userSourseType', 'normal')
- this.setData({
- hide: !this.data.hide
- })
- }, grade);
- },
- getFollowData: function () {
- httpRequestApi.getFollowWorks(this.data.followPageNo, this.data.followPageSize).success(res => {
- if (res.data.data.totalSize === 0) {
- this.setData({
- videoList: [],
- noFollow: true
- })
- console.log('没有关注人或关注的人没有发过作品')
- return
- } else {
- this.setData({
- noFollow: false
- })
- }
- console.log('关注列表', res)
- const followData = res.data.data.list;
- // const videoList = [];
- this.formatWorksList(followData);
- });
- },
- // 点击用户头像区域
- headTapHandler: function (e) {
- console.log('点击头像', e)
- let tapId = e.detail.activeId;
- // 点击头像既关注 测试
- httpRequestApi.followUser(this.uid, tapId).success(res => {
- console.log(res)
- })
- },
- getCoursesList: function () {
- const grade = wx.getStorageSync('grade');
- const data = {
- pageNo: this.data.coursePageNo,
- pageSize: 6,
- grade,
- type: 'EXAMPLE'
- };
- console.log('资源', data)
- httpRequestApi.getClassRead(data).success(res => {
- console.log('资源', this.data.coursesData)
- this.setData({
- coursesData: this.data.coursesData.concat(res.data.data.list)
- }, () => {
- console.log(this.data.coursesData)
- })
- })
- },
- goToReading: function (e) {
- console.log('去朗读', e)
- const id = e.detail.activeId ? e.detail.activeId : e.currentTarget.dataset.id;
- wx.navigateTo({
- url: `../../pages/reading/reading?id=${id}`
- });
- },
- courseCollectTap: function collectClass(e) {
- console.log('收藏按钮', e);
- const data = {
- targetCode: e.target.dataset.id ? e.target.dataset.id : e.currentTarget.dataset.id,
- favoritesType: e.target.dataset.type ? e.target.dataset.type : e.currentTarget.dataset.type
- }
- const index = e.target.dataset.index ? e.target.dataset.index : e.currentTarget.dataset.index;
- let str = `coursesData[${index}].isFavorites`
- httpRequestApi.collectClass(data).success((res) => {
- console.log('this.data.coursesData[index]', this.data.coursesData[index])
- this.setData({
- [str]: !this.data.coursesData[index].isFavorites
- })
- });
- },
- coursesOpenShare: function coursesOpenShare(e) {
- const obj = e.currentTarget.dataset
- console.log('分享', obj)
- console.log('分享', e)
- if (1) {
- this.shareDialog = this.selectComponent("#share-dialog");
- const data = {
- avatar: obj.avatar,
- author: obj.author,
- iconImg: obj.iconImg,
- title: obj.title,
- path: `pages/index/index`,
- scene: obj.id,
- productId: 1
- // tip: this.data.tip,
- }
- // console.log(data)
- this.setData({
- noScroll: 'noScroll',
- shareTitle: obj.title,
- shareId: obj.id,
- shareImg: obj.shareimg
- })
- this.shareDialog.share(data);
- }
- },
- collectTap: function (e) {
- console.log('点击收藏首页', e)
- const index = e.detail.index;
- let str = `videoList[${index}].isFavorite`
- this.setData({
- [str]: e.detail.isCollect
- })
- },
- likeTap: function (e) {
- console.log('点赞', e)
- const index = e.detail.index;
- let likeStr = `videoList[${index}].isLike`;
- let likeNumStr = `videoList[${index}].likes`;
- this.setData({
- [likeStr]: true,
- [likeNumStr]: this.data.videoList[index].likes + 1
- })
- },
- })
|