|
|
// 逛文章详情
|
|
|
import { ACTIVITY_HOST, API_HOST, SERVICE_HOST } from '../../libs/config';
|
|
|
import { ACTIVITY_HOST, YOHOOD_HOST, API_HOST, SERVICE_HOST } from '../../libs/config';
|
|
|
import { GET, POST } from '../../libs/request';
|
|
|
import guangUtil from './util';
|
|
|
import Promise from '../../vendors/es6-promise';
|
...
|
...
|
@@ -25,6 +25,7 @@ Page({ |
|
|
screenHeight: screenHeight - 60,
|
|
|
isShowIndicator: false,
|
|
|
|
|
|
isActivtyDetail: false,
|
|
|
replyTemArray: [],
|
|
|
articleInfo: {},
|
|
|
articleContent: {},
|
...
|
...
|
@@ -47,9 +48,10 @@ Page({ |
|
|
},
|
|
|
|
|
|
loadElement: function(options) {
|
|
|
|
|
|
let isActivtyDetail = options.isActivtyDetail || false;
|
|
|
this.setData({
|
|
|
options,
|
|
|
isActivtyDetail,
|
|
|
yasParam: `&page_name=${this.data.current_page_name}&page_param=${options.id || ''}`,
|
|
|
current_page_param: options.id || '',
|
|
|
from_page_name: options.page_name || '',
|
...
|
...
|
@@ -66,17 +68,13 @@ Page({ |
|
|
},
|
|
|
|
|
|
_init: function() {
|
|
|
return Promise.all([
|
|
|
this._getArticleExec(),
|
|
|
// this._getArticleContentExec(),
|
|
|
// this._getBrandExec(),
|
|
|
let isActivtyDetail = this.data.isActivtyDetail || false;
|
|
|
if (isActivtyDetail) { //活动详情
|
|
|
this._getActivityDetailExec();
|
|
|
} else { //资讯详情
|
|
|
this._getArticleExec();
|
|
|
}
|
|
|
|
|
|
]).then(result => {
|
|
|
// return Promise.all([
|
|
|
// this._recomandLi(result[1]),
|
|
|
// this._getOtherArticleExec(result[0].tag)
|
|
|
// ]);
|
|
|
});
|
|
|
},
|
|
|
_getArticleExec: function() {
|
|
|
let that = this;
|
...
|
...
|
@@ -92,7 +90,7 @@ Page({ |
|
|
|
|
|
console.log(replyTemArray);
|
|
|
// debugger;
|
|
|
this.setData({
|
|
|
that.setData({
|
|
|
articleInfo: data,
|
|
|
replyTemArray,
|
|
|
});
|
...
|
...
|
@@ -101,71 +99,39 @@ Page({ |
|
|
});
|
|
|
},
|
|
|
|
|
|
_getActivityDetailExec: function() {
|
|
|
let that = this;
|
|
|
let param = {
|
|
|
id: this.data.options.id
|
|
|
}
|
|
|
GET(YOHOOD_HOST + '/activity/detail', param)
|
|
|
.then(json => {
|
|
|
|
|
|
if (json && json.code == 200) {
|
|
|
let data = json.data;
|
|
|
console.log('====================================');
|
|
|
console.log(data);
|
|
|
console.log('====================================');
|
|
|
|
|
|
wx.setNavigationBarTitle({title: data.title || '文章详情'});
|
|
|
var article = data.content;
|
|
|
|
|
|
WxParse.wxParse('replyTemArray', 'html', article, that, 0);
|
|
|
let replyTemArray = this.data.replyTemArray;
|
|
|
|
|
|
console.log(replyTemArray);
|
|
|
// debugger;
|
|
|
that.setData({
|
|
|
articleInfo: data,
|
|
|
replyTemArray,
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
.catch(error => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_getArticleContentExec: function() {
|
|
|
return guangUtil._getArticleContent({
|
|
|
article_id: this.data.options.id
|
|
|
}, GET, API_HOST).then(rdata => {
|
|
|
rdata = guangUtil._processArticleDetail(rdata);
|
|
|
|
|
|
rdata.replyTexts.map((text, tindex) => {
|
|
|
|
|
|
WxParse.wxParse('reply' + tindex, 'html', text, this, 0);
|
|
|
|
|
|
if (tindex === rdata.replyTexts.length - 1) {
|
|
|
WxParse.wxParseTemArray("replyTemArray", 'reply', rdata.replyTexts.length, this);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
let replyTemArray = this.data.replyTemArray;
|
|
|
|
|
|
rdata.finalDetail.map(item => {
|
|
|
if (item.text) {
|
|
|
item.wxText = replyTemArray.shift();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
this.setData({articleContent: rdata, replyTemArray: []});
|
|
|
return rdata;
|
|
|
});
|
|
|
},
|
|
|
_recomandLi: function(data) {
|
|
|
return guangUtil._recomandLi({skns: data.allGoods}, GET, API_HOST).then(rdata => {
|
|
|
data.finalDetail = guangUtil._pushGoodsInfo(data.finalDetail, rdata.product_list);
|
|
|
this.setData({articleContent: data});
|
|
|
});
|
|
|
})
|
|
|
},
|
|
|
_getBrandExec: function() {
|
|
|
return guangUtil._getBrand({
|
|
|
article_id: this.data.options.id
|
|
|
}, GET, API_HOST).then(rdata => {
|
|
|
rdata.map(item => {
|
|
|
if (item.thumb) {
|
|
|
item.thumb = util.formatImageUrl(item.thumb.replace(/\?(.*)/, ''), 160, 80, 1);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
this.setData({brands: rdata});
|
|
|
return rdata;
|
|
|
});
|
|
|
},
|
|
|
_getOtherArticleExec: function(tag) {
|
|
|
return guangUtil._getOtherArticle({
|
|
|
article_id: this.data.options.id,
|
|
|
tags: tag || ''
|
|
|
}, GET, API_HOST).then(rdata => {
|
|
|
rdata.map(item => {
|
|
|
if (item.thumb) {
|
|
|
item.thumb = util.formatImageUrl(item.thumb, 240, 150, 1);
|
|
|
}
|
|
|
});
|
|
|
this.setData({otherArticles: rdata});
|
|
|
return rdata;
|
|
|
});
|
|
|
},
|
|
|
setGoodsMore: function(event) {
|
|
|
let data = event.currentTarget.dataset;
|
|
|
let findex = data.findex || 0;
|
...
|
...
|
@@ -202,6 +168,11 @@ Page({ |
|
|
});
|
|
|
},
|
|
|
|
|
|
applyAction: function(event) {
|
|
|
let id = event.currentTarget.dataset.id;
|
|
|
|
|
|
},
|
|
|
|
|
|
//跳转到登录页面
|
|
|
loginAndRegisterTapped:function(needBind) {
|
|
|
let app = getApp()
|
...
|
...
|
|