Просмотр исходного кода

【底部导航栏和消息推送冲突问题】

release
GL 4 лет назад
Родитель
Сommit
c385c706f3
10 измененных файлов: 124 добавлений и 331 удалений
  1. +2
    -18
      app.js
  2. +35
    -59
      custom-tab-bar/index.js
  3. +7
    -7
      custom-tab-bar/index.wxml
  4. +3
    -2
      custom-tab-bar/index.wxss
  5. +6
    -10
      ext.json
  6. +34
    -102
      index/index.js
  7. +16
    -129
      index/user.js
  8. +5
    -3
      pages/getphoneInfo/index.js
  9. +1
    -1
      pages/getuserinfo/index.js
  10. +15
    -0
      pages/specialcourtesy/specialcourtesy.js

+ 2
- 18
app.js Просмотреть файл

@@ -5,24 +5,8 @@ App({
data: {
newArr:[],//存放分享二维进入消息信息
},
// 这里这么写,是要在其他界面监听,而不是在app.js中监听,而且这个监听方法,需要一个回调方法。
watch: function (method) {
var obj = this.globalData;
Object.defineProperty(obj, "ifShowTab", {
configurable: true,
enumerable: true,
set: function (value) {
this._ifShowTab = value;
console.log('是否会被执行2')
method(value);
},
get: function () {
// 可以在这里打印一些东西,然后在其他界面调用getApp().globalData.name的时候,这里就会执行。
return this._ifShowTab
}
})
},
onLaunch: function(options) {
wx.hideTabBar()
var that = this;
if (that.globalData.previewFlag) {//解决微信图片预览重复进入app.js onshow
that.globalData.previewFlag = false
@@ -160,6 +144,7 @@ App({
})
}
},
/**
* 下载小程序新版本并重启应用
*/
@@ -182,7 +167,6 @@ App({
},
globalData: {
styleLsit:{},
ifShowTab: true,
previewFlag:false,//解决图片预览调用noshow
activityId:'',//活动id方便授权数据回传
typeLsit: [],//初始哈样式


+ 35
- 59
custom-tab-bar/index.js Просмотреть файл

@@ -100,8 +100,6 @@ Component({
console.log(data.index)
const url = data.path;
if (data.index == 0 || data.index == 3) {
console.log("ifShowTab = false")
app.globalData.ifShowTab = false
this.getTemplateId()
}
@@ -123,63 +121,42 @@ Component({
} = res
if (code == 200) {
app.globalData.styleLsit = data
this.setData({
list: [{
"pagePath": "/index/index",
"iconPath": `${data.t_in.icon}`,
"selectedIconPath": `${data.t_in_std.icon}`,
"text": "首页"
},
{
"pagePath": "/index/searchbar",
"iconPath": `${data.t_md.icon}`,
"selectedIconPath": `${data.t_md_std.icon}`,
"text": "门店"
},
{
"pagePath": "/index/passCar",
"iconPath": `${data.t_tc.icon}`,
"selectedIconPath": `${data.t_tc_std.icon}`,
"text": "停车"
},
{
"pagePath": "/index/user",
"iconPath": `${data.t_uc.icon}`,
"selectedIconPath": `${data.t_uc_std.icon}`,
"text": "我的"
}
],
selectedColor: `${data.t_uc_std.styleClass}`,
home_a_img: [{
"pagePath": "/index/index",
"iconPath": `${data.t_in.icon}`,
"selectedIconPath": `${data.t_in_std.icon}`,
"text": "首页"
},
{
"pagePath": "/index/searchbar",
"iconPath": `${data.t_md.icon}`,
"selectedIconPath": `${data.t_md_std.icon}`,
"text": "门店"
},
{
"pagePath": "/index/passCar",
"iconPath": `${data.t_tc.icon}`,
"selectedIconPath": `${data.t_tc_std.icon}`,
"text": "停车"
},
{
"pagePath": "/index/user",
"iconPath": `${data.t_uc.icon}`,
"selectedIconPath": `${data.t_uc_std.icon}`,
"text": "我的"
}
],
})
this.setTabStyle()
}
// console.log(this.data.list[0].selectedIconPath, '99999999999999999999999999999999999999999')
})
},
// 初始换底部导航栏
setTabStyle: function () {
this.getTabBar().setData({
selectedColor: `${app.globalData.styleLsit.t_in_std.styleClass}`,
list: [{
"pagePath": "/index/index",
"iconPath": `${app.globalData.styleLsit.t_in.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_in_std.icon}`,
"text": "首页"
},
{
"pagePath": "/index/searchbar",
"iconPath": `${app.globalData.styleLsit.t_md.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_md_std.icon}`,
"text": "门店"
},
{
"pagePath": "/index/passCar",
"iconPath": `${app.globalData.styleLsit.t_tc.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_tc_std.icon}`,
"text": "停车"
},
{
"pagePath": "/index/user",
"iconPath": `${app.globalData.styleLsit.t_uc.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_uc_std.icon}`,
"text": "我的"
}
],
})
},
getTemplateId() {
// console.log("隐藏")
@@ -210,7 +187,6 @@ Component({
this.data.templateId.map(res => {
tmplIds.push(res.templateId)
})
// console.log(tmplIds[0], "?|?|?|", this.data.templateId)
wx.requestSubscribeMessage({
tmplIds: tmplIds,
success(res) {
@@ -225,7 +201,7 @@ Component({
Http.post({
url: config.api.wxMsg
}).then(res => {
app.globalData.ifShowTab = true
wx.setStorageSync({
key: 'ifShowTab',
data: true,
@@ -234,7 +210,7 @@ Component({
})
return
}
app.globalData.ifShowTab = true
// for (let i = 0; i < tmplIds.length;i++){
// if (res.tmplIds[i] == 'accept'){
@@ -243,7 +219,7 @@ Component({
// }
},
complete(){
app.globalData.ifShowTab = true
}
})
},


+ 7
- 7
custom-tab-bar/index.wxml Просмотреть файл

@@ -1,8 +1,8 @@
<!--miniprogram/custom-tab-bar/index.wxml-->
<cover-view class="tab-bar" wx:if="{{list.length!=0}}">
<cover-view class="tab-bar-border"></cover-view>
<cover-view wx:for="{{list}}" wx:key="index" class="tab-bar-item" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab">
<cover-image src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></cover-image>
<cover-view style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</cover-view>
</cover-view>
</cover-view>
<view class="tab-bar" wx:if="{{list.length!=0}}">
<view class="tab-bar-border"></view>
<view wx:for="{{list}}" wx:key="index" class="tab-bar-item" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab">
<image src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></image>
<view style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</view>
</view>
</view>

+ 3
- 2
custom-tab-bar/index.wxss Просмотреть файл

@@ -8,6 +8,7 @@
background: white;
display: flex;
padding-bottom: env(safe-area-inset-bottom);
overflow: hidden;
}

.tab-bar-border {
@@ -29,11 +30,11 @@
flex-direction: column;
}

.tab-bar-item cover-image {
.tab-bar-item image {
width: 46rpx;
height: 46rpx;
}

.tab-bar-item cover-view {
.tab-bar-item view {
font-size: 20rpx;
}

+ 6
- 10
ext.json Просмотреть файл

@@ -1,13 +1,6 @@
{
"ext": {
"attr": {
"car": {
"etcp": {
"etcpAppId": "wx192b7d2e8dcbefd0",
"etcpVersion": "release",
"etcpCallbackUrl": "https://admintest.malls.iformall.com/api/carCallback/etcpPaidCallback"
}
},
"imgProxy": [
{
"newUrl": "https://ctest.malls.iformall.com/img",
@@ -23,11 +16,14 @@
}
],
"configUrl": "https://ctest.malls.iformall.com/C/api",
"etcpAppId": "wx9f3a77763caa7c89",
"etcpVersion": "release",
"etcpCallbackUrl": "https://admintest.malls.iformall.com/api/carCallback/etcpPaidCallback",
"ifHaveWebSocket": "0",
"ifHaveCarModular": "1"
},
"name": "金泸商务",
"weappId": "wx649b3be73c1afe47",
"name": "富茂望京测试版",
"weappId": "wx9f3a77763caa7c89",
"appVersion": "C.test.5.2.0"
},
"debug": false,
@@ -73,7 +69,7 @@
"provider": "wx2b03c6e691cd7370"
}
},
"extAppid": "wx649b3be73c1afe47",
"extAppid": "wx9f3a77763caa7c89",
"extEnable": true,
"permission": {
"scope.userLocation": {


+ 34
- 102
index/index.js Просмотреть файл

@@ -259,7 +259,6 @@ Page({
* 生命周期函数--监听页面初次渲染完成
*/
onLoad: function(options) {
console.log("我只执行一次")
this.getType()
this.getLocation();
let that = this;
@@ -320,110 +319,43 @@ Page({
onUnload() {
// wx.removeStorageSync('squareList')
},
watchBack: function (ifShowTab) { //监听ifShowTab变化
if (ifShowTab){
this.getTabBar().setData({
list: [{
"pagePath": "/index/index",
"iconPath": `${app.globalData.styleLsit.t_in.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_in_std.icon}`,
"text": "首页"
},
{
"pagePath": "/index/searchbar",
"iconPath": `${app.globalData.styleLsit.t_md.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_md_std.icon}`,
"text": "门店"
},
{
"pagePath": "/index/passCar",
"iconPath": `${app.globalData.styleLsit.t_tc.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_tc_std.icon}`,
"text": "停车"
},
{
"pagePath": "/index/user",
"iconPath": `${app.globalData.styleLsit.t_uc.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_uc_std.icon}`,
"text": "我的"
}
],
})
}else{
console.log("我隐藏了")
this.getTabBar().setData({
list:[]
})
}
// 初始换底部导航栏
setTabStyle: function () {
this.getTabBar().setData({
selectedColor: `${app.globalData.styleLsit.t_in_std.styleClass}`,
list: [{
"pagePath": "/index/index",
"iconPath": `${app.globalData.styleLsit.t_in.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_in_std.icon}`,
"text": "首页"
},
{
"pagePath": "/index/searchbar",
"iconPath": `${app.globalData.styleLsit.t_md.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_md_std.icon}`,
"text": "门店"
},
{
"pagePath": "/index/passCar",
"iconPath": `${app.globalData.styleLsit.t_tc.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_tc_std.icon}`,
"text": "停车"
},
{
"pagePath": "/index/user",
"iconPath": `${app.globalData.styleLsit.t_uc.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_uc_std.icon}`,
"text": "我的"
}
],
})
},

onShow: function() {
if (app.globalData.ifShowTab){
this.getTabBar().setData({
list: [{
"pagePath": "/index/index",
"iconPath": `${app.globalData.styleLsit.t_in.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_in_std.icon}`,
"text": "首页"
},
{
"pagePath": "/index/searchbar",
"iconPath": `${app.globalData.styleLsit.t_md.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_md_std.icon}`,
"text": "门店"
},
{
"pagePath": "/index/passCar",
"iconPath": `${app.globalData.styleLsit.t_tc.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_tc_std.icon}`,
"text": "停车"
},
{
"pagePath": "/index/user",
"iconPath": `${app.globalData.styleLsit.t_uc.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_uc_std.icon}`,
"text": "我的"
}
],
})
} else {
console.log("我隐藏")
this.getTabBar().setData({
list: []
})
}
if (wx.getStorageSync("tabFlag") && wx.getStorageSync("tabFlag")==1){//处理授权取消后回到首页底部导航栏显示
this.getTabBar().setData({
list: [{
"pagePath": "/index/index",
"iconPath": `${app.globalData.styleLsit.t_in.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_in_std.icon}`,
"text": "首页"
},
{
"pagePath": "/index/searchbar",
"iconPath": `${app.globalData.styleLsit.t_md.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_md_std.icon}`,
"text": "门店"
},
{
"pagePath": "/index/passCar",
"iconPath": `${app.globalData.styleLsit.t_tc.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_tc_std.icon}`,
"text": "停车"
},
{
"pagePath": "/index/user",
"iconPath": `${app.globalData.styleLsit.t_uc.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_uc_std.icon}`,
"text": "我的"
}
],
})
wx.removeStorageSync("tabFlag")
if(JSON.stringify(app.globalData.styleLsit)!="{}"){
this.setTabStyle()
}
console.log("我每次都执行" ,app.globalData.ifShowTab)
app.watch(this.watchBack)
this.ifShowSqare();
if (wx.getStorageSync("squareList")) {
var temp = wx.getStorageSync("squareList").filter(item => item.tenantId == wx.getStorageSync("selectedMall"))[0].name


+ 16
- 129
index/user.js Просмотреть файл

@@ -79,7 +79,20 @@ Page({
url: `/pages/getphoneInfo/index?path=main`
});
},

//是否授权手机号
ifPhoneInfo() {
let that = this;
Http.get({
url: config.api.checkPhoneStatus,
data: {}
}).then(res => {
return
}).catch(err => {
wx.navigateTo({
url: `/pages/getphoneInfo/index?mineFlag=mine`,
})
})
},
/* 判断是否授权*/
userAuthorization() {
Http.get({
@@ -88,7 +101,7 @@ Page({
token: app.globalData.token
}
}).then(res => {
// this.getUserInfo()
this.ifPhoneInfo()
}).catch(err => {
wx.navigateTo({
url: `/pages/getuserinfo/index`,
@@ -128,67 +141,7 @@ Page({
gotoedit: function() {
this.checkUserStatus();
},
watchBack: function (ifShowTab) { //监听ifShowTab变化
console.log("ifShowTab",ifShowTab)
if (ifShowTab) {
console.log("ifShowTab", ifShowTab)
this.getTabBar().setData({
list: [{
"pagePath": "/index/index",
"iconPath": `${app.globalData.styleLsit.t_in.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_in_std.icon}`,
"text": "首页"
},
{
"pagePath": "/index/searchbar",
"iconPath": `${app.globalData.styleLsit.t_md.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_md_std.icon}`,
"text": "门店"
},
{
"pagePath": "/index/passCar",
"iconPath": `${app.globalData.styleLsit.t_tc.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_tc_std.icon}`,
"text": "停车"
},
{
"pagePath": "/index/user",
"iconPath": `${app.globalData.styleLsit.t_uc.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_uc_std.icon}`,
"text": "我的"
}
],
})
} else {
console.log("我隐藏")
this.getTabBar().setData({
list: []
})
}
},
onLoad() {
if (typeof this.getTabBar === 'function' &&
this.getTabBar()) {
if (ifStoreApp == 1) {
this.getTabBar().setData({
selected: 1
})
} else if (ifStoreApp == 2) {
this.getTabBar().setData({
selected: 2
})
} else {
this.getTabBar().setData({
selected: 3,
list: []
})
}

}



this.getLocation();
this.updateScene();
// this.getRoomId();
@@ -263,42 +216,6 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function() {
console.log(app.globalData.ifShowTab,"////")
if (app.globalData.ifShowTab){
this.getTabBar().setData({
list: [{
"pagePath": "/index/index",
"iconPath": `${app.globalData.styleLsit.t_in.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_in_std.icon}`,
"text": "首页"
},
{
"pagePath": "/index/searchbar",
"iconPath": `${app.globalData.styleLsit.t_md.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_md_std.icon}`,
"text": "门店"
},
{
"pagePath": "/index/passCar",
"iconPath": `${app.globalData.styleLsit.t_tc.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_tc_std.icon}`,
"text": "停车"
},
{
"pagePath": "/index/user",
"iconPath": `${app.globalData.styleLsit.t_uc.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_uc_std.icon}`,
"text": "我的"
}
],
})
} else {
console.log("我隐藏")
this.getTabBar().setData({
list: []
})
}
app.watch(this.watchBack)
let that = this;
that.userAuthorization()
if (typeof that.getTabBar === 'function' &&
@@ -314,40 +231,10 @@ Page({
} else {
that.getTabBar().setData({
selected: 3,
})
}
}
if (wx.getStorageSync("tabFlag") && wx.getStorageSync("tabFlag") == 1) {//处理授权取消后回到首页底部导航栏显示
this.getTabBar().setData({
list: [{
"pagePath": "/index/index",
"iconPath": `${app.globalData.styleLsit.t_in.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_in_std.icon}`,
"text": "首页"
},
{
"pagePath": "/index/searchbar",
"iconPath": `${app.globalData.styleLsit.t_md.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_md_std.icon}`,
"text": "门店"
},
{
"pagePath": "/index/passCar",
"iconPath": `${app.globalData.styleLsit.t_tc.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_tc_std.icon}`,
"text": "停车"
},
{
"pagePath": "/index/user",
"iconPath": `${app.globalData.styleLsit.t_uc.icon}`,
"selectedIconPath": `${app.globalData.styleLsit.t_uc_std.icon}`,
"text": "我的"
}
],
})
wx.removeStorageSync("tabFlag")
}

that.setData({
appVersion: extConfig.appVersion,
})


+ 5
- 3
pages/getphoneInfo/index.js Просмотреть файл

@@ -67,13 +67,11 @@ Page({
})
},
backHome: function() {
wx.setStorageSync("tabFlag", 1)
wx.switchTab({
url: '/index/index',
})
},
getPhoneNumber: function(e) {
wx.setStorageSync("tabFlag", 1)
var that = this;
var iv = e.detail.iv;
var encryptedData = e.detail.encryptedData;
@@ -166,7 +164,11 @@ Page({
wx.switchTab({
url: '/index/user'
});
} else {
} else if (that.data.mineFlag == 'index'){
wx.switchTab({
url: '/index/index'
});
}else {
wx.showToast({
title: res.data.msg,


+ 1
- 1
pages/getuserinfo/index.js Просмотреть файл

@@ -136,7 +136,7 @@ Page({
})
},
backHome: function() {
wx.setStorageSync("tabFlag", 1)
wx.switchTab({
url: '/index/index',
})


+ 15
- 0
pages/specialcourtesy/specialcourtesy.js Просмотреть файл

@@ -22,10 +22,25 @@ Page({
phoneNumber: e.currentTarget.dataset.merchantlinkphone
});
},
//是否授权手机号
ifPhoneInfo() {
let that = this;
Http.get({
url: config.api.checkPhoneStatus,
data: {}
}).then(res => {
return
}).catch(err => {
wx.navigateTo({
url: `/pages/getphoneInfo/index?mineFlag=index`,
})
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.ifPhoneInfo()
let that = this;
console.log("渲染开始")
Http.get({


Загрузка…
Отмена
Сохранить