123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- var app = getApp();
- var util = require("../../../../utils/util.js")
- let wxparse = require("../../../../wxParse/wxParse.js");
- let pageid = ""
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- appAssetsUrl:app.appAssetsUrl,
- isCollected: false,
- show: true,
- options: "",
- videoplay:"",
- videoFile:"",
- parm: {
- type: "2",
- sid: '',
- vipid: util.getUserId()
- },
- pram: {
- type: "1",
- cid: '',
- sid: ''
- }
- },
- collect: function () {
- let isCollected = !this.data.isCollected
- this.setData({
- isCollected: isCollected
- })
- wx.showToast({
- title: isCollected ? '收藏成功' : '取消收藏',
- icon: 'success',
- duration: 2000
- })
- },
- courselisten:function(e){
- if (e.currentTarget.dataset.isbuy == "1"){
- wx.showToast({
- title: '已切换至' + this.data.data.video[e.currentTarget.dataset.index].title+',请观看!',
- icon:'none'
- })
- this.setData({
- videoFile: this.data.data.video[e.currentTarget.dataset.index].videoFile
- })
- }else{
- if (e.currentTarget.dataset.item == "1") {
- this.setData({
- videoFile: this.data.data.video[e.currentTarget.dataset.index].videoFile
- })
- } else if (e.currentTarget.dataset.item == "0") {
- wx.showToast({
- title: '购买课程后即可观看!',
- icon:'none',
- duration:2500
- })
- }
- }
-
- },
-
- upgrade() {
- let _this = this;
- if (util.UserLoginStatus()){
- wx.showActionSheet({
- itemList: ['微信支付', '会员卡支付'],
- success(res) {
- if (res.tapIndex === 0) {
- _this.data.pram.type = "1";
- app._post_form('cou/buy', 'application/json',
- JSON.stringify(_this.data.pram),
- function (result) {
- console.log(result)
- if (result.code === 0) {
- wx.showLoading({
- title: '正在处理...',
- mask: true
- })
- wx.requestPayment({
- 'timeStamp': result.data.timestamp,
- 'nonceStr': result.data.nonce_str,
- 'package': 'prepay_id=' + result.data.prepay_id,
- 'signType': 'MD5',
- 'paySign': result.data.sign,
- success: function (res) {
- if (res) {
- wx.hideLoading();
- wx.showModal({
- title: '温馨提示',
- content: "购买成功!",
- showCancel: false
- })
- }
- /* wx.request({
- url: App.apiRoot + 'notification.do',
- data: {
- formid: formid,
- cardNo: vipcard,
- orderNo: order,
- type: '1'
- },
- header: { 'content-type': 'application/json' },
- success(res) {
- if (res.code === 0 || res.code === '0') {
- console.log("已推送消息");
- }
- },
- fail: function (res) {
- console.log("推送失败");
- }
- })*/
- _this.loadData(_this.data.options.id)
- },
- fail: function (res) {
- wx.hideLoading();
- wx.showToast({
- title: '购买失败!',
- icon: 'none',
- duration: 1500
- })
- }
- })
- } else {
- wx.showModal({
- title: '温馨提示',
- content: result.msg,
- showCancel: false
- })
- }
- }
- )
- } else if (res.tapIndex === 1) {
- _this.data.pram.type = "yue";
- wx.showToast({
- title: '暂未开通!',
- duration: 1500
- })
- }
- },
- fail(res) { }
- })
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.data.pram.sid =util.getUserId();
- pageid = this.options.id
- wx.setNavigationBarTitle({ title: '课程详情' })
- let _this = this;
- _this.loadData(options.id);
- _this.data.options = options;
- // _this.data.pram.cid = _this.options.id
- },
- loadData: function(id){
- let _this = this;
- app._post_form('cou/one/' + id + "/" + util.getUserId(),"",null,function (res) {
- console.log(res)
- if(res.code===0){
- _this.data.pram.cid = res.data.id + ""
- _this.setData(res);
- for (var i = 0; i < res.data.video.length; i++) {
- _this.data.videoplay = res.data.video[i].videoFile
- }
- // _this.setData({
- // videoplay: _this.data.videoplay
- // })
- console.log(_this.data.data.title,'data')
- _this.setData({
- videoFile:res.data.videoFile
- })
- setTimeout(function () {
- wxparse.wxParse('content', 'html', res.data.content, _this, 5);
- }, 1000)
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- //获得popup组件
- this.popup = this.selectComponent("#popup");
- },
- // showPopup() {
- // console.log(123)
- // this.popup.showPopup();
- // },
- //取消事件
- _error() {
- // console.log('你点击了取消');
- this.popup.hidePopup();
- },
- //确认事件
- _success() {
- console.log('你点击了确定');
- this.signUp()
- },
- showShareMenu: function () {
- wx.showShareMenu();
- this.setData({
- show: true
- })
- console.log("显示了当前页面的转发按钮");
- },
- hideShareMenu() {
- wx.hideShareMenu();
- this.setData({
- show: false
- })
- console.log("隐藏了当前页面的转发按钮");
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage(){
- let _this=this
- console.log(pageid)
- var title = _this.data.data.title
- var introduction = _this.data.data.introduction
- return {
- title: title,
- path: '/pages/home/index/courseDetail/courseDetail?id=' + pageid,//这里的path是当前页面的path,必须是以 / 开头的完整路径,后面拼接的参数 是分享页面需要的参数 不然分享出去的页面可能会没有内容
- desc: introduction,
- success: (res) => {
- console.log("转发成功", res);
- console.log("成功了")
- },
- fail: (res) => {
- console.log("转发失败", res);
- }
- }
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- })
|