Commit e325defe by 赵雅纹

Merge branch 'dev_7.1.0' into fixbug-ZYW

parents f422f9cc ddc0b8c2
......@@ -2,6 +2,7 @@
var app = getApp()
const wxService = require('../../utils/wxService')
const utils = require('../../utils/util')
const utilLink = require('../../utils/currentLinkRouter')
const envInfo = require('../../config/index').envInfo
Component({
......@@ -9,11 +10,11 @@ Component({
* 组件的属性列表
*/
properties: {
currentHasUserInfo:{
currentHasUserInfo: {
type: Boolean,
type: false
},
tabBar:{
tabBar: {
type: Object,
value: null
},
......@@ -33,12 +34,11 @@ Component({
// 存在 row 处理数据 8 商品 9 分类
let newRow = null
if (item.link) {
if(item.link.type == 2){
if (item.link.type == 2) {
// 父组件 更新
const urls = getCurrentPages()
const currentPath = urls[0]
const pageId = item.link.url
console.log('currentPath', currentPath.route,item.link.url)
item.link.newPath = `/${currentPath.route}`
}
return
......@@ -51,13 +51,22 @@ Component({
} else {
newRow.newPath = ''
}
// item.row = JSON.stringify(newRow)
item.row = newRow
}
})
this.setData({ tabBar }, () => {
// 当前匹配路径是否需要授权 true 需要 false 不需要
tabBar.images.forEach(item => {
let checkUrl = ''
if (item.link) {
checkUrl = item.link.newPath ? item.link.newPath : item.link.url
} else if (item.row) {
checkUrl = item.row.newPath ? item.row.newPath : item.row.url
}
wxService.NoLoginPage(checkUrl).then(res => {
item.needAuth = res.needAuth
this.setData({ tabBarList: tabBar.images })
})
})
},
ready() {
......@@ -70,9 +79,9 @@ Component({
*/
data: {
currentRoute: '',
tabs: [],
type: 1,
baseImgUrl: ''
baseImgUrl: '',
tabBarList: []
},
/**
* 组件的方法列表
......@@ -81,64 +90,8 @@ Component({
_getUserInfo(res = {}) {
this.triggerEvent('getAuth', res);
},
handelToPage(event){
const ev = event.currentTarget.dataset;
let curItemType = ev.item
const userInfo = wx.getStorageSync('_baseUserInfo')
// link row
if (curItemType.link) {
let currentClickType = app.globalData.commonFunc.getLink(curItemType.link.type, curItemType)
if (curItemType.link.type == 1) {
// 触发父组件更新页面 外部小程序
} else if (curItemType.link.type == 2) {
// 触发父组件更新页面
wxService.nextTick(() => {
this.triggerEvent('updatePage', { pageId: currentClickType.url })
})
} else if (curItemType.link.type == 3) {
// 预览
wx.previewImage({
current: `${app.globalData.imageUrl}/${currentClickType.imageUrl}`, // 当前显示图片的http链接
urls: [`${app.globalData.imageUrl}/${currentClickType.link.url}`] // 需要预览的图片http链接列表
})
} else if (curItemType.link.type == 4) {
wxService.router(`${currentClickType}`)
} else if (curItemType.link.type == 5) {
if (currentClickType == 1) {
wxService.openCard()
} else if (currentClickType == 2) {
wxService.openCard()
}
} else if (curItemType.link.type == 6) {
wxService.router(`${currentClickType}`)
} else if (curItemType.link.type == 7) {
// 集点详情
wxService.router(`${currentClickType}`)
}
} else if (curItemType.row) {
// let rowObj = JSON.parse(curItemType.row)
let rowObj = curItemType.row
let currentClickRow = app.globalData.commonFunc.getLinkRow(rowObj.type, rowObj)
if (rowObj.type == 1) { }
else if (rowObj.type == 2) { }
else if (rowObj.type == 3) { }
else if (rowObj.type == 4) { }
else if (rowObj.type == 5) { }
else if (rowObj.type == 6) { }
else if (rowObj.type == 7) { }
else if (rowObj.type == 8) {
// 商品
wxService.router(`/pages/productDetail/productDetail?id=${currentClickRow}`)
}
else if (rowObj.type == 9) {
// 分类
wxService.router(`/subPackage/page/pages/categoryPro/categoryPro?${currentClickRow}`)
}
}
handelToPage(event) {
utilLink.currentLinkRouter(event)
}
}
})
......@@ -2,11 +2,10 @@
<wxs src="../../wxs/utils.wxs" module="utils" />
<!--<wxs src="./handlerData.wxs" module="tools" />-->
<view class='bgc fixed-bottom0' style="background-image:url({{tabBar.num == 4 ? '': '/assets/imgs/7_1_0/bg.png'}});" wx:if="{{tabBar.num == 4}}">
<block wx:for="{{tabBar.images}}" wx:key="{{index}}" wx:for-item="tab">
<block wx:for="{{tabBarList}}" wx:key="{{index}}" wx:for-item="tab">
<view class="tab">
<!--当前页面需要授权 且未授权-->
<!--<view wx:if="{{utils.hanlerLinkNeedAuth(tab.link.url)}}" class="btn-tab">-->
<view wx:if="{{tab.link ? utils.hanlerLinkNeedAuth(typeOf(tab.link.newPath) != undefined ? tab.link.newPath : tab.link.url) : utils.hanlerLinkNeedAuth(tab.row.newPath ? tab.row.newPath : tab.row.url)}}" class="btn-tab">
<view wx:if="{{tab.needAuth}}" class="btn-tab">
<view wx:if="{{!currentHasUserInfo}}" class="btn-tab">
<button
bindgetuserinfo="_getUserInfo"
......@@ -44,7 +43,7 @@
</block>
</view>
<view class="bottom-tab fixed-bottom0" wx:if="{{tabBar.num == 5}}">
<block wx:for="{{tabs}}" wx:key="{{index}}" wx:for-item="tab">
<block wx:for="{{tabBarList}}" wx:key="{{index}}" wx:for-item="tab">
<view class="tab" data-item="{{tab}}" bindtap="handelToPage">
<!--当前页面需要授权 且未授权-->
<view wx:if="{{utils.hanlerLinkNeedAuth(tab.link.url)}}" class="btn-tab">
......
......@@ -3,6 +3,7 @@
var app = getApp()
const wxService = require('../../utils/wxService')
const utils = require('../../utils/util')
const utilLink = require('../../utils/currentLinkRouter')
const envInfo = require('../../config/index').envInfo
Component({
......@@ -37,7 +38,7 @@ Component({
imageHeights: {}, // 记录所有图片的实际高度
},
observers: {
heights: function(heights) {
heights: function (heights) {
let imageData = this.data.imageData
if (heights.length === imageData.length) {
let maxHeight = Math.max.apply(null, heights)
......@@ -58,7 +59,7 @@ Component({
* 组件的方法列表
*/
methods: {
imageLoad: function(e) {
imageLoad: function (e) {
// 图片加载完成回调
let heights = this.data.heights
let id = e.target.id
......@@ -77,74 +78,7 @@ Component({
})
},
preview(event) {
const ev = event.currentTarget.dataset;
let curItemType = ev.item
// 获取当前帐号信息
const userInfo = wx.getStorageSync('_baseUserInfo')
// link row
if (curItemType.link) {
let currentClickType = app.globalData.commonFunc.getLink(curItemType.link.type, curItemType)
if (curItemType.link.type == 1) {
// 触发父组件更新页面 外部小程序
this.setData({
isAuthorization: false
})
return false
} else if (!userInfo) {
this.setData({
isAuthorization: true
})
return false
} else if (userInfo && userInfo.member && !userInfo.member.mobile) {
wxService.openCard()
return false
}
if (curItemType.link.type == 2) {
// 触发父组件更新页面
wxService.nextTick(() => {
this.triggerEvent('updatePage', { pageId: currentClickType.url })
})
} else if (curItemType.link.type == 3) {
// 预览
wx.previewImage({
current: `${app.globalData.imageUrl}/${currentClickType.imageUrl}`, // 当前显示图片的http链接
urls: [`${app.globalData.imageUrl}/${currentClickType.link.url}`] // 需要预览的图片http链接列表
})
} else if (curItemType.link.type == 4) {
wxService.router(`${currentClickType}`)
} else if (curItemType.link.type == 5) {
if (currentClickType == 1) {
wxService.openCard()
} else if (currentClickType == 2) {
wxService.openCard()
}
} else if (curItemType.link.type == 6) {
wxService.router(`/${currentClickType}`)
} else if (curItemType.link.type == 7) {
// 集点详情
wxService.router(`${currentClickType}`)
}
} else if (curItemType.row) {
let rowObj = JSON.parse(curItemType.row)
let currentClickRow = app.globalData.commonFunc.getLinkRow(rowObj.type, rowObj)
if (rowObj.type == 1) { }
else if (rowObj.type == 2) { }
else if (rowObj.type == 3) { }
else if (rowObj.type == 4) { }
else if (rowObj.type == 5) { }
else if (rowObj.type == 6) { }
else if (rowObj.type == 7) { }
else if (rowObj.type == 8) {
// 商品
wxService.router(`/pages/productDetail/productDetail?id=${currentClickRow}`)
}
else if (rowObj.type == 9) {
// 分类
wxService.router(`/subPackage/page/pages/categoryPro/categoryPro?${currentClickRow}`)
}
}
utilLink.currentLinkRouter(event)
}
}
})
......@@ -3,6 +3,7 @@
var app = getApp()
const wxService = require('../../utils/wxService')
const utils = require('../../utils/util')
const utilLink = require('../../utils/currentLinkRouter')
const envInfo = require('../../config/index').envInfo
Component({
......@@ -23,6 +24,10 @@ Component({
this.setData({
baseImgUrl: app.globalData.imageUrl
})
},
observers: {
picNav() {
const { picNav } = this.data
picNav.forEach(item => {
// 存在 row 处理数据 8 商品 9 分类
......@@ -33,7 +38,6 @@ Component({
const urls = getCurrentPages()
const currentPath = urls[0]
const pageId = item.link.url
console.log('currentPath', currentPath.route,item.link.url)
item.link.newPath = `/${currentPath.route}`
}
return
......@@ -46,14 +50,24 @@ Component({
} else {
newRow.newPath = ''
}
// item.row = JSON.stringify(newRow)
item.row = newRow
}
})
this.setData({ picNav }, () => {
// 当前匹配路径是否需要授权 true 需要 false 不需要
picNav.forEach(item => {
let checkUrl = ''
if(item.link) {
checkUrl = item.link.newPath ? item.link.newPath : item.link.url
} else if(item.row) {
checkUrl = item.row.newPath ? item.row.newPath : item.row.url
}
wxService.NoLoginPage(checkUrl).then(res=>{
item.needAuth = res.needAuth
this.setData({ newPicNav: picNav })
})
})
}
},
/**
* 组件的初始数据
......@@ -64,7 +78,8 @@ Component({
isAuthorization: false,
isAuthorizationActiveText: '',
isAuthorizationType: 2,
baseImgUrl: ''
baseImgUrl: '',
newPicNav: []
},
/**
* 组件的方法列表
......@@ -83,62 +98,7 @@ Component({
})
},
preview(event) {
const ev = event.currentTarget.dataset;
let curItemType = ev.item
// 获取当前帐号信息
const userInfo = wx.getStorageSync('_baseUserInfo')
// link row
if (curItemType.link) {
let currentClickType = app.globalData.commonFunc.getLink(curItemType.link.type, curItemType)
if (curItemType.link.type == 1) {
} else if (curItemType.link.type == 2) {
// 触发父组件更新页面
wxService.nextTick(() => {
this.triggerEvent('updatePage', { pageId: currentClickType.url })
})
} else if (curItemType.link.type == 3) {
// 预览
wx.previewImage({
current: `${app.globalData.imageUrl}/${currentClickType.imageUrl}`, // 当前显示图片的http链接
urls: [`${app.globalData.imageUrl}/${currentClickType.link.url}`] // 需要预览的图片http链接列表
})
} else if (curItemType.link.type == 4) {
wxService.router(`${currentClickType}`)
} else if (curItemType.link.type == 5) {
if (currentClickType == 1) {
wxService.openCard()
} else if (currentClickType == 2) {
wxService.openCard()
}
} else if (curItemType.link.type == 6) {
wxService.router(`/${currentClickType}`)
} else if (curItemType.link.type == 7) {
// 集点详情
wxService.router(`${currentClickType}`)
}
} else if (curItemType.row) {
// let rowObj = JSON.parse(curItemType.row)
let rowObj = curItemType.row
let currentClickRow = app.globalData.commonFunc.getLinkRow(rowObj.type, rowObj)
if (rowObj.type == 1) { }
else if (rowObj.type == 2) { }
else if (rowObj.type == 3) { }
else if (rowObj.type == 4) { }
else if (rowObj.type == 5) { }
else if (rowObj.type == 6) { }
else if (rowObj.type == 7) { }
else if (rowObj.type == 8) {
// 商品
wxService.router(`/pages/productDetail/productDetail?id=${currentClickRow}`)
}
else if (rowObj.type == 9) {
// 分类
wxService.router(`/subPackage/page/pages/categoryPro/categoryPro?${currentClickRow}`)
}
}
utilLink.currentLinkRouter(event)
},
activeTocard(e) {
if (e.detail) {
......
......@@ -2,13 +2,13 @@
<wxs src="../../wxs/utils.wxs" module="utils" />
<view class="pic-nav">
<view
wx:for="{{picNav}}"
wx:for="{{newPicNav}}"
wx:key="{{index}}"
wx:for-item="item"
class="nav-block"
>
<!--当前页面需要授权 且未授权-->
<view wx:if="{{item.link ? utils.hanlerLinkNeedAuth(typeOf(item.link.newPath) != undefined ? item.link.newPath : item.link.url) : utils.hanlerLinkNeedAuth(item.row.newPath ? item.row.newPath : item.row.url)}}">
<!-- 当前页面需要授权 且未授权-->
<view wx:if="{{item.needAuth}}">
<button
wx:if="{{!currentHasUserInfo}}"
bindgetuserinfo="_getUserInfo"
......@@ -19,7 +19,7 @@
style="height:100%"
>
<image
class="pic-img"
class="pic-img hhh"
style="width: {{100}}%;height: {{100}}px;"
src="{{utils.formateUrl(item.imageUrl,baseImgUrl)}}"
data-appid="{{item.link.appid}}"
......@@ -33,7 +33,7 @@
<image
wx:if="{{currentHasUserInfo}}"
class="pic-img"
class="pic-img yyyy"
style="width: {{100}}%;height: {{100}}px;"
src="{{utils.formateUrl(item.imageUrl,baseImgUrl)}}"
data-appid="{{item.link.appid}}"
......@@ -46,7 +46,7 @@
</view>
<view wx:else>
<image
class="pic-img"
class="pic-img ttt"
style="width: {{100}}%;height: {{100}}px;"
src="{{utils.formateUrl(item.imageUrl,baseImgUrl)}}"
data-appid="{{item.link.appid}}"
......
......@@ -79,7 +79,14 @@ class Http {
.catch(this.fail)
}
// header: {
// 'tunnel-token' : 'aa8a1bfb7f6c5031d172d94b6574293ef954a6f2d4e16657da008e0cc15588feD'
// },
get (url, parmas) {
let baseUserInfo = wx.getStorageSync('_baseUserInfo')
console.log('baseUserInfo', baseUserInfo ? 'buyer-token' : 'tunnel-token')
if(baseUserInfo){
return this.request({
url,
method: 'GET',
......@@ -89,9 +96,24 @@ class Http {
},
data: parmas
})
} else {
return this.request({
url,
method: 'GET',
header: {
'tunnel-token': this.getToken(),
'TENTACLE_CONTENT': this.getTentacle()
},
data: parmas
})
}
}
post (url, parmas, channel) {
let baseUserInfo = wx.getStorageSync('_baseUserInfo')
if(baseUserInfo){
return this.request({
url,
method: 'POST',
......@@ -102,6 +124,18 @@ class Http {
data: parmas,
channel: channel
})
} else {
return this.request({
url,
method: 'POST',
header: {
'tunnel-token': this.getToken(),
'TENTACLE_CONTENT': this.getTentacle()
},
data: parmas,
channel: channel
})
}
}
checkStatus (resp) {
......
const wxService = require('./wxService')
const app = getApp()
function currentLinkRouter(event) {
const ev = event.currentTarget.dataset;
let curItemType = ev.item
const userInfo = wx.getStorageSync('_baseUserInfo')
// link row
if (curItemType.link) {
let currentClickType = app.globalData.commonFunc.getLink(curItemType.link.type, curItemType)
if (curItemType.link.type == 1) {
// 触发父组件更新页面 外部小程序
} else if (curItemType.link.type == 2) {
// 触发父组件更新页面
wxService.nextTick(() => {
this.triggerEvent('updatePage', { pageId: currentClickType.url })
})
} else if (curItemType.link.type == 3) {
// 预览
wx.previewImage({
current: `${app.globalData.imageUrl}/${currentClickType.imageUrl}`, // 当前显示图片的http链接
urls: [`${app.globalData.imageUrl}/${currentClickType.link.url}`] // 需要预览的图片http链接列表
})
} else if (curItemType.link.type == 4) {
wxService.router(`${currentClickType}`)
} else if (curItemType.link.type == 5) {
if (currentClickType == 1) {
wxService.openCard()
} else if (currentClickType == 2) {
wxService.openCard()
}
} else if (curItemType.link.type == 6) {
wxService.router(`${currentClickType}`)
} else if (curItemType.link.type == 7) {
// 集点详情
wxService.router(`${currentClickType}`)
}
} else if (curItemType.row) {
// let rowObj = JSON.parse(curItemType.row)
let rowObj = curItemType.row
let currentClickRow = app.globalData.commonFunc.getLinkRow(rowObj.type, rowObj)
if (rowObj.type == 1) { }
else if (rowObj.type == 2) { }
else if (rowObj.type == 3) { }
else if (rowObj.type == 4) { }
else if (rowObj.type == 5) { }
else if (rowObj.type == 6) { }
else if (rowObj.type == 7) { }
else if (rowObj.type == 8) {
// 商品
wxService.router(`/pages/productDetail/productDetail?id=${currentClickRow}`)
}
else if (rowObj.type == 9) {
// 分类
wxService.router(`/subPackage/page/pages/categoryPro/categoryPro?${currentClickRow}`)
}
}
}
module.exports = {
currentLinkRouter: currentLinkRouter
}
\ No newline at end of file
......@@ -308,8 +308,9 @@ function _getUserInfo(ev) {
setUserInfo() // 判断有无开卡
}).catch(err => {
if (err) {
console.log('err', err)
wx.showToast({
title: `会员系统异常请稍后重试!`,
title: `您已拒绝授权!`,
icon: 'none'
})
}
......
......@@ -59,60 +59,30 @@ class WXService extends Http {
this.setPageLoadStatus()
wx.hideLoading()
}).catch(res => {
// if (res.msg && res.msg.indexOf('未登录') > -1) {
// // 判断是否登陆过 登陆过 重新登陆 未登陆 跳转首页
// const baseUserInfo = this.getBaseUserInfo()
// if(!baseUserInfo) {
// wxService.router('/pages/userCenter/userCenter').replace()
// return false
// }
// // 条件限制 getUserInfoLimitCount:重试次数
if (res.msg && res.msg.indexOf('未登录') > -1) {
wx.removeStorageSync('_baseUserInfo')
// if (!this.getUserInfoLimitCount) {
// this.getUserInfoLimitCount = 1
// } else {
// this.getUserInfoLimitCount++
// }
// console.log('count', this.getUserInfoLimitCount)
// if (this.getUserInfoLimitCount > 3) {
// wx.showToast({
// title: '登录超出重试次数!',
// icon: 'none'
// title: '会员系统异常,请联系管理员',
// icon: 'none',
// duration: 2000
// })
// wxService.router(`/pages/userCenter/userCenter`).replace()
// return false
// } else {
// // 重新登陆 更新缓存
// this.reLogin()
// // 重新登陆之前判断是否登陆过 重新登陆
// const baseUserInfo = this.getBaseUserInfo()
// if (baseUserInfo) {
// // this.reLogin()
// return false
// }
// setTimeout(()=>{
// const pages = getCurrentPages()
// const perpage = pages[pages.length - 1]
// perpage.onShow()
// },2000)
// }
if (res.msg && res.msg.indexOf('未登录') > -1) {
if (!this.getUserInfoLimitCount) {
this.getUserInfoLimitCount = 1
} else {
this.getUserInfoLimitCount++
}
console.log('count', this.getUserInfoLimitCount)
if (this.getUserInfoLimitCount > 3) {
wx.showToast({
title: '会员系统异常,请联系管理员',
icon: 'none',
duration: 2000
})
} else {
// 重新登陆之前判断是否登陆过 重新登陆
const baseUserInfo = this.getBaseUserInfo()
if (baseUserInfo) {
// this.reLogin()
return false
}
}
} else if (res.msg && res.msg.indexOf('请重新授权') > -1) {
} else
if (res.msg && res.msg.indexOf('请重新授权') > -1) {
wx.setStorageSync('reLoginErr', true)
wxService.router(`/pages/userCenter/userCenter`).back()
}
......@@ -425,6 +395,30 @@ class WXService extends Http {
})
}
NoLoginPage(page) {
// 首页/商品详情页/内容列表/内容详情/分类/商品列表/集点列表/分享列表
const NoLoginAuthPage = [
'/pages/userCenter/userCenter',
'/pages/myShare/myShare',
'/subPackage/page/pages/myReleaseDetail/myReleaseDetail',
'/pages/productDetail/productDetail',
'/pages/category/category',
'/subPackage/page/pages/categoryPro/categoryPro',
'/pages/pointList/pointList',
'/subPackage/page/pages/friendShareList/friendShareList',
]
return new Promise((resolve,reject) => {
if(NoLoginAuthPage.indexOf(page) > -1) {
resolve({needAuth : false})
} else {
resolve({needAuth : true})
}
}).catch((err) => {
console.log('不需要登录err', err)
reject()
})
}
handlerPage(page) {
const AccreditWhitePages = [
'pages/welcome/welcome'
......@@ -481,63 +475,6 @@ class WXService extends Http {
})
}
// handlerPage (page) {
// const AccreditWhitePages = [
// 'pages/welcome/welcome'
// ] // 免授权页面白名单
// const _self = this
// const app = _self.getApp()
// const baseUserInfo = wx.getStorageSync('_baseUserInfo')
// if (baseUserInfo && baseUserInfo.isMember === '1') {
// app.globalData.openCard = true
// }
// return new Promise((resolve, reject) => {
// let accreditUserInfo = wx.getStorageSync('_accreditUserInfo')
// if (app.globalData.openCard && accreditUserInfo) {
// resolve()
// return false
// }
// if (AccreditWhitePages.indexOf(page.route) > -1) {
// resolve()
// } else if (accreditUserInfo) {
// getAppUserInfo().then(() => {
// if (this.lock) {
// return false
// }
// if ((!baseUserInfo || baseUserInfo.isMember !== '1') && needOpenCard()) {
// reject({ state: 1 })
// _self.lock = false
// } else {
// _self.lock = false
// resolve()
// }
// }).catch((res) => {
// reject()
// })
// } else {
// reject({ state: 1 })
// }
// }).catch((err) => {
// if (err && err.state === 1) {
// const modifyMottoRoute = [
// "pos/express/pages/orderList/orderList",
// "pos/express/pages/confirm/confirm"
// ]
// let router = '/pages/welcome/welcome';
// if (modifyMottoRoute.indexOf(page.route) > -1) {
// page.options.motto = 'express';
// }
// wxService.router('/pages/welcome/welcome').search({
// route: `${page.route}`,
// options: JSON.stringify(page.options)
// }).replace()
// }
// return Promise.reject()
// })
// }
// 设置异步的全局变量值
initAppGlobalDataSync() {
const app = this.getApp()
......
......@@ -44,6 +44,7 @@ function hanlerLinkNeedAuth(link){
return flag
}
module.exports = {
formateUrl:formateUrl,
numberFormat: numberFormat,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment