|
|
|
|
// pages/user/service/info/index.js
|
|
|
|
|
import commonApi from "../../../../utils/https/common"
|
|
|
|
|
import util from "../../../../utils/util"
|
|
|
|
|
import WxParse from "../../../../utils/wxParse/wxParse.js"
|
|
|
|
|
Page({
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面的初始数据
|
|
|
|
|
*/
|
|
|
|
|
data: {
|
|
|
|
|
info:null,
|
|
|
|
|
linkData:[],
|
|
|
|
|
|
|
|
|
|
phoneList: ["0512-66555111","18915532527"],
|
|
|
|
|
showPhoneMask: false
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
|
*/
|
|
|
|
|
onLoad: function (options) {
|
|
|
|
|
if(options.id){
|
|
|
|
|
commonApi.user_post("ics/getQuestionDetail",{
|
|
|
|
|
id:options.id
|
|
|
|
|
}).then(res=>{
|
|
|
|
|
if(!res.data.useful_info) res.data.useful_info = {};
|
|
|
|
|
this.setData({
|
|
|
|
|
info:res.data
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
var article = res.data.answer.replace(/"/g, '');
|
|
|
|
|
var that = this;
|
|
|
|
|
WxParse.wxParse('article', 'html', article, that, 0);
|
|
|
|
|
|
|
|
|
|
// console.log(this.data)
|
|
|
|
|
let arrayData = []
|
|
|
|
|
this.parseTagA(this.data.article.nodes, arrayData)
|
|
|
|
|
this.setData({linkData: arrayData})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
util.back()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// wxParse 解析a标签
|
|
|
|
|
wxParseTagATap: function(e){
|
|
|
|
|
console.log(e)
|
|
|
|
|
let href = e.currentTarget.dataset.src;
|
|
|
|
|
let linkTarget = this.data.linkData.find(v=>v.href == href)
|
|
|
|
|
if (linkTarget) {
|
|
|
|
|
if (linkTarget["attr-minilink"]) {
|
|
|
|
|
wx.navigateTo({url: linkTarget["attr-minilink"]})
|
|
|
|
|
} else {
|
|
|
|
|
if(href.indexOf("http") >= 0){
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: "/pages/pbService/web/index?weburl=" + encodeURIComponent(href)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (this.data.link) {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: this.data.link
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
// console.log(e.currentTarget)
|
|
|
|
|
// var href = e.currentTarget.dataset.src;
|
|
|
|
|
// console.log(href);
|
|
|
|
|
// if(href.indexOf("http") >= 0){
|
|
|
|
|
// wx.navigateTo({
|
|
|
|
|
// url: "/pages/pbService/web/index?weburl=" + encodeURIComponent(href)
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 递归article取出所有a标签
|
|
|
|
|
parseTagA:function (nodes, array) {
|
|
|
|
|
nodes.forEach(v=>{
|
|
|
|
|
if (v.attr && v.attr.href) {
|
|
|
|
|
array.push(v.attr)
|
|
|
|
|
}
|
|
|
|
|
if (Array.isArray(v.nodes) && v.nodes.length>0) {
|
|
|
|
|
this.parseTagA(v.nodes,array)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
showService:function(){
|
|
|
|
|
util.pagePoint({
|
|
|
|
|
event:'customer_service_human_click',
|
|
|
|
|
param: {
|
|
|
|
|
id: this.data.info.id
|
|
|
|
|
}
|
|
|
|
|
},1)
|
|
|
|
|
// wx.showModal({
|
|
|
|
|
// title: '提示',
|
|
|
|
|
// content: '呼叫人工客服\n0512-66555111',
|
|
|
|
|
// confirmColor:"#0B898E",
|
|
|
|
|
// success (res) {
|
|
|
|
|
// if (res.confirm) {
|
|
|
|
|
// wx.makePhoneCall({
|
|
|
|
|
// phoneNumber: '0512-66555111',
|
|
|
|
|
// })
|
|
|
|
|
// } else if (res.cancel) {
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
this.setData({showPhoneMask: true})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
callPhone (e) {
|
|
|
|
|
let item = e.currentTarget.dataset.item;
|
|
|
|
|
wx.makePhoneCall({
|
|
|
|
|
phoneNumber: item,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
closePhoneMask () {
|
|
|
|
|
this.setData({showPhoneMask: false})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
zan:function(){
|
|
|
|
|
let info = this.data.info;
|
|
|
|
|
commonApi.user_post("ics/useful",{
|
|
|
|
|
id:info.id
|
|
|
|
|
}).then(res=>{
|
|
|
|
|
if(res.code==1){
|
|
|
|
|
if(info.useful_info && info.useful_info.is_useful===0){
|
|
|
|
|
// 如果已经点了没用 那么原来点的没用的数量要减1
|
|
|
|
|
info.unuseful_num--;
|
|
|
|
|
}
|
|
|
|
|
info.useful_info = res.data;
|
|
|
|
|
console.log(info.useful_info)
|
|
|
|
|
info.useful_num = info.useful_info.is_useful==1?(info.useful_num+1):(info.useful_num-1);
|
|
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
|
info:info
|
|
|
|
|
})
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '操作成功',
|
|
|
|
|
icon: 'success'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
unzan:function(){
|
|
|
|
|
let info = this.data.info;
|
|
|
|
|
commonApi.user_post("ics/unuseful",{
|
|
|
|
|
id:info.id
|
|
|
|
|
}).then(res=>{
|
|
|
|
|
if(res.code==1){
|
|
|
|
|
if(info.useful_info && info.useful_info.is_useful==1){
|
|
|
|
|
// 如果已经点了没用 那么原来点的没用的数量要减1
|
|
|
|
|
info.useful_num--;
|
|
|
|
|
}
|
|
|
|
|
info.useful_info = res.data
|
|
|
|
|
info.unuseful_num = info.useful_info.is_useful===0?(info.unuseful_num+1):(info.unuseful_num-1);
|
|
|
|
|
this.setData({
|
|
|
|
|
info:info
|
|
|
|
|
})
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '操作成功',
|
|
|
|
|
icon: 'success'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
|
*/
|
|
|
|
|
onReady: function () {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
|
*/
|
|
|
|
|
onShow: function () {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
|
*/
|
|
|
|
|
onHide: function () {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
|
*/
|
|
|
|
|
onUnload: function () {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
|
*/
|
|
|
|
|
onPullDownRefresh: function () {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
|
*/
|
|
|
|
|
onReachBottom: function () {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|