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

262 lines
7.5 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
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="type"
  27. type="2"
  28. :label="dropItem('type').label"
  29. :value="dropItem('type').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>11/40</text>
  53. <text class="btn">已开票</text>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. import Navbar from '@/pages/components/Navbar.vue'
  62. import { globalMixin } from '../pages/mixins/globalMixin';
  63. export default{
  64. onPageScroll() {
  65. // 滚动后及时更新位置
  66. this.$refs.dropDown.init();
  67. },
  68. mixins: [globalMixin],
  69. components:{
  70. Navbar
  71. },
  72. computed: {
  73. dropItem(name) {
  74. return (name) => {
  75. const result = {};
  76. const find = this.result.find(item => item.name === name);
  77. if (find) {
  78. result.label = find.label;
  79. result.value = find.value;
  80. } else {
  81. result.label = this[name].label;
  82. result.value = this[name].value;
  83. }
  84. return result;
  85. }
  86. },
  87. // 获取当前下拉筛选项
  88. currentDropItem() {
  89. return this[this.activeName];
  90. }
  91. },
  92. data() {
  93. return {
  94. params:{
  95. pageNo:1,
  96. pageSize:10
  97. },
  98. totalPage: '',
  99. cardListData: [],
  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. onReachBottom() {
  146. if(this.params.pageNo >= this.totalPage) return
  147. this.params.pageNo ++
  148. this.travelPageList()
  149. },
  150. onLoad() {
  151. this.travelPageList()
  152. },
  153. methods: {
  154. travelPageList() {
  155. this.$api('travelPageList',this.params, res=> {
  156. if(res.code == 200) {
  157. this.totalPage = res.result.pages
  158. this.cardListData = [...this.cardListData,...res.result.records]
  159. }
  160. })
  161. },
  162. toDetail({ id }) {
  163. uni.navigateTo({
  164. url:`/pages_order/lvyou-detail?travelId=${id}`
  165. })
  166. },
  167. change(e) {
  168. console.log('弹窗打开状态:',e);
  169. },
  170. /**
  171. * 点击每个筛选项回调
  172. * @param {Object} e { name, active, type } = e
  173. */
  174. selectMenu(e) {
  175. const { name, active, type } = e;
  176. this.activeName = name;
  177. // type 等于1 的需要特殊处理:type不等于1可以忽略
  178. if (type == 1) {
  179. this.clickItem({
  180. name: 'vip_type',
  181. label: 'VIP文档',
  182. value: e.active ? 1 : 0
  183. });
  184. } else {
  185. const find = this.result.find(item => item.name == this.activeName);
  186. if (find) {
  187. const findIndex = this[this.activeName].child.findIndex(item => item.label == find.label && item.value == find.value);
  188. this[this.activeName].activeIndex = findIndex;
  189. } else {
  190. this[this.activeName].activeIndex = 0;
  191. }
  192. }
  193. },
  194. /**
  195. * 点击菜单回调处理
  196. * @param {Object} item 选中项 { label,value } = e
  197. */
  198. clickItem(e) {
  199. // 下面有重新赋值,所以用let
  200. let { label, value } = e;
  201. const findIndex = this.result.findIndex(item => item.name == this.activeName);
  202. if (this.defaultValue.indexOf(value) > -1 && this[this.activeName].label) {
  203. label = this[this.activeName].label;
  204. }
  205. // 已经存在筛选项
  206. if (findIndex > -1) {
  207. this.$set(this.result, findIndex, {
  208. name: this.activeName,
  209. label,
  210. value
  211. })
  212. } else {
  213. this.result.push({
  214. name: this.activeName,
  215. label,
  216. value
  217. });
  218. }
  219. this.result = this.result.filter(item => this.defaultValue.indexOf(item.value) == -1);
  220. uni.showModal({
  221. content: `筛选的值:${JSON.stringify(this.result)}`
  222. })
  223. }
  224. }
  225. }
  226. </script>
  227. <style scoped lang="scss">
  228. /deep/.uv-sticky__content{
  229. .uv-drop-down {
  230. justify-content: normal;
  231. border: 0;
  232. background: transparent;
  233. }
  234. }
  235. .travelList {
  236. // margin-bottom: 500rpx;
  237. .content {
  238. .info {
  239. position: relative;
  240. margin: 10rpx 32rpx 36rpx;;
  241. padding: 35rpx 0 35rpx 24rpx;
  242. border-radius: 26rpx;
  243. .right {
  244. .data {
  245. display: flex;
  246. justify-content: space-between;
  247. align-items: center;
  248. .btn {
  249. background: #381615;
  250. color: $uni-color-primary;
  251. padding: 10rpx 40rpx;
  252. border-radius: 30rpx 0px 0px 30rpx;
  253. }
  254. }
  255. }
  256. }
  257. }
  258. }
  259. </style>