dt_menu_list.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <view class="menu-wrap">
  3. <view v-for="(item, idx) in itemData" :key="idx">
  4. <view
  5. v-if="item.isMarginTop"
  6. class="space-line"
  7. :style="{
  8. 'background-color': menuStyle.spaceColor,
  9. height: spaceHeightCal
  10. }"
  11. ></view>
  12. <view
  13. @click="tapItem(item)"
  14. class="comp-listItem"
  15. :style="{ 'border-bottom-color': menuStyle.splitLineColor, 'height':itemHeight }"
  16. >
  17. <view class="leftItem">
  18. <image v-if="item.image" :src="item.image" mode="aspectFit"></image>
  19. <text>{{ item.title }}</text>
  20. </view>
  21. <view class="rightItem">
  22. <text>{{ item.value }}</text>
  23. <image
  24. v-if="!item.hideArrow"
  25. src="http://139.9.103.171:1888/img/image/arrow.png"
  26. ></image>
  27. </view>
  28. <!-- 微信客服 -->
  29. <button
  30. v-if="item.isWxService"
  31. class="customer-service"
  32. open-type="contact"
  33. session-from="weapp"
  34. ></button>
  35. <!-- 微信授权 -->
  36. <button
  37. v-if="item.isOpenSetting"
  38. class="customer-service"
  39. open-type="openSetting"
  40. @opensetting="tapOpenSetting"
  41. ></button>
  42. </view>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. export default {
  48. props: {
  49. menuStyle: {
  50. type: Object,
  51. default: {
  52. spaceColor: '',
  53. splitLineColor: '',
  54. spaceHeight: '',
  55. height:''
  56. }
  57. },
  58. itemData: {
  59. type: Array,
  60. value: [{
  61. id: 0, title: '', value: '', isMarginTop: false, hideArrow: false, isWxService: false, isOpenSetting: false
  62. }]
  63. }
  64. },
  65. data() {
  66. return {}
  67. },
  68. computed: {
  69. itemHeight(){
  70. if(this.menuStyle.height){
  71. return uni.upx2px(this.menuStyle.height) +'px'
  72. }
  73. return ''
  74. },
  75. spaceHeightCal() {
  76. if (this.menuStyle.spaceHeight) {
  77. return uni.upx2px(this.menuStyle.spaceHeight) + 'px'
  78. }
  79. return ''
  80. }
  81. },
  82. methods: {
  83. tapItem(item) {
  84. if (!item.isWxService || !item.isOpenSetting) {
  85. this.$emit('tapitem', item)
  86. }
  87. },
  88. tapOpenSetting() {
  89. try { uni.openSetting() }
  90. catch (ex) { }
  91. }
  92. }
  93. }
  94. </script>
  95. <style lang="scss">
  96. .menu-wrap {
  97. .space-line {
  98. height: 20upx;
  99. }
  100. .comp-listItem {
  101. position: relative;
  102. display: flex;
  103. flex-direction: row;
  104. align-items: center;
  105. padding: 0 30upx;
  106. color: #353535;
  107. font-size: 30upx;
  108. justify-content: space-between;
  109. margin-top: 0;
  110. height: 100upx;
  111. border-bottom: 2upx solid #f5f5f5;
  112. background: #fff;
  113. .customer-service {
  114. position: absolute;
  115. top: 0;
  116. left: 0;
  117. width: 100%;
  118. height: 100%;
  119. opacity: 0;
  120. }
  121. }
  122. .comp-listItem .leftItem {
  123. display: flex;
  124. align-items: center;
  125. }
  126. .comp-listItem .leftItem text {
  127. max-height: 100%;
  128. overflow: hidden;
  129. display: -webkit-box;
  130. -webkit-box-orient: vertical;
  131. -webkit-line-clamp: 1;
  132. text-overflow: ellipsis;
  133. }
  134. .comp-listItem .leftItem image {
  135. width: 40upx;
  136. height: 40upx;
  137. margin-right: 20upx;
  138. }
  139. .comp-listItem .rightItem {
  140. display: flex;
  141. align-items: center;
  142. }
  143. .comp-listItem .rightItem text {
  144. color: #999999;
  145. }
  146. .comp-listItem .rightItem image {
  147. margin-left: 20upx;
  148. width: 13upx;
  149. height: 24upx;
  150. }
  151. }
  152. </style>