Commit 0b7c296d232325f9fa18cc2bb5e1d2de5d102816
1 parent
61b3c79c
优选库——优选页面,下部商品瀑布流,完成~
Showing
2 changed files
with
123 additions
and
2 deletions
src/pages/discountList/discountList.vue
| ... | ... | @@ -70,7 +70,7 @@ |
| 70 | 70 | :discountType="tabs.list[tabs.active].discountType"> |
| 71 | 71 | |
| 72 | 72 | <!-- 折扣角标 --> |
| 73 | - <div class="discount-flag" slot="flag" v-if="tabs.list[tabs.active].type == '0' && (parseFloat(item.price) < parseFloat(item.prices))"> | |
| 73 | + <div class="discount-flag" slot="flag" v-if="tabs.list[tabs.active].type == '0' && (item.tag || (parseFloat(item.price) < parseFloat(item.prices)))"> | |
| 74 | 74 | {{item.tag || getDiscount(item.price, item.prices)}} |
| 75 | 75 | </div> |
| 76 | 76 | </goods-item-8> | ... | ... |
src/pages/optimization2/optimization2.vue
| ... | ... | @@ -136,6 +136,27 @@ |
| 136 | 136 | com="7"> |
| 137 | 137 | </column-list-box> |
| 138 | 138 | </div> |
| 139 | + | |
| 140 | + <!-- 推荐(瀑布流) --> | |
| 141 | + <div class="section goods-list"> | |
| 142 | + | |
| 143 | + <!-- 标题 --> | |
| 144 | + <text-title-box | |
| 145 | + :titles="{ | |
| 146 | + title: '推荐' | |
| 147 | + }"> | |
| 148 | + </text-title-box> | |
| 149 | + | |
| 150 | + <!-- 上拉加载 --> | |
| 151 | + <van-list class="column-list-container" v-model="shopGoodsLists.loading" :finished="shopGoodsLists.finished" finished-text="没有更多了" @load="loadMore"> | |
| 152 | + | |
| 153 | + <!-- 商品样式 7 列表 --> | |
| 154 | + <column-list-box class="column-list-box" v-if="shopGoodsLists && shopGoodsLists.list && shopGoodsLists.list.length" @jump="toDetail" @primary="primary" | |
| 155 | + :lists="shopGoodsLists.list" | |
| 156 | + com="7"> | |
| 157 | + </column-list-box> | |
| 158 | + </van-list> | |
| 159 | + </div> | |
| 139 | 160 | </div> |
| 140 | 161 | |
| 141 | 162 | <!-- 回到顶部按钮 --> |
| ... | ... | @@ -148,7 +169,9 @@ |
| 148 | 169 | <script> |
| 149 | 170 | |
| 150 | 171 | // 引入组件 |
| 172 | + import Vue from "vue"; | |
| 151 | 173 | import { Toast, Indicator } from "mint-ui"; |
| 174 | + import { List } from "vant"; | |
| 152 | 175 | import callAppBox from "@/components/callAppBox/callAppBox"; |
| 153 | 176 | import backBox from "@/components/backBox/backBox"; |
| 154 | 177 | import textBgTitleCom from "@/components/textBgTitleCom/textBgTitleCom"; |
| ... | ... | @@ -161,6 +184,8 @@ |
| 161 | 184 | import columnListBox from "@/components/columnListBox/columnListBox"; |
| 162 | 185 | import gotoTop from "@/components/gotoTop/gotoTop"; |
| 163 | 186 | |
| 187 | + Vue.use(List); | |
| 188 | + | |
| 164 | 189 | export default { |
| 165 | 190 | name: 'optimization', |
| 166 | 191 | data () { |
| ... | ... | @@ -178,7 +203,14 @@ |
| 178 | 203 | points: null, // 用户积分 |
| 179 | 204 | pointsLists: null, // 积分商城数据 |
| 180 | 205 | likeLists: null, // 猜你喜欢列表 |
| 181 | - likeNum: 0 // 猜你喜欢二维数组当前显示的下标 | |
| 206 | + likeNum: 0, // 猜你喜欢二维数组当前显示的下标 | |
| 207 | + shopGoodsLists: { // 推荐商品瀑布流 | |
| 208 | + loading: false, | |
| 209 | + loadingNow: false, | |
| 210 | + finished: false, | |
| 211 | + page: 1, | |
| 212 | + list: [] | |
| 213 | + } | |
| 182 | 214 | } |
| 183 | 215 | }, |
| 184 | 216 | computed: { |
| ... | ... | @@ -237,6 +269,9 @@ |
| 237 | 269 | // 优选页面接口 |
| 238 | 270 | this.index(); |
| 239 | 271 | |
| 272 | + // 商品列表 | |
| 273 | + // this.shopGoodsList(); | |
| 274 | + | |
| 240 | 275 | // 设置锚点定位数据 |
| 241 | 276 | this.$set(this, 'navs', [ |
| 242 | 277 | { |
| ... | ... | @@ -277,6 +312,19 @@ |
| 277 | 312 | methods: { |
| 278 | 313 | |
| 279 | 314 | /** |
| 315 | + * 加载更多 | |
| 316 | + */ | |
| 317 | + loadMore() { | |
| 318 | + | |
| 319 | + // 判断是否可加载 | |
| 320 | + if (this.shopGoodsLists.loadingNow === false && this.shopGoodsLists.finished === false) { | |
| 321 | + | |
| 322 | + // 商品列表 | |
| 323 | + this.shopGoodsList(); | |
| 324 | + } | |
| 325 | + }, | |
| 326 | + | |
| 327 | + /** | |
| 280 | 328 | * 优选页面接口 |
| 281 | 329 | */ |
| 282 | 330 | index() { |
| ... | ... | @@ -396,6 +444,79 @@ |
| 396 | 444 | }, |
| 397 | 445 | |
| 398 | 446 | /** |
| 447 | + * 商品列表 | |
| 448 | + */ | |
| 449 | + shopGoodsList() { | |
| 450 | + | |
| 451 | + // 校验登录 | |
| 452 | + if (this.$parent.checkLogin()) { | |
| 453 | + | |
| 454 | + // 加载中提示 | |
| 455 | + Indicator.open("加载中..."); | |
| 456 | + | |
| 457 | + // 设置开始加载 | |
| 458 | + this.$set(this.shopGoodsLists, 'loading', true); | |
| 459 | + this.$set(this.shopGoodsLists, 'loadingNow', true); | |
| 460 | + | |
| 461 | + // 请求接口 | |
| 462 | + this.http("/Api/" + this.getApiVersion().index + "/shopGoodsList", { | |
| 463 | + page: this.shopGoodsLists.page | |
| 464 | + }, this.shopGoodsListCallback, { | |
| 465 | + method: "POST" | |
| 466 | + }); | |
| 467 | + } | |
| 468 | + }, | |
| 469 | + | |
| 470 | + /** | |
| 471 | + * 商品列表回调 | |
| 472 | + * @param {Object} res [服务器返回数据] | |
| 473 | + * @param {Object} ext [扩展参数] | |
| 474 | + */ | |
| 475 | + shopGoodsListCallback(res, ext) { | |
| 476 | + | |
| 477 | + // 加载完成 | |
| 478 | + Indicator.close(); | |
| 479 | + | |
| 480 | + // 设置加载结束 | |
| 481 | + this.$set(this.shopGoodsLists, 'loading', false); | |
| 482 | + this.$set(this.shopGoodsLists, 'loadingNow', false); | |
| 483 | + | |
| 484 | + // 返回处理 | |
| 485 | + if (res.code == 200) { | |
| 486 | + | |
| 487 | + // 解构数据 | |
| 488 | + let { data: datas } = res; | |
| 489 | + | |
| 490 | + /* 获取商品列表数据 开始 */ | |
| 491 | + | |
| 492 | + // 判断是否有商品 | |
| 493 | + if (datas && datas.length) { | |
| 494 | + | |
| 495 | + // 设置列表数据 | |
| 496 | + this.$set(this.shopGoodsLists, 'list', [...this.shopGoodsLists.list, ...datas]); | |
| 497 | + | |
| 498 | + // 设置页码 | |
| 499 | + this.$set(this.shopGoodsLists, 'page', ++this.shopGoodsLists.page); | |
| 500 | + } else { | |
| 501 | + | |
| 502 | + // 设置全部商品加载完成 | |
| 503 | + this.$set(this.shopGoodsLists, 'finished', true); | |
| 504 | + } | |
| 505 | + | |
| 506 | + /* 获取商品列表数据 结束 */ | |
| 507 | + | |
| 508 | + } else if (res.code == 400) { | |
| 509 | + | |
| 510 | + // 获取优选失败 | |
| 511 | + Toast(res.message); | |
| 512 | + } else { | |
| 513 | + | |
| 514 | + // 获取优选失败 | |
| 515 | + Toast("获取数据失败"); | |
| 516 | + } | |
| 517 | + }, | |
| 518 | + | |
| 519 | + /** | |
| 399 | 520 | * 跳转折扣专区列表 |
| 400 | 521 | * @param {Object} item [通用跳转对象] |
| 401 | 522 | */ | ... | ... |