123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- const util = require("../../../utils/util")
- const app = getApp()
- Page({
- data: {
- articalId:0,
- isLike:0,
- info:{},
- confirmModal: false,
- publishModal: false,
- content:'',
- categorys:{},
- userInfo:{},
- isLeader:0,
- logs:[]
- },
- preview( e ){
- var imgs = [];
- let brirf = this.data.info.brief||''
- brirf.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, function (match, capture) {
- imgs.push(capture);
- });
- if( imgs.length > 0 ){
- wx.previewImage({
- current: imgs[0],
- urls: imgs
- })
- }
- },
- openDialog( e ){
- let param = {content:''}
- param[e.currentTarget.dataset.id] =true
- this.setData( param )
- },
- closeDialog( e ){
- let param = {content:''}
- param[e.currentTarget.dataset.id] =false
- this.setData( param )
- },
- onLoad: function (options) {
- let articalId = +options.articalId||2135;
- this.setData({articalId})
- },
- onShow: function(){
- app.checkLogin( this.loadData )
- },
- inputContent(e){
- let content = e.detail.value
- this.setData({ content });
- },
- confirmArtical: function (e) {
- let articalId = this.data.info.articalId
- let content = this.data.content;
- let action = 1
- if( !content ){
- util.showMsg("请留下宝贵意见")
- return
- }
- let info = this.data.info;
- app.formPost( "artical/confirmArtical", {articalId,content,action}).then( res=>{
- if( res.code == 200 ){
- info.status = 2
- app.showMsg( "确认成功")
- this.setData({info, confirmModal:false})
- }
- })
- },
- publishArtical:function (e) {
- let articalId = this.data.info.articalId
- let content = this.data.content;
- let action = 1
- if( !content ){
- util.showMsg("请留下宝贵意见")
- return
- }
- app.formPost( "artical/publishArtical", {articalId,content,action}).then( res=>{
- if( res.code == 200 ){
- info.status = 3
- app.showMsg( "发布成功")
- this.setData({info, confirmModal:false})
- }
- })
- },
- loadData(){
- let articalId = this.data.articalId
- app.formPost( "weixin/getArticalInfo", {articalId}).then( res=>{
- if( res.code == 200 ){
- let {isLike,info,logs, isLeader} = res.data
- this.setData({isLike,info,logs,isLeader})
- }
- })
- },
- downloadUrl( url ){
- wx.downloadFile({
- url: url,
- timeout: 0,
- success: (res) => {
- var rr=res.tempFilePath;
- wx.openDocument({
- filePath:rr,
- showMenu: true,
- success(res) {
- wx.showToast({
- title: '保存成功',
- icon: 'success',
- duration: 2000
- })
- }
- })
- },
- fail: (res) => {
- console.log("res_fail", res)
- },
- complete: (res) => {
- console.log("res_complete", res)
- },
- })
- },
- download(){
- let articalId = this.data.info.articalId;
- app.formPost( "artical/downloadFile", {articalId}).then( res=>{
- if( res.code == 200 ){
- this.downloadUrl( res.data )
- }
- })
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- let {title, articalId} = this.data.info;
- return {
- title: title,
- path: `/pages/artical/info/index?articalId=${articalId}`
- }
- }
- })
|