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

330 lines
7.9 KiB

2 months ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
2 months ago
2 months ago
1 month ago
2 months ago
1 month ago
1 month ago
2 months ago
2 months ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
2 months ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
1 month ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
2 months ago
1 month ago
1 month ago
1 month ago
2 months ago
1 month ago
1 month ago
1 month ago
1 month ago
2 months ago
2 months ago
2 months ago
2 months ago
1 month ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
1 month ago
1 month ago
2 months ago
1 month ago
1 month ago
1 month ago
2 months ago
2 months ago
1 month ago
2 months ago
2 months ago
2 months ago
2 months ago
1 month ago
2 months ago
2 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="state" type="2" :label="dropItem('state').label" :value="dropItem('state').value">
  12. </uv-drop-down-item>
  13. <uv-drop-down-item name="address" type="2" :label="dropItem('address').label" :value="dropItem('address').value">
  14. </uv-drop-down-item>
  15. <uv-drop-down-item name="date" type="1" :label="dropItem('date').label" :value="dropItem('date').value">
  16. </uv-drop-down-item>
  17. <!-- <uv-drop-down-item name="type" type="2" :label="dropItem('type').label" :value="dropItem('type').value">
  18. </uv-drop-down-item> -->
  19. </uv-drop-down>
  20. <uv-drop-down-popup sign="dropDown_1" :click-overlay-on-close="true" :currentDropItem="currentDropItem"
  21. @clickItem="clickItem" @popupChange="change"></uv-drop-down-popup>
  22. </view>
  23. <active-item :cardListData="cardListData"/>
  24. <uv-load-more :status="status" fontSize="24rpx" dashed line />
  25. <!-- <view class="info cardStyle_">
  26. <view class="left">
  27. <image src="https://img0.baidu.com/it/u=4274003247,920124130&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1031"
  28. alt="">
  29. </view>
  30. <view class="right">
  31. <view class="detailed">
  32. <view class="title">夏日去撒野旅游计划</view>
  33. <view class="date">2024.10.28 10:00</view>
  34. <view class="address">成都市东丽湖露营地32号</view>
  35. </view>
  36. <view class="data">
  37. <text>¥233.00</text>
  38. <text>11/40</text>
  39. <text class="btn">已开票</text>
  40. </view>
  41. </view>
  42. </view> -->
  43. <uv-calendars ref="calendars"
  44. @close="closeCalendars"
  45. @confirm="confirmCalendars" />
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import Navbar from '@/pages/components/Navbar.vue'
  51. import activeItem from '@/components/active/active-item.vue'
  52. // import { globalMixin } from '../pages/mixins/globalMixin';
  53. export default {
  54. components:{
  55. activeItem
  56. },
  57. onPageScroll(e) {
  58. if(e.scrollTop > 50) {
  59. this.bgColor = '#49070c'
  60. }else{
  61. this.bgColor = 'transparent'
  62. }
  63. // this.$refs.dropDown.init();
  64. },
  65. onReachBottom() {
  66. if(this.params.pageNo >= this.totalPage) return
  67. this.params.pageNo ++
  68. this.getActivityPageList()
  69. },
  70. // mixins: [globalMixin],
  71. // components:{
  72. // Navbar
  73. // },
  74. computed: {
  75. dropItem(name) {
  76. return (name) => {
  77. const result = {};
  78. const find = this.result.find(item => item.name === name);
  79. if (find) {
  80. result.label = find.label;
  81. result.value = find.value;
  82. } else {
  83. result.label = this[name].label;
  84. result.value = this[name].value;
  85. }
  86. return result;
  87. }
  88. },
  89. // 获取当前下拉筛选项
  90. currentDropItem() {
  91. return this[this.activeName];
  92. }
  93. },
  94. data() {
  95. return {
  96. status:"loading",
  97. bgColor:'transparent',
  98. // 表示value等于这些值,就属于默认值
  99. defaultValue: ['-1', 'all', 'allAddress'],
  100. // 筛选结果
  101. result: [],
  102. // { name: 'order', label: '最新发布', value: 'new' }
  103. activeName: 'state',
  104. state: {
  105. label: '全部',
  106. value: '-1',
  107. activeIndex: 0,
  108. color: '#999',
  109. activeColor: '#FF4546',
  110. child: [{
  111. label: '全部',
  112. value: '-1'
  113. },{
  114. label: '报名中',
  115. value: '0'
  116. }, {
  117. label: '已结束',
  118. value: '1'
  119. }]
  120. },
  121. date: {
  122. label: '时间',
  123. value: 'all',
  124. activeIndex: 0,
  125. color: '#999',
  126. activeColor: '#FF4546',
  127. child: [
  128. {
  129. label: '时间',
  130. value: 'all'
  131. },
  132. ]
  133. },
  134. address: {
  135. label: '全部地区',
  136. value: 'allAddress',
  137. activeIndex: 0,
  138. color: '#999',
  139. activeColor: '#FF4546',
  140. child: [
  141. {
  142. label: '全部地区',
  143. value: 'allAddress'
  144. },
  145. ]
  146. },
  147. totalPage:0,
  148. cardListData:[],
  149. params:{
  150. state : '',
  151. pageNo:1,
  152. pageSize:10
  153. },
  154. isC : false,
  155. }
  156. },
  157. onLoad() {
  158. this.getActivityPageList()
  159. this.getArea()
  160. },
  161. onPullDownRefresh() {
  162. this.params.pageNo = 1
  163. this.cardListData = []
  164. this.getActivityPageList()
  165. },
  166. methods: {
  167. getActivityPageList() {
  168. let params = {
  169. ...this.params
  170. }
  171. this.result.forEach(n => {
  172. params[n.name] = n.value
  173. })
  174. this.$api('activityPageList', params, res=>{
  175. uni.stopPullDownRefresh()
  176. if(res.code == 200) {
  177. this.totalPage = res.result.pages
  178. this.cardListData = [...this.cardListData,...res.result.records]
  179. if(this.params.pageNo >= this.totalPage) {
  180. this.status = "nomore"
  181. }else {
  182. this.status = "loadmore"
  183. }
  184. }
  185. })
  186. },
  187. getArea(){
  188. this.$api('getArea', res => {
  189. if(res.code == 200){
  190. res.result.forEach(n => {
  191. this.address.child.push({
  192. label: n.city,
  193. value: n.id
  194. })
  195. })
  196. }
  197. })
  198. },
  199. change(e) {
  200. console.log('弹窗打开状态:', e);
  201. },
  202. selectMenu(e) {
  203. const {
  204. name,
  205. active,
  206. type
  207. } = e;
  208. this.activeName = name;
  209. // type 等于1 的需要特殊处理:type不等于1可以忽略
  210. if (type == 1) {
  211. this.$refs.calendars.open()
  212. } else {
  213. const find = this.result.find(item => item.name == this.activeName);
  214. if (find) {
  215. const findIndex = this[this.activeName].child.findIndex(item => item.label == find.label && item.value ==
  216. find.value);
  217. this[this.activeName].activeIndex = findIndex;
  218. } else {
  219. this[this.activeName].activeIndex = 0;
  220. }
  221. }
  222. },
  223. clickItem(e) {
  224. // 下面有重新赋值,所以用let
  225. let {
  226. label,
  227. value
  228. } = e;
  229. const findIndex = this.result.findIndex(item => item.name == this.activeName);
  230. if (this.defaultValue.indexOf(value) > -1 && this[this.activeName].label) {
  231. label = this[this.activeName].label;
  232. }
  233. // // 已经存在筛选项
  234. if (findIndex > -1) {
  235. this.$set(this.result, findIndex, {
  236. name: this.activeName,
  237. label,
  238. value
  239. })
  240. } else {
  241. this.result.push({
  242. name: this.activeName,
  243. label,
  244. value
  245. });
  246. }
  247. this.result = this.result.filter(item => this.defaultValue.indexOf(item.value) == -1);
  248. this.params.pageNo = 1
  249. this.cardListData = []
  250. this.getActivityPageList()
  251. },
  252. confirmCalendars(e){
  253. this.isC = true
  254. this.clickItem({
  255. name: 'date',
  256. label: e.fulldate,
  257. value: e.fulldate
  258. });
  259. },
  260. closeCalendars(){
  261. if(this.isC) return this.isC = false
  262. this.clickItem({
  263. name: 'date',
  264. label: 'all',
  265. value: 'all'
  266. });
  267. },
  268. }
  269. }
  270. </script>
  271. <style scoped lang="scss">
  272. .head-box {
  273. background: url('@/static/image/nav-bg.png') no-repeat;
  274. background-size: 100% 100%;
  275. width: 100%;
  276. height: 534rpx;
  277. position: absolute;
  278. }
  279. .content {
  280. margin-top: 40rpx;
  281. padding-top: calc(var(--status-bar-height) + 110rpx);
  282. }
  283. /deep/.uv-sticky__content {
  284. .uv-drop-down {
  285. justify-content: normal;
  286. border: 0;
  287. background: transparent;
  288. }
  289. }
  290. .travelList {
  291. // margin-bottom: 500rpx;
  292. .content {
  293. padding-left: 20rpx;
  294. padding-right: 20rpx;
  295. .info {
  296. position: relative;
  297. margin: 10rpx 32rpx 36rpx;
  298. ;
  299. padding: 35rpx 0 35rpx 24rpx;
  300. border-radius: 26rpx;
  301. .right {
  302. .data {
  303. display: flex;
  304. justify-content: space-between;
  305. align-items: center;
  306. .btn {
  307. background: #381615;
  308. color: $uni-color-primary;
  309. padding: 10rpx 40rpx;
  310. border-radius: 30rpx 0px 0px 30rpx;
  311. }
  312. }
  313. }
  314. }
  315. }
  316. }
  317. </style>