推广小程序前端代码
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.

243 lines
6.1 KiB

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