arrow-bar.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <view class="arrow-bar">
  3. <text class="icon iconfont" :class="icon" :style="{color: textColor}"></text>
  4. <text class="title">{{ title }}</text>
  5. <uni-icons class="arrow" type="right" size="16"></uni-icons>
  6. </view>
  7. </template>
  8. <script>
  9. export default {
  10. name: "arrow-bar",
  11. props: {
  12. title: {
  13. type: String,
  14. required: true
  15. },
  16. icon: {
  17. type: String,
  18. default: ''
  19. }
  20. },
  21. data() {
  22. return {
  23. colors: ["#5daa31", "#c7515a", "#e03697", "#85029b",
  24. "#c9b455", "#326eb6"]
  25. }
  26. },
  27. computed:{
  28. textColor() {
  29. let hash = 0;
  30. for (var i = 0; i < this.title.length; i++) {
  31. hash += this.title.charCodeAt(i);
  32. }
  33. return this.colors[hash % this.colors.length];
  34. }
  35. }
  36. }
  37. </script>
  38. <style lang="scss" scoped>
  39. .arrow-bar {
  40. width: 100%;
  41. height: 90rpx;
  42. font-size: $im-font-size;
  43. color: $im-text-color;
  44. margin-top: 5rpx;
  45. background-color: white;
  46. line-height: 90rpx;
  47. display: flex;
  48. .icon {
  49. margin-left: 40rpx;
  50. }
  51. .title {
  52. flex: 1;
  53. margin-left: 10rpx;
  54. }
  55. .arrow {
  56. margin-right: 40rpx;
  57. }
  58. }
  59. </style>