From 6f7449d577eb73d8adb01c20e0b8ee2b6044ea65 Mon Sep 17 00:00:00 2001 From: xuxu Date: Fri, 14 Aug 2020 17:40:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B4=BB=E5=8A=A8=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E6=8A=A5=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/artice.js | 14 ++++++++++++ pages/article/index.js | 47 +++++++++++++++++++++++++++++++++++----- pages/article/index.wxml | 16 ++++++++++++-- 3 files changed, 70 insertions(+), 7 deletions(-) diff --git a/models/artice.js b/models/artice.js index 4027b54..64d80c7 100644 --- a/models/artice.js +++ b/models/artice.js @@ -5,6 +5,7 @@ const ArticeConst = { artice_url: '/api/content/queryById', artice_add_remove_collect_url: '/api/content/addOrDeleteCollection', artice_online_url: '/api/content/signin', + cancel_artice_online_url: '/api/content/signout', } class ArticeModel extends HTTP { @@ -48,6 +49,19 @@ class ArticeModel extends HTTP { } this.request(params) } + + // 在线报名 + cancelOnlineSign(aId, success) { + let params = { + url: ArticeConst.cancel_artice_online_url, + success: success, + method: Method.GET, + data: { + contentId: aId + } + } + this.request(params) + } } export { ArticeModel } \ No newline at end of file diff --git a/pages/article/index.js b/pages/article/index.js index edb759a..8e9b373 100644 --- a/pages/article/index.js +++ b/pages/article/index.js @@ -23,6 +23,7 @@ Page({ disable: true, readNum: 0, collectNum: 0, + flag:5 }, onClickCollect () { // 收藏功能 @@ -83,6 +84,12 @@ Page({ wx.setNavigationBarTitle({ title: data.title, }) + + if(data.flag == 0 || data.flag == 1){ + var disable = false; + }else{ + var disable = true; + } this.setData({ nodes: data.content, title: data.title, @@ -90,10 +97,11 @@ Page({ image: data.titlePic, origin: data.source, isStar: data.isCollection ? true : false, - showBtn: data.typeFlag >= 2 ? true : false, - disable: data.typeFlag == 3 ? true : false, + // showBtn: data.typeFlag >= 2 ? true : false, + disable: disable, readNum: data.readNum, collectNum: data.collectNum, + flag:data.flag }, () => { wx.hideLoading() }) @@ -115,7 +123,6 @@ Page({ }, onlineSignApi () { artice.onlineSign(this.data.aId, res => { - console.log(res) if(res.code == 200){ console.log(res.code); wx.showToast({ @@ -124,7 +131,7 @@ Page({ }) } if(res.code != 200){ - console.log(res.code); + // console.log(res.code); this.setData({ disable: false }) @@ -133,8 +140,38 @@ Page({ icon: 'none' }) } - // this.fetchArticeApi() + this.fetchArticeApi() }) }, + cancelSignApi () { + this.setData({ + disable: true + }) + if (store.hasBindUserInfo()) { + artice.cancelOnlineSign(this.data.aId, res => { + if(res.code == 200){ + wx.showToast({ + title: res.message, + icon: 'none' + }) + + }else{ + this.setData({ + disable: false + }) + wx.showToast({ + title: res.message, + icon: 'none' + }) + } + this.fetchArticeApi() + }) + } else { + wx.redirectTo({ + url: '/pages/weChatAuth/index', + }) + } + + } }) \ No newline at end of file diff --git a/pages/article/index.wxml b/pages/article/index.wxml index 0579ca0..9a8ac42 100644 --- a/pages/article/index.wxml +++ b/pages/article/index.wxml @@ -19,8 +19,20 @@ 收藏:{{collectNum}} - - + + + + + + + + + + + + + +