var t, a = require("../../../@babel/runtime/helpers/defineProperty"), e = getApp(), n = wx.createInnerAudioContext(); Page((a(t = { data: { nameTxt: "名片", dataList: [], curIndex: 0, speedStep: 5, waitFlag: !1, avatarUrl: e.globalData.userInfo.avatarUrl, areaList: [], cardHeight: "", cardInfo: {}, cardUrl: e.baseUrls.baseCardUrl, personIntro: {}, companyIntro: {}, shareImg: "", phoneTxt: "未录入", emailTxt: "未录入", wechateTxt: "未录入", addressTxt: "未录入", viewInfo: {}, forwardCount: "", imgUrl: e.baseUrls.baseCardUrl, shareRecordId: "", isShowBarCode: !1, browUserList: [], shareImgUrl: "", tempUserId: "", cardTemplateDispatchId: "", cardTemplateUseId: "", isShowCard: !1, otherCardList: [], isPlayAudio: !1, audioId: "", count: 3, animationData: {}, isShowBtn: !1 }, onLoad: function(t) { this.setData({ cardTemplateUseId: t.cardTemplateUseId }), this.buildId(), this.getCard(); }, getCard: function() { var t = this; e.http.get(e.urls.shareCard.format({ cardTemplateUseId: t.data.cardTemplateUseId }), { header: { token: e.globalData.token } }).then(function(a) { var e = a.data.areaList; e.forEach(function(a) { "name" == a.templateAreaSource && t.setData({ nameTxt: a.templateAreaFontValue }); }), t.setData({ cardInfo: a.data, areaList: e, dataList: [] }), a.data && (t.toSaveLocalImg(a.data.cardTemplateUseDispatchPhoto), t.getBrowCardUserList(a.data.cardTemplateUseId), t.setData({ tempUserId: a.data.creator }), t.getMainColumn(a.data.creator), t.getMainBaseUserInfo(a.data.creator)); }); }, toSaveLocalImg: function(t) { var a = t, e = wx.env.USER_DATA_PATH + "/indexshare.png", n = a.replace(/^data:image\/\w+;base64,/, ""); wx.getFileSystemManager().writeFileSync(e, n, "base64"), this.setData({ shareImgUrl: e }); }, getBrowCardUserList: function(t) { var a = this; e.http.get(e.urls.getCardBrowUserList, { header: { token: e.globalData.token }, data: { page: "1", rows: "7", cardTemplateUseId: t } }).then(function(t) { t.data && a.setData({ browUserList: t.data.rows }); }).catch(function(t) { console.log(t); }); }, getMainColumn: function(t) { var a = this; a.setData({ dataList: [] }), e.http.get(e.urls.getMainColumn, { header: { token: e.globalData.token }, data: { creator: t } }).then(function(e) { wx.showLoading({ title: "加载中..." }), a.getMainMoment(e.data, t, 0); }).catch(function(t) { wx.stopPullDownRefresh({}); }); }, getMainMoment: function(t, a, n) { var i = this; n < t.length ? e.http.get(e.urls.getMainMoment.format({ configColumnId: t[i.data.curIndex].configColumnId }), { header: { token: e.globalData.token }, data: { userId: a } }).then(function(e) { if (e.data.length > 0) { var n = t[i.data.curIndex], o = { funcSwitch: "2" == n.configColumnCollect || "4" == n.configColumnCollect || "2" == n.configColumnLike && "4" == n.configColumnLike || "2" == n.configColumnDispatch || "4" == n.configColumnDispatch || "2" == n.configColumnComment || "4" == n.configColumnComment, collectSwitch: t[i.data.curIndex].configColumnCollect, commentSwitch: t[i.data.curIndex].configColumnComment, shareSwitch: t[i.data.curIndex].configColumnDispatch, likeSwitch: t[i.data.curIndex].configColumnLike, cId: t[i.data.curIndex].configColumnId, type: t[i.data.curIndex].configColumnType, name: t[i.data.curIndex].configColumnName, mode: t[i.data.curIndex].configTableMode, list: e.data.slice(0, t[i.data.curIndex].configColumnRowCount) }; i.data.dataList.push(o); } i.setData({ curIndex: ++i.data.curIndex }), i.getMainMoment(t, a, i.data.curIndex); }).catch(function(e) { i.setData({ curIndex: ++i.data.curIndex }), t[i.data.curIndex] && i.getMainMoment(t, a, i.data.curIndex); }) : (wx.hideLoading({}), wx.stopPullDownRefresh({}), i.buildMainData()); }, buildMainData: function() { var t = ""; this.data.dataList.forEach(function(a) { a.list.forEach(function(a) { t += 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(t) { switch (t.dataType) { case "2": if (t.value.length > 0) { var a = t.value.split("@"); a.length > 1 ? t.dataMode = a[1] : t.dataMode = "1"; var n = a[0].split(","), i = []; n.forEach(function(t) { var a = { id: t, path: e.baseUrls.baseCardUrl + t }; i.push(a); }), t.valueList = i; } break; case "3": n = t.value.split(","), i = []; n.forEach(function(t) { if (t.length > 0) { var a = t.split("&"), n = "00:00"; if (a.length > 1) { var o = a[1], s = parseInt(o / 60), r = parseInt(o % 60); n = (s > 9 ? s : "0" + s) + ":" + (+r > 9 ? r : "0" + r); } var d = { id: a[0], path: e.baseUrls.baseCardUrl + a[0], isPlay: !1, duration: 1e5, curDuration: 0, curDurationStr: "00:00", totalDurationStr: n }; i.push(d); } }), t.valueList = i; break; case "4": n = t.value.split(","), i = []; for (var o = 0; o < n.length; o++) if (n[o].length > 0) { var s = n[o].split("&"), r = { path: e.baseUrls.baseCardUrl + s[0], imgPath: e.baseUrls.baseCardUrl + s[1] }; i.push(r); } t.valueList = i; break; case "6": n = t.value.split("-"), i = []; n.forEach(function(t) { if (t.length > 0) { var a = t.split(","), e = { name: "", address: "", latitude: a[0], longitude: a[1] }; i.push(e); } }), t.valueList = i; break; case "8": t.dictionariesList.forEach(function(a) { -1 != t.value.indexOf(a.dataId) && (t.selValue = a.dataName); }); break; case "9": t.dictionariesList.forEach(function(a) { -1 != t.value.indexOf(a.dataId) ? a.isSel = !0 : a.isSel = !1; }); } }); }); }), this.setData({ curIndex: 0, dataList: this.data.dataList }), this.getColumnContentHandle(t); }, getColumnContentHandle: function(t) { var a = this; wx.showLoading({ title: "加载中..." }), e.http.get(e.urls.getColumnContentHandle.format({ projectId: "column", businessIds: t }), { header: { token: e.globalData.token } }).then(function(t) { wx.hideLoading({}), t.data.forEach(function(t) { a.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); }); }); }), a.setData({ curIndex: 0, dataList: a.data.dataList }); }).catch(function(t) {}); }, getMainBaseUserInfo: function(t) { var a = this; e.http.get(e.urls.getMainMoment.format({ configColumnId: "de7b5e22-64f9-4c60-a1f9-6ac004dfb9a8" }), { header: { token: e.globalData.token }, data: { userId: t } }).then(function(t) { t.data.length > 0 ? (a.setData({ isShowBtn: !0 }), t.data[0].list.forEach(function(t) { switch (t.name) { case "phone": a.setData({ phoneTxt: t.value }); break; case "wechat": a.setData({ wechateTxt: t.value }); break; case "email": a.setData({ emailTxt: t.value }); break; case "address": a.setData({ addressTxt: t.value }); } })) : a.setData({ isShowBtn: !1 }); }).catch(function(t) { console.log(t); }); }, 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; }, 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, n = t.currentTarget.dataset.like, i = "&collectSwitch=" + t.currentTarget.dataset.collect + "&likeSwitch=" + n + "&commentSwitch=" + t.currentTarget.dataset.comment + "&shareSwitch=" + t.currentTarget.dataset.share; wx.navigateTo({ url: "/packagecard/moments/momentsdetail/momentsdetail?uId=" + e + "&cId=" + a + i }); } }, onHide: function(t) { this.setData({ isShowCard: !1 }), n && n.stop(); }, onShareAppMessage: function(t) { wx.showShareMenu({ withShareTicket: !0, success: function(t) { console.log(t); } }); var a = this.buildId(); return this.shareRecord(a), { title: "您好,这是我的电子名片,请查看.", path: "/pages/index/index?cardTemplateDispatchId=" + a, imageUrl: this.data.shareImgUrl }; }, shareRecord: function(t) { var a = this; e.http.post(e.urls.shareRecord, { header: { token: e.globalData.token }, data: { cardTemplateUseId: a.data.cardInfo.cardTemplateUseId, cardTemplateDispatchParentId: "", cardTemplateDispatchId: t } }).then(function(t) { a.setData({ shareRecordId: t.data.data }); }); }, showBarCode: function() { wx.navigateTo({ url: "/packagecard/sharePage/cardcode?cardImg=" + this.data.cardInfo.cardTemplateUsePhotoUrl + "&id=" + this.data.cardInfo.cardTemplateUseBarcode }); }, hideBarCode: function() { this.setData({ isShowBarCode: !1 }), wx.showTabBar(); }, getForwardCount: function() { var t = this; e.restAjax.get(e.restAjax.path("{cardUrl}app/templateforwardingrecord/count", [ e.cardUrl ]), { templateUseId: t.data.cardInfo.cardPersonId }, { headers: { token: e.globalData.token } }, function(a, e) { t.setData({ forwardCount: e.data }); }, function(t, a) { e.dialog.msg(a.msg); }); }, copyText: function(t) { var a = t.currentTarget.dataset.text; a && wx.setClipboardData({ data: a, success: function() {} }); }, includedCard: function() { e.http.post(e.urls.includedCard, { header: { token: e.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) {}); }, makeCall: function() { var t = this.data.phoneTxt; t && wx.makePhoneCall({ phoneNumber: t }); }, getViewCount: function() { var t = this; e.restAjax.get(e.restAjax.path("{cardUrl}app/templateviewrecord/getByTemplateUseId/" + t.data.cardInfo.cardPersonId, [ e.cardUrl ]), {}, { headers: { token: e.globalData.token } }, function(a, e) { t.setData({ viewInfo: e }); }, function(t, a) { a.msg && e.dialog.msg(a.msg); }); } }, "getBrowCardUserList", function(t) { var a = this; e.http.get(e.urls.getCardBrowUserList, { header: { token: e.globalData.token }, data: { page: "1", rows: "7", cardTemplateUseId: t } }).then(function(t) { t.data && a.setData({ browUserList: t.data.rows }); }).catch(function(t) { console.log(t); }); }), a(t, "addContact", function() { wx.addPhoneContact({ firstName: this.data.nameTxt, mobilePhoneNumber: this.data.phoneNum }); }), a(t, "viewImg", function(t) { var a = t.currentTarget.dataset.values, e = t.currentTarget.dataset.url, n = []; a.forEach(function(t) { n.push(t.path); }), wx.previewImage({ urls: n, current: e }); }), a(t, "viewVideo", function(t) { var a = t.currentTarget.dataset.url; wx.previewMedia({ sources: [ { url: a, type: "video" } ] }); }), a(t, "play", function(t) { var a = this, e = t.currentTarget.dataset.index, i = t.currentTarget.dataset.idx, o = t.currentTarget.dataset.i, s = t.currentTarget.dataset.a, r = t.currentTarget.dataset.item; console.log(a.data.isPlayAudio), a.data.isPlayAudio ? (a.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"; }); }); }); }), a.setData({ dataList: a.data.dataList }), n.stop(), a.data.audioId != r.id && (wx.showLoading({ title: "加载中..." }), setTimeout(function() { wx.hideLoading({}), n.src = a.data.dataList[e].list[i].list[o].valueList[s].path + ".mp3", n.startTime = 0, n.autoplay = !0, a.data.dataList[e].list[i].list[o].valueList[s].isPlay = !0, a.setData({ dataList: a.data.dataList, isPlayAudio: !0, audioId: r.id }); }, 1500))) : (n.src = a.data.dataList[e].list[i].list[o].valueList[s].path + ".mp3", n.startTime = 0, n.autoplay = !0, n.play(), a.data.dataList[e].list[i].list[o].valueList[s].isPlay = !0, a.setData({ dataList: a.data.dataList, isPlayAudio: !0, audioId: r.id })), n.onPlay(function() {}), n.onCanplay(function(t) {}), n.onStop(function(t) { console.log("onStop==="), a.data.dataList[e].list[i].list[o].valueList[s].isPlay = !1, a.data.dataList[e].list[i].list[o].valueList[s].curDuration = 0, a.data.dataList[e].list[i].list[o].valueList[s].curDurationStr = "00:00", a.setData({ dataList: a.data.dataList, isPlayAudio: !1 }); }), n.onEnded(function(t) { console.log(t), console.log("播放完毕"), a.data.dataList[e].list[i].list[o].valueList[s].isPlay = !1, a.data.dataList[e].list[i].list[o].valueList[s].curDuration = 0, a.data.dataList[e].list[i].list[o].valueList[s].curDurationStr = "00:00", a.setData({ dataList: a.data.dataList, isPlayAudio: !1 }); }), n.onError(function(t) { console.log("播放错误"), console.log(t), a.data.dataList[e].list[i].list[o].valueList[s].isPlay = !1, a.data.dataList[e].list[i].list[o].valueList[s].curDuration = 0, a.data.dataList[e].list[i].list[o].valueList[s].curDurationStr = "00:00", a.setData({ dataList: a.data.dataList, isPlayAudio: !1 }); }), n.onSeeking(function() {}); }), a(t, "goList", function() { wx.navigateTo({ url: "/packagecard/cardList/cardList" }); }), a(t, "showMore", function(t) { var a = t.currentTarget.dataset.item; if ("2" == a.mode) { var e = t.currentTarget.dataset.userid, n = t.currentTarget.dataset.idx; wx.navigateTo({ url: "/packagecard/moments/showlist/showlist?id=" + a.cId + "&userId=" + e + "&index=" + n }); } }), a(t, "showComment", function(t) { var a = t.currentTarget.dataset.cid, e = t.currentTarget.dataset.uid, n = t.currentTarget.dataset.like, i = "&collectSwitch=" + t.currentTarget.dataset.collect + "&likeSwitch=" + n + "&commentSwitch=" + t.currentTarget.dataset.comment + "&shareSwitch=" + t.currentTarget.dataset.share; console.log(i), wx.navigateTo({ url: "/packagecard/moments/momentsdetail/momentsdetail?uId=" + e + "&cId=" + a + i }); }), a(t, "doLike", function(t) { var a = this, n = t.currentTarget.dataset.item, i = t.currentTarget.dataset.idx, o = t.currentTarget.dataset.index, s = ""; s = n.likeStatus ? "取消中..." : "保存中...", wx.showLoading({ title: s }), e.http.post(e.urls.doSaveLike, { header: { token: e.globalData.token }, data: { businessId: n.uid, projectId: "column" } }).then(function(t) { wx.hideLoading({}), a.data.dataList[o].list[i].likeStatus = !n.likeStatus, n.likeStatus ? --a.data.dataList[o].list[i].likeCount : ++a.data.dataList[o].list[i].likeCount, a.setData({ dataList: a.data.dataList }); }).catch(function(t) {}); }), a(t, "doCollect", function(t) { var a = this, n = t.currentTarget.dataset.item, i = t.currentTarget.dataset.idx, o = t.currentTarget.dataset.index, s = ""; s = n.collectStatus ? "取消收藏..." : "收藏中...", wx.showLoading({ title: s }), e.http.post(e.urls.doSaveCollect, { header: { token: e.globalData.token }, data: { businessId: n.uid, projectId: "column" } }).then(function(t) { wx.hideLoading({}), a.data.dataList[o].list[i].collectStatus = !n.collectStatus, a.setData({ dataList: a.data.dataList }); }).catch(function(t) {}); }), t));