index.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <view class="cardCom">
  3. <view class="card-bg">
  4. <image class="" :src="bgList[imgSerial]" />
  5. </view>
  6. <view class="card-container">
  7. <view class="card-header">
  8. <view class="header-left">
  9. <view class="header-title">
  10. <text>{{ cardData.name || '' }}</text>
  11. <text>{{ cardData.positions }}</text>
  12. </view>
  13. <view class="company">{{ cardData.company || '' }}</view>
  14. </view>
  15. <view class="header-right" @click="changeImg">
  16. <view class="edit" v-if="isEdit">编辑</view>
  17. <view class="img-box">
  18. <template v-if="cardData.head">
  19. <image
  20. class=""
  21. :src="cardData.head"
  22. />
  23. </template>
  24. <template v-else>
  25. <image
  26. class=""
  27. src="@/static/images/default_avatar.png"
  28. />
  29. </template>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="card-content">
  34. <view class="content-item" v-if="cardData.mobile">
  35. <image class="" src="@/static/images/icon_1.png" />
  36. <text>{{ cardData.mobile }}</text>
  37. </view>
  38. <view class="content-item" v-if="cardData.wechat">
  39. <image class="" src="@/static/images/icon_2.png" />
  40. <text>{{ cardData.wechat }}</text>
  41. </view>
  42. <view class="content-item" v-if="cardData.address">
  43. <image class="" src="@/static/images/icon_3.png" />
  44. <text>{{ cardData.address }}</text>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. export default {
  52. props: {
  53. // 控制第几章名片背景
  54. imgSerial: {
  55. typeof: Number,
  56. default: 0,
  57. },
  58. // 控制编辑背景是否需要
  59. isEdit: {
  60. typeof: Boolean,
  61. default: false,
  62. },
  63. // 传递过来的卡片数据
  64. cardData:{
  65. typeof: Object,
  66. default:{}
  67. }
  68. },
  69. data() {
  70. return {
  71. bgList: [
  72. require("@/static/images/card_0.png"),
  73. require("@/static/images/card_1.png"),
  74. require("@/static/images/card_2.png"),
  75. ],
  76. };
  77. },
  78. methods: {
  79. changeImg(){
  80. if(!this.isEdit)return
  81. this.$emit("changeImg")
  82. }
  83. }
  84. };
  85. </script>
  86. <style lang="scss" scoped>
  87. @import "./index.scss";
  88. </style>