| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- <template>
- <view>
- <view :class="'Tabbar savepadding '+(about.greyTheme==1?' grayTheme':'')">
- <view v-for="(item, index) in list" :key="index" class="tab-item" @tap="goUrl(item.click)">
- <image class="nav_icon11 image" :src="channel===item.channel ?item.selectedIconPath:item.iconPath">
- </image>
- <view :class="channel===item.channel?'active':''">{{item.text}}<text class="dots" style="width: 20rpx;height: 20rpx;min-width: 20rpx;right: 30%;top: 18rpx;"
- v-if="count > 0&&item.channel==='found'"></text></view>
-
- </view>
- </view>
- <view class="savepadding" style="height:115rpx"></view>
- </view>
- </template>
- <script>
- const app = getApp();
- const req = require("../../utils/request.js");
- const utils = require("../../utils/util.js");
- import foot from "./index";
- export default {
- data() {
- return {
- bottomBlankHeignt: app.globalData.isIPhoneX ? 68 : 0,
- iconSrc: req.public.iconSrc,
- about: {},
- list: [],
- count: ""
- };
- },
- components: {
- foot
- },
- props: {
- channel: {
- type: String,
- default: 'home'
- },
- isUpdate: {
- type: Boolean,
- default: false
- },
- productType: {
- type: Number,
- default: 0
- }
- },
- watch: {
- "isUpdate": function(isUpdate) {
- // console.log('需要更新消息', isUpdate);
- if (!this.isReady) return;
- this.getCount();
- }
- },
- created() {
- uni.$on('updataTab',()=>{
- this.getCount()
- })
- },
- async mounted() {
- // console.log('ready');
- this.about = await req.getsysConfig()
- this.isReady = true;
- this.getCount();
- this.getTab();
- },
- methods: {
- getCount() {
- // console.log(this.productType);
- let from = {};
- if (this.productType == 2) {
- from.purchaseType = 2;
- } else {
- from.purchaseType = 1;
- }
-
- // req.getRequest('/api/purchase/count', from, res => {
- // this.setData({
- // count: res
- // });
- // });
-
- req.getRequest('/api/content/category/list', {
- parentCode: req.public.fxCode
- }, res => {
- console.log('sss',res)
- this.count = 0
- if(res&&res.length>0){
- res.map(item=>{
- let s = req.getStorage('readFindCode')
- let readObj = {
- date:utils.formatTime(new Date()).t2,
- readCode:(s && s.date == utils.formatTime(new Date()).t2)?s.readCode:{}
- }
- if(readObj.readCode[item.code]){
-
- }else{
- this.count = this.count + item.addToday
- }
- console.log(this.count)
- })
- }
- })
- },
- // 获取tab导航
- getTab() {
- // console.log(req.tab); // 过滤关闭的tab
- let data = req.tab.filter(it => it.show == true); // 排序更换位置
- // console.log(data.sort(this.compare('index')))
- this.setData({
- list: data.sort(this.compare('index'))
- }); // console.log(data.sort(this.compare('index')))
- },
- // 排序
- compare(property) {
- return function(a, b) {
- var value1 = a[property];
- var value2 = b[property];
- return value1 - value2;
- };
- },
- /**
- * 跳转
- */
- goUrl: function(e) {
- // console.log(e)
- if (e == "goShop") {
- this.goShop()
- }
- if (e == "goHome") {
- this.goHome()
- }
- if (e == "goSort") {
- this.goSort()
- }
- if (e == "goInteractive") {
- this.goInteractive()
- }
- if (e == "goLive") {
- this.goLive()
- }
- if (e == "goCart") {
- this.goCart()
- }
- if (e == "goUser") {
- this.goUser()
- }
- if (e == "goMatch") {
- this.goMatch()
- }
- if (e == "goFound"){
- this.goFound()
- }
- },
- goHome: function() {
- if (this.channel === "home") return;
- app.globalData.switchTab('pages/index/index');
- },
- goSort: function() {
- if (this.channel === "sort") return;
- app.globalData.switchTab('pages/sort/sort');
- },
- goInteractive: function() {
- if (this.channel === "interactive") return;
- app.globalData.switchTab('pages/interactive/index');
- },
- goLive: function() {
- if (this.channel === "live") return;
- app.globalData.switchTab('pages/live/live');
- },
- goCart: function() {
- if (this.channel === "cart") return;
- app.globalData.switchTab('pages/cart/cart');
- },
- goUser: function() {
- if (this.channel === "user") return;
- app.globalData.switchTab('pages/user/user');
- },
- goShop: function() {
- if (this.channel === "shop") return;
- app.globalData.switchTab('pages/timelyDelivery/index');
- },
- goMatch: function() {
- if (this.channel === "match") return;
- app.globalData.switchTab('pages/matchList/index');
- },
- goFound: function() {
- if (this.channel === "found") return;
- app.globalData.switchTab('pages/found/found');
- }
- }
- };
- </script>
- <style>
- @import "./index.css";
- </style>
|