yuminge-app/yun-min-program-plugin-master/packageB/member/income/courseIncome/courseIncome.js

200 lines
4.8 KiB
JavaScript

// pages/courseIncome/courseIncome.js
var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
language: "",
lecturer_name: "",
avatar: "",
order_bonus: "0.00",
reward_bonus: "0.00",
lecturer_bonus: "0.00",
activeName: "first",
active: 0,
first_content: [],
second_content: [],
third_content: [],
currentTabIndex: "0",
is_first_content: false,
is_second_content: false,
is_third_content: false,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.checkrouter();
this.getLecturerInfo();
this.setDataByTabIndex();
},
checkrouter() {
try {
// 推广中心是否开启该功能,没开启跳转到指定路径
let basic_info = wx.getStorageSync("yz_basic_info");
let stop_info = basic_info.popularize_page.mini.vue_route;
for (let i = 0; i < stop_info.length; i++) {
if (stop_info[i] == "courseIncome") {
console.log(basic_info.popularize_page.mini.mini_url + "跳转的路径");
wx.showToast({
title: "未开启推广权限",
duration: 1000,
icon: "none",
success: function () {
setTimeout(() => {
wx.redirectTo({
url: basic_info.popularize_page.mini.mini_url,
});
}, 1000);
},
});
return;
}
}
} catch (e) {
console.log(e);
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
let language = wx.getStorageSync("langIndex");
this.setData({ language: language.en });
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {},
//获取讲师信息
getLecturerInfo() {
let that = this;
let urlStr = app.getNetAddresss("plugin.video-demand.api.video-demand-lecturer.get-lecturer-info");
app._getNetWork({
url: urlStr,
success: function (resdata) {
var res = resdata.data;
if (res.result == 1) {
that.setData({
lecturer_name: res.data.lecturer_name,
avatar: res.data.avatar,
order_bonus: res.data.order_bonus,
reward_bonus: res.data.reward_bonus,
lecturer_bonus: res.data.lecturer_bonus,
});
} else {
wx.showToast({
icon: "none",
title: res.msg,
duration: 1500,
});
}
},
fail: function (res) {
console.log(res);
},
});
},
//设置选择后的数据
setDataByTabIndex() {
if (this.data.currentTabIndex == "0" && !this.data.is_first_content) {
this.setData({
is_first_content: true,
});
this.getLecturerBonusInfo("");
} else if (this.data.currentTabIndex == "1" && !this.data.is_second_content) {
this.setData({
is_second_content: true,
});
this.getLecturerBonusInfo("0");
} else if (this.data.currentTabIndex == "2" && !this.data.is_third_content) {
this.setData({
is_third_content: true,
});
this.getLecturerBonusInfo("1");
}
},
getLecturerBonusInfo(status) {
let that = this;
let urlStr = app.getNetAddresss("plugin.video-demand.api.video-demand-lecturer.lecturer-reward-info");
urlStr + "&account_status=" + status;
app._getNetWork({
url: urlStr,
success: function (resdata) {
var res = resdata.data;
if (res.result == 1) {
switch (that.data.currentTabIndex) {
case "0":
that.setData({
first_content: res.data,
});
break;
case "1":
that.setData({
second_content: res.data,
});
break;
case "2":
that.setData({
third_content: res.data,
});
break;
default:
break;
}
} else {
wx.showToast({
icon: "none",
title: res.msg,
duration: 1500,
});
}
},
fail: function (res) {
console.log(res);
},
});
},
//tab 点击
handleClick(e) {
let tab = e.detail.index;
if (this.data.currentTabIndex == tab) {
return;
} else {
this.setData({
currentTabIndex: tab,
});
}
this.setDataByTabIndex();
},
});