920 lines
34 KiB
JavaScript
920 lines
34 KiB
JavaScript
var t = getApp(), a = wx.createInnerAudioContext();
|
|
|
|
Page({
|
|
data: {
|
|
token: t.globalData.token,
|
|
serviceUrl: t.baseUrls.serviceUrl,
|
|
baseImgUrl: t.baseUrls.baseImgUrl,
|
|
imgUrl: t.baseUrls.baseCardUrl,
|
|
sourceUrl: t.baseUrls.sourceUrl,
|
|
cardUrl: t.baseUrls.baseCardUrl,
|
|
gridMiniId: "",
|
|
gridDetail: {},
|
|
showCode: !1,
|
|
nameTxt: "名片",
|
|
dataList: [],
|
|
curIndex: 0,
|
|
speedStep: 5,
|
|
waitFlag: !1,
|
|
avatarUrl: t.globalData.userInfo.avatarUrl,
|
|
areaList: [],
|
|
cardHeight: "",
|
|
cardInfo: {},
|
|
personIntro: {},
|
|
companyIntro: {},
|
|
shareImg: "",
|
|
phoneTxt: "未录入",
|
|
emailTxt: "未录入",
|
|
wechateTxt: "未录入",
|
|
addressTxt: "未录入",
|
|
forwardCount: "",
|
|
shareRecordId: "",
|
|
isShowBarCode: !1,
|
|
browUserList: [],
|
|
isShowBrowseUser: !1,
|
|
shareImgUrl: "",
|
|
tempUserId: "",
|
|
cardTemplateDispatchId: "",
|
|
cardTemplateUseId: "",
|
|
isShowCard: !1,
|
|
otherCardList: [],
|
|
isPlayAudio: !1,
|
|
audioId: "",
|
|
count: 3,
|
|
isMine: 1,
|
|
isDefault: !0,
|
|
animationData: {},
|
|
isShowBtn: !1,
|
|
isShowPhone: !1,
|
|
isBindPhone: !1,
|
|
isNeedRefresh: !0,
|
|
isShowComment: !1,
|
|
posterId: "",
|
|
isShowPoster: !1,
|
|
defaultBtnIcon: "/images/ic_share_img.png"
|
|
},
|
|
onLoad: function(t) {
|
|
this.checkPermission(), t.cardTemplateDispatchId && this.setData({
|
|
cardTemplateDispatchId: t.cardTemplateDispatchId,
|
|
isMine: 2
|
|
}), "" != t.title && null != t.title && wx.setNavigationBarTitle({
|
|
title: t.title
|
|
}), this.buildId(), console.log(null != t.gridMiniId && "" != t.gridMiniId), console.log(t.gridMiniId),
|
|
null != t.gridMiniId && "" != t.gridMiniId ? (console.log("获取名片"), this.setData({
|
|
cardTemplateUseId: t.gridMiniId
|
|
}), this.getCard()) : this.getDefault();
|
|
},
|
|
doLogin: function() {
|
|
var a = this;
|
|
wx.showLoading({
|
|
title: "加载中..."
|
|
}), wx.login({
|
|
success: function(e) {
|
|
t.http.post(t.urls.wxLogin, {
|
|
data: {
|
|
jsCode: e.code
|
|
}
|
|
}).then(function(e) {
|
|
wx.hideLoading({});
|
|
var s = e.data.data.split("_")[0], o = e.data.data.split("_")[1];
|
|
a.setData({
|
|
isBindPhone: 0 == o
|
|
}), wx.setStorageSync("token", s), wx.setStorageSync("bindPhone", o), t.globalData.token = s,
|
|
a.doSaveUserInfo(), a.getInfo(), 2 == a.data.isMine ? "" != a.data.cardTemplateDispatchId && a.getCardId() : a.getDefault(),
|
|
a.getOtherCard(2), a.getBtnIcon();
|
|
}).catch(function(t) {
|
|
wx.hideLoading({});
|
|
});
|
|
}
|
|
});
|
|
},
|
|
getBtnIcon: function() {
|
|
var a = this;
|
|
t.http.get(t.urls.getIndexIcon, {
|
|
header: {
|
|
token: t.globalData.token
|
|
}
|
|
}).then(function(t) {
|
|
t.data.data && a.setData({
|
|
defaultBtnIcon: a.data.imgUrl + t.data.data
|
|
});
|
|
}).catch(function(t) {});
|
|
},
|
|
doSaveUserInfo: function() {
|
|
try {
|
|
var a = wx.getStorageSync("name"), e = wx.getStorageSync("userIcon");
|
|
a && t.http.put(t.urls.doSaveUserInfo, {
|
|
header: {
|
|
token: t.globalData.token
|
|
},
|
|
data: {
|
|
avatarUrl: e,
|
|
nickName: a
|
|
}
|
|
}).then(function(t) {}).catch(function(t) {
|
|
console.log(t);
|
|
});
|
|
} catch (t) {
|
|
t = VM2_INTERNAL_STATE_DO_NOT_USE_OR_PROGRAM_WILL_FAIL.handleException(t);
|
|
console.log(t);
|
|
}
|
|
},
|
|
getMainColumn: function(a) {
|
|
var e = this;
|
|
e.setData({
|
|
dataList: []
|
|
}), t.http.get(t.urls.getMainColumn, {
|
|
header: {
|
|
token: t.globalData.token
|
|
},
|
|
data: {
|
|
creator: a
|
|
}
|
|
}).then(function(t) {
|
|
wx.showLoading({
|
|
title: "加载中..."
|
|
}), e.getMainMoment(t.data, a, 0);
|
|
}).catch(function(t) {
|
|
wx.stopPullDownRefresh({});
|
|
});
|
|
},
|
|
getMainBaseUserInfo: function(a) {
|
|
var e = this;
|
|
t.http.get(t.urls.getMainMoment.format({
|
|
configColumnId: "de7b5e22-64f9-4c60-a1f9-6ac004dfb9a8"
|
|
}), {
|
|
header: {
|
|
token: t.globalData.token
|
|
},
|
|
data: {
|
|
userId: a
|
|
}
|
|
}).then(function(t) {
|
|
t.data.length > 0 ? (e.setData({
|
|
isShowBtn: !0
|
|
}), t.data[0].list.forEach(function(t) {
|
|
switch (t.name) {
|
|
case "phone":
|
|
e.setData({
|
|
phoneTxt: t.value
|
|
});
|
|
break;
|
|
|
|
case "wechat":
|
|
e.setData({
|
|
wechateTxt: t.value
|
|
});
|
|
break;
|
|
|
|
case "email":
|
|
e.setData({
|
|
emailTxt: t.value
|
|
});
|
|
break;
|
|
|
|
case "address":
|
|
e.setData({
|
|
addressTxt: t.value
|
|
});
|
|
}
|
|
})) : e.setData({
|
|
isShowBtn: !1
|
|
});
|
|
}).catch(function(t) {
|
|
console.log(t);
|
|
});
|
|
},
|
|
onClose: function() {
|
|
this.setData({
|
|
isShowPoster: !1,
|
|
isShowBrowseUser: !1
|
|
});
|
|
},
|
|
getMainMoment: function(a, e, s) {
|
|
var o = this;
|
|
s < a.length ? t.http.get(t.urls.getMainMoment.format({
|
|
configColumnId: a[o.data.curIndex].configColumnId
|
|
}), {
|
|
header: {
|
|
token: t.globalData.token
|
|
},
|
|
data: {
|
|
userId: e
|
|
}
|
|
}).then(function(t) {
|
|
if (t.data.length > 0) {
|
|
var s = a[o.data.curIndex], n = {
|
|
funcSwitch: "2" == s.configColumnCollect || "4" == s.configColumnCollect || "2" == s.configColumnLike && "4" == s.configColumnLike || "2" == s.configColumnDispatch || "4" == s.configColumnDispatch || "2" == s.configColumnComment || "4" == s.configColumnComment,
|
|
collectSwitch: a[o.data.curIndex].configColumnCollect,
|
|
commentSwitch: a[o.data.curIndex].configColumnComment,
|
|
shareSwitch: a[o.data.curIndex].configColumnDispatch,
|
|
likeSwitch: a[o.data.curIndex].configColumnLike,
|
|
cId: a[o.data.curIndex].configColumnId,
|
|
type: a[o.data.curIndex].configColumnType,
|
|
name: a[o.data.curIndex].configColumnName,
|
|
mode: a[o.data.curIndex].configTableMode,
|
|
list: t.data.slice(0, a[o.data.curIndex].configColumnRowCount)
|
|
};
|
|
o.data.dataList.push(n);
|
|
}
|
|
o.setData({
|
|
curIndex: ++o.data.curIndex
|
|
}), o.getMainMoment(a, e, o.data.curIndex);
|
|
}).catch(function(t) {
|
|
o.setData({
|
|
curIndex: ++o.data.curIndex
|
|
}), a[o.data.curIndex] && o.getMainMoment(a, e, o.data.curIndex);
|
|
}) : (wx.hideLoading({}), wx.stopPullDownRefresh({}), o.buildMainData());
|
|
},
|
|
buildMainData: function() {
|
|
var t = this, a = "";
|
|
t.data.dataList.forEach(function(e) {
|
|
e.list.forEach(function(e) {
|
|
a += e.uid + ",", e.collectCount = 0, e.collectStatus = !1, e.commentCount = 0,
|
|
e.dispatchCount = 0, e.likeCount = 0, e.likeStatus = !1, e.scansCount = 0, e.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 s = e[0].split(","), o = [];
|
|
s.forEach(function(a) {
|
|
if ("" != a) {
|
|
var e = {
|
|
id: a,
|
|
path: t.data.imgUrl + a
|
|
};
|
|
o.push(e);
|
|
}
|
|
}), a.valueList = o;
|
|
break;
|
|
|
|
case "3":
|
|
s = a.value.split(","), o = [];
|
|
s.forEach(function(a) {
|
|
if ("" != a) {
|
|
var e = a.split("&"), s = "00:00";
|
|
if (e.length > 1) {
|
|
var n = e[1], r = parseInt(n / 60), i = parseInt(n % 60);
|
|
s = (r > 9 ? r : "0" + r) + ":" + (+i > 9 ? i : "0" + i);
|
|
}
|
|
var d = {
|
|
id: e[0],
|
|
path: t.data.imgUrl + e[0],
|
|
isPlay: !1,
|
|
duration: 1e5,
|
|
curDuration: 0,
|
|
curDurationStr: "00:00",
|
|
totalDurationStr: s
|
|
};
|
|
o.push(d);
|
|
}
|
|
}), a.valueList = o;
|
|
break;
|
|
|
|
case "4":
|
|
s = a.value.split(","), o = [];
|
|
for (var n = 0; n < s.length; n++) if ("" != s[n]) {
|
|
var r = s[n].split("&"), i = {
|
|
path: t.data.imgUrl + r[0],
|
|
imgPath: t.data.imgUrl + r[1]
|
|
};
|
|
o.push(i);
|
|
}
|
|
a.valueList = o;
|
|
break;
|
|
|
|
case "6":
|
|
s = a.value.split("-"), o = [];
|
|
s.forEach(function(t) {
|
|
if ("" != t) {
|
|
var a = t.split(","), e = {
|
|
name: "",
|
|
address: "",
|
|
latitude: a[0],
|
|
longitude: a[1]
|
|
};
|
|
o.push(e);
|
|
}
|
|
}), a.valueList = o;
|
|
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;
|
|
});
|
|
}
|
|
});
|
|
});
|
|
}), t.setData({
|
|
curIndex: 0,
|
|
dataList: t.data.dataList
|
|
}), t.getColumnContentHandle(a);
|
|
},
|
|
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.list.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({
|
|
curIndex: 0,
|
|
dataList: e.data.dataList
|
|
});
|
|
}).catch(function(t) {});
|
|
},
|
|
showMore: function(t) {
|
|
var a = t.currentTarget.dataset.item;
|
|
if ("2" == a.mode) {
|
|
var e = t.currentTarget.dataset.userid, s = t.currentTarget.dataset.idx;
|
|
this.setData({
|
|
isNeedRefresh: !1
|
|
}), wx.navigateTo({
|
|
url: "/packagecard/moments/showlist/showlist?id=" + a.cId + "&userId=" + e + "&index=" + s
|
|
});
|
|
}
|
|
},
|
|
onPullDownRefresh: function() {
|
|
"" != t.globalData.token ? (this.setData({
|
|
isNeedRefresh: !0
|
|
}), 2 == this.data.isMine ? "" != this.data.cardTemplateUseId && (this.setData({
|
|
dataList: [],
|
|
cardInfo: null,
|
|
areaList: null
|
|
}), this.getCard()) : 3 == this.data.isMine ? (this.setData({
|
|
dataList: [],
|
|
cardInfo: null,
|
|
areaList: null
|
|
}), this.getBrowUserCard()) : this.getDefault(), this.getOtherCard(2), this.getBtnIcon()) : this.doLogin();
|
|
},
|
|
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;
|
|
this.setData({
|
|
isNeedRefresh: !1
|
|
}), wx.previewMedia({
|
|
sources: [ {
|
|
url: a,
|
|
type: "video"
|
|
} ]
|
|
});
|
|
},
|
|
play: function(t) {
|
|
var e = this, s = t.currentTarget.dataset.index, o = t.currentTarget.dataset.idx, n = t.currentTarget.dataset.i, r = t.currentTarget.dataset.a, i = t.currentTarget.dataset.item;
|
|
console.log(e.data.isPlayAudio), e.data.isPlayAudio ? (e.data.dataList.forEach(function(t) {
|
|
t.list.forEach(function(t) {
|
|
t.list.forEach(function(t) {
|
|
"3" == t.dataType && t.valueList && t.valueList.forEach(function(t) {
|
|
t.isPlay = !1, t.curDuration = 0, t.curDuationStr = "00:00";
|
|
});
|
|
});
|
|
});
|
|
}), e.setData({
|
|
dataList: e.data.dataList
|
|
}), a.stop(), e.data.audioId != i.id && (wx.showLoading({
|
|
title: "加载中..."
|
|
}), setTimeout(function() {
|
|
wx.hideLoading({}), a.src = e.data.dataList[s].list[o].list[n].valueList[r].path + ".mp3",
|
|
a.startTime = 0, a.autoplay = !0, e.data.dataList[s].list[o].list[n].valueList[r].isPlay = !0,
|
|
e.setData({
|
|
dataList: e.data.dataList,
|
|
isPlayAudio: !0,
|
|
audioId: i.id
|
|
});
|
|
}, 1500))) : (a.src = e.data.dataList[s].list[o].list[n].valueList[r].path + ".mp3",
|
|
a.startTime = 0, a.autoplay = !0, a.play(), e.data.dataList[s].list[o].list[n].valueList[r].isPlay = !0,
|
|
e.setData({
|
|
dataList: e.data.dataList,
|
|
isPlayAudio: !0,
|
|
audioId: i.id
|
|
})), a.onPlay(function() {}), a.onCanplay(function(t) {}), a.onStop(function(t) {
|
|
console.log("onStop==="), e.data.dataList[s].list[o].list[n].valueList[r].isPlay = !1,
|
|
e.data.dataList[s].list[o].list[n].valueList[r].curDuration = 0, e.data.dataList[s].list[o].list[n].valueList[r].curDurationStr = "00:00",
|
|
e.setData({
|
|
dataList: e.data.dataList,
|
|
isPlayAudio: !1
|
|
});
|
|
}), a.onEnded(function(t) {
|
|
console.log(t), console.log("播放完毕"), e.data.dataList[s].list[o].list[n].valueList[r].isPlay = !1,
|
|
e.data.dataList[s].list[o].list[n].valueList[r].curDuration = 0, e.data.dataList[s].list[o].list[n].valueList[r].curDurationStr = "00:00",
|
|
e.setData({
|
|
dataList: e.data.dataList,
|
|
isPlayAudio: !1
|
|
});
|
|
}), a.onError(function(t) {
|
|
console.log("播放错误"), console.log(t), e.data.dataList[s].list[o].list[n].valueList[r].isPlay = !1,
|
|
e.data.dataList[s].list[o].list[n].valueList[r].curDuration = 0, e.data.dataList[s].list[o].list[n].valueList[r].curDurationStr = "00:00",
|
|
e.setData({
|
|
dataList: e.data.dataList,
|
|
isPlayAudio: !1
|
|
});
|
|
}), a.onSeeking(function() {});
|
|
},
|
|
goList: function() {
|
|
wx.navigateTo({
|
|
url: "/packagecard/cardList/cardList"
|
|
});
|
|
},
|
|
getPersonIntro: function() {
|
|
var a = this;
|
|
t.restAjax.get(t.restAjax.path("{personIntroUrl}app/userexpand/get/" + t.globalData.userInfo.userId, [ t.personIntroUrl ]), {}, {
|
|
headers: {
|
|
token: t.globalData.token
|
|
}
|
|
}, function(t, e) {
|
|
a.setData({
|
|
personIntro: e
|
|
});
|
|
}, function(a, e) {
|
|
t.dialog.msg(e.msg);
|
|
});
|
|
},
|
|
getUserInfo: function() {
|
|
var a = this;
|
|
t.restAjax.get(t.restAjax.path("{loginUrl}app/user/get-app-user", [ t.personIntroUrl ]), {}, {
|
|
headers: {
|
|
token: t.globalData.token
|
|
}
|
|
}, function(e, s) {
|
|
t.globalData.userInfo = s, a.getList();
|
|
}, function(a, e) {
|
|
t.dialog.msg(e.msg);
|
|
});
|
|
},
|
|
getInfo: function() {
|
|
t.http.get(t.urls.getUserBaseInfo, {
|
|
header: {
|
|
token: t.globalData.token
|
|
}
|
|
}).then(function(a) {
|
|
wx.setStorageSync("usercode", a.data.userCode), t.globalData.currentUserId = a.data.userId;
|
|
}).catch(function(t) {
|
|
console.log(t);
|
|
});
|
|
},
|
|
getDefault: function() {
|
|
var a = this;
|
|
t.globalData.showUserId = "", a.setData({
|
|
cardInfo: {},
|
|
areaList: []
|
|
}), t.http.get(t.urls.getDefaultCard, {
|
|
header: {
|
|
token: t.globalData.token
|
|
},
|
|
data: {}
|
|
}).then(function(e) {
|
|
var s = e.data.areaList;
|
|
s.forEach(function(t) {
|
|
"name" == t.templateAreaSource && a.setData({
|
|
nameTxt: t.templateAreaFontValue
|
|
});
|
|
}), a.setData({
|
|
cardInfo: e.data,
|
|
isDefault: "1" == e.data.cardTemplateUseSystem,
|
|
areaList: s,
|
|
dataList: []
|
|
}), e.data && (a.toSaveLocalImg(e.data.cardTemplateUseDispatchPhoto), a.getBrowCardUserList(e.data.cardTemplateUseId),
|
|
a.setData({
|
|
tempUserId: e.data.creator,
|
|
cardTemplateUseId: e.data.cardTemplateUseId
|
|
}), t.globalData.userId = e.data.creator, a.getMainColumn(e.data.creator), a.getMainBaseUserInfo(e.data.creator));
|
|
}).catch(function(t) {});
|
|
},
|
|
getBrowCardUserList: function(a) {
|
|
var e = this;
|
|
t.http.get(t.urls.getCardBrowUserList, {
|
|
header: {
|
|
token: t.globalData.token
|
|
},
|
|
data: {
|
|
page: "1",
|
|
rows: "7",
|
|
cardTemplateUseId: a
|
|
}
|
|
}).then(function(t) {
|
|
t.data && e.setData({
|
|
browUserList: t.data.rows
|
|
});
|
|
}).catch(function(t) {
|
|
console.log(t);
|
|
});
|
|
},
|
|
addContact: function() {
|
|
wx.addPhoneContact({
|
|
firstName: this.data.nameTxt,
|
|
mobilePhoneNumber: this.data.phoneNum
|
|
});
|
|
},
|
|
includedCard: function() {
|
|
t.http.post(t.urls.includedCard, {
|
|
header: {
|
|
token: t.globalData.token
|
|
},
|
|
data: {
|
|
cardTemplateUseBagId: "",
|
|
cardTemplateUseId: this.data.cardInfo.cardTemplateUseId,
|
|
cardTemplateUseStar: "",
|
|
cardTemplateUseTag: "",
|
|
cardTemplateUseTop: ""
|
|
}
|
|
}).then(function(t) {
|
|
console.log(t.data), wx.showToast({
|
|
title: "加入卡包成功!"
|
|
});
|
|
}).catch(function(t) {});
|
|
},
|
|
getBrowUserCard: function() {
|
|
var a = this;
|
|
a.setData({
|
|
cardInfo: {},
|
|
areaList: []
|
|
}), t.http.get(t.urls.getBrowUserCard.format({
|
|
userId: a.data.cardTemplateUseId
|
|
}), {
|
|
header: {
|
|
token: t.globalData.token
|
|
},
|
|
data: {}
|
|
}).then(function(e) {
|
|
t.globalData.showUserId = e.data.creator, wx.stopPullDownRefresh({});
|
|
var s = e.data.areaList;
|
|
s.forEach(function(t) {
|
|
"name" == t.templateAreaSource && a.setData({
|
|
nameTxt: t.templateAreaFontValue
|
|
});
|
|
}), a.setData({
|
|
cardInfo: e.data,
|
|
areaList: s,
|
|
dataList: []
|
|
}), e.data && (a.toSaveLocalImg(e.data.cardTemplateUseDispatchPhoto), a.getBrowCardUserList(e.data.cardTemplateUseId),
|
|
t.globalData.userId = e.data.creator, a.setData({
|
|
tempUserId: e.data.creator
|
|
}), a.getMainColumn(e.data.creator), a.getMainBaseUserInfo(e.data.creator));
|
|
}).catch(function(t) {
|
|
wx.stopPullDownRefresh({});
|
|
});
|
|
},
|
|
makeCall: function() {
|
|
var t = this.data.phoneTxt;
|
|
t && wx.makePhoneCall({
|
|
phoneNumber: t
|
|
});
|
|
},
|
|
copyText: function(t) {
|
|
var a = t.currentTarget.dataset.text;
|
|
a && wx.setClipboardData({
|
|
data: a,
|
|
success: function() {}
|
|
});
|
|
},
|
|
checkPermission: function() {
|
|
var t = this;
|
|
try {
|
|
var a = wx.getStorageSync("name"), e = wx.getStorageSync("userIcon");
|
|
a ? this.setData({
|
|
name: a,
|
|
userIcon: e
|
|
}) : wx.showModal({
|
|
title: "提示",
|
|
content: "小程序需要您微信头像以及昵称用于展示,请授权.",
|
|
showCancel: !1,
|
|
success: function(a) {
|
|
a.confirm && t.getUserProfile(3);
|
|
}
|
|
});
|
|
} catch (t) {
|
|
t = VM2_INTERNAL_STATE_DO_NOT_USE_OR_PROGRAM_WILL_FAIL.handleException(t);
|
|
wx.showToast({
|
|
title: "获取信息失败",
|
|
icon: "error"
|
|
});
|
|
}
|
|
},
|
|
getPhoneNumber: function(a) {
|
|
var e = this, s = a.detail.iv, o = a.detail.encryptedData;
|
|
console.log(o), o && (wx.showLoading({
|
|
title: "绑定中..."
|
|
}), t.http.put(t.urls.doUpdatePhone, {
|
|
header: {
|
|
token: t.globalData.token
|
|
},
|
|
data: {
|
|
iv: s,
|
|
encryptedData: o
|
|
}
|
|
}).then(function(a) {
|
|
wx.hideLoading({}), wx.setStorageSync("token", a.data.data), wx.setStorageSync("bindPhone", 0),
|
|
e.setData({
|
|
isBindPhone: !0
|
|
}), t.globalData.token = a.data.data, wx.showToast({
|
|
title: "绑定成功",
|
|
success: function(t) {
|
|
wx.navigateTo({
|
|
url: "/packagecard/cardList/cardList"
|
|
});
|
|
}
|
|
});
|
|
}).catch(function(t) {}));
|
|
},
|
|
getUserProfile: function(a) {
|
|
var e = this;
|
|
wx.getUserProfile({
|
|
desc: "获取微信头像以及昵称用于展示",
|
|
success: function(a) {
|
|
wx.setStorage({
|
|
data: a.userInfo.nickName,
|
|
key: "name"
|
|
}), wx.setStorage({
|
|
data: a.userInfo.avatarUrl,
|
|
key: "userIcon"
|
|
}), e.setData({
|
|
name: a.userInfo.nickName,
|
|
userIcon: a.userInfo.avatarUrl
|
|
}), t.globalData.userIcon = a.userInfo.avatarUrl, t.globalData.userInfo = a.userInfo,
|
|
e.selectComponent("#head").refreshCart();
|
|
},
|
|
fail: function(t) {
|
|
wx.showToast({
|
|
title: "获取信息失败",
|
|
icon: "error"
|
|
});
|
|
}
|
|
});
|
|
},
|
|
buildId: function() {
|
|
for (var t = [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" ], a = "", e = 0; e < 36; e++) {
|
|
a += t[parseInt(61 * Math.random())];
|
|
}
|
|
return a;
|
|
},
|
|
showBarCode: function() {
|
|
this.setData({
|
|
isNeedRefresh: !1
|
|
});
|
|
wx.navigateTo({
|
|
url: "/packagecard/sharePage/cardcode?cardImg=" + this.data.cardInfo.cardTemplateUsePhotoUrl + "&id=" + this.data.cardInfo.cardTemplateUseBarcode
|
|
});
|
|
},
|
|
hideBarCode: function() {
|
|
this.setData({
|
|
isShowBarCode: !1
|
|
}), wx.showTabBar();
|
|
},
|
|
shareRecord: function(a) {
|
|
var e = this;
|
|
t.http.post(t.urls.shareRecord, {
|
|
header: {
|
|
token: t.globalData.token
|
|
},
|
|
data: {
|
|
cardTemplateUseId: e.data.cardInfo.cardTemplateUseId,
|
|
cardTemplateDispatchParentId: "",
|
|
cardTemplateDispatchId: a
|
|
}
|
|
}).then(function(t) {
|
|
e.setData({
|
|
shareRecordId: t.data.data
|
|
});
|
|
});
|
|
},
|
|
onShareAppMessage: function(t) {
|
|
console.log(t);
|
|
wx.showShareMenu({
|
|
withShareTicket: !0,
|
|
success: function(t) {
|
|
console.log(t);
|
|
}
|
|
});
|
|
var a = t.target.dataset.sharetype;
|
|
if (!a || "2" != a) {
|
|
var e = this.buildId();
|
|
return this.shareRecord(e), {
|
|
title: "您好,这是我的电子名片,请查看.",
|
|
path: "/pages/index/index?cardTemplateDispatchId=" + e,
|
|
imageUrl: this.data.shareImgUrl
|
|
};
|
|
}
|
|
var s = t.target.dataset.item;
|
|
t.target.dataset.idx, t.target.dataset.index;
|
|
console.log(s);
|
|
},
|
|
toSaveLocalImg: function(t) {
|
|
var a = t, e = wx.env.USER_DATA_PATH + "/indexshare.png", s = a.replace(/^data:image\/\w+;base64,/, "");
|
|
wx.getFileSystemManager().writeFileSync(e, s, "base64"), this.setData({
|
|
shareImgUrl: e
|
|
});
|
|
},
|
|
showDetail: function(t) {
|
|
if (-1 != t.currentTarget.dataset.ctype.indexOf("dda5007c-5fb7-48f2-8537-3cb8ea298242")) {
|
|
var a = t.currentTarget.dataset.cid, e = t.currentTarget.dataset.id, s = t.currentTarget.dataset.like, o = "&collectSwitch=" + t.currentTarget.dataset.collect + "&likeSwitch=" + s + "&commentSwitch=" + t.currentTarget.dataset.comment + "&shareSwitch=" + t.currentTarget.dataset.share;
|
|
wx.navigateTo({
|
|
url: "/packagecard/moments/momentsdetail/momentsdetail?uId=" + e + "&cId=" + a + o
|
|
});
|
|
}
|
|
},
|
|
getCardId: function() {
|
|
var a = this;
|
|
t.http.get(t.urls.getCardUseId.format({
|
|
cardTemplateDispatchId: a.data.cardTemplateDispatchId
|
|
}), {
|
|
header: {
|
|
token: t.globalData.token
|
|
}
|
|
}).then(function(t) {
|
|
a.setData({
|
|
cardTemplateUseId: t.data.cardTemplateUseDTO.cardTemplateUseId
|
|
}), a.getCard(), a.saveCheckRecord();
|
|
});
|
|
},
|
|
getCard: function() {
|
|
var a = this;
|
|
t.http.get(t.urls.shareCard.format({
|
|
cardTemplateUseId: a.data.cardTemplateUseId
|
|
}), {
|
|
header: {
|
|
token: t.globalData.token
|
|
},
|
|
data: {}
|
|
}).then(function(e) {
|
|
var s = e.data.areaList;
|
|
s.forEach(function(t) {
|
|
"name" == t.templateAreaSource && a.setData({
|
|
nameTxt: t.templateAreaFontValue
|
|
});
|
|
}), a.setData({
|
|
cardInfo: e.data,
|
|
areaList: s,
|
|
dataList: []
|
|
}), e.data && (a.toSaveLocalImg(e.data.cardTemplateUseDispatchPhoto), a.getBrowCardUserList(e.data.cardTemplateUseId),
|
|
t.globalData.userId = e.data.creator, a.setData({
|
|
tempUserId: e.data.creator
|
|
}), a.getMainColumn(e.data.creator), a.getMainBaseUserInfo(e.data.creator));
|
|
}).catch(function(t) {});
|
|
},
|
|
saveCheckRecord: function() {
|
|
t.http.post(t.urls.checkRecord, {
|
|
header: {
|
|
token: t.globalData.token
|
|
},
|
|
data: {
|
|
cardTemplateUseId: this.data.cardTemplateUseId,
|
|
cardTemplateDispatchId: this.data.cardTemplateDispatchId
|
|
}
|
|
}).then(function(t) {
|
|
console.log(t);
|
|
}).catch(function(t) {
|
|
console.log(t);
|
|
});
|
|
},
|
|
onHide: function(t) {
|
|
this.setData({
|
|
isShowCard: !1,
|
|
isShowPhone: !1
|
|
}), a && a.stop();
|
|
},
|
|
showCardHistory: function(t) {
|
|
this.data.otherCardList.length > 0 ? this.setData({
|
|
isShowCard: !0
|
|
}) : this.getOtherCard(1);
|
|
},
|
|
getOtherCard: function(a) {
|
|
var e = this;
|
|
e.setData({
|
|
otherCardList: []
|
|
}), t.http.get(t.urls.getBrowseHistoryList, {
|
|
header: {
|
|
token: t.globalData.token
|
|
},
|
|
data: {
|
|
page: 1,
|
|
rows: 7,
|
|
homePage: 1
|
|
}
|
|
}).then(function(t) {
|
|
t.data.rows.length > 0 && e.buildOtherCardList(t.data.rows), 1 == a && e.setData({
|
|
isShowCard: !0
|
|
});
|
|
}).catch(function(t) {});
|
|
},
|
|
changeCard: function(t) {
|
|
var a = t.currentTarget.dataset.item, e = t.currentTarget.dataset.type;
|
|
1 == e ? (this.setData({
|
|
cardTemplateDispatchId: "",
|
|
cardTemplateUseId: "",
|
|
isShowCard: !1,
|
|
isMine: 1,
|
|
isDefault: !1
|
|
}), this.getDefault()) : 2 == e ? (this.setData({
|
|
cardTemplateUseId: "",
|
|
isShowCard: !1,
|
|
isMine: 2,
|
|
isDefault: !0
|
|
}), this.getCard()) : 4 == e ? (this.setData({
|
|
cardTemplateUseId: a.creator,
|
|
isShowCard: !1,
|
|
isMine: 3,
|
|
isDefault: !0,
|
|
isShowBrowseUser: !1
|
|
}), this.getBrowUserCard()) : (this.setData({
|
|
cardTemplateUseId: a.cardTemplateUseId,
|
|
isShowCard: !1,
|
|
isMine: 2,
|
|
isDefault: !0
|
|
}), this.getCard());
|
|
},
|
|
buildOtherCardList: function(t) {
|
|
var a, e = this;
|
|
t.forEach(function(t) {
|
|
var s = t.cardTemplateUseDTO.areaList;
|
|
a = {}, s.forEach(function(t) {
|
|
"name" == t.templateAreaSource ? a.name = t.templateAreaFontValue : "phone" == t.templateAreaSource ? a.phone = t.templateAreaFontValue : "address" == t.templateAreaSource ? a.address = t.templateAreaFontValue : "department" == t.templateAreaSource && (a.department = t.templateAreaFontValue);
|
|
}), a.cardTemplateUseId = t.cardTemplateUseId, e.data.otherCardList.push(a);
|
|
}), e.setData({
|
|
otherCardList: e.data.otherCardList
|
|
});
|
|
},
|
|
onShow: function(t) {},
|
|
onCloseDialog: function() {
|
|
this.setData({
|
|
isShowComment: !1
|
|
});
|
|
},
|
|
showBrowseUser: function() {
|
|
this.data.browUserList.length > 0 && this.setData({
|
|
isShowBrowseUser: !0
|
|
});
|
|
},
|
|
showComment: function(t) {
|
|
var a = t.currentTarget.dataset.cid, e = t.currentTarget.dataset.uid, s = t.currentTarget.dataset.like, o = "&collectSwitch=" + t.currentTarget.dataset.collect + "&likeSwitch=" + s + "&commentSwitch=" + t.currentTarget.dataset.comment + "&shareSwitch=" + t.currentTarget.dataset.share;
|
|
console.log(o), wx.navigateTo({
|
|
url: "/packagecard/moments/momentsdetail/momentsdetail?uId=" + e + "&cId=" + a + o
|
|
});
|
|
},
|
|
doLike: function(a) {
|
|
var e = this, s = a.currentTarget.dataset.item, o = a.currentTarget.dataset.idx, n = a.currentTarget.dataset.index, r = "";
|
|
r = s.likeStatus ? "取消中..." : "保存中...", wx.showLoading({
|
|
title: r
|
|
}), t.http.post(t.urls.doSaveLike, {
|
|
header: {
|
|
token: t.globalData.token
|
|
},
|
|
data: {
|
|
businessId: s.uid,
|
|
projectId: "column"
|
|
}
|
|
}).then(function(t) {
|
|
wx.hideLoading({}), e.data.dataList[n].list[o].likeStatus = !s.likeStatus, s.likeStatus ? --e.data.dataList[n].list[o].likeCount : ++e.data.dataList[n].list[o].likeCount,
|
|
e.setData({
|
|
dataList: e.data.dataList
|
|
});
|
|
}).catch(function(t) {});
|
|
},
|
|
doCollect: function(a) {
|
|
var e = this, s = a.currentTarget.dataset.item, o = a.currentTarget.dataset.idx, n = a.currentTarget.dataset.index, r = "";
|
|
r = s.collectStatus ? "取消收藏..." : "收藏中...", wx.showLoading({
|
|
title: r
|
|
}), t.http.post(t.urls.doSaveCollect, {
|
|
header: {
|
|
token: t.globalData.token
|
|
},
|
|
data: {
|
|
businessId: s.uid,
|
|
projectId: "column"
|
|
}
|
|
}).then(function(t) {
|
|
wx.hideLoading({}), e.data.dataList[n].list[o].collectStatus = !s.collectStatus,
|
|
e.setData({
|
|
dataList: e.data.dataList
|
|
});
|
|
}).catch(function(t) {});
|
|
}
|
|
}); |