index.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view class="page-container">
  3. <!-- 顶部导航栏 -->
  4. <wd-navbar
  5. title="联系客服"
  6. left-arrow
  7. placeholder
  8. safe-area-inset-top
  9. fixed
  10. @click-left="handleBack"
  11. />
  12. <!-- 客服卡片 -->
  13. <view class="mx-30rpx mt-20rpx rounded-16rpx bg-white px-60rpx py-80rpx">
  14. <view class="flex flex-col items-center">
  15. <!-- 二维码图片 -->
  16. <view class="mb-30rpx h-280rpx w-280rpx overflow-hidden rounded-16rpx">
  17. <wd-img
  18. :src="qrCodeUrl"
  19. width="280rpx"
  20. height="280rpx"
  21. mode="aspectFit"
  22. />
  23. </view>
  24. <text class="mb-40rpx text-32rpx text-gray-800 font-bold">
  25. 添加客服二维码
  26. </text>
  27. <text class="mb-16rpx text-28rpx text-gray-500">
  28. 服务时间:早上 9:00 - 22:00
  29. </text>
  30. <!-- 客服电话 -->
  31. <view class="flex items-center text-28rpx text-gray-500">
  32. <text>客服电话:{{ servicePhone }}</text>
  33. <text
  34. class="ml-10rpx text-blue-500 underline"
  35. @click="handleCallPhone"
  36. >
  37. 拨打
  38. </text>
  39. </view>
  40. <!-- 保存按钮 -->
  41. <view class="mt-60rpx w-full">
  42. <wd-button type="primary" block @click="handleSaveQRCode">
  43. 保存二维码图片
  44. </wd-button>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script lang="ts" setup>
  51. import { ref } from 'vue'
  52. import { navigateBackPlus } from '@/utils'
  53. import { saveImageToAlbum } from '@/utils/download'
  54. definePage({
  55. style: {
  56. navigationBarTitleText: '',
  57. navigationStyle: 'custom',
  58. },
  59. })
  60. const qrCodeUrl = ref('/static/images/qrcode.png') // 客服二维码图片地址
  61. const servicePhone = ref('18818818818') // 客服电话号码
  62. /** 返回上一页 */
  63. function handleBack() {
  64. navigateBackPlus('/pages/user/index')
  65. }
  66. /** 拨打电话 */
  67. function handleCallPhone() {
  68. uni.makePhoneCall({
  69. phoneNumber: servicePhone.value,
  70. fail: (err) => {
  71. uni.showToast({
  72. icon: 'none',
  73. title: '拨打失败',
  74. })
  75. },
  76. })
  77. }
  78. /** 保存二维码图片 */
  79. async function handleSaveQRCode() {
  80. await saveImageToAlbum(qrCodeUrl.value, 'weixin_qrcode.png')
  81. }
  82. </script>