123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678 |
- import httpRequestApi from '../../../utils/APIClient';
- import {
- formatDate
- } from '../../../utils/util';
- import {
- getOpenidSessionKey
- } from '../../../utils/httpUtil';
- const app = getApp()
- Page({
- data: {
- fullScreenBtn: false,
- playBtn: true,
- gesture: false,
- author: '',
- videoSrc: '',
- total: '',
- authorAvatar: '',
- user: [],
- inputValue: '',
- inputSBValue: '',
- replyList: [],
- howMuch: '200',
- moneySelect: 'moneySelect',
- moneyNormal: 'moneyNormal',
- ifReward: false,
- id: '',
- path: '',
- replyModal: false,
- totalRead: 0,
- pageNo: 1,
- pageSize: 3,
- goBackHome: false,
- isIOS: app.globalData.isIOS,
- alertFlag: false,
- modalType: "text",
- noScroll: '',
- modalText: [{
- text: '您还不是本课程的会员',
- type: 'bigOrange'
- },
- {
- text: '您可以开团,拼团成功获得使用权',
- type: 'normal'
- }
- ],
- modalBtnText: '去开团',
- isModalShow: false,
- modalCloseShow: true,
- hide: true,
- addComeOut: ''
-
- },
- showAlert: function () {
- this.setData({
- alertFlag: !this.data.alertFlag
- })
- },
- onLoad: function (option) {
- console.log(option)
- if (option.count) {
- this.flowerBox = this.selectComponent("#flower-box");
- this.flowerBox.comeOut();
- }
- getOpenidSessionKey((res) => {
- let id = option.id ? option.id : option.scene.replace('QR', '')
- if (option.scene || option.shareCard) {
- this.setData({
- goBackHome: true
- })
- }
-
-
-
- this.uid = wx.getStorageSync('uid');
- let stackSize = 1;
- if (option.stackSize) {
- stackSize = option.stackSize;
- }
- this.setData({
-
- id,
- myUid: this.uid,
- stackSize
- })
- this.getWorks(this.uid, id);
- }, (error) => {
- this.setData({
- hide: !this.data.hide,
- onLoadOption: option
- })
- return;
- });
- },
- onHide: function () {
-
- if (this.innerAudioContext) {
- this.innerAudioContext.pause();
- }
- this.videoCtx = null
- },
- onUnload: function () {
- console.log(this.videoPlayTime)
- if (this.videoPlayTime) {
- const data = {
- "title": this.data.title,
- "lessonId": this.data.classId,
- "productId": this.data.productId,
- "playStopTime": this.videoPlayTime,
- "userReadId": this.data.userReadId,
- "type": 'READ',
- }
- httpRequestApi.playLogReport(data).success(res => {
- console.log(res)
- })
- }
- if (this.innerAudioContext) {
- this.innerAudioContext.destroy();
- }
- this.videoCtx = null
-
-
- },
- getWorks: function (uid, id) {
- httpRequestApi.getWorksDetail(uid, id).success((res) => {
- const others = res.data.data.otherRead;
- const author = res.data.data.user;
- const works = res.data.data.userRead;
- wx.setNavigationBarTitle({
- title: works.title
- })
- const othersTemp = [];
- others.forEach((item) => {
- const temp = {};
- temp.uid = item.userRead.id;
- temp.title = item.userRead.title;
- temp.image = item.user.avatar;
- temp.nickName = item.user.wechatName;
- othersTemp.push(temp);
- });
- this.setData({
- user: othersTemp,
- totalRead: res.data.data.totalRead,
- author: author.wechatName,
- authorAvatar: author.avatar,
- authorProfession: author.profession,
- authorUid: author.uid,
- videoSrc: works.originVideo,
- audioSrc: works.audioPath,
- iconImg: works.iconImg,
- classId: works.lessonId,
- isLike: res.data.data.isLike,
- isFans: res.data.data.isFans,
- title: works.title,
- userReadId: works.id
- })
- httpRequestApi.checkLesson(works.lessonId).success(res => {
- const productId = res.data.data[0];
- this.setData({
- productId
- })
- });
-
- this.innerAudioContext = wx.createInnerAudioContext();
- this.innerAudioContext.onPause((res) => {
-
- console.log('音频暂停')
- })
- this.innerAudioContext.src = this.data.audioSrc;
- });
- },
- onShow() {
- console.log(this.data.stackSize)
- this.setData({
- replyList: [],
- pageNo: 1,
- pageSize: 2
- }, () => {
- this.getReply();
- })
- },
- videoPlayHandler: function () {
- this.setData({
- videoLoad: true
- }, () => {
- this.videoCtx = wx.createVideoContext('worksVideo', this);
- this.videoCtx.play();
- })
- },
- likeWorks: function (e) {
-
- this.setData({
- addComeOut: 'add-one-come-out'
- })
- setTimeout(() => {
- if (this.data.addComeOut) {
- this.setData({
- addComeOut: ''
- })
- }
- }, 1200)
-
- if (this.data.isLike) {
-
-
-
-
-
- return;
- }
- httpRequestApi.likeWorks(this.uid, this.data.id).success(res => {
- this.setData({
- isLike: true
- });
- })
- },
-
- openShare: function (e) {
- if (this.data.authorAvatar && this.data.author && this.data.iconImg && this.data.title && this.data.id) {
- this.shareDialog = this.selectComponent("#share-dialog");
- const data = {
- avatar: this.data.authorAvatar,
- author: this.data.author,
- iconImg: this.data.iconImg,
- title: this.data.title,
- path: `pages/social/works/works`,
- scene: this.data.id,
- productId: this.data.productId
-
- }
-
- this.setData({
- noScroll: 'noScroll'
- })
- this.shareDialog.share(data);
- }
- },
-
- shareDialogClose: function (e) {
- this.setData({
- noScroll: ''
- })
- },
- videoPlay: function () {
-
-
-
-
-
-
-
-
-
- this.innerAudioContext.play();
-
-
-
-
- },
-
- videoEnd: function (e) {
- console.log(e)
- this.innerAudioContext.stop();
- },
- videoPause: function () {
- console.log('视频暂停')
- this.innerAudioContext.pause();
- },
- videoWaiting: function () {
- console.log('视频缓冲')
- this.innerAudioContext.pause();
- },
- videoProgress: function (e) {
- console.log('视频加载进度变化')
- console.log(e)
- if (e.detail.buffered <= 10) {
- this.innerAudioContext.pause();
- } else {
- this.innerAudioContext.play();
- }
- },
- videoTimeupdate: function (e) {
- console.log('视频播放进度发生变化')
- console.log('视频当前时长', e.detail.currentTime);
- this.videoPlayTime = e.detail.currentTime
- console.log('音频当前时长', this.innerAudioContext.currentTime)
- if (e.detail.currentTime - this.innerAudioContext.currentTime >= 1) {
- this.innerAudioContext.seek(e.detail.currentTime - 0.1);
- }
- },
- goToReading: function () {
- const classId = this.data.classId;
- httpRequestApi.areYouSuper(this.data.productId).success(res => {
- if (res.data.success) {
- wx.navigateTo({
- url: `../../main/reading/reading?id=${classId}`
- })
- } else {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- console.log('chulaiba')
- this.setData({
- isModalShow: true
- })
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- })
- },
- onShareAppMessage: function () {
- console.log(this.data.productId);
- const data = {
- shareTypeEnum: 'LINK',
- shareContentEnum: 'READ',
- productId: this.data.productId
- }
- httpRequestApi.shareRecord(data).success((res) => {
- console.log(res)
- })
- return {
- title: '一样的课文,不一样的味道!我的配音表演已开始,求各位大咖围观、点评!',
- path: `pages/social/works/works?id=${this.data.id}&title=${this.data.title}&shareCard=true`,
- imageUrl: `https://efunbox.lingjiao.cn/reader/resource/share/read_${this.data.productId}.jpg`,
- }
- },
- follow: function () {
- let followUid = this.data.authorUid;
- if (this.data.isFans) {
- httpRequestApi.cancerFollow(this.uid, followUid).success((res) => {
- this.setData({
- isFans: false
- })
- wx.showToast({
- title: '取消关注',
- icon: 'success',
- duration: 1000
- })
- });
- } else {
- httpRequestApi.followUser(this.uid, followUid).success((res) => {
- this.setData({
- isFans: true
- })
- wx.showToast({
- title: '关注啦',
- icon: 'success',
- duration: 1000
- })
- });
- }
- },
-
- likeCommend: function (e) {
- console.log(e);
-
- let followUid = e.currentTarget.dataset.id;
- let index = e.currentTarget.dataset.index;
- httpRequestApi.likeCommend(this.uid, followUid).success(res => {
- console.log(res);
- const str = `replyList[${index}].likes`;
- const strImg = `replyList[${index}].isLike`;
- this.setData({
- [str]: res.data.data.favors,
- [strImg]: true
- })
- });
- },
-
- goToUsers: function (e) {
- let uid = e.currentTarget.dataset.uid;
- wx.navigateTo({
- url: `../../user/myworks/myworks?uid=${uid}`
- });
- },
-
- goToOthers: function (e) {
- this.data.stackSize++;
- console.log(this.data.stackSize)
- if (this.data.stackSize >= 3) {
- console.log('跳转', this.data.stackSize)
- wx.redirectTo({
- url: `../../social/works/works?id=${e.currentTarget.dataset.uid}&title=${e.currentTarget.dataset.title}&stackSize=${this.data.stackSize}`
- })
- } else {
- console.log('下一个页面', this.data.stackSize)
- wx.navigateTo({
- url: `../../social/works/works?id=${e.currentTarget.dataset.uid}&title=${e.currentTarget.dataset.title}&stackSize=${this.data.stackSize}`
- })
- }
- },
-
- getReply: function () {
-
- let columnId = this.data.id;
- let pageNo = this.data.pageNo;
- let pageSize = this.data.pageSize;
- httpRequestApi.getReply(this.uid, columnId, pageNo, pageSize).success((res) => {
- const replyList = res.data.data.list;
-
- replyList.forEach((item) => {
- const temp = {};
- temp.nickName = item.user.wechatName;
- temp.avatar = item.user.avatar;
- temp.profession = item.user.profession;
- 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;
- this.data.replyList.push(temp);
- });
- this.setData({
- replyList: this.data.replyList,
- total: res.data.data.totalSize,
- totalPage: res.data.data.totalNo
- })
- });
- },
-
- goToDetail: function (e) {
- let id = e.currentTarget.dataset.id;
-
- wx.navigateTo({
- url: `../../social/replyDetail/replyDetail?id=${id}&productId=${this.data.productId}`
- })
- },
-
- inputValue: function (e) {
- this.setData({
- inputValue: e.detail.value
- });
- },
-
- sendHandler: function () {
- console.log(this.data.productId)
- if (this.data.inputValue !== '') {
-
- let data = {
- "columnId": this.data.id,
- colunmNames: 'what',
-
- "detailDesc": this.data.inputValue,
- productId: this.data.productId
- }
- httpRequestApi.postReply(this.uid, data).success(res => {
- this.setData({
- inputValue: '',
- pageNo: 1,
- replyList: [],
- })
- this.getReply();
- });
-
- }
- },
-
- onReachBottom: function () {
-
- if (this.data.pageNo <= this.data.totalPage) {
- this.setData({
- pageNo: this.data.pageNo + 1
- }, () => {
- this.getReply();
- })
- }
- },
-
- setSBId: function (e) {
- this.setData({
- replySBId: e.currentTarget.dataset.id,
- replyModal: true,
- replyIndex: e.currentTarget.dataset.index
- })
- },
-
- replySB: function () {
- const data = {
- postsId: this.data.replySBId,
- content: this.data.inputSBValue,
- productId: this.data.productId
- }
- httpRequestApi.postReplyComment(this.uid, data).success(res => {
- const replyWho = this.data.replyList[this.data.replyIndex];
- const indexStr = `replyList[${this.data.replyIndex}]`;
- replyWho.replyCount++;
- this.setData({
- replyModal: false,
- [indexStr]: replyWho
- })
- });
- },
-
- inputSBValue: function (e) {
- this.setData({
- inputSBValue: e.detail.value
- });
- },
-
- setMoney: function (e) {
- this.setData({
- howMuch: e.currentTarget.dataset.money
- })
- },
- reward: function () {
- if (this.data.isIOS) {
- return
- };
- this.setData({
- ifReward: true
- })
- },
- quitReward: function () {
- this.setData({
- ifReward: false
- })
- },
-
- rewardMoney: function () {
- const data = {
- targetUid: this.data.authorUid,
- amount: this.data.howMuch
- }
-
- httpRequestApi.rewardMoney(this.uid, data).success(res => {
- if (res.data.message) {
- wx.showModal({
- title: '提示',
- content: res.data.message,
- success(res) {
- if (res.confirm) {
- console.log('用户点击确定')
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- return false;
- }
- this.payMoney(res.data.data);
- })
- },
-
- payMoney: function (orderInfo) {
- if (this.data.haveTapMoney) {
- return false
- }
- this.setData({
- haveTapMoney: true
- })
- wx.requestPayment({
- 'appId': orderInfo.appId,
- 'timeStamp': orderInfo.timeStamp,
- 'nonceStr': orderInfo.nonceStr,
- 'package': orderInfo.package,
- 'signType': orderInfo.signType,
- 'paySign': orderInfo.sign,
- 'success': res => {
- this.setData({
- modalType: 'image',
- isModalShow: true,
- modalCloseShow: false,
- modalBtnText: '确定',
- haveTapMoney: false,
- ifReward: false
- })
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- },
- 'fail': res => {
- this.setData({
- haveTapMoney: false,
- })
- console.log('支付失败', res)
- }
- })
- },
-
- goBackHome: function () {
- wx.redirectTo({
- url: '../../index/index'
- })
- },
- modalConfirmHandler: function () {
- if (this.data.modalType === 'image') {
- this.setData({
- modalType: 'text',
- isModalShow: false,
- ifReward: false,
- modalCloseShow: true,
- modalBtnText: "去开团",
-
- })
- return false
- }
- this.setData({
- isModalShow: false
- })
- wx.navigateTo({
- url: `../../groupPage/grade-details/grade-details?productId=${this.data.productId}`
- })
- },
- modalCloseHandler: function () {
- this.setData({
- isModalShow: false
- })
- },
- jurisdiction: function () {
-
- this.setData({
- hide: !this.data.hide
- })
-
- this.onLoad(this.data.onLoadOption);
- },
- goToClass: function () {
- wx.navigateTo({
- url: `../../main/class/class?id=${this.data.classId}`
- })
- }
- })
|