dt_menu_list.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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="https://szsq.nxzhsq.cn/community/miniofile/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,
  62. title: '',
  63. value: '',
  64. isMarginTop: false,
  65. hideArrow: false,
  66. isWxService: false,
  67. isOpenSetting: false
  68. }]
  69. }
  70. },
  71. data() {
  72. return {}
  73. },
  74. computed: {
  75. itemHeight() {
  76. if (this.menuStyle.height) {
  77. return uni.upx2px(this.menuStyle.height) + 'px'
  78. }
  79. return ''
  80. },
  81. spaceHeightCal() {
  82. if (this.menuStyle.spaceHeight) {
  83. return uni.upx2px(this.menuStyle.spaceHeight) + 'px'
  84. }
  85. return ''
  86. }
  87. },
  88. methods: {
  89. tapItem(item) {
  90. if (!item.isWxService || !item.isOpenSetting) {
  91. this.$emit('tapitem', item)
  92. }
  93. },
  94. tapOpenSetting() {
  95. try {
  96. uni.openSetting()
  97. } catch (ex) {
  98. }
  99. }
  100. }
  101. }
  102. </script>
  103. <style lang="scss">
  104. .menu-wrap {
  105. .space-line {
  106. height: 20 upx;
  107. }
  108. .comp-listItem {
  109. position: relative;
  110. display: flex;
  111. flex-direction: row;
  112. align-items: center;
  113. padding: 0 30 upx;
  114. color: #353535;
  115. font-size: 30 upx;
  116. justify-content: space-between;
  117. margin-top: 0;
  118. height: 100 upx;
  119. border-bottom: 2 upx solid #f5f5f5;
  120. background: #fff;
  121. .customer-service {
  122. position: absolute;
  123. top: 0;
  124. left: 0;
  125. width: 100%;
  126. height: 100%;
  127. opacity: 0;
  128. }
  129. }
  130. .comp-listItem .leftItem {
  131. display: flex;
  132. align-items: center;
  133. }
  134. .comp-listItem .leftItem text {
  135. max-height: 100%;
  136. overflow: hidden;
  137. display: -webkit-box;
  138. -webkit-box-orient: vertical;
  139. -webkit-line-clamp: 1;
  140. text-overflow: ellipsis;
  141. }
  142. .comp-listItem .leftItem image {
  143. width: 40 upx;
  144. height: 40 upx;
  145. margin-right: 20 upx;
  146. }
  147. .comp-listItem .rightItem {
  148. display: flex;
  149. align-items: center;
  150. }
  151. .comp-listItem .rightItem text {
  152. color: #999999;
  153. }
  154. .comp-listItem .rightItem image {
  155. margin-left: 20 upx;
  156. width: 13 upx;
  157. height: 24 upx;
  158. }
  159. }
  160. </style>