320 lines
14 KiB
JavaScript
Executable File
320 lines
14 KiB
JavaScript
Executable File
var t = getApp(), a = wx.createInnerAudioContext();
|
|
|
|
Page({
|
|
data: {
|
|
currentIndex: 0,
|
|
tabList: [],
|
|
curId: "",
|
|
tempUserId: "",
|
|
dataList: [],
|
|
speedStep: 5,
|
|
waitFlag: !1,
|
|
topHeight: t.globalData.CustomBar,
|
|
currentTab: "",
|
|
count: 3
|
|
},
|
|
onLoad: function(t) {
|
|
console.log(t.userId), this.setData({
|
|
curId: t.id,
|
|
tempUserId: t.userId
|
|
}), wx.setNavigationBarTitle({
|
|
title: "栏目"
|
|
}), this.getTabs();
|
|
},
|
|
getTabs: function() {
|
|
var a = this;
|
|
wx.showLoading({
|
|
title: "加载中..."
|
|
}), t.http.get(t.urls.getMainColumn, {
|
|
header: {
|
|
token: t.globalData.token
|
|
},
|
|
data: {
|
|
cardTemplateUseId: a.data.tempUserId
|
|
}
|
|
}).then(function(t) {
|
|
for (var e = 0; e < t.data.length; e++) t.data[e].configColumnId == a.data.curId && a.setData({
|
|
currentTab: t.data[e],
|
|
currentIndex: e
|
|
});
|
|
wx.hideLoading({}), a.setData({
|
|
tabList: t.data
|
|
}), a.getMainMoment(a.data.curId);
|
|
}).catch(function(t) {
|
|
wx.hideLoading({});
|
|
});
|
|
},
|
|
onChange: function(t) {
|
|
var a = t.detail.index, e = this.data.tabList[a].configColumnId;
|
|
console.log(e);
|
|
this.setData({
|
|
currentIndex: a,
|
|
currentTab: this.data.tabList[a]
|
|
}), this.getMainMoment(e);
|
|
},
|
|
getMainMoment: function(a) {
|
|
wx.showLoading({
|
|
title: "加载中..."
|
|
});
|
|
var e = this;
|
|
t.http.get(t.urls.getMainMoment.format({
|
|
configColumnId: a
|
|
}), {
|
|
header: {
|
|
token: t.globalData.token
|
|
},
|
|
data: {
|
|
userId: e.data.tempUserId
|
|
}
|
|
}).then(function(t) {
|
|
wx.hideLoading({}), e.buildMainData(t.data);
|
|
}).catch(function(t) {
|
|
wx.hideLoading({});
|
|
});
|
|
},
|
|
buildMainData: function(a) {
|
|
var e = this, i = "";
|
|
a.forEach(function(a) {
|
|
var n = e.data.tabList[e.data.currentIndex], s = "2" == n.configColumnCollect || "4" == n.configColumnCollect || "2" == n.configColumnLike && "4" == n.configColumnLike || "2" == n.configColumnDispatch || "4" == n.configColumnDispatch || "2" == n.configColumnComment || "4" == n.configColumnComment;
|
|
a.cId = e.data.tabList[e.data.currentIndex].configColumnId, a.collectSwitch = e.data.tabList[e.data.currentIndex].configColumnCollect,
|
|
a.commentSwitch = e.data.tabList[e.data.currentIndex].configColumnComment, a.shareSwitch = e.data.tabList[e.data.currentIndex].configColumnDispatch,
|
|
a.likeSwitch = e.data.tabList[e.data.currentIndex].configColumnLike, a.funcSwitch = s,
|
|
i += a.uid + ",", a.collectCount = 0, a.collectStatus = !1, a.commentCount = 0,
|
|
a.dispatchCount = 0, a.likeCount = 0, a.likeStatus = !1, a.scansCount = 0, a.list.forEach(function(a) {
|
|
switch (a.dataType) {
|
|
case "2":
|
|
var e = a.value.split("@");
|
|
e.length > 1 ? a.dataMode = e[1] : a.dataMode = "1";
|
|
var i = e[0].split(","), n = [];
|
|
i.forEach(function(a) {
|
|
if (a.length > 0) {
|
|
var e = {
|
|
id: a,
|
|
path: t.baseUrls.baseCardUrl + a
|
|
};
|
|
n.push(e);
|
|
}
|
|
}), a.valueList = n;
|
|
break;
|
|
|
|
case "3":
|
|
i = a.value.split(","), n = [];
|
|
i.forEach(function(a) {
|
|
if (a.length > 0) {
|
|
var e = a.split("&"), i = "00:00";
|
|
if (e.length > 1) {
|
|
var s = e[1], d = parseInt(s / 60), r = parseInt(s % 60);
|
|
i = (d > 9 ? d : "0" + d) + ":" + (+r > 9 ? r : "0" + r);
|
|
}
|
|
var o = {
|
|
id: e[0],
|
|
path: t.baseUrls.baseCardUrl + e[0],
|
|
isPlay: !1,
|
|
duration: 1e5,
|
|
curDuration: 0,
|
|
curDurationStr: "00:00",
|
|
totalDurationStr: i
|
|
};
|
|
n.push(o);
|
|
}
|
|
}), a.valueList = n;
|
|
break;
|
|
|
|
case "4":
|
|
i = a.value.split(","), n = [];
|
|
for (var s = 0; s < i.length; s++) if (i[s].length > 0) {
|
|
var d = i[s].split("&"), r = {
|
|
path: t.baseUrls.baseCardUrl + d[0],
|
|
imgPath: t.baseUrls.baseCardUrl + d[1]
|
|
};
|
|
n.push(r);
|
|
}
|
|
a.valueList = n;
|
|
break;
|
|
|
|
case "6":
|
|
i = a.value.split("-"), n = [];
|
|
i.forEach(function(t) {
|
|
if (t.length > 0) {
|
|
var a = t.split(","), e = {
|
|
name: "",
|
|
address: "",
|
|
latitude: a[0],
|
|
longitude: a[1]
|
|
};
|
|
n.push(e);
|
|
}
|
|
}), a.valueList = n;
|
|
break;
|
|
|
|
case "8":
|
|
a.dictionariesList.forEach(function(t) {
|
|
-1 != a.value.indexOf(t.dataId) && (a.selValue = t.dataName);
|
|
});
|
|
break;
|
|
|
|
case "9":
|
|
a.dictionariesList.forEach(function(t) {
|
|
-1 != a.value.indexOf(t.dataId) ? t.isSel = !0 : t.isSel = !1;
|
|
});
|
|
}
|
|
});
|
|
}), e.setData({
|
|
dataList: a
|
|
}), e.data.dataList.length > 0 && e.getColumnContentHandle(i);
|
|
},
|
|
getColumnContentHandle: function(a) {
|
|
var e = this;
|
|
wx.showLoading({
|
|
title: "加载中..."
|
|
}), t.http.get(t.urls.getColumnContentHandle.format({
|
|
projectId: "column",
|
|
businessIds: a
|
|
}), {
|
|
header: {
|
|
token: t.globalData.token
|
|
}
|
|
}).then(function(t) {
|
|
wx.hideLoading({}), t.data.forEach(function(t) {
|
|
e.data.dataList.forEach(function(a) {
|
|
a.uid == t.businessId && (a.collectCount = t.collectCount, a.collectStatus = t.collectStatus,
|
|
a.commentCount = t.commentCount, a.dispatchCount = t.dispatchCount, a.likeCount = t.likeCount,
|
|
a.likeStatus = t.likeStatus, a.scansCount = t.scansCount);
|
|
});
|
|
}), e.setData({
|
|
dataList: e.data.dataList
|
|
});
|
|
}).catch(function(t) {});
|
|
},
|
|
viewImg: function(t) {
|
|
var a = [], e = t.currentTarget.dataset.values;
|
|
this.setData({
|
|
isNeedRefresh: !1
|
|
}), e.forEach(function(t) {
|
|
a.push(t.path);
|
|
}), wx.previewImage({
|
|
urls: a,
|
|
current: t.currentTarget.dataset.cur
|
|
});
|
|
},
|
|
viewVideo: function(t) {
|
|
var a = t.currentTarget.dataset.url;
|
|
wx.previewMedia({
|
|
sources: [ {
|
|
url: a,
|
|
type: "video"
|
|
} ]
|
|
});
|
|
},
|
|
play: function(t) {
|
|
var e = this, i = t.currentTarget.dataset.index, n = t.currentTarget.dataset.i, s = t.currentTarget.dataset.a, d = t.currentTarget.dataset.item;
|
|
e.data.dataList.forEach(function(t) {
|
|
t.list.forEach(function(t) {
|
|
"3" == t.dataType && t.valueList && t.valueList.forEach(function(t) {
|
|
t.isPlay && a.stop(), t.isPlay = !1, t.curDuration = 0, t.curDuationStr = "00:00";
|
|
});
|
|
});
|
|
}), d.isPlay ? a.stop() : ((a = wx.createInnerAudioContext()).src = e.data.dataList[i].list[n].valueList[s].path + ".mp3",
|
|
a.autoplay = !0), a.onPlay(function() {
|
|
console.log("onPlay"), e.data.dataList[i].list[n].valueList[s].isPlay = !0, e.setData({
|
|
dataList: e.data.dataList
|
|
});
|
|
}), a.onCanplay(function(t) {}), a.onStop(function(t) {
|
|
e.data.dataList[i].list[n].valueList[s].isPlay = !1, e.data.dataList[i].list[n].valueList[s].curDuration = 0,
|
|
e.data.dataList[i].list[n].valueList[s].curDurationStr = "00:00", e.setData({
|
|
dataList: e.data.dataList
|
|
}), a.destroy();
|
|
}), a.onEnded(function(t) {
|
|
e.data.dataList[i].list[n].valueList[s].isPlay = !1, e.data.dataList[i].list[n].valueList[s].curDuration = 0,
|
|
e.data.dataList[i].list[n].valueList[s].curDurationStr = "00:00", e.setData({
|
|
dataList: e.data.dataList
|
|
}), a.destroy();
|
|
}), a.onError(function(t) {
|
|
e.data.dataList[i].list[n].valueList[s].isPlay = !1, e.data.dataList[i].list[n].valueList[s].curDuration = 0,
|
|
e.data.dataList[i].list[n].valueList[s].curDurationStr = "00:00", e.setData({
|
|
dataList: e.data.dataList
|
|
}), a.destroy();
|
|
}), a.onSeeking(function() {}), a.onWaiting(function() {}), a.onTimeUpdate(function() {
|
|
if (a.duration != 1 / 0) {
|
|
e.data.dataList[i].list[n].valueList[s].curDuration = parseInt(a.currentTime), e.data.dataList[i].list[n].valueList[s].duration = parseInt(a.duration);
|
|
var t = parseInt(a.currentTime / 60), d = parseInt(a.currentTime % 60), r = parseInt(a.duration / 60), o = parseInt(a.duration % 60), u = t > 9 ? t : "0" + t, c = d > 9 ? d : "0" + d, l = r > 9 ? r : "0" + r, h = +o > 9 ? o : "0" + o;
|
|
e.data.dataList[i].list[n].valueList[s].curDurationStr = u + ":" + c, e.data.dataList[i].list[n].valueList[s].totalDurationStr = l + ":" + h,
|
|
e.setData({
|
|
dataList: e.data.dataList
|
|
});
|
|
}
|
|
});
|
|
},
|
|
rewind: function(t) {
|
|
var e = t.currentTarget.dataset.index, i = t.currentTarget.dataset.item, n = t.currentTarget.dataset.a, s = t.currentTarget.dataset.i;
|
|
i.isPlay && (this.data.dataList[e].list[s].valueList[n].curDuration = this.data.dataList[e].list[s].valueList[n].curDuration - this.data.speedStep,
|
|
a.seek(this.data.dataList[e].list[s].valueList[n].curDuration), this.setData({
|
|
dataList: this.data.dataList
|
|
}));
|
|
},
|
|
speed: function(t) {
|
|
var e = t.currentTarget.dataset.index, i = t.currentTarget.dataset.item, n = t.currentTarget.dataset.a, s = t.currentTarget.dataset.i;
|
|
i.isPlay && (this.data.dataList[e].list[s].valueList[n].curDuration = this.data.dataList[e].list[s].valueList[n].curDuration + this.data.speedStep,
|
|
a.seek(this.data.dataList[e].list[s].valueList[n].curDuration), this.setData({
|
|
dataList: this.data.dataList
|
|
}));
|
|
},
|
|
slider4change: function(t) {
|
|
t.currentTarget.dataset.index;
|
|
t.currentTarget.dataset.item.isPlay && a.seek(t.detail.value);
|
|
},
|
|
onUnload: function(t) {
|
|
a && a.stop();
|
|
},
|
|
showDetail: function(t) {
|
|
if (-1 != this.data.currentTab.configColumnType.indexOf("dda5007c-5fb7-48f2-8537-3cb8ea298242")) {
|
|
var a = this.data.currentTab.configColumnId, e = t.currentTarget.dataset.uid;
|
|
console.log(t), wx.navigateTo({
|
|
url: "/packagecard/moments/momentsdetail/momentsdetail?uId=" + e + "&cId=" + a
|
|
});
|
|
}
|
|
},
|
|
showComment: function(t) {
|
|
var a = t.currentTarget.dataset.cid, e = t.currentTarget.dataset.uid, i = t.currentTarget.dataset.like, n = "&collectSwitch=" + t.currentTarget.dataset.collect + "&likeSwitch=" + i + "&commentSwitch=" + t.currentTarget.dataset.comment + "&shareSwitch=" + t.currentTarget.dataset.share;
|
|
console.log(n), wx.navigateTo({
|
|
url: "/packagecard/moments/momentsdetail/momentsdetail?uId=" + e + "&cId=" + a + n
|
|
});
|
|
},
|
|
doLike: function(a) {
|
|
var e = this, i = a.currentTarget.dataset.item, n = a.currentTarget.dataset.index, s = "";
|
|
s = i.likeStatus ? "取消中..." : "保存中...", wx.showLoading({
|
|
title: s
|
|
}), t.http.post(t.urls.doSaveLike, {
|
|
header: {
|
|
token: t.globalData.token
|
|
},
|
|
data: {
|
|
businessId: i.uid,
|
|
projectId: "column"
|
|
}
|
|
}).then(function(t) {
|
|
wx.hideLoading({}), e.data.dataList[n].likeStatus = !i.likeStatus, i.likeStatus ? --e.data.dataList[n].likeCount : ++e.data.dataList[n].likeCount,
|
|
e.setData({
|
|
dataList: e.data.dataList
|
|
});
|
|
}).catch(function(t) {});
|
|
},
|
|
doCollect: function(a) {
|
|
var e = this, i = a.currentTarget.dataset.item, n = a.currentTarget.dataset.index, s = "";
|
|
s = i.collectStatus ? "取消收藏..." : "收藏中...", wx.showLoading({
|
|
title: s
|
|
}), t.http.post(t.urls.doSaveCollect, {
|
|
header: {
|
|
token: t.globalData.token
|
|
},
|
|
data: {
|
|
businessId: i.uid,
|
|
projectId: "column"
|
|
}
|
|
}).then(function(t) {
|
|
wx.hideLoading({}), e.data.dataList[n].collectStatus = !i.collectStatus, e.setData({
|
|
dataList: e.data.dataList
|
|
});
|
|
}).catch(function(t) {});
|
|
}
|
|
}); |