Commit db55fc7b by 高淑倩

add: 首页支付授权弹框

parent a52b17e5
......@@ -53,6 +53,9 @@
]
}
],
"usingComponents": {
"authorization-modal": "/component/authorization-modal/authorization-modal"
},
"window": {
"backgroundTextStyle": "dark",
"navigationBarBackgroundColor": "#fff",
......
{
"component": true,
"usingComponents": {
"authorization-modal": "./../../component/authorization-modal/authorization-modal"
}
}
\ No newline at end of file
{
"component": true,
"usingComponents": {
"authorization-modal": "./../../component/authorization-modal/authorization-modal"
}
}
\ No newline at end of file
{
"component": true,
"usingComponents": {
"authorization-modal": "./../../component/authorization-modal/authorization-modal"
}
}
\ No newline at end of file
......@@ -2,6 +2,6 @@
"component": true,
"onReachBottomDistance": 0,
"usingComponents": {
"authorization-modal": "./../../component/authorization-modal/authorization-modal"
}
}
\ No newline at end of file
......@@ -26,34 +26,3 @@
isAuthorizationType="{{isAuthorizationType}}"
isAuthorizationActiveText="{{isAuthorizationActiveText}}"
/>
<!--<view class="pic-nav">
<view
wx:for="{{picNav}}"
wx:key="{{index}}"
wx:for-item="item"
class="nav-block"
style="width: {{imagewidth}}px;height: {{imageheight}}px;"
>
<image
wx:if="{{baseImgUrl}}"
class="pic-img"
style="width: {{imagewidth}}px;height: {{imageheight}}px;"
src="{{baseImgUrl}}{{item.imageUrl}}"
data-appid="{{item.link.appid}}"
data-path="{{item.link.url}}"
data-link="{{item.link}}"
data-item="{{item}}"
bindload="imageLoad"
bindtap='preview'
/>
</view>
</view>
<authorization-modal
isAuthorization='{{isAuthorization}}'
bind:activeTocard="activeTocard"
isAuthorizationType="{{isAuthorizationType}}"
isAuthorizationActiveText="{{isAuthorizationActiveText}}"
/>
-->
// component/plus/plus.js
const wxService = require('../../utils/wxService')
const utils = require('../../utils/util')
Component({
/**
......@@ -13,6 +14,10 @@ Component({
plusBgi:{
type: Object,
value: null
},
currentHasUserInfo:{
type: Boolean,
type: false
}
},
......@@ -22,11 +27,59 @@ Component({
data: {
currentTab:'999'
},
/**
* 组件的方法列表
*/
methods: {
_getUserInfo(res = {}) {
const userInfo = res.detail || {}
console.log('userInfo',userInfo)
// 先授权再领卡
if (res.detail.userInfo) {
utils.getUserInfoByBtn(userInfo).then( (data = {} ) => {
const {token} = data
wx.setStorageSync('_accreditUserInfo', userInfo)
wx.hideNavigationBarLoading()
if (token) {
wx.setStorageSync('token', token)
} else {
wx.setStorageSync('token', '')
}
wx.setStorageSync('_baseUserInfo', data) // 缓存用户信息
this.setUserInfo() // 判断有无开卡
}).catch(err=> {
if (err) {
wx.showToast({
title: `会员系统异常请稍后重试!`,
icon: 'none'
})
}
})
}
},
setUserInfo () {
const userInfo = wx.getStorageSync('_baseUserInfo')
// 新用户去激活领卡
if (userInfo && userInfo.member && !userInfo.member.mobile) {
wxService.openCard()
return false
}
// 跳转
const urls = getCurrentPages()
setTimeout(() => {
const item = urls[0].options
if (item.route) {
try {
const options = JSON.parse(item.options)
wxService.router(`/${item.route}`).search(options).replace()
} catch (e) {
wxService.router('/pages/userCenter/userCenter').replace()
}
} else {
wxService.router('/pages/userCenter/userCenter').replace()
}
}, 200)
},
switchNav(e){
this.setData({
currentTab: e.currentTarget.dataset.current,
......
......@@ -36,10 +36,25 @@
</block>
</scroll-view>
<view class="pay">
<!--微信授权-->
<block wx:if="{{!currentHasUserInfo}}">
<button
bindgetuserinfo="_getUserInfo"
data-jflag="false"
open-type='getUserInfo'
class='btn btn-primary'
hover-class="btn-hover"
>
<text>{{currentHasUserInfo}}立即支付</text>
<text>¥158</text>
</button>
</block>
<block wx:else>
<button class="btn btn-primary" bindtap="payPlus">
<text>立即支付</text>
<text>{{currentHasUserInfo}}立即支付</text>
<text>¥158</text>
</button>
</block>
</view>
</view>
......@@ -75,6 +75,7 @@ wxService.page({
* 生命周期函数--监听页面显示
*/
onShow() {
console.log('0this.data.currentHasUserInfo', this.data.currentHasUserInfo)
// 取会员卡号
const baseUserInfo = wx.getStorageSync('_baseUserInfo')
const cardMember = wx.getStorageSync('_cardMember')
......
......@@ -5,7 +5,6 @@
"person-center": "/component/personCenter/personCenter",
"pic-nav": "/component/picNav/picNav",
"bottom": "/component/bottom/bottom",
"authorization-modal": "/component/authorization-modal/authorization-modal",
"tab-sort": "/component/tabSort/tabSort",
"announcement": "/component/announcement/announcement",
"icon-swiper": "/component/iconSwiper/iconSwiper",
......@@ -14,6 +13,7 @@
"attention": "/component/attention/attention",
"guide-page-modal": "/component/guidePageModal/guidePageModal",
"bottom-tabs": "/component/bottomTabs/bottomTabs",
"authorization-modal": "/component/authorization-modal/authorization-modal",
"plus": "/component/plus/plus"
}
}
\ No newline at end of file
......@@ -27,10 +27,9 @@
<attention focus-wx="{{pItem.focusWx}}" />
</view>
<view class="" wx:if="{{pItem.type == 9}}">
<plus sku-list="{{skuVOList}}" plus-bgi="{{pItem.plus}}"/>
<plus sku-list="{{skuVOList}}" plus-bgi="{{pItem.plus}}" currentHasUserInfo="{{currentHasUserInfo}}"/>
</view>
</block>
</view>
<authorization-modal isAuthorization='{{isAuthorization}}' />
<guide-page-modal show="{{guidePageModalShow}}" />
<!--<authorization-modal isAuthorization='{{isAuthorization}}'/>-->
......@@ -5,7 +5,6 @@
"person-center": "/component/personCenter/personCenter",
"pic-nav": "/component/picNav/picNav",
"bottom": "/component/bottom/bottom",
"authorization-modal": "/component/authorization-modal/authorization-modal",
"tab-sort": "/component/tabSort/tabSort",
"announcement": "/component/announcement/announcement",
"icon-swiper": "/component/iconSwiper/iconSwiper",
......
......@@ -33,5 +33,4 @@
<!--goHome-->
<go-home wx:if="{{goHome}}"/>
</view>
<authorization-modal isAuthorization='{{isAuthorization}}' />
<guide-page-modal show="{{guidePageModalShow}}" />
......@@ -100,12 +100,15 @@ class WXService extends Http {
duration: 2000
})
} else {
// 重新登陆之前判断是否登陆过 重新登陆
const baseUserInfo = this.getBaseUserInfo()
if (baseUserInfo) {
this.reLogin()
return false
}
}
} else if (res.msg && res.msg.indexOf('请重新授权') > -1) {
wx.setStorageSync('reLoginErr', true)
// wxService.router(`/pages/userCenter/userCenter`).replace()
console.log("授权跳转")
wxService.router(`/pages/userCenter/userCenter`).back()
}
})
......@@ -220,7 +223,8 @@ class WXService extends Http {
})
} else if (res.data.data.isMember === '1') {
let baseUserInfo = this.getBaseUserInfo()
let newBaseUserInfo = { ...baseUserInfo,
let newBaseUserInfo = {
...baseUserInfo,
...res.data.data
}
this.baseUserInfo = newBaseUserInfo
......@@ -245,7 +249,7 @@ class WXService extends Http {
}
//生成触点对象Id
getTentacleContent(tentacleInfo){
getTentacleContent(tentacleInfo) {
return this.post('/marketing/tentacleContent/getTentacleContent', tentacleInfo).then((res) => {
let data = res.data.data
return Promise.resolve(data);
......@@ -255,8 +259,8 @@ class WXService extends Http {
}
//根据触点对象id获取触点对象信息
getTentacleContentByTentacleId(tentacleId){
this.post('/marketing/tentacleContent/getTentacleContent', { tentacleId: tentacleId}).then((res) => {
getTentacleContentByTentacleId(tentacleId) {
this.post('/marketing/tentacleContent/getTentacleContent', { tentacleId: tentacleId }).then((res) => {
let data = res.data.data
let TENTACLE_CONTENT = {
id: data.id,
......@@ -267,7 +271,7 @@ class WXService extends Http {
}
let storageObj = {
memberId : '',
memberId: '',
obj: TENTACLE_CONTENT
}
......@@ -283,7 +287,7 @@ class WXService extends Http {
}
//更新本地触点对象信息
updateLocalTentacleInfo(){
updateLocalTentacleInfo() {
//先获取本地触点对象信息
let tentacleInfo = wx.getStorageSync('TENTACLE_CONTENT');
//获取从种草详情商品购买时存储的临时触点对象信息
......@@ -297,16 +301,16 @@ class WXService extends Http {
*
*/
//判断tentacleInfo是否为空
if (!tentacleInfo){
if (!tentacleInfo) {
wx.setStorageSync('TENTACLE_CONTENT', tempTentacleInfo);
return ;
return;
}
//tentacleInfo 不为空
//判断先获取本地触点对象信息 中memberid 是否为空
let memberId = tentacleInfo.memberId;
// 若memberId 为空 表示从分享过来的链接 此时不能更新wx.getStorageSync('TENTACLE_CONTENT') 信息
if (!memberId){
return ;
if (!memberId) {
return;
}
//不为空 则表示 之前从种草详情中的商品直接购买过 直接更新本地TENTACLE_CONTENT
......@@ -327,7 +331,7 @@ class WXService extends Http {
scrollOffset() {
return new Promise((resolve, reject) => {
wx.createSelectorQuery().selectViewport().scrollOffset(function(res) {
wx.createSelectorQuery().selectViewport().scrollOffset(function (res) {
resolve(res)
}).exec()
})
......@@ -367,7 +371,7 @@ class WXService extends Http {
})
}
getNavBarBackGroundColor(fc,bgc) {
getNavBarBackGroundColor(fc, bgc) {
wx.setNavigationBarColor({
frontColor: fc,
backgroundColor: bgc,
......@@ -378,6 +382,62 @@ 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()
})
}
// handlerPage (page) {
// const AccreditWhitePages = [
......@@ -454,53 +514,66 @@ class WXService extends Http {
page(config) {
const _self = this
// 当前是否有用户信息
config.data.currentHasUserInfo = false;
// 当前页面是否需要授权
config.data.currentPageRequireAuth = false;
const CONFIG_PAPGE = {
onLoad: function(...args) {
onLoad: function (...args) {
const page = this
_self.initAppGlobalDataSync()
//修改参数
let pageIsFromShare = false, tentacleId = null;
args.forEach(item => {
if(item['t']){
if (item['t']) {
pageIsFromShare = true;
tentacleId = Integer.digit(item['t'],64,10);
if (item['i']){
tentacleId = Integer.digit(item['t'], 64, 10);
if (item['i']) {
item['id'] = Integer.digit(item['i'], 64, 10);
}
}
});
console.log('--------', args)
//如果打开的是分享界面则进行触点对象信息请求并存储到本地 放到后续的header中
if (pageIsFromShare){
if (pageIsFromShare) {
//调用接口
_self.getTentacleContentByTentacleId(tentacleId);
}
config.onLoad && config.onLoad.apply(page, args);
},
onShow: function(...args) {
onShow: function (...args) {
const page = this
_self.currentPage = page
config.onShow && config.onShow.apply(page, args)
const baseUserInfo = wx.getStorageSync('_baseUserInfo')
if (baseUserInfo) {
page.setData({
currentHasUserInfo: true
});
} else {
page.setData({
currentHasUserInfo: false
});
}
},
onReady: function(...args) {
onReady: function (...args) {
config.onReady && config.onReady.apply(this, args)
},
onHide: function(...args) {
onHide: function (...args) {
const page = this
config.onHide && config.onHide.apply(this, args)
// page.setData({
// currentHasUserInfo: false
// });
},
onUnload: function(...args) {
onUnload: function (...args) {
config.onUnload && config.onUnload.apply(this, args)
},
onPageScroll: function(...args) {
onPageScroll: function (...args) {
config.onPageScroll && config.onPageScroll.apply(this, args)
},
onShareAppMessage: function(...args) {
onShareAppMessage: function (...args) {
const page = this
const baseUserInfo = wx.getStorageSync('_baseUserInfo')
let openId = ''
......@@ -570,7 +643,7 @@ class WXService extends Http {
fail: (res) => {
reject(res)
},
complete: () => {}
complete: () => { }
})
})
}
......@@ -579,7 +652,7 @@ class WXService extends Http {
const _self = this
const promise = new Promise((resolve, reject) => {
if (!openCardLister) {
openCardLister = cEvent.on('openCardSuccess', function(data) {
openCardLister = cEvent.on('openCardSuccess', function (data) {
openCardLister = null
resolve(data)
})
......@@ -606,11 +679,11 @@ class WXService extends Http {
wx.navigateToMiniProgram({
appId: 'wxeb490c6f9b154ef9', // 固定为此 appid,不可改动
extraData: options, // 包括 encrypt_card_id, outer_str, biz三个字段,须从 step3 中获得的链接中获取参数
success: function(data) {
success: function (data) {
console.log('navigateToMiniProgram success data is %o', data)
_self.lock = false
},
fail: function(data) {
fail: function (data) {
console.log('navigateToMiniProgram fail data is %o', data)
this.router('/pages/userCenter/userCenter')
// this.router('/pages/welcome/welcome')
......
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