index.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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="copy(config.phone)">复制</button>
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. data() {
  13. return {
  14. user: {},
  15. config: {}
  16. }
  17. },
  18. onLoad: async function(e) {
  19. const that = this;
  20. that.searchToken();
  21. that.searchConfig();
  22. },
  23. methods: {
  24. searchToken() {
  25. const that = this;
  26. try {
  27. const res = uni.getStorageSync('token');
  28. if (res) that.$set(that, `user`, res);
  29. } catch (e) {
  30. uni.showToast({
  31. title: err.errmsg,
  32. icon: 'error',
  33. duration: 2000
  34. });
  35. }
  36. },
  37. searchConfig() {
  38. const that = this;
  39. try {
  40. const res = uni.getStorageSync('config');
  41. if (res) that.$set(that, `config`, res);
  42. } catch (e) {
  43. uni.showToast({
  44. title: err.errmsg,
  45. icon: 'error',
  46. duration: 2000
  47. });
  48. }
  49. },
  50. // 复制
  51. copy(context) {
  52. uni.setClipboardData({
  53. data: context, //被复制的内容
  54. success: () => { //复制成功的回调函数
  55. uni.showToast({
  56. title: '复制成功'
  57. })
  58. }
  59. });
  60. }
  61. }
  62. }
  63. </script>
  64. <style lang="scss" scoped>
  65. .main {
  66. padding: 2vw;
  67. text-align: center;
  68. font-size: var(--font18Size);
  69. font-weight: bold;
  70. .two {
  71. display: flex;
  72. align-items: center;
  73. justify-content: center;
  74. .button {
  75. margin: 10px;
  76. font-size: var(--font12Size);
  77. background-color: var(--f3CColor);
  78. }
  79. }
  80. }
  81. </style>