codeHisPicker.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <view
  3. class="codeHisPicker"
  4. v-if="isShow"
  5. @click="close"
  6. :style="{
  7. height: height + 'px',
  8. }"
  9. >
  10. <view
  11. class="codeList"
  12. @click.stop
  13. >
  14. <view class="head">
  15. <view class="title">
  16. <text class="titleText">历史运行代码:</text>
  17. </view>
  18. <view class="subTitle">
  19. <text class="subTitleText">(保留100条运行记录)</text>
  20. </view>
  21. </view>
  22. <scroll-view
  23. scroll-y
  24. class="codeScroll"
  25. >
  26. <view
  27. class="hisItem"
  28. v-for="(item, index) in list"
  29. :key="index"
  30. @click="selectedRow(item)"
  31. >
  32. <text class="hisItemCode">
  33. {{ item }}
  34. </text>
  35. </view>
  36. <view style="height: 100rpx"></view>
  37. </scroll-view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. export default {
  43. data() {
  44. return {
  45. /**
  46. * 是否展示
  47. */
  48. isShow: false,
  49. /**
  50. * 筛选的列表
  51. */
  52. list: [],
  53. /**
  54. * 默认选中的索引
  55. */
  56. index: 0,
  57. /**
  58. * 选中的回调事件
  59. */
  60. callback: null,
  61. /**
  62. * 屏幕高度
  63. */
  64. height: uni.getSystemInfoSync().screenHeight,
  65. };
  66. },
  67. methods: {
  68. /**
  69. * 展示弹窗
  70. */
  71. show(list = []) {
  72. let that = this;
  73. that.index = 0;
  74. that.list = list;
  75. that.isShow = true;
  76. return new Promise((yes) => {
  77. that.callback = yes;
  78. });
  79. },
  80. /**
  81. * 选择改变事件
  82. */
  83. pickerChange(e) {
  84. that.callback = "";
  85. console.log("e", e);
  86. },
  87. /**
  88. * 关闭弹窗
  89. */
  90. close() {
  91. this.isShow = false;
  92. },
  93. /**
  94. * 选择单行代码
  95. */
  96. selectedRow(row) {
  97. this.callback(row);
  98. this.close();
  99. },
  100. },
  101. };
  102. </script>
  103. <style lang="scss" scoped>
  104. .codeHisPicker {
  105. position: fixed;
  106. bottom: 0;
  107. left: 0;
  108. width: 750rpx;
  109. background-color: rgba(0, 0, 0, 0.3);
  110. /* #ifndef APP-PLUS */
  111. backdrop-filter: blur(1px);
  112. /* #endif */
  113. display: flex;
  114. flex-direction: column-reverse;
  115. z-index: 999;
  116. .codeList {
  117. width: 750rpx;
  118. border-radius: 20rpx 20rpx 0 0;
  119. background-color: #fff;
  120. .head {
  121. padding: 20rpx;
  122. border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  123. display: flex;
  124. flex-direction: row;
  125. align-items: center;
  126. justify-content: space-between;
  127. .title {
  128. .titleText {
  129. font-size: 24rpx;
  130. line-height: 28rpx;
  131. color: #333;
  132. }
  133. }
  134. .subTitle {
  135. display: flex;
  136. flex-direction: row;
  137. align-items: center;
  138. .subTitleText {
  139. font-size: 20rpx;
  140. line-height: 28rpx;
  141. color: #777;
  142. }
  143. }
  144. }
  145. .codeScroll {
  146. height: 750rpx;
  147. width: 750rpx;
  148. .hisItem {
  149. width: 750rpx;
  150. padding: 10rpx 20rpx;
  151. border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  152. .hisItemCode {
  153. font-size: 20rpx;
  154. color: #333;
  155. line-height: 26rpx;
  156. overflow: hidden;
  157. text-overflow: ellipsis;
  158. /* #ifdef H5 */
  159. display: -webkit-box;
  160. -webkit-line-clamp: 3;
  161. -webkit-box-orient: vertical;
  162. /* #endif */
  163. lines: 3;
  164. }
  165. }
  166. .hisItem:active {
  167. background-color: rgba(0, 0, 0, 0.03);
  168. }
  169. }
  170. }
  171. }
  172. </style>