@tencentcloud/ai-desk-customer-wechat
Version:
AI Desk customer UIKit for wechat mini program
67 lines (66 loc) • 2.17 kB
JavaScript
;
const common_vendor = require("../../../../../common/vendor.js");
const aiDeskCustomerUniapp_adapterVue = require("../../../../adapter-vue.js");
const aiDeskCustomerUniapp_utils_utils = require("../../../../utils/utils.js");
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
__name: "message-timestamp",
props: {
currTime: {
type: Number,
default: 0
},
prevTime: {
type: Number,
default: 0
}
},
setup(__props) {
const { toRefs, ref, watch } = aiDeskCustomerUniapp_adapterVue.vue;
const props = __props;
const { currTime, prevTime } = toRefs(props);
const timestampShowFlag = ref(false);
const timestampShowContent = ref("");
const handleItemTime = (currTime2, prevTime2) => {
timestampShowFlag.value = false;
if (currTime2 <= 0) {
return "";
} else if (!prevTime2 || prevTime2 <= 0) {
timestampShowFlag.value = true;
return aiDeskCustomerUniapp_utils_utils.calculateTimestamp(currTime2 * 1e3);
} else {
const minDiffToShow = 10 * 60;
const diff = currTime2 - prevTime2;
if (diff >= minDiffToShow) {
timestampShowFlag.value = true;
return aiDeskCustomerUniapp_utils_utils.calculateTimestamp(currTime2 * 1e3);
}
}
return "";
};
watch(
() => [currTime.value, prevTime.value],
(newVal, oldVal) => {
if ((newVal == null ? void 0 : newVal.toString()) === (oldVal == null ? void 0 : oldVal.toString())) {
return;
} else {
timestampShowContent.value = handleItemTime(
currTime.value,
prevTime.value
);
}
},
{
immediate: true
}
);
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.unref(timestampShowFlag)
}, common_vendor.unref(timestampShowFlag) ? {
b: common_vendor.t(common_vendor.unref(timestampShowContent))
} : {});
};
}
});
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-c003f1a7"]]);
wx.createComponent(Component);