推广小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

241 lines
7.1 KiB

2 months ago
  1. <template>
  2. <view class="travelList">
  3. <view class="head-box"></view>
  4. <Navbar title="活动列表" :autoBack="true" :bgColor="bgColor" leftIconSize="18px" height="100rpx" :leftIconColor="leftIconColor" :titleStyle="{color:fontColor}" />
  5. <view class="content contentPosition_">
  6. <view class="drop">
  7. <uv-drop-down
  8. ref="dropDown"
  9. text-color="#fff"
  10. text-size="30rpx"
  11. sign="dropDown_1"
  12. text-active-color="#fff"
  13. :extra-icon="{name:'arrow-down-fill',color:'#666',size:'26rpx'}"
  14. :extra-active-icon="{name:'arrow-up-fill',color:'#fff',size:'26rpx'}"
  15. :defaultValue="defaultValue"
  16. :custom-style="{padding: '0 30rpx'}"
  17. @click="selectMenu"
  18. >
  19. <uv-drop-down-item
  20. name="order"
  21. type="2"
  22. :label="dropItem('order').label"
  23. :value="dropItem('order').value">
  24. </uv-drop-down-item>
  25. <uv-drop-down-item
  26. name="place"
  27. type="2"
  28. :label="dropItem('type').label"
  29. :value="dropItem('type').value">
  30. </uv-drop-down-item>
  31. <uv-drop-down-item
  32. name="type"
  33. type="2"
  34. :label="dropItem('type').label"
  35. :value="dropItem('type').value">
  36. </uv-drop-down-item>
  37. </uv-drop-down>
  38. <uv-drop-down-popup
  39. sign="dropDown_1"
  40. :click-overlay-on-close="true"
  41. :currentDropItem="currentDropItem"
  42. @clickItem="clickItem"
  43. @popupChange="change"
  44. ></uv-drop-down-popup>
  45. </view>
  46. <view class="info cardStyle_">
  47. <view class="left">
  48. <image src="https://img0.baidu.com/it/u=4274003247,920124130&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1031" alt="">
  49. </view>
  50. <view class="right">
  51. <view class="detailed">
  52. <view class="title">夏日去撒野旅游计划</view>
  53. <view class="date">2024.10.28 10:00</view>
  54. <view class="address">成都市东丽湖露营地32号</view>
  55. </view>
  56. <view class="data">
  57. <text>¥233.00</text>
  58. <text>11/40</text>
  59. <text class="btn">已开票</text>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. import Navbar from '@/pages/components/Navbar.vue'
  68. import { globalMixin } from '../pages/mixins/globalMixin';
  69. export default{
  70. onPageScroll() {
  71. // 滚动后及时更新位置
  72. this.$refs.dropDown.init();
  73. },
  74. mixins: [globalMixin],
  75. components:{
  76. Navbar
  77. },
  78. computed: {
  79. dropItem(name) {
  80. return (name) => {
  81. const result = {};
  82. const find = this.result.find(item => item.name === name);
  83. if (find) {
  84. result.label = find.label;
  85. result.value = find.value;
  86. } else {
  87. result.label = this[name].label;
  88. result.value = this[name].value;
  89. }
  90. return result;
  91. }
  92. },
  93. // 获取当前下拉筛选项
  94. currentDropItem() {
  95. return this[this.activeName];
  96. }
  97. },
  98. data() {
  99. return {
  100. // 表示value等于这些值,就属于默认值
  101. defaultValue: [0, 'all', '0'],
  102. // 筛选结果
  103. result: [{ name: 'order', label: '全部', value: 'new' }],
  104. // { name: 'order', label: '最新发布', value: 'new' }
  105. activeName: 'order',
  106. order: {
  107. label: '全部',
  108. value: 'all',
  109. activeIndex: 0,
  110. color: '#333',
  111. activeColor: '#FF4546',
  112. child: [{
  113. label: '综合排序',
  114. value: 'all'
  115. }, {
  116. label: '最新发布',
  117. value: 'new'
  118. }, {
  119. label: '低价优先',
  120. value: 'money'
  121. }]
  122. },
  123. type: {
  124. label: '时间',
  125. value: 'all',
  126. activeIndex: 0,
  127. color: '#333',
  128. activeColor: '#FF4546',
  129. child: [{
  130. label: '全部',
  131. value: 'all'
  132. }, {
  133. label: 'PDF',
  134. value: 'pdf'
  135. }, {
  136. label: 'WROD',
  137. value: 'word'
  138. }, {
  139. label: 'PPT',
  140. value: 'ppt'
  141. }]
  142. }
  143. }
  144. },
  145. methods: {
  146. change(e) {
  147. console.log('弹窗打开状态:',e);
  148. },
  149. /**
  150. * 点击每个筛选项回调
  151. * @param {Object} e { name, active, type } = e
  152. */
  153. selectMenu(e) {
  154. const { name, active, type } = e;
  155. this.activeName = name;
  156. // type 等于1 的需要特殊处理:type不等于1可以忽略
  157. if (type == 1) {
  158. this.clickItem({
  159. name: 'vip_type',
  160. label: 'VIP文档',
  161. value: e.active ? 1 : 0
  162. });
  163. } else {
  164. const find = this.result.find(item => item.name == this.activeName);
  165. if (find) {
  166. const findIndex = this[this.activeName].child.findIndex(item => item.label == find.label && item.value == find.value);
  167. this[this.activeName].activeIndex = findIndex;
  168. } else {
  169. this[this.activeName].activeIndex = 0;
  170. }
  171. }
  172. },
  173. /**
  174. * 点击菜单回调处理
  175. * @param {Object} item 选中项 { label,value } = e
  176. */
  177. clickItem(e) {
  178. // 下面有重新赋值,所以用let
  179. let { label, value } = e;
  180. const findIndex = this.result.findIndex(item => item.name == this.activeName);
  181. if (this.defaultValue.indexOf(value) > -1 && this[this.activeName].label) {
  182. label = this[this.activeName].label;
  183. }
  184. // 已经存在筛选项
  185. if (findIndex > -1) {
  186. this.$set(this.result, findIndex, {
  187. name: this.activeName,
  188. label,
  189. value
  190. })
  191. } else {
  192. this.result.push({
  193. name: this.activeName,
  194. label,
  195. value
  196. });
  197. }
  198. this.result = this.result.filter(item => this.defaultValue.indexOf(item.value) == -1);
  199. uni.showModal({
  200. content: `筛选的值:${JSON.stringify(this.result)}`
  201. })
  202. }
  203. }
  204. }
  205. </script>
  206. <style scoped lang="scss">
  207. /deep/.uv-sticky__content{
  208. .uv-drop-down {
  209. justify-content: normal;
  210. border: 0;
  211. background: transparent;
  212. }
  213. }
  214. .travelList {
  215. margin-bottom: 500rpx;
  216. .content {
  217. .info {
  218. position: relative;
  219. margin: 10rpx 32rpx 36rpx;;
  220. padding: 35rpx 0 35rpx 24rpx;
  221. border-radius: 26rpx;
  222. .right {
  223. .data {
  224. display: flex;
  225. justify-content: space-between;
  226. align-items: center;
  227. .btn {
  228. background: #381615;
  229. color: $uni-color-primary;
  230. padding: 10rpx 40rpx;
  231. border-radius: 30rpx 0px 0px 30rpx;
  232. }
  233. }
  234. }
  235. }
  236. }
  237. }
  238. </style>