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

336 lines
8.2 KiB

1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
11 months ago
11 months ago
11 months ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
11 months ago
11 months ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
11 months ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
1 year ago
11 months ago
11 months ago
11 months ago
1 year ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
11 months ago
1 year ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
  1. <template>
  2. <view class="travelList">
  3. <view class="head-box"></view>
  4. <uv-navbar autoBack :title="$t('pages_my.activeList.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="cityId" type="2" :label="dropItem('cityId').label" :value="dropItem('cityId').value">
  14. </uv-drop-down-item>
  15. <uv-drop-down-item name="timeStr" type="1" :label="dropItem('timeStr').label" :value="dropItem('timeStr').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: ['all', 'allAddress'],
  100. // 筛选结果
  101. result: [
  102. {
  103. label: '报名中',
  104. value: '0',
  105. name : 'state',
  106. }
  107. ],
  108. // { name: 'order', label: '最新发布', value: 'new' }
  109. activeName: 'state',
  110. state: {
  111. label: this.$t('pages_my.activeList.enrolling'),
  112. value: '0',
  113. activeIndex: 0,
  114. color: '#999',
  115. activeColor: '#FF4546',
  116. child: [
  117. {
  118. label: this.$t('pages_my.activeList.enrolling'),
  119. value: '0'
  120. },
  121. {
  122. label: this.$t('pages_my.activeList.ended'),
  123. value: '1'
  124. },
  125. ]
  126. },
  127. timeStr: {
  128. label: this.$t('pages_my.activeList.time'),
  129. value: 'all',
  130. activeIndex: 0,
  131. color: '#999',
  132. activeColor: '#FF4546',
  133. child: [
  134. {
  135. label: this.$t('pages_my.activeList.time'),
  136. value: 'all'
  137. }
  138. ]
  139. },
  140. cityId: {
  141. label: this.$t('pages_my.activeList.all_area'),
  142. value: 'allAddress',
  143. activeIndex: 0,
  144. color: '#999',
  145. activeColor: '#FF4546',
  146. child: [
  147. {
  148. label: this.$t('pages_my.activeList.all_area'),
  149. value: 'allAddress'
  150. },
  151. ]
  152. },
  153. totalPage:0,
  154. cardListData:[],
  155. params:{
  156. state : '',
  157. pageNo:1,
  158. pageSize:10
  159. },
  160. isC : false,
  161. }
  162. },
  163. onLoad() {
  164. this.getActivityPageList()
  165. this.getArea()
  166. },
  167. onPullDownRefresh() {
  168. this.params.pageNo = 1
  169. this.cardListData = []
  170. this.getActivityPageList()
  171. },
  172. methods: {
  173. getActivityPageList() {
  174. let params = {
  175. ...this.params
  176. }
  177. this.result.forEach(n => {
  178. params[n.name] = n.value
  179. })
  180. this.$api('activityPageList', params, res=>{
  181. uni.stopPullDownRefresh()
  182. if(res.code == 200) {
  183. this.totalPage = res.result.pages
  184. this.cardListData = [...this.cardListData,...res.result.records]
  185. if(this.params.pageNo >= this.totalPage) {
  186. this.status = "nomore"
  187. }else {
  188. this.status = "loadmore"
  189. }
  190. }
  191. })
  192. },
  193. getArea(){
  194. this.$api('getArea', res => {
  195. if(res.code == 200){
  196. res.result.forEach(n => {
  197. this.cityId.child.push({
  198. label: n.city,
  199. value: n.id
  200. })
  201. })
  202. }
  203. })
  204. },
  205. change(e) {
  206. console.log('弹窗打开状态:', e);
  207. },
  208. selectMenu(e) {
  209. const {
  210. name,
  211. active,
  212. type
  213. } = e;
  214. this.activeName = name;
  215. // type 等于1 的需要特殊处理:type不等于1可以忽略
  216. if (type == 1) {
  217. this.$refs.calendars.open()
  218. } else {
  219. const find = this.result.find(item => item.name == this.activeName);
  220. if (find) {
  221. const findIndex = this[this.activeName].child.findIndex(item => item.label == find.label && item.value ==
  222. find.value);
  223. this[this.activeName].activeIndex = findIndex;
  224. } else {
  225. this[this.activeName].activeIndex = 0;
  226. }
  227. }
  228. },
  229. clickItem(e) {
  230. // 下面有重新赋值,所以用let
  231. let {
  232. label,
  233. value
  234. } = e;
  235. const findIndex = this.result.findIndex(item => item.name == this.activeName);
  236. if (this.defaultValue.indexOf(value) > -1 && this[this.activeName].label) {
  237. label = this[this.activeName].label;
  238. }
  239. // // 已经存在筛选项
  240. if (findIndex > -1) {
  241. this.$set(this.result, findIndex, {
  242. name: this.activeName,
  243. label,
  244. value
  245. })
  246. } else {
  247. this.result.push({
  248. name: this.activeName,
  249. label,
  250. value
  251. });
  252. }
  253. this.result = this.result.filter(item => this.defaultValue.indexOf(item.value) == -1);
  254. this.params.pageNo = 1
  255. this.cardListData = []
  256. this.getActivityPageList()
  257. },
  258. confirmCalendars(e){
  259. this.isC = true
  260. this.clickItem({
  261. name: 'timeStr',
  262. label: e.fulldate,
  263. value: e.fulldate
  264. });
  265. },
  266. closeCalendars(){
  267. if(this.isC) return this.isC = false
  268. this.clickItem({
  269. name: 'timeStr',
  270. label: 'all',
  271. value: 'all'
  272. });
  273. },
  274. }
  275. }
  276. </script>
  277. <style scoped lang="scss">
  278. .head-box {
  279. background: url('@/static/image/nav-bg.png') no-repeat;
  280. background-size: 100% 100%;
  281. width: 100%;
  282. height: 534rpx;
  283. position: absolute;
  284. }
  285. .content {
  286. margin-top: 40rpx;
  287. padding-top: calc(var(--status-bar-height) + 110rpx);
  288. }
  289. /deep/.uv-sticky__content {
  290. .uv-drop-down {
  291. justify-content: normal;
  292. border: 0;
  293. background: transparent;
  294. }
  295. }
  296. .travelList {
  297. // margin-bottom: 500rpx;
  298. .content {
  299. padding-left: 20rpx;
  300. padding-right: 20rpx;
  301. .info {
  302. position: relative;
  303. margin: 10rpx 32rpx 36rpx;
  304. ;
  305. padding: 35rpx 0 35rpx 24rpx;
  306. border-radius: 26rpx;
  307. .right {
  308. .data {
  309. display: flex;
  310. justify-content: space-between;
  311. align-items: center;
  312. .btn {
  313. background: #381615;
  314. color: $uni-color-primary;
  315. padding: 10rpx 40rpx;
  316. border-radius: 30rpx 0px 0px 30rpx;
  317. }
  318. }
  319. }
  320. }
  321. }
  322. }
  323. </style>