import Vue, { CreateElement, VNode } from "vue";
import { Component, Prop } from "vue-property-decorator";
@Component
class Ussd extends Vue {
tel: String = "";
@Prop({ default: null }) phone: String;
@Prop({ default: false }) withoutLeftSpace: Boolean;
@Prop({ default: 0 }) checkAfterTime: number;
private hasHtml: boolean = false;
private telHtml: string = '';
mounted() {
setTimeout(() => {
let tel = "";
if (this.phone) {
tel = "tel:" + this.phone;
} else {
if (this.$slots.default[0].text) {
if (this.$slots.default[0].text.endsWith('#')) {
tel = "tel:" + this.$slots.default[0].text.replace(/#$/gm, '%23')
}else{
tel = "tel:" + this.$slots.default[0].text;
}
} else {
if (this.$el && this.$el.querySelector && this.$el.querySelector(".epc-options__value")) {
this.telHtml = this.$el.querySelector(".epc-options__value").innerHTML;
if(this.telHtml.endsWith('#')) {
tel = "tel:" + this.telHtml.replace(/#$/gm, '%23');
}else{
tel = "tel:" + this.telHtml
}
this.tel = tel;
this.hasHtml = true;
}
}
}
this.tel = tel;
}, this.checkAfterTime);
}
render(h: CreateElement): VNode {
let ussdClassName = "rt-ussd";
if (this.withoutLeftSpace) {
ussdClassName += " rt-ussd--stand-alone";
}
if (this.tel) {
return
{this.hasHtml ? this.telHtml : this.$slots.default}
;
} else {
if (this.$slots && this.$slots.default && this.$slots.default[0]) {
return {this.$slots.default[0]};
}
return null;
}
}
}
export default {
component: Ussd,
name: "RtUssd"
};