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

290 lines
8.1 KiB

10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
9 months ago
9 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
9 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
9 months ago
10 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 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="state"
  21. type="2"
  22. :label="dropItem('state').label"
  23. :value="dropItem('state').value">
  24. </uv-drop-down-item>
  25. <uv-drop-down-item
  26. name="timeStr"
  27. type="1"
  28. :label="dropItem('timeStr').label"
  29. :value="dropItem('timeStr').value">
  30. </uv-drop-down-item>
  31. </uv-drop-down>
  32. <uv-drop-down-popup
  33. sign="dropDown_1"
  34. :click-overlay-on-close="true"
  35. :currentDropItem="currentDropItem"
  36. @clickItem="clickItem"
  37. @popupChange="change"
  38. ></uv-drop-down-popup>
  39. </view>
  40. <view class="info cardStyle_" v-for="(item, index) in cardListData" :key="index" @click="toDetail(item)">
  41. <view class="left">
  42. <image :src="item.image" alt="">
  43. </view>
  44. <view class="right">
  45. <view class="detailed">
  46. <view class="title">{{item.title}}</view>
  47. <view class="date">{{item.startTime}}</view>
  48. <view class="address">{{item.address}}</view>
  49. </view>
  50. <view class="data">
  51. <text>¥{{item.price}}</text>
  52. <text>{{item.num}}/{{item.sum}}</text>
  53. <text class="btn" v-if="item.state == 0">报名中</text>
  54. <text class="btn-2" v-if="item.state == 1">已结束</text>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <uv-calendars ref="calendars"
  60. @close="closeCalendars"
  61. @confirm="confirmCalendars" />
  62. </view>
  63. </template>
  64. <script>
  65. import Navbar from '@/pages/components/Navbar.vue'
  66. import { globalMixin } from '../pages/mixins/globalMixin';
  67. export default{
  68. onPageScroll() {
  69. // 滚动后及时更新位置
  70. this.$refs.dropDown.init();
  71. },
  72. mixins: [globalMixin],
  73. components:{
  74. Navbar
  75. },
  76. computed: {
  77. dropItem(name) {
  78. return (name) => {
  79. const result = {};
  80. const find = this.result.find(item => item.name === name);
  81. if (find) {
  82. result.label = find.label;
  83. result.value = find.value;
  84. } else {
  85. result.label = this[name].label;
  86. result.value = this[name].value;
  87. }
  88. return result;
  89. }
  90. },
  91. // 获取当前下拉筛选项
  92. currentDropItem() {
  93. return this[this.activeName];
  94. }
  95. },
  96. data() {
  97. return {
  98. params:{
  99. pageNo:1,
  100. pageSize:10
  101. },
  102. totalPage: '',
  103. cardListData: [],
  104. // 表示value等于这些值,就属于默认值
  105. defaultValue: ['all'],
  106. // 筛选结果
  107. result: [],
  108. // { name: 'state', label: '最新发布', value: 'new' }
  109. activeName: 'state',
  110. state: {
  111. label: '全部',
  112. value: 'all',
  113. activeIndex: 0,
  114. color: '#999',
  115. activeColor: '#FF4546',
  116. child: [{
  117. label: '全部',
  118. value: 'all'
  119. }, {
  120. label: '报名中',
  121. value: '0'
  122. }, {
  123. label: '已结束',
  124. value: '1'
  125. }]
  126. },
  127. timeStr: {
  128. label: '时间',
  129. value: 'all',
  130. activeIndex: 0,
  131. color: '#999',
  132. activeColor: '#FF4546',
  133. child: []
  134. },
  135. isC : false,
  136. }
  137. },
  138. onReachBottom() {
  139. if(this.params.pageNo >= this.totalPage) return
  140. this.params.pageNo ++
  141. this.travelPageList()
  142. },
  143. onLoad() {
  144. this.travelPageList()
  145. },
  146. onPullDownRefresh() {
  147. this.params.pageNo = 1
  148. this.cardListData = []
  149. this.travelPageList()
  150. },
  151. methods: {
  152. travelPageList() {
  153. let params = {
  154. ...this.params
  155. }
  156. this.result.forEach(n => {
  157. params[n.name] = n.value
  158. })
  159. this.$api('travelPageList',params, res=> {
  160. uni.stopPullDownRefresh()
  161. if(res.code == 200) {
  162. this.totalPage = res.result.pages
  163. this.cardListData = [...this.cardListData,...res.result.records]
  164. }
  165. })
  166. },
  167. toDetail({ id }) {
  168. uni.navigateTo({
  169. url:`/pages_order/lvyou-detail?travelId=${id}`
  170. })
  171. },
  172. change(e) {
  173. console.log('弹窗打开状态:',e);
  174. },
  175. /**
  176. * 点击每个筛选项回调
  177. * @param {Object} e { name, active, type } = e
  178. */
  179. selectMenu(e) {
  180. const { name, active, type } = e;
  181. this.activeName = name;
  182. // type 等于1 的需要特殊处理:type不等于1可以忽略
  183. if (type == 1) {
  184. this.$refs.calendars.open()
  185. } else {
  186. const find = this.result.find(item => item.name == this.activeName);
  187. if (find) {
  188. const findIndex = this[this.activeName].child.findIndex(item => item.label == find.label && item.value == find.value);
  189. this[this.activeName].activeIndex = findIndex;
  190. } else {
  191. this[this.activeName].activeIndex = 0;
  192. }
  193. }
  194. },
  195. /**
  196. * 点击菜单回调处理
  197. * @param {Object} item 选中项 { label,value } = e
  198. */
  199. clickItem(e) {
  200. // 下面有重新赋值,所以用let
  201. let { label, value } = e;
  202. const findIndex = this.result.findIndex(item => item.name == this.activeName);
  203. if (this.defaultValue.indexOf(value) > -1 && this[this.activeName].label) {
  204. label = this[this.activeName].label;
  205. }
  206. // 已经存在筛选项
  207. if (findIndex > -1) {
  208. this.$set(this.result, findIndex, {
  209. name: this.activeName,
  210. label,
  211. value
  212. })
  213. } else {
  214. this.result.push({
  215. name: this.activeName,
  216. label,
  217. value
  218. });
  219. }
  220. this.result = this.result.filter(item => this.defaultValue.indexOf(item.value) == -1);
  221. this.params.pageNo = 1
  222. this.cardListData = []
  223. this.travelPageList()
  224. },
  225. confirmCalendars(e){
  226. this.isC = true
  227. this.clickItem({
  228. name: 'timeStr',
  229. label: e.fulldate,
  230. value: e.fulldate
  231. });
  232. },
  233. closeCalendars(){
  234. if(this.isC) return this.isC = false
  235. this.clickItem({
  236. name: 'timeStr',
  237. label: 'all',
  238. value: 'all'
  239. });
  240. },
  241. }
  242. }
  243. </script>
  244. <style scoped lang="scss">
  245. /deep/.uv-sticky__content{
  246. .uv-drop-down {
  247. justify-content: normal;
  248. border: 0;
  249. background: transparent;
  250. }
  251. }
  252. .travelList {
  253. // margin-bottom: 500rpx;
  254. .content {
  255. margin-top: 40rpx;
  256. .info {
  257. position: relative;
  258. margin: 10rpx 32rpx 36rpx;;
  259. padding: 35rpx 0 35rpx 24rpx;
  260. border-radius: 26rpx;
  261. .right {
  262. .data {
  263. display: flex;
  264. justify-content: space-between;
  265. align-items: center;
  266. .btn {
  267. background: #381615;
  268. color: $uni-color-primary;
  269. padding: 10rpx 40rpx;
  270. border-radius: 30rpx 0px 0px 30rpx;
  271. }
  272. .btn-2 {
  273. background: #333;
  274. color: #999;
  275. padding: 10rpx 40rpx;
  276. border-radius: 30rpx 0px 0px 30rpx;
  277. }
  278. }
  279. }
  280. }
  281. }
  282. }
  283. </style>