123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510 |
- <template>
- <view class="content">
- <!-- 导航 -->
- <view class="nav">
- <view class="leftView" @click="back">
- <image v-if="type == 'app'" src="../../static/mobile/backBtn.png" mode=""
- style="width: 22rpx; height: 40rpx; padding-left: 24rpx;"></image>
- </view>
- <view class="navTitle">门店学院</view>
- <view class="rightView">
- <image src="../../static/mobile/icona_fenlei@2x.png" mode="" class="rightImg" @click="goSift"></image>
- <image src="../../static/mobile/icon_search@2x.png" mode="" class="rightImg" style="margin-left: 40rpx;"
- @click="goSearch"></image>
- </view>
- </view>
- <!-- 推荐 -->
- <view class="commend" v-if="bannerArr.length != 0">
- <view class="top">
- <image src="../../static/mobile/icon_tuijian@2x.png" mode="" style="width: 28rpx; height: 28rpx;">
- <text class="tuijian">推荐文章</text>
- </image>
- </view>
- <!-- item -->
- <view class="scrollBg">
- <scroll-view scroll-x="true" @scroll="scroll">
- <view class="itemBg">
- <view v-for="(item,index) in bannerArr" :key="index" class="item" @click="goDetail(item)">
- <image :src="item.logoImg" mode="" class="swpImg"></image>
- <view class="title">{{item.title}}</view>
- <view style="display: flex;">
- <view class="title2" @click.stop="goTuijianTab(item)">{{item.categoryName}}</view>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- <!-- 分类 -->
- <view v-for="(item,index) in itemArr" :key="index">
- <view class="fenleiBg">
- <!-- 头 -->
- <view class="fenTop" :class="{fenTopNo:item.children == 0}">
- <view class="leftTop">
- <view class="tuijian">{{item.name}}</view>
- <view class="sum">共{{item.count}}篇文章</view>
- </view>
- <view class="rightTop">
- <view class="allBtn" @click="goTopTab(item)">查看全部
- <image src="../../static/mobile/icon_arrow@2x.png" mode=""
- style="width: 11rpx; height: 18rpx; margin-left: 10rpx;"></image>
- </view>
- </view>
- </view>
- <!-- item -->
- <view class="itemBg">
- <view v-for="(item2,index2) in item.children" :key="index2" v-if="index2<2" class="twoItem"
- @click="goList(item2)">
- <image :src="item2.logoImg" mode="" class="img2"></image>
- <view class="itemTitle">{{item2.title}}</view>
- </view>
- </view>
- </view>
- </view>
- <!-- 下拉菜单 -->
- <view class="sift" v-show="showSift" @click="goHide()">
- <view class="siftItemBg">
- <view v-for="(item,index) in siftData" :key="index" class="siftItem">
- <view @click="goTopTab(item)">{{item.name}}</view>
- </view>
- </view>
- </view>
- <view class="gotop" @click="gotoTop">
- <image src="../../static/pcimg/btn_top@2x.png" mode="" class="gotopImg"></image>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- bannerArr: [],
- scrollTop: 0,
- old: {
- scrollTop: 0
- },
- itemArr: [],
- showSift: false,
- siftData: [],
- type: '',
- }
- },
- onLoad(opt) {
- this.getDetailData()
- this.getSiftData()
- this.type = opt.type
-
- if (this.type) {
- uni.setStorage({
- key: 'userType',
- data: this.type,
- success: function() {
-
- }
- });
- }
- },
- methods: {
- back() {
- console.log('type', this.type);
- if (this.type == "app") {
- var standalone = window.navigator.standalone
- var userAgent = window.navigator.userAgent.toLowerCase()
- var safari = /safari/.test(userAgent)
- var ios = /iphone|ipod|ipad|mac/.test(userAgent)
- var android = /android/.test(userAgent)
- if (ios) {
- if (true) { //!standalone&& !safari
- window.webkit.messageHandlers.goMyNav.postMessage(null)
- }
- } else if (android) {
- window.android.postMessage()
- }
- } else {
- uni.navigateBack({
- })
- }
- },
- gotoTop() {
- uni.pageScrollTo({
- scrollTop: 0,
- duration: 300
- });
- },
- goHide() {
- this.showSift = false
- },
- goDetail(item) {
- uni.navigateTo({
- url: 'detail?id=' + item.id
- })
- },
- goTuijianTab(item) {
- uni.navigateTo({
- url: 'topTab?topCode=' + item.categoryCode + '&comment=' + item.comment + '&topName=' + item
- .categoryName
- })
- },
- goList(item) {
- // 1分类2文章
- if (item.type == 1) {
- uni.navigateTo({
- url: 'list?topCode=' + item.code + '&comment=' + item.comment + '&topName=' + item.name
- })
- }
- if (item.type == 2) {
- uni.navigateTo({
- url: 'detail?id=' + item.id
- })
- }
- },
- goTopTab(item) {
- this.showSift = false
- uni.navigateTo({
- url: 'topTab?topCode=' + item.code + '&comment=' + item.comment + '&topName=' + item.name
- })
- },
- goSift() {
- this.showSift = !this.showSift
- },
- goSearch() {
- uni.navigateTo({
- url: 'search'
- })
- },
- scroll: function(e) {
- console.log(e)
- this.old.scrollTop = e.detail.scrollTop
- },
- goNav(urlStr) {
- uni.navigateTo({
- url: urlStr
- })
- },
- getDetailData() {
- uni.showLoading({
- title: '加载中'
- })
- let url = '/trainingOpenApiV2/indexData',
- params = {
- }
- this.$http(url, params, 'GET').then(res => {
- uni.hideLoading();
- var data = res.data
- // 处理 undefined和null转为空白字符串
- for (const key in data) {
- data[key] = this.$praseStrEmpty(data[key])
- }
- this.detailData = data
- this.bannerArr = this.detailData.recommendList
- this.itemArr = this.detailData.categoryList
- })
- },
- getSiftData() {
- uni.showLoading({
- title: '加载中'
- })
- let url = '/trainingOpenApiV2/allCategory',
- params = {
- }
- this.$http(url, params, 'GET').then(res => {
- uni.hideLoading();
- var data = res.data
- // 处理 undefined和null转为空白字符串
- for (const key in data) {
- data[key] = this.$praseStrEmpty(data[key])
- }
- this.siftData = data
- })
- },
- // 下拉刷新 上拉加载更多
- onPullDownRefresh() {
- // this.page = 1;
- // this.getItemData()
- this.getDetailData()
- setTimeout(function() {
- uni.stopPullDownRefresh();
- }, 1000);
- },
- // onReachBottom() {
- // this.page++;
- // this.getItemData()
- // },
- }
- }
- </script>
- <style scoped>
- .content {
- min-height: 100vh;
- background-color: #f4f5f7;
- padding-top: 88rpx;
- padding-bottom: 20rpx;
- }
- .nav {
- position: fixed;
- left: 0;
- top: 0;
- width: 100vw;
- height: 88rpx;
- background-color: #FFFFFF;
- display: flex;
- justify-content: space-between;
- align-items: center;
- z-index: 999;
- border-bottom: #eeeeee 2rpx solid;
- }
- .navTitle {
- font-size: 36rpx;
- font-weight: bold;
- color: #3c3c3c;
- }
- .leftView {
- width: 30%;
- }
- .rightView {
- width: 30%;
- display: flex;
- justify-content: flex-end;
- padding-right: 24rpx;
- }
- .rightImg {
- width: 40rpx;
- height: 40rpx;
- }
- .commend {
- background-color: #FFFFFF;
- margin: 20rpx 0;
- padding: 30rpx 25rpx;
- }
- .top {
- padding-bottom: 24rpx;
- }
- .tuijian {
- font-size: 32rpx;
- font-weight: bold;
- color: #3c3c3c;
- margin-left: 10rpx;
- }
- .scrollBg {
- background-color: #FFFFFF;
- }
- .scroll-view {
- white-space: nowrap;
- }
- .itemBg {
- display: flex;
- }
- .item {
- width: 398rpx;
- margin-right: 25rpx;
- }
- .swpImg {
- border-radius: 10rpx;
- width: 398rpx;
- height: 224rpx;
- }
- .title {
- font-size: 28rpx;
- color: #3c3c3c;
- /* 隐藏文字显示 ...不换行 */
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- margin: 14rpx 0;
- }
- .itemTitle {
- font-size: 28rpx;
- color: #3c3c3c;
- /* 隐藏文字显示 ...不换行 */
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- margin-top: 14rpx;
- }
- .title2 {
- background: rgba(63, 144, 247, 0.1);
- font-size: 22rpx;
- color: #3F90F7;
- height: 36rpx;
- line-height: 36rpx;
- border-radius: 18rpx;
- padding: 3rpx 14rpx;
- min-width: 0;
- max-width: 138rpx;
- margin-bottom: 10rpx;
- text-align: center;
- /* 隐藏文字显示 ...不换行 */
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .fenleiBg {
- background-color: #FFFFFF;
- margin: 20rpx 0;
- padding: 30rpx 25rpx;
- }
- .fenTop {
- padding-bottom: 24rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .fenTopNo {
- padding-bottom: 0;
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .leftTop {
- display: flex;
- align-items: center;
- }
- .allBtn {
- font-size: 24rpx;
- color: #999999;
- }
- .sum {
- font-size: 24rpx;
- color: #999999;
- margin-left: 16rpx;
- }
- .twoItem {
- width: 339rpx;
- margin-right: 25rpx;
- }
- .img2 {
- width: 339rpx;
- height: 191rpx;
- border-radius: 10rpx;
- border: #EEEEEE 2rpx solid;
- }
- .sift {
- position: fixed;
- left: 0;
- top: 88rpx;
- width: 100vw;
- min-height: 100vh;
- background-color: rgba(0, 0, 0, 0.4);
- }
- .siftItemBg {
- background-color: #FFFFFF;
- width: 100%;
- height: 500rpx;
- overflow-y: scroll;
- }
- .siftItem {
- background-color: #FFFFFF;
- color: #333333;
- font-size: 30rpx;
- text-align: center;
- padding: 30rpx 0;
- }
- .gotopImg {
- width: 100rpx;
- height: 100rpx;
- }
- .gotop {
- position: fixed;
- right: 15rpx;
- bottom: 100rpx;
- cursor: pointer;
- }
- </style>
|