123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388 |
- <template>
- <view class="course_box">
- <nav-logo title="选购中心"></nav-logo>
- <view class="body_course">
- <view class="top">
- <u-tabs :list="courseLists" height="100" :current="current" @change="change" :scrollable="false"
- font-size="32" active-color="#333"></u-tabs>
- <view class="search_box">
- <u-search class="u_search" :show-action="false" @clear="search"
- :placeholder="`请输入${current == 4 ? '商品':courseLists[current].name}名称`"
- v-model="formData.goodsName" @search="search"></u-search>
- <view class="btns" @click="openFilterBox">
- <text>筛选</text>
- <img src="@/static/modIcon/screen.png" alt="">
- </view>
- </view>
- </view>
- <view class="content">
- <scroll-view scroll-y="true" class="scroll-Y" @scrolltolower="lower" :scroll-top="scrollTop"
- @scroll="scroll" scroll-with-animation>
- <view class="noGoods" v-if="goodsList.length == 0">
- <img src="https://file.xyyxt.net/web/static/img/no-content.png" alt="">
- <view class="">
- 暂无数据
- </view>
- </view>
- <view class="content_box" v-for="(item,index) in goodsList" :key="index" @click="tobuy(item)">
- <view class="title">
- {{item.goodsName}}
- </view>
- <view class="f_x">
- <view class="img_goods">
- <img :src="$method.splitImgHost(item.coverUrl)" alt="">
- </view>
- <view class="content_goods">
- <view class="top_bus">
- <text>{{item.educationName}}</text>
- <text>{{item.aliasName}}</text>
- </view>
- <view class="price">
- <text class="price1" v-if="!item.specTemplateId ||
- (!item.maxPrice && !item.minPrice)"><text v-if="item.standPrice"
- style="font-size: 28rpx;font-weight: 400;">¥</text><text
- v-if="item.standPrice">{{item.standPrice | formatPrice}}</text><text
- v-else>免费</text></text>
- <text class="price1" v-else><text
- style="font-size: 28rpx;font-weight: 400;">¥</text>{{item.minPrice | formatPrice}}
- <template v-if="item.minPrice != item.maxPrice">
- <text>-</text>
- <text
- style="font-size: 28rpx;font-weight: 400;">¥</text>{{ item.maxPrice | formatPrice }}
- </template></text>
- <text class="price2"
- v-if="item.linePrice">原价:¥{{item.linePrice | formatPrice}}</text>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- <!-- tabbar -->
- <myTabbar></myTabbar>
- <filter-show-status ref="filterShowStatus"></filter-show-status>
- </view>
- </template>
- <script>
- import filterShowStatus from "./filterStatus.vue"
- import {
- mapGetters
- } from "vuex";
- export default {
- components: {
- filterShowStatus
- },
- data() {
- return {
- scrollTop: 0,
- courseLists: [{
- name: "课程",
- type: 1
- },
- {
- name: "直播",
- type: 6
- },
- {
- name: "题库",
- type: 2
- },
- {
- name: "资料",
- type: 8
- },
- // {
- // name: "会员商城",
- // aliaName: "商品",
- // type: 7
- // },
- ],
- goodsList: [],
- formData: {
- goodsName: "",
- pageSize: 8,
- pageNum: 1,
- goodsStatus: 1,
- showStatus: 1
- },
- total: 0,
- oldScrollTop: 0,
- activeData: {
- educationId: "",
- projectId: "",
- businessId: "",
- subjectId: "",
- sortType: 1
- },
- };
- },
- onPullDownRefresh() {
- // this.initList();
- // setTimeout(function() {
- // uni.stopPullDownRefresh();
- // }, 500);
- },
- onLoad(option) {
- uni.hideTabBar();
- this.initList()
- uni.$on('backTop', res => {
- //视图会发生重新渲染
- this.scrollTop = this.oldScrollTop
- //当视图渲染结束 重新设置为0
- this.$nextTick(() => {
- this.scrollTop = 0
- });
- })
- },
- onUnload() {
- uni.$off('backTop')
- },
- watch: {
- "current"(newVal, oldVal) {
- this.formData.pageNum = 1
- this.formData.goodsName = ""
- this.activeData = {
- educationId: "",
- projectId: "",
- businessId: "",
- subjectId: "",
- sortType: 1
- }
- this.goodsList = []
- this.initList()
- }
- },
- computed: {
- ...mapGetters(["current"])
- },
- methods: {
- backFunc(item) {
- this.activeData = item
- this.search()
- },
- scroll(e) {
- //记录scroll 位置
- this.oldScrollTop = e.detail.scrollTop
- },
- openFilterBox() {
- this.$refs.filterShowStatus.openBoxs(this.activeData)
- },
- search() {
- this.formData.pageNum = 1
- this.goodsList = []
- this.initList()
- },
- //触底
- lower() {
- if (this.goodsList.length >= this.total) {
- uni.showToast({
- title: "已经到底啦~",
- icon: "none"
- })
- return
- }
- this.formData.pageNum++
- this.initList()
- },
- change(e) {
- this.$store.state.current = e
- },
- initList() {
- this.$api.goodsList({
- ...this.formData,
- ...this.activeData,
- educationTypeId: this.activeData.educationId,
- goodsName: this.formData.goodsName,
- goodsType: this.courseLists[this.$store.state.current].type
- }).then((res) => {
- this.goodsList = this.goodsList.concat(res.data.rows)
- this.total = res.data.total
- });
- },
- tobuy(item) {
- if (item.goodsType == 2) {
- uni.navigateTo({
- url: "/pages2/bank/detail?id=" + item.goodsId,
- });
- } else {
- // 视频、直播 /pages5/liveDetail/index
- uni.navigateTo({
- url: "/pages3/course/detail?id=" +
- item.goodsId +
- "&goodsType=" +
- item.goodsType,
- });
- }
- },
- },
- };
- </script>
- <style scoped lang="scss">
- .noGoods {
- height: 80%;
- display: flex;
- flex-direction: column;
- align-items: center;
- &>img {
- margin-top: 50rpx;
- width: 500rpx;
- height: 500rpx;
- }
- &>view {
- font-size: 34rpx;
- margin-top: 30rpx;
- color: #666;
- }
- }
- .course_box {
- display: flex;
- flex-direction: column;
- height: 100vh;
- background-color: rgba(241, 244, 247, 1);
- .body_course {
- flex: 1;
- height: 1rpx;
- display: flex;
- flex-direction: column;
- .top {
- flex-shrink: 0;
- background-color: #fff;
- .search_box {
- display: flex;
- align-items: center;
- padding: 40rpx 30rpx;
- &>.u_search {
- flex: 1;
- }
- &>.btns {
- display: flex;
- align-items: center;
- margin-left: 30rpx;
- &>text {
- color: #333;
- font-size: 28rpx;
- font-weight: 600;
- }
- &>img {
- margin-left: 6rpx;
- width: 30rpx;
- height: 30rpx;
- }
- }
- }
- }
- .content {
- flex: 1;
- height: 1rpx;
- overflow: hidden;
- &>.scroll-Y {
- height: 100%;
- }
- }
- }
- }
- .content_box {
- background-color: #fff;
- border-radius: 8rpx;
- padding: 20rpx;
- margin: 20rpx;
- &>.title {
- padding-top: 10rpx;
- margin-bottom: 30rpx;
- color: #333;
- font-weight: 600;
- font-size: 28rpx;
- }
- &>.f_x {
- display: flex;
- &>.img_goods {
- width: 235rpx;
- height: 138rpx;
- overflow: hidden;
- border-radius: 8rpx;
- margin-right: 20rpx;
- flex-shrink: 0;
- &>img {
- width: 100%;
- height: 100%;
- }
- }
- &>.content_goods {
- flex: 1;
- width: 1rpx;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- &>.top_bus {
- text-overflow: ellipsis;
- white-space: nowrap;
- overflow: hidden;
- &>text {
- background-color: #f5f7f9;
- border-radius: 4rpx;
- padding: 6rpx 10rpx;
- &:first-child {
- margin-right: 14rpx;
- }
- }
- }
- &>.price {
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- justify-content: space-between;
- &>.price1 {
- font-size: 36rpx;
- font-weight: 700;
- color: red;
- }
- &>.price2 {
- text-decoration: line-through;
- color: #aaaaaa;
- font-size: 24rpx;
- }
- }
- }
- }
- }
- /deep/ .u-scroll-box {
- display: flex;
- }
- /deep/ .u-tab-bar {
- background-color: #2979ff !important;
- }
- /deep/ .u-content {
- border: 1rpx solid #2979ff !important;
- }
- </style>
|