|
@@ -61,7 +61,6 @@ Page({
|
|
|
hotInput: '12345',
|
|
|
mineSettingInfo: '528',
|
|
|
hide: true,
|
|
|
- isIOS: app.globalData.isIOS,
|
|
|
ifHaveMore: true,
|
|
|
indexSignDialog: false,
|
|
|
indexMissionDialog: false,
|
|
@@ -83,7 +82,15 @@ Page({
|
|
|
grade: wx.getStorageSync('grade'),
|
|
|
noMoreWork: false, // 没有更多作品 已经到底了
|
|
|
upgradeHide: true,
|
|
|
- gradeActivity: ''
|
|
|
+ gradeActivity: '',
|
|
|
+ helpPayHide: true,
|
|
|
+ tipsType: '',
|
|
|
+ helpPayImg: '',
|
|
|
+ tipsImg: '',
|
|
|
+ payPrice: '',
|
|
|
+ iphoneType: '',
|
|
|
+ isVip: null,
|
|
|
+ isIos: null
|
|
|
},
|
|
|
jurisdiction: function () {
|
|
|
//隐藏弹框
|
|
@@ -250,6 +257,9 @@ Page({
|
|
|
}, 2800)
|
|
|
},
|
|
|
onLoad: function (options) {
|
|
|
+ this.setData({
|
|
|
+ isIos: app.globalData.isIOS
|
|
|
+ })
|
|
|
console.log('onload', options);
|
|
|
if (options.scene) {
|
|
|
// this.setData({
|
|
@@ -257,8 +267,16 @@ Page({
|
|
|
// })
|
|
|
let optionsStr = decodeURIComponent(options.scene);
|
|
|
let optionsArr = optionsStr.split('&');
|
|
|
- options.readId = optionsArr[0];
|
|
|
- options.activity = optionsArr[1];
|
|
|
+ // 暂时这样写
|
|
|
+ if (optionsArr[0].split("=")[0] === "type"){
|
|
|
+ console.log('我是团购分享')
|
|
|
+ options.type = optionsArr[0].split("=")[1];
|
|
|
+ options.sid = optionsArr[1].split("=")[1];
|
|
|
+ } else {
|
|
|
+ options.readId = optionsArr[0];
|
|
|
+ options.activity = optionsArr[1];
|
|
|
+ }
|
|
|
+
|
|
|
console.log('整理后options', options)
|
|
|
}
|
|
|
if (options.readId) {
|
|
@@ -275,9 +293,27 @@ Page({
|
|
|
console.log(res)
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
+ /**团购弹窗时间紧逻辑越写越乱功能越加越多 */
|
|
|
+ this.setData({
|
|
|
+ iphoneType: options.type || ''
|
|
|
+ })
|
|
|
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)
|
|
|
+ })
|
|
|
+ // 获取用户权限
|
|
|
+ this.getHelpAuth()
|
|
|
if (!res.data.data.grade) {
|
|
|
// 没有年级的老用户
|
|
|
if (res.data.data.wechatName) {
|
|
@@ -313,6 +349,14 @@ Page({
|
|
|
|
|
|
|
|
|
this.uid = wx.getStorageSync('uid');
|
|
|
+ if (options.sid) {
|
|
|
+ httpRequestApi.getUserRec(options.sid).success(res => {
|
|
|
+ options.uid = res.data.data;
|
|
|
+ this.shareGetPage(options)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.shareGetPage(options)
|
|
|
+ }
|
|
|
// if (!this.uid || !grade) {
|
|
|
// this.setData({
|
|
|
// isGradeShow: true,
|
|
@@ -347,7 +391,34 @@ Page({
|
|
|
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+ },
|
|
|
+ // 封装分享方法之后跳到页面方法
|
|
|
+ shareGetPage(options) {
|
|
|
+ console.log(this.uid, options.uid ,this.uid !== options.uid)
|
|
|
+ if(options.type && options.type === 'iphone' && !app.globalData.isIOS && this.uid !== options.uid) {
|
|
|
+ this.setData({
|
|
|
+ helpPayHide: false,
|
|
|
+ tipsType: 'helpPay',
|
|
|
+ helpPayImg: 'http://reader-wx.ai160.com/images/reader/pay/buy.png',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if(options.type && options.type === 'ios' && this.uid !== options.uid) {
|
|
|
+ this.setData({
|
|
|
+ helpPayHide: false,
|
|
|
+ tipsType: 'helpPay',
|
|
|
+ helpPayImg: 'http://reader-wx.ai160.com/images/reader/pay/help.png',
|
|
|
+ })
|
|
|
+ console.log(options.uid)
|
|
|
+ }
|
|
|
+ const recOsType = options.type === 'iphone' ? 'ANDROID' : (options.type === 'ios' && 'IOS');
|
|
|
+ if (options.type && options.uid) {
|
|
|
+ httpRequestApi.settingUserInfo({
|
|
|
+ rec_uid: options.uid,
|
|
|
+ recOsType,
|
|
|
+ }).success(res => {
|
|
|
+ console.log(res)
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
onShow: function () {
|
|
|
let grade = wx.getStorageSync('grade');
|
|
@@ -356,6 +427,7 @@ Page({
|
|
|
})
|
|
|
if (this.data.myIndex === 3) {
|
|
|
this.getUserWorksInfo(1)
|
|
|
+ this.getHelpAuth()
|
|
|
}
|
|
|
wx.setNavigationBarTitle({
|
|
|
title: '小学语文朗读配音'
|
|
@@ -495,8 +567,10 @@ Page({
|
|
|
}
|
|
|
res.data.data.user = this.formatGrade(res.data.data.user);
|
|
|
this.setData({
|
|
|
- myData: res.data.data,
|
|
|
- ['myData.userInfo']: res.data.data.user
|
|
|
+ // myData: res.data.data,
|
|
|
+ ['myData.user']: res.data.data,
|
|
|
+ ['myData.userInfo']: res.data.data.user,
|
|
|
+ ['myData.isIOS']: app.globalData.isIOS
|
|
|
}, () => {
|
|
|
this.getMyRead()
|
|
|
});
|
|
@@ -1045,9 +1119,194 @@ Page({
|
|
|
url: `../activity/index/index`
|
|
|
});
|
|
|
},
|
|
|
- goToActivityPrice(){
|
|
|
- wx.navigateTo({
|
|
|
- url: `../activity/priceList/priceList`
|
|
|
- });
|
|
|
+ /**
|
|
|
+ * banner点击
|
|
|
+ */
|
|
|
+ bannerTap() {
|
|
|
+ if (!this.data.isLogin) {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `../../pages/login/login?index=0`
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(this.data.isIos || this.data.isVip) {
|
|
|
+ this.myPlase();
|
|
|
+ } else {
|
|
|
+ this.messageAuth();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /**活动改版 */
|
|
|
+ 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({
|
|
|
+ helpPayHide: !this.data.helpPayHide
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 支付或者助力
|
|
|
+ payAndHelp() {
|
|
|
+ if (!this.data.isLogin) {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `../../pages/login/login?index=0`
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (this.data.iphoneType === 'ios') {
|
|
|
+ httpRequestApi.postUserHelp().success(res => {
|
|
|
+ console.log(res)
|
|
|
+ if (res.data.data) {
|
|
|
+ this.setData({
|
|
|
+ tipsType: 'tips',
|
|
|
+ tipsImg: 'http://reader-wx.ai160.com/images/reader/pay/help_success.png'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ tipsType: 'tips',
|
|
|
+ tipsImg: 'http://reader-wx.ai160.com/images/reader/pay/helped.png'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ // 去支付需要获取权限
|
|
|
+ this.messageAuth();
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ // 授权
|
|
|
+ messageAuth() {
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ this.order();
|
|
|
+ },
|
|
|
+ fail: () => {
|
|
|
+ this.order();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.order();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 支付
|
|
|
+ order () {
|
|
|
+ // 渠道id
|
|
|
+ const productId = wx.getStorageSync('productId');
|
|
|
+ httpRequestApi.createOrder(productId).success(res => {
|
|
|
+ console.log(res.data.data.package);
|
|
|
+ const timeStamp = res.data.data.timeStamp;
|
|
|
+ const nonceStr = res.data.data.nonceStr;
|
|
|
+ const packages = res.data.data.package;
|
|
|
+ const paySign = res.data.data.sign;
|
|
|
+ wx.requestPayment({
|
|
|
+ timeStamp,
|
|
|
+ nonceStr,
|
|
|
+ package: packages,
|
|
|
+ signType: 'MD5',
|
|
|
+ paySign,
|
|
|
+ success: (res) => {
|
|
|
+ if (this.data.iphoneType === 'iphone') {
|
|
|
+ this.setData({
|
|
|
+ tipsType: 'tips',
|
|
|
+ tipsImg: 'http://reader-wx.ai160.com/images/reader/pay/success.png'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ httpRequestApi.getAuthActivity().success(res => {
|
|
|
+ if (!res.data.data) {
|
|
|
+ wx.setStorageSync('vip', false)
|
|
|
+ wx.setStorageSync('date', '')
|
|
|
+ } else {
|
|
|
+ wx.setStorageSync('vip', true)
|
|
|
+ wx.setStorageSync('date', res.data.data)
|
|
|
+ this.setData({
|
|
|
+ ['myData.isVIP']: true,
|
|
|
+ ['myData.date']: res.data.data
|
|
|
+ })
|
|
|
+ this.showGift();
|
|
|
+ }
|
|
|
+ }).fail(error => {
|
|
|
+ console.log(error)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail (res) { }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 助力或者支付提示
|
|
|
+ tips() {
|
|
|
+ console.log('支付完了')
|
|
|
+ this.setData({
|
|
|
+ helpPayHide: true
|
|
|
+ })
|
|
|
+ this.updateData("2");
|
|
|
+ },
|
|
|
+ // 购买成功告诉首页显示邀请有礼
|
|
|
+ showGift() {
|
|
|
+ console.log('通知')
|
|
|
+ this.setData({
|
|
|
+ isVip: true
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 首页获取权限
|
|
|
+ getHelpAuth() {
|
|
|
+ httpRequestApi.getAuthActivity().success(res => {
|
|
|
+ if (!res.data.data) {
|
|
|
+ wx.setStorageSync('vip', false)
|
|
|
+ wx.setStorageSync('date', '')
|
|
|
+ this.setData({
|
|
|
+ isVip: false
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.setStorageSync('vip', true)
|
|
|
+ wx.setStorageSync('date', res.data.data)
|
|
|
+ this.setData({
|
|
|
+ isVip: true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).fail(error => {
|
|
|
+ console.log(error)
|
|
|
+ })
|
|
|
}
|
|
|
})
|