index.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <!-- 联系我们 -->
  2. <script>
  3. import Cookies from "js-cookie";
  4. import { ProjectInfo } from "@/api/business/as/after-sales";
  5. export default {
  6. name: "contactUs",
  7. data() {
  8. return {
  9. phone: "",
  10. show: false,
  11. actions: [
  12. { name: "拨号", key: "call" },
  13. { name: "复制", key: "copy" },
  14. ],
  15. };
  16. },
  17. methods: {
  18. async onSelect({ key, name }) {
  19. this.show = false;
  20. if (key === "call") {
  21. window.location.href = `tel:${this.phone}`;
  22. return;
  23. }
  24. if (key === "copy") {
  25. await navigator.clipboard.writeText(this.phone);
  26. return this.$toast("已复制到剪贴板");
  27. }
  28. },
  29. onCancel() {},
  30. async getProjectInfo(id) {
  31. try {
  32. this.loading = true;
  33. let { code, data } = await ProjectInfo({ id });
  34. if (code === 200) {
  35. this.phone = data.defaultContactWay;
  36. }
  37. } catch (error) {
  38. } finally {
  39. this.loading = false;
  40. }
  41. },
  42. },
  43. created() {
  44. const projectId = Cookies.get("salesProId");
  45. this.getProjectInfo(projectId);
  46. },
  47. };
  48. </script>
  49. <template>
  50. <div>
  51. <van-cell
  52. is-link
  53. :title="'热线电话' + phone"
  54. value="8:00-22:00"
  55. @click="show = true"
  56. />
  57. <van-action-sheet
  58. v-model="show"
  59. :actions="actions"
  60. cancel-text="取消"
  61. close-on-click-action
  62. @cancel="onCancel"
  63. @select="onSelect"
  64. />
  65. </div>
  66. </template>
  67. <style scope lang="scss">
  68. .van-cell {
  69. background-color: #f5f5f5;
  70. .van-cell__title {
  71. flex-grow: 2;
  72. }
  73. }
  74. </style>