|
@@ -91,14 +91,15 @@ Page({
|
|
|
payPrice: '',
|
|
|
iphoneType: '',
|
|
|
isVip: null,
|
|
|
- isIos: null
|
|
|
+ isIos: null,
|
|
|
+ temporaryGrade: null
|
|
|
},
|
|
|
- jurisdiction: function () {
|
|
|
+ jurisdiction: function() {
|
|
|
//隐藏弹框
|
|
|
this.setData({
|
|
|
- hide: !this.data.hide
|
|
|
- })
|
|
|
- //登录页信息
|
|
|
+ hide: !this.data.hide
|
|
|
+ })
|
|
|
+ //登录页信息
|
|
|
this.updateData(0)
|
|
|
},
|
|
|
// 隐藏升级弹窗
|
|
@@ -108,19 +109,19 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
jumpMy() {
|
|
|
- wx.reLaunch({
|
|
|
- url: `/pages/my/index`
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pages/my/index'
|
|
|
});
|
|
|
},
|
|
|
//tab点击
|
|
|
- switcher: function ({
|
|
|
+ switcher: function({
|
|
|
currentTarget
|
|
|
}) {
|
|
|
if (currentTarget.dataset.index === this.data.myIndex) return;
|
|
|
this.updateData(currentTarget.dataset.index);
|
|
|
},
|
|
|
// 根据index 更新template
|
|
|
- updateData: function (index) {
|
|
|
+ updateData: function(index) {
|
|
|
let myIndex = parseInt(index);
|
|
|
this.setData({
|
|
|
myIndex,
|
|
@@ -151,7 +152,7 @@ Page({
|
|
|
}
|
|
|
|
|
|
console.log('继续')
|
|
|
- // 刷新关注列表
|
|
|
+ // 刷新关注列表
|
|
|
if (myIndex == 1) {
|
|
|
this.setData({
|
|
|
videoList: [],
|
|
@@ -188,7 +189,7 @@ Page({
|
|
|
return;
|
|
|
}
|
|
|
},
|
|
|
- showPage: function () {
|
|
|
+ showPage: function() {
|
|
|
let options = this.data.options;
|
|
|
if (this.data.workId) {
|
|
|
// 需要在推荐第一个上插入一条分享或者刚朗读完数据
|
|
@@ -261,18 +262,14 @@ Page({
|
|
|
}
|
|
|
}, 2800)
|
|
|
},
|
|
|
- onLoad: function (options) {
|
|
|
+ onLoad: function(options) {
|
|
|
this.setData({
|
|
|
isIos: app.globalData.isIOS
|
|
|
})
|
|
|
- console.log('onload', options);
|
|
|
if (options.tabbarIndx) {
|
|
|
this.updateData(options.tabbarIndx);
|
|
|
}
|
|
|
if (options.scene) {
|
|
|
- // this.setData({
|
|
|
- // workId: options.scene
|
|
|
- // })
|
|
|
let optionsStr = decodeURIComponent(options.scene);
|
|
|
let optionsArr = optionsStr.split('&');
|
|
|
// 暂时这样写
|
|
@@ -284,8 +281,6 @@ Page({
|
|
|
options.readId = optionsArr[0];
|
|
|
options.activity = optionsArr[1];
|
|
|
}
|
|
|
-
|
|
|
- console.log('整理后options', options)
|
|
|
}
|
|
|
if (options.readId) {
|
|
|
this.setData({
|
|
@@ -304,26 +299,28 @@ Page({
|
|
|
this.setData({
|
|
|
iphoneType: options.type || ''
|
|
|
})
|
|
|
+ console.log('onload', options);
|
|
|
+ let shareUid = options.uid
|
|
|
getOpenidNoLogin((res) => {
|
|
|
console.log('getOpenidNoLogin', res)
|
|
|
- /**获取权限和订单信息 */
|
|
|
- // 获取商品信息
|
|
|
+ /**获取权限和订单信息 */
|
|
|
+ // 获取商品信息
|
|
|
httpRequestApi.getProductActivity().success(res => {
|
|
|
- wx.setStorageSync('price', res.data.data.price / 100)
|
|
|
- wx.setStorageSync('productId', res.data.data.id)
|
|
|
- if (options.type && options.type === 'iphone') {
|
|
|
- this.setData({
|
|
|
- payPrice: res.data.data.price / 100
|
|
|
- })
|
|
|
- }
|
|
|
- }).fail(error => {
|
|
|
- console.log(error)
|
|
|
- })
|
|
|
- // 获取用户权限
|
|
|
+ wx.setStorageSync('price', res.data.data.price / 100)
|
|
|
+ wx.setStorageSync('productId', res.data.data.id)
|
|
|
+ if (options.type && options.type === 'iphone') {
|
|
|
+ this.setData({
|
|
|
+ payPrice: res.data.data.price / 100
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).fail(error => {
|
|
|
+ console.log(error)
|
|
|
+ })
|
|
|
+ // 获取用户权限
|
|
|
this.getHelpAuth()
|
|
|
if (!res.data.data.grade) {
|
|
|
// 没有年级的老用户
|
|
|
- if (res.data.data.wechatName) {
|
|
|
+ if (res.data.data.nickName) {
|
|
|
this.setData({
|
|
|
isGradeShow: true,
|
|
|
options,
|
|
@@ -340,7 +337,7 @@ Page({
|
|
|
})
|
|
|
return
|
|
|
} else {
|
|
|
- if (res.data.data.wechatName) {
|
|
|
+ if (res.data.data.nickName) {
|
|
|
this.setData({
|
|
|
isLogin: true
|
|
|
}, () => {
|
|
@@ -351,10 +348,21 @@ Page({
|
|
|
this.showPage();
|
|
|
}
|
|
|
}
|
|
|
- // 登录或注册完成 展示页面
|
|
|
- }, (error) => {
|
|
|
- console.log('获取失败', error)
|
|
|
- });
|
|
|
+ // 获取商品信息
|
|
|
+ httpRequestApi.getProductActivity().success(res => {
|
|
|
+ wx.setStorageSync('price', res.data.data.price / 100)
|
|
|
+ wx.setStorageSync('productId', res.data.data.id)
|
|
|
+ if (options.type && options.type === 'iphone') {
|
|
|
+ this.setData({
|
|
|
+ payPrice: res.data.data.price / 100
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).fail(error => {
|
|
|
+ console.log(error)
|
|
|
+ })
|
|
|
+ // 获取用户权限
|
|
|
+ this.getHelpAuth()
|
|
|
+ }, () => {}, shareUid);
|
|
|
this.uid = wx.getStorageSync('uid');
|
|
|
if (options.sid) {
|
|
|
httpRequestApi.getUserRec(options.sid).success(res => {
|
|
@@ -366,27 +374,18 @@ Page({
|
|
|
}
|
|
|
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'
|
|
|
-
|
|
|
});
|
|
|
-
|
|
|
}
|
|
|
});
|
|
|
},
|
|
@@ -418,7 +417,7 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- onShow: function () {
|
|
|
+ onShow: function() {
|
|
|
let grade = wx.getStorageSync('grade');
|
|
|
this.setData({
|
|
|
gradeActivity: grade
|
|
@@ -437,7 +436,7 @@ Page({
|
|
|
let userInfo = wx.getStorageSync('user');
|
|
|
this.setData({
|
|
|
fromLoginIndex: null,
|
|
|
- isLogin: userInfo.wechatName ? true : false
|
|
|
+ isLogin: userInfo.nickName ? true : false
|
|
|
}, () => {
|
|
|
this.updateData(index)
|
|
|
})
|
|
@@ -458,7 +457,7 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- onHide: function () {
|
|
|
+ onHide: function() {
|
|
|
const str = 'hotData.inputFocus'
|
|
|
this.setData({
|
|
|
[str]: false
|
|
@@ -467,7 +466,7 @@ Page({
|
|
|
/* 两个接口维护同一个数组,手动的结束后添加算法的 */
|
|
|
// 推荐页信息 获取消息和手动推荐内容
|
|
|
// 获取热门作品 算法出来的
|
|
|
- getHotRecommend: function () {
|
|
|
+ getHotRecommend: function() {
|
|
|
let grade = wx.getStorageSync('grade')
|
|
|
let pageNo = this.data.recommendPageNo;
|
|
|
let pageSize = this.data.recommendPageSize;
|
|
@@ -519,7 +518,7 @@ Page({
|
|
|
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.nickName = item.user.nickName;
|
|
|
temp.isLike = item.isLike;
|
|
|
temp.isFans = item.isFans ? true : item.user.uid === this.uid ? true : false;
|
|
|
temp.isFavorite = item.isFavorites;
|
|
@@ -536,23 +535,23 @@ Page({
|
|
|
// tempList.push(temp);
|
|
|
});
|
|
|
console.log('当前list', this.data.videoList)
|
|
|
- // if (!notSet) {
|
|
|
+ // if (!notSet) {
|
|
|
this.setData({
|
|
|
- videoList: this.data.videoList
|
|
|
- })
|
|
|
- // }
|
|
|
+ videoList: this.data.videoList
|
|
|
+ })
|
|
|
+ // }
|
|
|
|
|
|
},
|
|
|
// 获取用户信息
|
|
|
- getUserWorksInfo: function (flag) {
|
|
|
+ getUserWorksInfo: function(flag) {
|
|
|
if (flag) {
|
|
|
httpRequestApi.getUserWorksInfo().success(res => {
|
|
|
const userInfo = this.formatGrade(res.data.data.user);
|
|
|
- const str = 'myData.userInfo.wechatName';
|
|
|
+ const str = 'myData.userInfo.nickName';
|
|
|
const avatarStr = 'myData.userInfo.avatar';
|
|
|
const gradeTextStr = 'myData.userInfo.gradeText';
|
|
|
this.setData({
|
|
|
- [str]: userInfo.wechatName,
|
|
|
+ [str]: userInfo.nickName,
|
|
|
[avatarStr]: userInfo.avatar,
|
|
|
[gradeTextStr]: userInfo.gradeText
|
|
|
})
|
|
@@ -598,7 +597,7 @@ Page({
|
|
|
}
|
|
|
return userInfo;
|
|
|
},
|
|
|
- videoChange: function (e) {
|
|
|
+ videoChange: function(e) {
|
|
|
if (e.detail.activeId === this.data.updateId) {
|
|
|
console.log('应该刷新')
|
|
|
if (this.data.myIndex === 1) {
|
|
@@ -621,7 +620,7 @@ Page({
|
|
|
|
|
|
},
|
|
|
// 触底加载
|
|
|
- onReachBottom: function () {
|
|
|
+ onReachBottom: function() {
|
|
|
if (this.data.myIndex === 2) {
|
|
|
this.setData({
|
|
|
coursePageNo: this.data.coursePageNo + 1
|
|
@@ -661,17 +660,17 @@ Page({
|
|
|
// }
|
|
|
|
|
|
},
|
|
|
- onPullDownRefresh: function () {
|
|
|
+ onPullDownRefresh: function() {
|
|
|
//当前在团购页下拉加载
|
|
|
this.updateData(this.data.myIndex)
|
|
|
wx.showNavigationBarLoading() //在标题栏中显示加载
|
|
|
- //模拟加载
|
|
|
- setTimeout(function () {
|
|
|
+ //模拟加载
|
|
|
+ setTimeout(function() {
|
|
|
wx.hideNavigationBarLoading() //完成停止加载
|
|
|
wx.stopPullDownRefresh() //停止下拉刷新
|
|
|
}, 1000);
|
|
|
},
|
|
|
- goToMessage: function () {
|
|
|
+ goToMessage: function() {
|
|
|
wx.navigateTo({
|
|
|
url: `../../pages/social/insideMessage/insideMessage`
|
|
|
});
|
|
@@ -681,10 +680,10 @@ Page({
|
|
|
[str]: 0
|
|
|
})
|
|
|
},
|
|
|
- goToService: function () {
|
|
|
+ goToService: function() {
|
|
|
httpRequestApi.userEvent('SERVICE');
|
|
|
},
|
|
|
- toMyCollage: function (e) {
|
|
|
+ toMyCollage: function(e) {
|
|
|
if (app.globalData.isIOS) {
|
|
|
wx.navigateTo({
|
|
|
url: `../../pages/groupPage/my-group/my-group?title=我的助力`
|
|
@@ -696,19 +695,19 @@ Page({
|
|
|
}
|
|
|
|
|
|
},
|
|
|
- toMyCourse: function () {
|
|
|
+ toMyCourse: function() {
|
|
|
wx.navigateTo({
|
|
|
url: `../../pages/user/mycourse/mycourse?title=我的课程`
|
|
|
});
|
|
|
},
|
|
|
- goToFlower: function () {
|
|
|
+ goToFlower: function() {
|
|
|
wx.navigateTo({
|
|
|
url: `../../pages/social/littleFlower/littleFlower`
|
|
|
});
|
|
|
httpRequestApi.userEvent('INTEGRAL');
|
|
|
|
|
|
},
|
|
|
- signInBtn: function (e) {
|
|
|
+ signInBtn: function(e) {
|
|
|
this.setData({
|
|
|
indexSignDialog: false
|
|
|
})
|
|
@@ -718,13 +717,13 @@ Page({
|
|
|
})
|
|
|
this.goToFlower();
|
|
|
},
|
|
|
- missionBtn: function () {
|
|
|
+ missionBtn: function() {
|
|
|
this.setData({
|
|
|
indexMissionDialog: false
|
|
|
})
|
|
|
this.goToFlower();
|
|
|
},
|
|
|
- getUserAuth: function () {
|
|
|
+ getUserAuth: function() {
|
|
|
httpRequestApi.getUserAuth().success(res => {
|
|
|
console.log(res)
|
|
|
const str = 'myData.isVIP'
|
|
@@ -739,11 +738,11 @@ Page({
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- delHideMyWork: function () {
|
|
|
+ delHideMyWork: function() {
|
|
|
this.getMyRead()
|
|
|
},
|
|
|
// 获取我的朗读
|
|
|
- getMyRead: function () {
|
|
|
+ getMyRead: function() {
|
|
|
httpRequestApi.myRead().success(res => {
|
|
|
console.log(123123, res)
|
|
|
console.log('mydata', this.data.myData)
|
|
@@ -776,11 +775,11 @@ Page({
|
|
|
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.nickName = item.user.nickName;
|
|
|
temp.isLike = item.isLike;
|
|
|
temp.isFavorite = item.isFavorites;
|
|
|
temp.showMyBtn = true;
|
|
|
- temp.nickName = this.data.myData.userInfo.wechatName;
|
|
|
+ temp.nickName = this.data.myData.userInfo.nickName;
|
|
|
temp.status = item.userRead.status;
|
|
|
temp.ifCheck = item.userRead.status === 'CHECK' ? true : false;
|
|
|
temp.coverImg = item.userRead.coverImg;
|
|
@@ -801,7 +800,7 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
// 评论区点击
|
|
|
- commentTap: function (e) {
|
|
|
+ commentTap: function(e) {
|
|
|
console.log('点击评论区', e)
|
|
|
if (e.target.dataset.type === 'blank') {
|
|
|
if (this.data.commentShow && this.data.commentId) {
|
|
@@ -818,11 +817,11 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- touchMove: function (e) {
|
|
|
+ touchMove: function(e) {
|
|
|
return
|
|
|
},
|
|
|
// 打开评论
|
|
|
- openComment: function (e) {
|
|
|
+ openComment: function(e) {
|
|
|
//
|
|
|
console.log('id', e.detail.activeId)
|
|
|
console.log('id', e)
|
|
@@ -830,17 +829,17 @@ Page({
|
|
|
commentShow: !this.data.commentShow,
|
|
|
commentId: e.detail.activeId,
|
|
|
commentIndex: e.detail.activeIndex
|
|
|
- // commentList: []
|
|
|
+ // commentList: []
|
|
|
});
|
|
|
// this.getReply(e.detail.activeId);
|
|
|
},
|
|
|
// 获取评论信息
|
|
|
- getReply: function (columnId) {
|
|
|
+ getReply: function(columnId) {
|
|
|
debugger
|
|
|
// let columnId = this.data.id;
|
|
|
console.log(123123123, columnId)
|
|
|
- // let pageNo = this.data.pageNo;
|
|
|
- // let pageSize = this.data.pageSize;
|
|
|
+ // 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;
|
|
@@ -848,7 +847,7 @@ Page({
|
|
|
console.log('评论数量', commentNum)
|
|
|
commentList.forEach((item) => {
|
|
|
const temp = {};
|
|
|
- temp.nickName = item.user.wechatName;
|
|
|
+ temp.nickName = item.user.nickName;
|
|
|
temp.avatar = item.user.avatar;
|
|
|
temp.uid = item.user.uid;
|
|
|
temp.text = item.detailDesc;
|
|
@@ -867,7 +866,7 @@ Page({
|
|
|
});
|
|
|
},
|
|
|
// 发布回复
|
|
|
- sendReply: function (e) {
|
|
|
+ sendReply: function(e) {
|
|
|
console.log('triger', e.detail.content);
|
|
|
let data = {
|
|
|
columnId: this.data.commentId,
|
|
@@ -885,13 +884,13 @@ Page({
|
|
|
})
|
|
|
});
|
|
|
},
|
|
|
- gradeTap: function () {
|
|
|
+ gradeTap: function() {
|
|
|
// console.log("组件回调,返回上一页");
|
|
|
this.setData({
|
|
|
isGradeShow: true
|
|
|
})
|
|
|
},
|
|
|
- onShareAppMessage: function (res) {
|
|
|
+ onShareAppMessage: function(res) {
|
|
|
if (res.from === 'button') {
|
|
|
return {
|
|
|
title: '请欣赏我的课文朗读作品,点赞+评论。',
|
|
@@ -905,21 +904,40 @@ Page({
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- openShare: function (e) {
|
|
|
+ openShare: function(e) {
|
|
|
console.log('点击分享', e)
|
|
|
+ /* this.setData({
|
|
|
+ shareTitle: e.detail.currentTarget.dataset.title,
|
|
|
+ shareId: e.detail.currentTarget.dataset.id,
|
|
|
+ shareImg: e.detail.currentTarget.dataset.shareimg,
|
|
|
+ goToShare: true,
|
|
|
+ ifTapActivity: e.detail.currentTarget.dataset.activity
|
|
|
+ }) */
|
|
|
+ },
|
|
|
+ // 选择年纪
|
|
|
+ selectGrade({
|
|
|
+ target
|
|
|
+ }) {
|
|
|
+ let code = target.dataset.code
|
|
|
+ if (!code) {
|
|
|
+ return
|
|
|
+ }
|
|
|
this.setData({
|
|
|
- shareTitle: e.detail.currentTarget.dataset.title,
|
|
|
- shareId: e.detail.currentTarget.dataset.id,
|
|
|
- shareImg: e.detail.currentTarget.dataset.shareimg,
|
|
|
- goToShare: true,
|
|
|
- ifTapActivity: e.detail.currentTarget.dataset.activity
|
|
|
+ temporaryGrade: code
|
|
|
})
|
|
|
+ console.log(code);
|
|
|
},
|
|
|
// 修改年级
|
|
|
- changeGrade: function (e) {
|
|
|
- const grade = e.target.dataset.code;
|
|
|
- console.log(grade);
|
|
|
- /* wx.setStorageSync('grade', grade)
|
|
|
+ changeGrade: function(e) {
|
|
|
+ const grade = this.data.temporaryGrade
|
|
|
+ if (!grade) {
|
|
|
+ return wx.showToast({
|
|
|
+ title: '请选择年级',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ }
|
|
|
+ wx.setStorageSync('grade', grade)
|
|
|
this.setData({
|
|
|
isGradeShow: false,
|
|
|
grade
|
|
@@ -928,15 +946,13 @@ Page({
|
|
|
let data = {
|
|
|
grade: e.target.dataset.code
|
|
|
};
|
|
|
- httpRequestApi.settingUserInfo(data).success(res => {
|
|
|
-
|
|
|
- })
|
|
|
+ httpRequestApi.settingUserInfo(data).success(res => {})
|
|
|
return;
|
|
|
};
|
|
|
getOpenidNoLogin((res) => {
|
|
|
console.log('getOpenidNoLogin', res)
|
|
|
- // 登录或注册完成 展示页面
|
|
|
- if (res.data.data.wechatName) {
|
|
|
+ // 登录或注册完成 展示页面
|
|
|
+ if (res.data.data.nickName) {
|
|
|
this.setData({
|
|
|
isLogin: true
|
|
|
})
|
|
@@ -952,10 +968,10 @@ Page({
|
|
|
this.setData({
|
|
|
hide: !this.data.hide
|
|
|
})
|
|
|
- }, grade); */
|
|
|
+ }, grade);
|
|
|
},
|
|
|
|
|
|
- getFollowData: function () {
|
|
|
+ getFollowData: function() {
|
|
|
httpRequestApi.getFollowWorks(this.data.followPageNo, this.data.followPageSize).success(res => {
|
|
|
if (res.data.data.totalSize === 0) {
|
|
|
this.setData({
|
|
@@ -978,7 +994,7 @@ Page({
|
|
|
httpRequestApi.userEvent('SUBSCRIBE');
|
|
|
},
|
|
|
// 点击用户头像区域
|
|
|
- headTapHandler: function (e) {
|
|
|
+ headTapHandler: function(e) {
|
|
|
console.log('点击头像', e)
|
|
|
let tapId = e.detail.activeId;
|
|
|
// 点击头像既关注 测试
|
|
@@ -986,7 +1002,7 @@ Page({
|
|
|
console.log(res)
|
|
|
})
|
|
|
},
|
|
|
- getCoursesList: function () {
|
|
|
+ getCoursesList: function() {
|
|
|
const grade = wx.getStorageSync('grade');
|
|
|
const data = {
|
|
|
pageNo: this.data.coursePageNo,
|
|
@@ -1006,7 +1022,7 @@ Page({
|
|
|
})
|
|
|
httpRequestApi.userEvent('RESOURCES');
|
|
|
},
|
|
|
- goToReading: function (e) {
|
|
|
+ goToReading: function(e) {
|
|
|
console.log('去朗读', e)
|
|
|
const id = e.detail.activeId ? e.detail.activeId : e.currentTarget.dataset.id;
|
|
|
const index = e.currentTarget.dataset.index;
|
|
@@ -1067,16 +1083,16 @@ Page({
|
|
|
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)
|
|
|
+ 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,
|
|
@@ -1086,7 +1102,7 @@ Page({
|
|
|
this.shareDialog.share(data);
|
|
|
}
|
|
|
},
|
|
|
- collectTap: function (e) {
|
|
|
+ collectTap: function(e) {
|
|
|
const index = e.detail.index;
|
|
|
let str = `videoList[${index}].isFavorite`;
|
|
|
let str2 = `videoList[${index}].favoritesAmount`;
|
|
@@ -1096,7 +1112,7 @@ Page({
|
|
|
[str2]: favoritesAmount
|
|
|
})
|
|
|
},
|
|
|
- likeTap: function (e) {
|
|
|
+ likeTap: function(e) {
|
|
|
console.log('点赞', e)
|
|
|
const index = e.detail.index;
|
|
|
let likeStr = `videoList[${index}].isLike`;
|
|
@@ -1105,15 +1121,8 @@ Page({
|
|
|
[likeStr]: true,
|
|
|
[likeNumStr]: this.data.videoList[index].likes + 1
|
|
|
})
|
|
|
- // this.flowerAnimationHandler()
|
|
|
- },
|
|
|
- flowerAnimationHandler: function () {
|
|
|
- this.flowerBox = this.selectComponent("#flower-box");
|
|
|
- console.log('this.flower', this.flowerBox)
|
|
|
- this.flowerBox.comeOut();
|
|
|
},
|
|
|
- addShareAmount: function (e) {
|
|
|
- console.log('+++++1', e)
|
|
|
+ addShareAmount: function(e) {
|
|
|
let str = `videoList[${e.detail.index}].shareAmount`;
|
|
|
this.setData({
|
|
|
[str]: this.data.videoList[e.detail.index].shareAmount + 1
|
|
@@ -1124,12 +1133,12 @@ Page({
|
|
|
*/
|
|
|
goToActivity() {
|
|
|
httpRequestApi.postActEvent('BANNER').success(res => {
|
|
|
- console.log('活动banner', res)
|
|
|
- })
|
|
|
- // wx.navigateTo({
|
|
|
- // url: `../activity/index/index`
|
|
|
- // // url: `../activity/rule/rule`
|
|
|
- // });
|
|
|
+ console.log('活动banner', res)
|
|
|
+ })
|
|
|
+ // wx.navigateTo({
|
|
|
+ // url: `../activity/index/index`
|
|
|
+ // // url: `../activity/rule/rule`
|
|
|
+ // });
|
|
|
wx.navigateTo({
|
|
|
url: `../activity/goodList/goodList`
|
|
|
});
|
|
@@ -1151,41 +1160,41 @@ Page({
|
|
|
}
|
|
|
},
|
|
|
/**活动改版 */
|
|
|
- myPlase() {
|
|
|
- if (!wx.getStorageSync('message')) {
|
|
|
- wx.requestSubscribeMessage({
|
|
|
- tmplIds: ['KJ0YtcAacJNSXDBsE27JXqoaFrcJ1-N6Jcu85yTtQuY',
|
|
|
- '-2ZZpWFoyKvAtX1HwEIQLQ92LnN8cryamB94LqLGo98'
|
|
|
- ],
|
|
|
- success: (res) => {
|
|
|
- console.log(res)
|
|
|
- if (res['KJ0YtcAacJNSXDBsE27JXqoaFrcJ1-N6Jcu85yTtQuY'] === 'reject') {
|
|
|
- console.log('用户不同意订阅')
|
|
|
- // 用户不同意订阅
|
|
|
- wx.setStorageSync('message', false)
|
|
|
- } else if (res['KJ0YtcAacJNSXDBsE27JXqoaFrcJ1-N6Jcu85yTtQuY'] === 'accept') {
|
|
|
- console.log('订阅成功')
|
|
|
- // 用户点击统一订阅
|
|
|
- wx.setStorageSync('message', true)
|
|
|
- }
|
|
|
- wx.navigateTo({
|
|
|
- url: `../vipActivity/vipActivity`
|
|
|
- });
|
|
|
- },
|
|
|
- fail: () => {
|
|
|
- wx.navigateTo({
|
|
|
- url: `../vipActivity/vipActivity`
|
|
|
- });
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- wx.navigateTo({
|
|
|
- url: `../vipActivity/vipActivity`
|
|
|
- });
|
|
|
- }
|
|
|
+ // myPlase() {
|
|
|
+ // if (!wx.getStorageSync('message')) {
|
|
|
+ // wx.requestSubscribeMessage({
|
|
|
+ // tmplIds: ['KJ0YtcAacJNSXDBsE27JXqoaFrcJ1-N6Jcu85yTtQuY',
|
|
|
+ // '-2ZZpWFoyKvAtX1HwEIQLQ92LnN8cryamB94LqLGo98'
|
|
|
+ // ],
|
|
|
+ // success: (res) => {
|
|
|
+ // console.log(res)
|
|
|
+ // if (res['KJ0YtcAacJNSXDBsE27JXqoaFrcJ1-N6Jcu85yTtQuY'] === 'reject') {
|
|
|
+ // console.log('用户不同意订阅')
|
|
|
+ // // 用户不同意订阅
|
|
|
+ // wx.setStorageSync('message', false)
|
|
|
+ // } else if (res['KJ0YtcAacJNSXDBsE27JXqoaFrcJ1-N6Jcu85yTtQuY'] === 'accept') {
|
|
|
+ // console.log('订阅成功')
|
|
|
+ // // 用户点击统一订阅
|
|
|
+ // wx.setStorageSync('message', true)
|
|
|
+ // }
|
|
|
+ // wx.navigateTo({
|
|
|
+ // url: `../vipActivity/vipActivity`
|
|
|
+ // });
|
|
|
+ // },
|
|
|
+ // fail: () => {
|
|
|
+ // wx.navigateTo({
|
|
|
+ // url: `../vipActivity/vipActivity`
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // } else {
|
|
|
+ // wx.navigateTo({
|
|
|
+ // url: `../vipActivity/vipActivity`
|
|
|
+ // });
|
|
|
+ // }
|
|
|
|
|
|
|
|
|
- },
|
|
|
+ // },
|
|
|
// 弹窗提示
|
|
|
helpPayHideEvent() {
|
|
|
this.setData({
|
|
@@ -1331,5 +1340,98 @@ Page({
|
|
|
}).fail(error => {
|
|
|
console.log(error)
|
|
|
})
|
|
|
+ },
|
|
|
+ // 分享作品逻辑
|
|
|
+ creatShare(video) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ let context = wx.createSelectorQuery();
|
|
|
+ context
|
|
|
+ .select('#share')
|
|
|
+ .fields({
|
|
|
+ node: true,
|
|
|
+ size: true
|
|
|
+ }).exec((res) => {
|
|
|
+ const canvas = res[0].node;
|
|
|
+ const ctx = canvas.getContext('2d');
|
|
|
+ const dpr = wx.getSystemInfoSync().pixelRatio;
|
|
|
+ canvas.width = res[0].width * dpr;
|
|
|
+ canvas.height = res[0].height * dpr;
|
|
|
+ ctx.scale(dpr, dpr);
|
|
|
+ ctx.font = '14px PingFang';
|
|
|
+ let pic = canvas.createImage();
|
|
|
+ pic.src = video.coverImg; //可以是本地,也可以是网络图片
|
|
|
+ pic.onload = () => {
|
|
|
+ ctx.drawImage(pic, 0, 0, 375, 211);
|
|
|
+ }
|
|
|
+ let peiyin = canvas.createImage();
|
|
|
+ peiyin.src = '/static/image/peiyin.jpg';
|
|
|
+ peiyin.onload = () => {
|
|
|
+ ctx.drawImage(peiyin, 0, 211, 375, 89);
|
|
|
+ // 收藏,一个一个渲染
|
|
|
+ let sc = canvas.createImage();
|
|
|
+ sc.src = '/static/image/no_collect.png'
|
|
|
+ sc.onload = () => {
|
|
|
+ ctx.drawImage(sc, 12, 220, 20, 20)
|
|
|
+ ctx.fillText('收藏', 36, 238)
|
|
|
+ //分享
|
|
|
+ let fx = canvas.createImage();
|
|
|
+ fx.src = '/static/index/share.png'
|
|
|
+ fx.onload = () => {
|
|
|
+ ctx.drawImage(fx, 78, 220, 22, 22)
|
|
|
+ ctx.fillText('分享', 104, 238)
|
|
|
+ //点赞
|
|
|
+ let dz = canvas.createImage();
|
|
|
+ dz.src = video.isLike ? '/static/index/heart_colored.png' : '/static/index/heart.png'
|
|
|
+
|
|
|
+ dz.onload = () => {
|
|
|
+ ctx.drawImage(dz, 258, 222, 22, 22)
|
|
|
+ ctx.fillText(video.likes, 284, 238)
|
|
|
+ //评论
|
|
|
+ let pl = canvas.createImage();
|
|
|
+ pl.src = '/static/index/comment.png'
|
|
|
+ pl.onload = () => {
|
|
|
+ ctx.drawImage(pl, 318, 222, 22, 22)
|
|
|
+ ctx.fillText(video.commentAmount, 340, 238)
|
|
|
+ setTimeout(() => {
|
|
|
+ wx.canvasToTempFilePath({
|
|
|
+ canvas: canvas,
|
|
|
+ success(res) {
|
|
|
+ resolve({
|
|
|
+ title: video.title,
|
|
|
+ path: `/pages/index/index?readId=${video.id}&uid=${wx.getStorageSync('uid')}`,
|
|
|
+ imageUrl: res.tempFilePath
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail(res) {
|
|
|
+ reject()
|
|
|
+ }
|
|
|
+ }, this)
|
|
|
+ }, 500)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onShareAppMessage({
|
|
|
+ target
|
|
|
+ }) {
|
|
|
+ let video = target.dataset.info
|
|
|
+ console.log(`/pages/index/index?readId=${video.id}&uid=${wx.getStorageSync('uid')}`)
|
|
|
+ const promise = new Promise(resolve => {
|
|
|
+ this.creatShare(video).then(res => {
|
|
|
+ resolve(res)
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ return {
|
|
|
+ title: video.title,
|
|
|
+ path: `/pages/index/index?readId=${video.id}&uid=${wx.getStorageSync('uid')}`,
|
|
|
+ imageUrl: video.coverImg,
|
|
|
+ promise
|
|
|
+ }
|
|
|
}
|
|
|
})
|