Commit d11e4c83 by 高淑倩

modify: 首页_type跳转

parent 6f663702
......@@ -2,6 +2,7 @@
import { cEvent } from './utils/event.js'
const Promise = require('lib/bluebird')
var utils = require('utils/util.js')
var commonFunc = require('utils/common.js')
var wxService = require('utils/wxService')
let config = require('./configScreen/configScreen');
const envInfo = require('config/index').envInfo
......@@ -27,10 +28,8 @@ App({
}
if (res.windowHeight > 750) config.isAllScreen = true;
config.systemHeight = res.windowHeight;
// console.log('config', config)
} catch (e) {
console.log(e);
console.log(err);
}
},
......@@ -113,8 +112,9 @@ App({
loginFirst: false,
imageUrl:"", //图片地址
isFullSucreen: false, // 当前设备是否为 FullSucreen
brandId: 2005,
// brandId: 1001,
commonFunc: commonFunc,
// brandId: 2005,
brandId: 1001,
// brandId: 1002,
}
})
......@@ -12,7 +12,8 @@
"pages/consumptionDetails/consumptionDetails",
"pages/IntegralMall/IntegralMall",
"pages/integralMallDetail/integralMallDetail",
"pages/activateCard/activateCardCallback"
"pages/activateCard/activateCardCallback",
"component/bottom/bottom"
],
"subPackages": [
{
......
......@@ -49,7 +49,6 @@ Component({
const userInfo = res.detail || {}
if (res.detail.userInfo) {
utils.getUserInfoByBtn(userInfo).then( (data = {} ) => {
console.log('----',data)
const {token} = data
wx.setStorageSync('_accreditUserInfo', userInfo)
wx.hideNavigationBarLoading()
......@@ -71,7 +70,6 @@ Component({
}
})
} else {
console.log('点击了取消')
this.setData({
isAuthorization: false
})
......
// component/bottom/bottom.js
// component/imageSwiper/imageSwiper.js
var app = getApp()
const wxService = require('../../utils/wxService')
const utils = require('../../utils/util')
const envInfo = require('../../config/index').envInfo
Component({
/**
* 组件的属性列表
*/
properties: {
bottom: {
type: Object,
value: {},
},
},
attached () {},
/**
* 组件的初始数据
*/
data: {
startX: 0,
startY: 0,
isAuthorization: false
},
/**
* 组件的方法列表
*/
methods: {
touchStart(e) {
this.setData({
startX: e.changedTouches[0].clientX,
startY: e.changedTouches[0].clientY
});
},
touchEnd(e) {
let x = e.changedTouches[0].clientX;
let y = e.changedTouches[0].clientY;
// endX, endY, startX, startY
const {startX, startY} = this.data
let isTouchLeft = utils.getTouchData(x, y, startX, startY)
// 触发左划事件
if(isTouchLeft == 'left') {
const {appid, path, link,item} = e.currentTarget.dataset
// 获取当前帐号信息
const accountInfo = utils.getAccountInfo()
// 是当前小程序 直接跳转
if (wx.getStorageSync('_baseUserInfo')){
// navigateToMiniProgram:fail can only be invoked by user TAP gesture.
if( link.type == 1) return false
// 更改数据问题
let currentClickType = app.globalData.commonFunc.getLink(item.link.type, item)
if(link.type == 2) {
// 触发父组件更新页面
wxService.nextTick(() => {
this.triggerEvent('updatePage', { pageId: currentClickType.url })
})
} else if(link.type == 3) {
// 预览
wx.previewImage({
current: `https://images.unsplash.com/${currentClickType.imageUrl}`, // 当前显示图片的http链接
urls: [`http://testimg3.bigaka.com/${currentClickType.link.url}`] // 需要预览的图片http链接列表
})
} else if(link.type == 4) {
wxService.router(`${currentClickType}`)
}
}else{
this.setData({
isAuthorization: true
})
}
}
}
}
})
{
"component": true,
"usingComponents": {
"authorization-modal": "./../../component/authorization-modal/authorization-modal"
}
}
\ No newline at end of file
<!--component/bottom/bottom.wxml-->
<view class='footer-content' style="background:{{bottom.color}};color:{{bottom.color}}" data-link="{{bottom.link}}" data-appid="{{bottom.link.appid}}" data-item="{{bottom}}" data-path="{{bottom.link.url}}" catchtouchstart='touchStart' catchtouchend="touchEnd">
<text class="footer-arrow" style="color:{{bottom.fontColor}}"><<</text>
<text class='footer-text' style="color:{{bottom.fontColor}}">{{bottom.title}}</text>
</view>
<authorization-modal isAuthorization='{{isAuthorization}}'/>
/* component/bottom/bottom.wxss */
.footer-content{
text-align: center;
background-color: #02bb70;
line-height: 100rpx;
position: fixed;
margin-top:20rpx;
bottom: 0;
width:100%;
}
.footer-arrow {
position: absolute;
left: 50rpx;
color: #ffffff;
}
.footer-text{
color: #ffffff;
font-size: 32rpx;
font-weight: 700;
letter-spacing:2rpx;
}
\ No newline at end of file
......@@ -93,7 +93,7 @@ Component({
})
}
}).catch(err => {
console.log('ffff',err)
console.log('err',err)
})
}
}
......
......@@ -33,32 +33,49 @@ Component({
*/
methods: {
preview(e) {
const {appid, path} = e.currentTarget.dataset
const {appid, path, link,item} = e.currentTarget.dataset
// 获取当前帐号信息
const accountInfo = utils.getAccountInfo()
const userInfo = wx.getStorageSync('_baseUserInfo')
if (userInfo){
// app.globalData.commonFunc.getLink(item.link.type, item)
let currentClickType = app.globalData.commonFunc.getLink(item.link.type, item)
if(link.type == 2) {
// 触发父组件更新页面
wxService.nextTick(() => {
this.triggerEvent('updatePage', { pageId: currentClickType.url })
})
} else if(link.type == 3) {
// 预览
wx.previewImage({
current: `https://images.unsplash.com/${currentClickType.imageUrl}`, // 当前显示图片的http链接
urls: [`http://testimg3.bigaka.com/${currentClickType.link.url}`] // 需要预览的图片http链接列表
})
} else if(link.type == 4) {
wxService.router(`${currentClickType}`)
}
// 是当前小程序 直接跳转
if(accountInfo.miniProgram.appId == appid){
wxService.router(`${path}`)
} else {
// 跳转其他小程序
wx.navigateToMiniProgram({
appId: appid,
path: `${path}`,
success: e => {
console.log(e)
},
fail: e => {
console.log(e)
},
complete: e => {
console.log(e)
},
})
}
// if(accountInfo.miniProgram.appId == appid){
// wxService.router(`${path}`)
// } else {
// // 跳转其他小程序
// wx.navigateToMiniProgram({
// appId: appid,
// path: `${path}`,
// success: e => {
// console.log(e)
// },
// fail: e => {
// console.log(e)
// },
// complete: e => {
// console.log(e)
// },
// })
// }
}else{
console.log('1111')
this.setData({
isAuthorization: true
})
......
......@@ -9,7 +9,7 @@
>
<block wx:for="{{imageData}}" wx:key="{{item}}">
<swiper-item class="swiper-item">
<image src="http://testimg3.bigaka.com{{item.imageUrl}}" data-appid="{{item.link.appid}}" data-path="{{item.link.url}}" bindtap='preview' class="slide-image" />
<image src="http://testimg3.bigaka.com{{item.imageUrl}}" data-appid="{{item.link.appid}}" data-path="{{item.link.url}}" data-link="{{item.link}}" data-item="{{item}}" bindtap='preview' class="slide-image" />
</swiper-item>
</block>
</swiper>
......
......@@ -81,21 +81,7 @@ Component({
},
handleGoWxCard() {
console.log('kabao')
wxService.openCardList()
// wechatCardId wechatCode
// const {wechatCardId,wechatCode} = wx.getStorageSync('_baseUserInfo')
// wx.openCard({
// cardList: [{
// cardId: wechatCardId,
// code: wechatCode
// }],
// success (res) {
// console.log('查看微信卡包中的卡券', res)
// }
// })
}
}
})
\ No newline at end of file
......@@ -36,44 +36,61 @@ Component({
})
},
preview(e) {
const {appid, path} = e.currentTarget.dataset
const {appid, path, link, item} = e.currentTarget.dataset
const {memberActivateStatus} = wx.getStorageSync('_baseUserInfo')
// 获取当前帐号信息
const accountInfo = utils.getAccountInfo()
const userInfo = wx.getStorageSync('_baseUserInfo')
if(accountInfo.miniProgram.appId == appid){
if (userInfo){
if (!memberActivateStatus){
wxService.openCard()
}else{
wxService.router(`${path}`)
}
// if (!memberActivateStatus){
// wxService.openCard()
// }else{
// wxService.router(`${path}`)
// }
}else{
if (path == '/pages/deliveryService/deliveryService') {
wxService.router(`${path}`)
return
}
// if (path == '/pages/deliveryService/deliveryService') {
// wxService.router(`${path}`)
// return
// }
this.setData({
isAuthorization: true
})
}
} else {
// 跳转其他小程序
wx.navigateToMiniProgram({
appId: appid,
path: `${path}`,
success: e => {
console.log(e)
},
fail: e => {
console.log(e)
},
complete: e => {
console.log(e)
},
})
// wx.navigateToMiniProgram({
// appId: appid,
// path: `${path}`,
// success: e => {
// console.log(e)
// },
// fail: e => {
// console.log(e)
// },
// complete: e => {
// console.log(e)
// },
// })
}
// 2019.06.14
let currentClickType = app.globalData.commonFunc.getLink(item.link.type, item)
if(link.type == 2) {
// 触发父组件更新页面
wxService.nextTick(() => {
this.triggerEvent('updatePage', { pageId: currentClickType.url })
})
} else if(link.type == 3) {
// 预览
wx.previewImage({
current: `https://images.unsplash.com/${currentClickType.imageUrl}`, // 当前显示图片的http链接
urls: [`http://testimg3.bigaka.com/${currentClickType.link.url}`] // 需要预览的图片http链接列表
})
} else if(link.type == 4) {
wxService.router(`${currentClickType}`)
}
}
}
})
......@@ -2,7 +2,7 @@
<view class="pic-nav">
<block wx:for="{{picNav}}" wx:key="{{index}}" wx:for-item="item">
<view class="nav-block" style="width: {{imagewidth}}px;height: {{imageheight}}px;">
<image style="width: {{imagewidth}}px;height: {{imageheight}}px;" src="http://testimg3.bigaka.com{{item.imageUrl}}" data-appid="{{item.link.appid}}" data-path="{{item.link.url}}" bindload="imageLoad" bindtap='preview' />
<image style="width: {{imagewidth}}px;height: {{imageheight}}px;" src="http://testimg3.bigaka.com{{item.imageUrl}}" data-appid="{{item.link.appid}}" data-path="{{item.link.url}}" data-link="{{item.link}}" data-item="{{item}}" bindload="imageLoad" bindtap='preview' />
</view>
</block>
</view>
......
const PROJECT_ENV = 'prod' // 生产 prod, 开发 dev, 测试 test, 预生产 pre
const PROJECT_ENV = 'dev' // 生产 prod, 开发 dev, 测试 test, 预生产 pre
const needMock = '' //
// appid_dev_wx wxc3b64b09b1d3dfc2
......
......@@ -26,8 +26,6 @@ wxService.page({
if(cardno){
wxbarcode.barcode('barcode', cardno, 600, 180);
this.getCouponDetail(cardno)
console.log('cardno', cardno)
}
},
onLoad() {
......
......@@ -57,7 +57,6 @@ wxService.page({
// 获取会员信息
this.getMemberFind()
// 条形码
console.log('memberCardNo',memberCardNo)
wxbarcode.barcode('barcode', memberCardNo, 500, 120);
})
}
......@@ -159,18 +158,17 @@ wxService.page({
})
},
handleGoWxCard() {
console.log('kabao')
// wechatCardId wechatCode
const { wechatCardId, wechatCode } = wx.getStorageSync('_baseUserInfo')
wx.openCard({
cardList: [{
cardId: wechatCardId,
code: wechatCode
}],
success(res) {
console.log('查看微信卡包中的卡券', res)
}
})
// const { wechatCardId, wechatCode } = wx.getStorageSync('_baseUserInfo')
// wx.openCard({
// cardList: [{
// cardId: wechatCardId,
// code: wechatCode
// }],
// success(res) {
// console.log('查看微信卡包中的卡券', res)
// }
// })
}
})
\ No newline at end of file
......@@ -17,8 +17,6 @@ wxService.page({
pages:[],
render: null, // 渲染页面数据对象(安全渲染)
renderPageOver: false, // 渲染页面结束
startX: 0,
startY: 0,
integralNum: 0,
couponNum: 0,
// isAllScreen: fullSucreen.isAllScreen
......@@ -51,7 +49,18 @@ wxService.page({
handlerDataOnPage.init(this, 'pages')
this.initPage(this.data.pageId)
},
/**
* 监听子组件事件
* */
updatePage(ev) {
const {pageId} = ev.detail
this.setData({
pages: [],
pageId
},()=>{
this.initPage(pageId)
})
},
/**
* 生命周期函数--监听页面显示
*/
......@@ -105,50 +114,6 @@ wxService.page({
}
})
},
touchStart(e) {
this.setData({
startX: e.changedTouches[0].clientX,
startY: e.changedTouches[0].clientY
});
},
touchEnd(e) {
let x = e.changedTouches[0].clientX;
let y = e.changedTouches[0].clientY;
// endX, endY, startX, startY
const {startX, startY} = this.data
let isTouchLeft = utils.getTouchData(x, y, startX, startY)
// 触发左划事件
if(isTouchLeft == 'left') {
const {appid, path} = e.currentTarget.dataset
// 获取当前帐号信息
const accountInfo = utils.getAccountInfo()
// 是当前小程序 直接跳转
if (wx.getStorageSync('_baseUserInfo')){
if(accountInfo.miniProgram.appId == appid){
wxService.router(`${path}`)
} else {
// 跳转其他小程序
wx.navigateToMiniProgram({
appId: appid,
path: `${path}`,
success: e => {
console.log(e)
},
fail: e => {
console.log(e)
},
complete: e => {
console.log(e)
},
})
}
}else{
this.setData({
isAuthorization: true
})
}
}
},
// page 信息
initPage(pageId){
this.setData({
......
......@@ -4,6 +4,7 @@
"image-swiper": "/component/imageSwiper/imageSwiper",
"person-center": "/component/personCenter/personCenter",
"pic-nav": "/component/picNav/picNav",
"bottom": "/component/bottom/bottom",
"authorization-modal": "/component/authorization-modal/authorization-modal"
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@
<!--{{pItem.type}}-->
<!-- 轮播 -->
<view class="pd1530" wx:if="{{pItem.type == 1}}">
<image-swiper image-data="{{pItem.rotationchart.images}}" />
<image-swiper bind:updatePage="updatePage" image-data="{{pItem.rotationchart.images}}" />
</view>
<!-- 个人中心 {{pItem.customer}}-->
......@@ -16,14 +16,11 @@
<!-- 图片导航 {{pItem.navigation.images}} pd1530-->
<view class="pd1530" wx:if="{{pItem.type == 3}}">
<pic-nav pic-nav="{{pItem.navigation.images}}" />
<pic-nav bind:updatePage="updatePage" pic-nav="{{pItem.navigation.images}}" />
</view>
<!-- 底部 -->
<view class="" wx:if="{{pItem.type == 4}}">
<view class='footer-content' style="background:{{pItem.bottom.color}};color:{{pItem.bottom.color}}" data-appid="{{pItem.bottom.link.appid}}" data-path="{{pItem.bottom.link.url}}" catchtouchstart='touchStart' catchtouchend="touchEnd">
<text class="footer-arrow" style="color:{{pItem.bottom.fontColor}}"><<</text>
<text class='footer-text' style="color:{{pItem.bottom.fontColor}}">{{pItem.bottom.title}}</text>
</view>
<bottom bind:updatePage="updatePage" bottom="{{pItem.bottom}}"/>
</view>
</block>
</view>
......
......@@ -33,30 +33,9 @@ page {
width: 337rpx;
height: 160rpx;
}
.footer-content{
text-align: center;
background-color: #02bb70;
line-height: 100rpx;
position: fixed;
margin-top:20rpx;
bottom: 0;
width:100%;
}
.arrow-left {
width: 32rpx;
height: 32rpx;
vertical-align: middle;
}
.footer-text{
color: #ffffff;
font-size: 32rpx;
font-weight: 700;
letter-spacing:2rpx;
/* font-family:"iconfont-711" !important; */
}
.footer-arrow {
position: absolute;
left: 50rpx;
color: #ffffff;
}
......@@ -13,7 +13,7 @@
},
"compileType": "miniprogram",
"libVersion": "2.6.6",
"appid": "wx358b56af62edbde1",
"appid": "wxc3b64b09b1d3dfc2",
"projectname": "7-Eleven",
"debugOptions": {
"hidedInDevtools": []
......
import { cEvent } from './event'
const wxService = require('./wxService')
const env = require('../config/index').envInfo
function Chain() {
this.hanlers = {}
}
Chain.prototype = {
add: function (type, fn) {
const hanlers = this.hanlers[type] || []
if (hanlers.length > 1) {
const preFn = hanlers[length - 1]
preFn.next = fn
}
hanlers.push(fn)
},
hanler: function () {
const args = [].slice.call(arguments)
const type = args.pop()
const hanler = this.hanlers[type]
hanler.apply(this, [hanler.next, ...args])
},
}
const HandlerLink = function () { }
HandlerLink.prototype = {
init(type, item = {}) {
let res = this.currentLinkType(type, item)
return res
},
currentLinkType(type, item={}) {
// 1. 外部小程序_url 2. 内部动态页面_pageId 3.预览 4. 内部页面 5. 卡券__1_卡包 2_激活领卡
if (type == 1) {
wx.navigateToMiniProgram({
// 跳转外部小程序
appId: item.link.appid,
path: `${item.link.url}`,
success: e => {
console.log('type=1',e)
},
fail: e => {
console.log('type=1',e)
},
complete: e => {
console.log(e)
},
})
return ''
} else if (type == 2) {
return item.link
} else if (type == 3) {
return item
} else if (type == 4) {
return `${item.link.url}`
} else if (type == 5) {
if(item.link.url == 1){
// 卡包
wxService.openCardList()
} else if(item.link.url == 2){
// 激活领卡--开卡
wxService.openCard()
}
}
}
}
const getLink = function (type, id, name) {
const handlerLink = new HandlerLink()
return handlerLink.init.apply(handlerLink, arguments)
}
const getUrlParam = function (name, url) {
if (!url) {
return null
}
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i')
var r = url.match(reg)
if (r != null) return decodeURI(r[2])
return null
}
class Parmas {
constructor() {
this.cache = new Map()
}
setObject(key, val) {
this.cache.set(key, val)
if (key === '_defaultAddress') {
cEvent.notify('selectAdress', val)
}
if (key === '_posDefaultAddress') {
cEvent.notify('selectAddress', val)
}
console.log(this.cache)
}
getObject(key) {
let res = null
if (this.cache.has(key)) {
res = this.cache.get(key)
}
return res
}
getObjectOnce(key) {
let res = null
if (this.cache.has(key)) {
res = this.cache.get(key)
this.cache.delete(key)
}
return res
}
}
module.exports = {
getLink: getLink,
parmas: new Parmas(),
getUrlParam: getUrlParam,
handlerLink: new HandlerLink(),
}
......@@ -523,6 +523,8 @@ class WXService extends Http {
const baseUserInfo = wx.getStorageSync('_baseUserInfo')
return new Promise((resolve, reject) => {
if (baseUserInfo && baseUserInfo.member && baseUserInfo.member.mobile) {
console.log('已开卡')
wxService.openCardList()
resolve(baseUserInfo)
} else if (!baseUserInfo || !baseUserInfo.member || !baseUserInfo.member.mobile) {
console.log('去开卡')
......
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