index.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <view class="main">
  3. <view class="one">客服电话</view>
  4. <view class="two">
  5. <text>{{config.phone||'暂无联系电话'}}</text>
  6. <button class="button" type="primary" size="mini" @tap="toCopy(config.phone)">复制</button>
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. data() {
  13. return {
  14. config: {}
  15. }
  16. },
  17. onLoad: async function(e) {
  18. const that = this;
  19. that.searchConfig();
  20. },
  21. methods: {
  22. searchConfig() {
  23. const that = this;
  24. try {
  25. const res = uni.getStorageSync('config');
  26. if (res) that.$set(that, `config`, res);
  27. } catch (e) {
  28. uni.showToast({
  29. title: err.errmsg,
  30. icon: 'error',
  31. duration: 2000
  32. });
  33. }
  34. },
  35. // 复制
  36. toCopy(context) {
  37. uni.setClipboardData({
  38. data: context, //被复制的内容
  39. success: () => { //复制成功的回调函数
  40. uni.showToast({
  41. title: '复制成功'
  42. })
  43. }
  44. });
  45. }
  46. }
  47. }
  48. </script>
  49. <style lang="scss" scoped>
  50. .main {
  51. padding: 2vw;
  52. text-align: center;
  53. font-size: var(--font18Size);
  54. font-weight: bold;
  55. .two {
  56. display: flex;
  57. align-items: center;
  58. justify-content: center;
  59. .button {
  60. margin: 10px;
  61. font-size: var(--font12Size);
  62. background-color: var(--f3CColor);
  63. }
  64. }
  65. }
  66. </style>