Commit 29d5d981 by 张立顺

订阅模块功能开发

1 parent af1a02ba
......@@ -10,9 +10,9 @@
"integrity": "sha512-hFJ48SCSvRgcwT/9TcxwNnNnWSpy2BpaBfwQwVdU6uwgFH+2OqGL435VQN7EDpIMH8YjHbiM84hueTyxAzIPqQ=="
},
"glsx-applet-component": {
"version": "1.0.26",
"resolved": "https://registry.npmjs.org/glsx-applet-component/-/glsx-applet-component-1.0.26.tgz",
"integrity": "sha512-piMTmDIUq4x7fpE3/GgZI1pIFV6SlmsJdtm/TxBqM5VG4i38+7bXZSkjqvu3xdb2TIXw6FuA4lq6I/QfVVX7LQ=="
"version": "1.0.32",
"resolved": "https://registry.npmmirror.com/glsx-applet-component/-/glsx-applet-component-1.0.32.tgz",
"integrity": "sha512-1YnE+r/tHpQS0FYLN/YV7EHvhOhY3leprkghtSpl3jjNP6KkMzrQoRuTatSIe3AWzVOKeXVP6ZsCIm9cdtB4pQ=="
}
}
}
......@@ -5,7 +5,7 @@
"main": "app.js",
"dependencies": {
"@vant/weapp": "^1.10.9",
"glsx-applet-component": "^1.0.26"
"glsx-applet-component": "^1.0.32"
},
"devDependencies": {},
"scripts": {
......
......@@ -54,6 +54,7 @@ Page({
//接受跳转的路由参数(小程序页面跳转)
onRoute(options) {
// console.log( options);
if (!options || utils.isEmptyObj(options)) return
let { actNum = 0, activeNavIdx = 0, phone, cardInfo } = options
console.log(options)
......
const systemData = [
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/'
const subscriptionIMG_URL = 'https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/index/subscription/'
const IMG_URL2 = 'https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/index/'
const subscriptionBannerUrl = IMG_URL2 + 'banner/banner4.webp'
const productImgs0 = [`${IMG_URL}index/productImgs/product00.webp`, `${IMG_URL}index/productImgs/product01.webp`, `${IMG_URL}index/productImgs/product02.webp`, `${IMG_URL}index/productImgs/product03.webp`]
// 车损升级
const sceneImgs5 = [`${IMG_URL}index/scene/scene00.png`, `${IMG_URL}index/scene/scene01.png`, `${IMG_URL}index/scene/scene02.png`, `${IMG_URL}index/scene/scene03.png`]
const videoList0 = [
{
videoUrl: `${IMG_URL2}video/digital_card_30s.mp4`,
posterUrl: `${IMG_URL}index/poster/subscribeVideoPoster-0.webp`,
name: 'SOP数字化管理提升门店效率',
manufacturer: '嘀加智慧',
view: 188
},
{
videoUrl: `${IMG_URL2}video/digital_card_money3.mp4`,
posterUrl: `${IMG_URL}index/poster/subscribeVideoPoster-1.webp`,
name: '1分钟告诉你数字化招揽的核心优势',
manufacturer: '嘀加智慧云',
view: 188
}
// {
// videoUrl: `${IMG_URL2}video/digital_card.mp4`,
// posterUrl: `${IMG_URL}index/poster/digital_card_bitmap.png`,
// name: '数字无忧卡服务',
// manufacturer: '嘀加智慧',
// view: 1320
// },
// {
// videoUrl: `${IMG_URL2}video/digital_card_reason6.mp4`,
// posterUrl: `${IMG_URL}index/poster/digital_card_reason6_bitmap.png`,
// name: '数字无忧卡6大理由',
// manufacturer: '嘀加智慧',
// view: 1485
// }
]
// const posterList0 = [
// {
// src: `${IMG_URL}index/poster/poster3-0.webp`,
// name: '劲爆来袭'
// },
// {
// src: `${IMG_URL}index/poster/poster3-1.webp`,
// name: '疯狂让利'
// },
// {
// src: `${IMG_URL}index/poster/poster3-2.webp`,
// name: '娱乐系统'
// },
// {
// src: `${IMG_URL}index/poster/poster3-3.webp`,
// name: 'AR实景导航'
// }
// ]
const subscriptionSystemData = [
{
id: 100,
name: '客户沉淀',
bannerUrl: '',
//场景详情图片
sceneImgs: sceneImgs5,
// 产品详情图片
productImgs: productImgs0,
productList: [
{
id: 0,
img: 'product-img1',
proName: '私域用户活跃代运营',
price: '100',
profit: '1200000',
type: 'service',
productType: 'benefitCard',
path: 'equity',
sale: 100, //销量
varType: 0,
flow: 10000,
productCode: 'PC011',
productName: '私域用户活跃代运营',
category: '代运营',
prodImg: `${IMG_URL2}/prod2/prod4-0.webp`
},
{
id: 0,
img: 'product-img1',
proName: '定保/续保数字化招揽',
price: '100',
profit: '1200000',
type: 'service',
productType: 'benefitCard',
path: 'equity',
sale: 100, //销量
varType: 0,
flow: 10000,
productCode: 'PC012',
productName: '定保/续保数字化招揽',
category: '招揽',
prodImg: `${IMG_URL}index/prod2/prod4-1.webp`
}
],
videoList: videoList0
// posterList: posterList0
},
{
name: '客户活跃',
//场景详情图片
sceneImgs: sceneImgs5,
// 产品详情图片
productImgs: productImgs0,
productList: [
{
id: 101,
proName: '私欲用户活跃代运营',
img: ''
id: 0,
img: 'product-img1',
proName: '事故车救援服务',
price: '100',
profit: '1200000',
type: 'service',
productType: 'benefitCard',
path: 'equity',
sale: 100, //销量
varType: 0,
flow: 10000,
productCode: 'PC001',
productName: '事故车救援服务',
category: '救援',
prodImg: `${IMG_URL}index/prod2/prod4-2.webp`
}
]
],
videoList: videoList0
// posterList: posterList0
}
]
module.exports = {
systemData
}
\ No newline at end of file
// systemData,
subscriptionBannerUrl,
subscriptionSystemData
}
......@@ -6,11 +6,12 @@
* @LastEditTime: 2022-12-20 11:13:44
*/
// pages/tab/index/index.js
import Draw from "../../../utils/Draw";
import { entmicroApi } from "../../../api/api";
import { commonMixin } from "../../../mixins/index";
import { trackData } from "../../../utils/data";
import { senceData, productData } from "./constant/senceData";
import Draw from '../../../utils/Draw'
import { entmicroApi } from '../../../api/api'
import { commonMixin } from '../../../mixins/index'
import { trackData } from '../../../utils/data'
import { senceData, productData } from './constant/senceData'
import { subscriptionBannerUrl, subscriptionSystemData } from './constant/systemData'
Page({
behaviors: [commonMixin],
/**
......@@ -19,38 +20,36 @@ Page({
data: {
tabList: [
{
name: "增值转化",
icon: "icon-product",
icon1: "icon-product1",
name: '增值转化',
icon: 'icon-product',
icon1: 'icon-product1'
},
{
name: "系统订阅",
icon: "icon-measure",
icon1: "icon-measure",
name: '系统订阅',
icon: 'icon-measure',
icon1: 'icon-measure'
},
{
name: "公司介绍",
icon: "icon-company",
icon1: "icon-company1",
name: '公司介绍',
icon: 'icon-company',
icon1: 'icon-company1'
},
{
name: "视频直播",
icon: "icon-video",
icon1: "icon-video",
},
name: '视频直播',
icon: 'icon-video',
icon1: 'icon-video'
}
],
curTabIndex: 0,
// 员工名片信息
cardInfo: null,
defaultInfo: {
staffName: "虚拟员工",
operation: "虚拟职位",
staffPhone: "xxxxxxxx",
image:
"https://img.zcool.cn/community/01e47e60ab5b4011013eaf70962e3f.jpg@520w_390h_1c_1e_2o_100sh.jpg",
qrCode:
"https://img.zcool.cn/community/01e47e60ab5b4011013eaf70962e3f.jpg@520w_390h_1c_1e_2o_100sh.jpg",
staffName: '虚拟员工',
operation: '虚拟职位',
staffPhone: 'xxxxxxxx',
image: 'https://img.zcool.cn/community/01e47e60ab5b4011013eaf70962e3f.jpg@520w_390h_1c_1e_2o_100sh.jpg',
qrCode: 'https://img.zcool.cn/community/01e47e60ab5b4011013eaf70962e3f.jpg@520w_390h_1c_1e_2o_100sh.jpg'
},
// 是否授权手机号
hasPhoneNumber: false,
......@@ -61,14 +60,16 @@ Page({
// 增值转化模块
senceData,
productData,
activityList: []
activityList: [],
subscriptionBannerUrl: Object.freeze(subscriptionBannerUrl),
subscriptionSystemData: Object.freeze(subscriptionSystemData)
},
// 一级菜单
introduce(e) {
const curTabIndex = e.currentTarget.dataset.index;
const curTabIndex = e.currentTarget.dataset.index
this.setData({
autoplay: false,
});
autoplay: false
})
console.log(curTabIndex)
// 视频直播是跳转新页面,不需要设置激活样式
// 0-增值转化 1-系统订阅 2-公司介绍 3-视频直播
......@@ -76,21 +77,21 @@ Page({
case 2:
this.setData({
curTabIndex: curTabIndex,
autoplay: true,
});
wx.$Track.sendTrack(this.data.curTab[this.data.curTabIndex]);
break;
autoplay: true
})
wx.$Track.sendTrack(this.data.curTab[this.data.curTabIndex])
break
case 3:
wx.openChannelsUserProfile({
finderUserName: "sphPIdcy0NVpuao",
});
wx.$Track.sendTrack(trackData.VIDEO);
break;
finderUserName: 'sphPIdcy0NVpuao'
})
wx.$Track.sendTrack(trackData.VIDEO)
break
default:
this.setData({
curTabIndex: curTabIndex,
});
wx.$Track.sendTrack(this.data.curTab[this.data.curTabIndex]);
curTabIndex: curTabIndex
})
wx.$Track.sendTrack(this.data.curTab[this.data.curTabIndex])
}
},
......@@ -99,41 +100,46 @@ Page({
// 更新手机号
updatePhoneNumber(e) {
console.log(e);
console.log(e)
if (e.detail) {
this.setData({
hasPhoneNumber: true,
});
hasPhoneNumber: true
})
}
},
// 合作申请
toApplication() {
console.log("合作申请");
console.log('合作申请')
},
// 获取二级菜单下标
getCurrentScen(e) {
console.log(e)
const index = e.detail
wx.$Track.sendTrack(this.data.secondTab[index]);
wx.$Track.sendTrack(this.data.secondTab[index])
},
proClick(e) {
console.log(e, 'proClick')
let { detail } = e
//登录的用户手机号
// let userInfo = wx.$storage.get("userInfo")
const {cardInfo} = this.data
const { cardInfo } = this.data
let obj = {
actNum: detail.scenIndex, //选中的场景
activeNavIdx: detail.id, //选中的产品,
cardInfo
}
wx.$router.go("/packagesList/pages/productDetail/productDetail", obj)
wx.$router.go('/packagesList/pages/productDetail/productDetail', obj)
},
// 跳转视频详情
videoClick(e) {
console.log(e,'000');
const { index, info: {videoUrl}, scenIndex } = e.detail
console.log(e, '000')
const {
index,
info: { videoUrl },
scenIndex
} = e.detail
const videoList = productData[scenIndex][0].videoList
console.log(videoList)
wx.$router.go('/packagesList/pages/videoDetal/videoDetal', {
......@@ -146,28 +152,28 @@ Page({
// 跳转活动页
activityClick(e) {
const {hasPhoneNumber} = this.data
const { hasPhoneNumber } = this.data
const id = e.detail
console.log(e)
wx.$router.go('/packagesList/pages/activityDetail/activityDetail', {hasPhoneNumber, id})
wx.$router.go('/packagesList/pages/activityDetail/activityDetail', { hasPhoneNumber, id })
},
// 场景跳转
senceClick(e) {
const {hasPhoneNumber} = this.data
const { hasPhoneNumber } = this.data
console.log(e)
const {scenIndex} = e.detail
wx.$router.go('/packagesList/pages/scenarioDetail/scenarioDetail', {hasPhoneNumber, actNum: scenIndex})
const { scenIndex } = e.detail
wx.$router.go('/packagesList/pages/scenarioDetail/scenarioDetail', { hasPhoneNumber, actNum: scenIndex })
},
// 获取全部活动列表
getActivityRecord() {
entmicroApi.getActivityRecord({}).then(({data, code, message}) => {
entmicroApi.getActivityRecord({}).then(({ data, code, message }) => {
if (code == -1) {
wx.showToast({
title: message,
icon: "none",
duration: 2000,
});
icon: 'none',
duration: 2000
})
}
this.setData({
activityList: data
......@@ -185,53 +191,54 @@ Page({
.then(({ data }) => {
if (data && data.phone) {
this.setData({
hasPhoneNumber: true,
});
hasPhoneNumber: true
})
}
this.getCardDetail();
this.getCardDetail()
this.getActivityRecord()
});
})
wx.hideShareMenu({
menus: ["shareAppMessage"],
});
menus: ['shareAppMessage']
})
this.setData({
productData: this.addAll(productData),
});
productData: this.addAll(productData)
// productData: productData
})
},
addAll(data) {
for (let i in data) {
let arr = [],
m = [],
n = [];
data[i].map((item) => {
arr = arr.concat(item.productList);
m = item.videoList;
n = item.posterList;
});
n = []
data[i].map(item => {
arr = arr.concat(item.productList)
m = item.videoList
n = item.posterList
})
const allData = {
name: "全部",
name: '全部',
productList: arr,
videoList: m,
posterList: n,
};
data[i].unshift(allData);
posterList: n
}
data[i].unshift(allData)
}
return data;
return data
},
// 咨询
handleOpen() {
this.setData({
showCustomer: true,
});
showCustomer: true
})
},
closeQR() {
console.log(1111);
console.log(1111)
this.setData({
showCustomer: false,
});
showCustomer: false
})
},
/**
......@@ -243,12 +250,12 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
const userInfo = wx.$util.getUserInfo();
const userInfo = wx.$util.getUserInfo()
this.setData({
hasPhoneNumber: !!(userInfo && userInfo.phone),
});
const options = wx.getEnterOptionsSync();
wx.$trackData = options.query;
hasPhoneNumber: !!(userInfo && userInfo.phone)
})
const options = wx.getEnterOptionsSync()
wx.$trackData = options.query
if (wx.$trackData.merchant) {
wx.$Track.sendTrack(this.data.curTab[this.data.curTabIndex])
if (this.data.curTabIndex == 0) {
......@@ -281,48 +288,47 @@ Page({
* 用户点击右上角分享
*/
onShareAppMessage() {
const cardId = wx.$storage.get("scene").cardId;
const cardId = wx.$storage.get('scene').cardId
// merchantId 兼容旧链接
const merchant =
wx.$storage.get("scene").merchant || wx.$storage.get("scene").merchantId;
const shareType = "SHARE_HOME";
console.log("cardId", cardId, "merchant", merchant);
const merchant = wx.$storage.get('scene').merchant || wx.$storage.get('scene').merchantId
const shareType = 'SHARE_HOME'
console.log('cardId', cardId, 'merchant', merchant)
return {
title: `您好,我向你推荐了广联数科${this.data.cardInfo.staffName}的智能名片~`,
imageUrl: this.data.shareImg,
path: `pages/tab/index/index?cardId=${cardId}&merchant=${merchant}&shareType=${shareType}`,
};
path: `pages/tab/index/index?cardId=${cardId}&merchant=${merchant}&shareType=${shareType}`
}
},
setShareInfo(data = {}) {
const canvasWidth = 208,
canvasHeight = 166,
textBaseline = "top";
textBaseline = 'top'
const draw_function = new Draw(this, {
width: canvasWidth,
height: canvasHeight,
height: canvasHeight
// pixelRatio: 2,
// backgroundColor: '#096'
});
const drawCard = (callBack) => {
let index = 0;
})
const drawCard = callBack => {
let index = 0
const iconWidth = 9,
iconHeight = 9,
iconX = 18,
iconY = 79,
imgList = [
{
url: "https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/share/bg.png",
url: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/share/bg.png',
x: 0,
y: 0,
width: canvasWidth,
height: 124,
height: 124
},
{
url: "https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/share/logo.png",
url: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/share/logo.png',
x: 15,
y: 18,
width: 152,
height: 10,
height: 10
},
// 头像的
{
......@@ -331,129 +337,129 @@ Page({
x: 154,
y: 36,
width: 36,
height: 36,
height: 36
},
{
url: "https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/share/icon-phone.png",
url: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/share/icon-phone.png',
x: iconX,
y: iconY,
width: iconWidth,
height: iconHeight,
height: iconHeight
},
{
url: "https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/share/icon-address.png",
url: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/share/icon-address.png',
x: iconX,
y: iconY + 13,
width: iconWidth,
height: iconHeight,
height: iconHeight
},
{
url: "https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/share/btn.png",
url: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/share/btn.png',
x: 64,
y: 138,
width: 80,
height: 24,
},
height: 24
}
],
textList = [
{
text: data.staffName,
x: 18,
y: 40,
color: "#2D2D33",
color: '#2D2D33',
fontWeight: 600,
fontSize: 14,
fontSize: 14
},
{
text: data.operation,
x: 22 + draw_function.getTextWidth(data.staffName, 14),
y: 44,
color: "#6E6E7A",
color: '#6E6E7A',
fontWeight: 400,
fontSize: 8,
fontSize: 8
},
{
text: data.staffPhone,
x: 30,
y: 80,
color: "#6E6E7A",
fontSize: 7,
color: '#6E6E7A',
fontSize: 7
},
{
text: "深圳市南山区留仙大道3370号南山智园崇文园区1号楼14层",
text: '深圳市南山区留仙大道3370号南山智园崇文园区1号楼14层',
x: 30,
y: 94,
color: "#6E6E7A",
color: '#6E6E7A',
fontSize: 7,
lineNum: 2,
width: 185,
lineHeight: 9,
},
];
const drawImages = (callBack) => {
lineHeight: 9
}
]
const drawImages = callBack => {
draw_function.drawImages(imgList[index], () => {
index += 1;
if (index != imgList.length) drawImages(callBack);
else callBack();
});
};
index += 1
if (index != imgList.length) drawImages(callBack)
else callBack()
})
}
drawImages(() => {
try {
textList.map((e, ind) => {
e.textBaseline = textBaseline;
draw_function.drawText(e);
if (ind == textList.length - 1) throw true;
});
e.textBaseline = textBaseline
draw_function.drawText(e)
if (ind == textList.length - 1) throw true
})
} catch (error) {
draw_function.toDataURL(({ path }) => {
this.setData(
{
shareImg: path,
shareDisabled: false,
shareDisabled: false
},
() => {
wx.showShareMenu({
menus: ["shareAppMessage"],
});
menus: ['shareAppMessage']
})
}
);
});
)
})
}
});
};
drawCard();
})
}
drawCard()
},
// 获取员工名片信息
getCardDetail() {
console.log(wx.showMeasure);
console.log(wx.showMeasure)
this.setData({
"tabList[3].isShow": wx.showMeasure,
});
console.log(wx.$storage.get("scene"), wx.$trackData.cardId);
const scene = wx.$storage.get("scene");
'tabList[3].isShow': wx.showMeasure
})
console.log(wx.$storage.get('scene'), wx.$trackData.cardId)
const scene = wx.$storage.get('scene')
let params = {
cardId: wx.$trackData.cardId || scene.cardId,
};
cardId: wx.$trackData.cardId || scene.cardId
}
entmicroApi.getCardDetail(params).then(({ data, code, message }) => {
wx.hideLoading();
wx.hideLoading()
if (code == -1) {
wx.showToast({
title: message,
icon: "none",
duration: 2000,
});
icon: 'none',
duration: 2000
})
}
const cardInfo = data || this.data.defaultInfo;
console.log(data, cardInfo);
const cardInfo = data || this.data.defaultInfo
console.log(data, cardInfo)
this.setData(
{
cardInfo,
cardInfo
},
() => {
this.setShareInfo(cardInfo);
this.setShareInfo(cardInfo)
}
);
});
},
});
)
})
}
})
<!-- pages/tab/index/index.wxml -->
<view class="loadding" wx:if="{{!cardInfo}}">
<glsx-image custom-class="loadding-img" src="home/loadding.webp"></glsx-image>
<glsx-image custom-class="loadding-img" src="home/loadding.webp" />
<view>努力加载中</view>
</view>
<block wx:if="{{!!cardInfo}}">
<view class="main-box">
<user-info shareDisabled="{{shareDisabled}}" cardInfo="{{cardInfo}}"></user-info>
<user-info shareDisabled="{{shareDisabled}}" cardInfo="{{cardInfo}}" />
<view class="main-bottom">
<!-- tab介绍 -->
<view class="tab-list">
<block wx:for="{{tabList}}" wx:key="index">
<view class="tab-item {{curTabIndex === index ? 'tab-item-active' : '' }}" data-name="{{item}}" data-index="{{index}}" bindtap="introduce">
<image wx:if="{{curTabIndex !== index}}" class="tab-img" mode="widthFix" webp src="{{IMGURL}}home/{{item.icon1}}.png?v={{img_version}}"></image>
<image wx:else class="tab-img" mode="widthFix" webp src="{{IMGURL}}home/{{item.icon}}.png?v={{img_version}}"></image>
<image wx:if="{{curTabIndex !== index}}" class="tab-img" mode="widthFix" webp src="{{IMGURL}}home/{{item.icon1}}.png?v={{img_version}}" />
<image wx:else class="tab-img" mode="widthFix" webp src="{{IMGURL}}home/{{item.icon}}.png?v={{img_version}}" />
<view class="tab-text">{{item.name}}</view>
</view>
</block>
......@@ -20,34 +20,34 @@
<view class="main-content">
<block wx:if="{{curTabIndex == 0}}">
<!-- 增值转化 -->
<gl-scenario productData="{{productData}}" senceData="{{senceData}}" activityList="{{activityList}}" bindactivityClick="activityClick" bind:proClick="proClick" bind:videoClick="videoClick" bind:senceClick="senceClick" bindcurrentScen="getCurrentScen">
</gl-scenario>
<gl-scenario productData="{{productData}}" senceData="{{senceData}}" activityList="{{activityList}}" bindactivityClick="activityClick" bind:proClick="proClick" bind:videoClick="videoClick" bind:senceClick="senceClick" bindcurrentScen="getCurrentScen" />
<!-- <scenario productData="{{productData}}" senceData="{{senceData}}">
<activity-info slot="swiper"></activity-info>
</scenario> -->
</block>
<block wx:if="{{curTabIndex == 1}}">
<gl-subscription list="{{productData[0]}}" menuClick="sysMenuClick" bannerUrl="{{'https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/index/banner/banner0.png'}}"></gl-subscription>
<!-- menuClick="sysMenuClick" -->
<gl-subscription list="{{subscriptionSystemData}}" bannerUrl="{{subscriptionBannerUrl}}" bindactivityClick="activityClick" bind:proClick="proClick" bind:videoClick="videoClick" bind:senceClick="senceClick" bindcurrentScen="getCurrentScen" />
</block>
<block wx-if="{{curTabIndex == 2}}">
<company-introduce autoplay="{{autoplay}}"></company-introduce>
<company-introduce autoplay="{{autoplay}}" />
</block>
</view>
</view>
<!-- 服务咨询 -->
<view class="floating-box">
<image class="floating-icon" style="margin-bottom: 10rpx;" webp bindtap="toStoreMiniProgram" src="{{IMGURL}}home/icon-store.png?v={{img_version}}"></image>
<image class="floating-icon" bindtap="toBusinessMiniProgram" webp src="{{IMGURL}}home/icon-business.png?v={{img_version}}"></image>
<image class="floating-icon" bindtap="handleOpen" webp src="{{IMGURL}}home/custom.png?v={{img_version}}"></image>
<image class="floating-icon" style="margin-bottom: 10rpx;" webp bindtap="toStoreMiniProgram" src="{{IMGURL}}home/icon-store.png?v={{img_version}}" />
<image class="floating-icon" bindtap="toBusinessMiniProgram" webp src="{{IMGURL}}home/icon-business.png?v={{img_version}}" />
<image class="floating-icon" bindtap="handleOpen" webp src="{{IMGURL}}home/custom.png?v={{img_version}}" />
</view>
</view>
<!-- 服务咨询 -->
<view class="floating-box">
<image class="floating-icon" style="margin-bottom: 10rpx;" webp bindtap="toStoreMiniProgram" src="{{IMGURL}}home/icon-store.png?v={{img_version}}"></image>
<image class="floating-icon" bindtap="toBusinessMiniProgram" webp src="{{IMGURL}}home/icon-business.png?v={{img_version}}"></image>
<image class="floating-icon" bindtap="handleOpen" webp src="{{IMGURL}}home/custom.png?v={{img_version}}"></image>
<image class="floating-icon" style="margin-bottom: 10rpx;" webp bindtap="toStoreMiniProgram" src="{{IMGURL}}home/icon-store.png?v={{img_version}}" />
<image class="floating-icon" bindtap="toBusinessMiniProgram" webp src="{{IMGURL}}home/icon-business.png?v={{img_version}}" />
<image class="floating-icon" bindtap="handleOpen" webp src="{{IMGURL}}home/custom.png?v={{img_version}}" />
</view>
<phone-number type="{{'home'}}" bindtoApplication="toApplication" hasPhoneNumber="{{hasPhoneNumber}}"></phone-number>
<phone-number type="{{'home'}}" bindtoApplication="toApplication" hasPhoneNumber="{{hasPhoneNumber}}" />
<!-- 客服咨询 -->
<customer wx:if="{{showCustomer}}" qrCode="{{cardInfo.qrCode}}" bindcloseQR="closeQR"></customer>
<customer wx:if="{{showCustomer}}" qrCode="{{cardInfo.qrCode}}" bindcloseQR="closeQR" />
</block>
\ No newline at end of file
const _routeHooks = Symbol("_routeHooks");
const _query = Symbol("_query");
const _routerList = Symbol("_routerList");
import util from "../utils/util.js";
const generateRoutList = (routerList) => {
let _routerList = routerList;
const tabBarList = __wxConfig?.tabBar?.list || []
const _routeHooks = Symbol('_routeHooks')
const _query = Symbol('_query')
const _routerList = Symbol('_routerList')
import util from '../utils/util.js'
const generateRoutList = routerList => {
let _routerList = routerList
const tabBarList = __wxConfig?.tabBar?.list || []
try {
_routerList = routerList.map((item) => {
let obj = {};
if (item.parent != "__plugin__") {
obj = {
...item,
isTab: tabBarList.some(({ pagePath }) =>
item.url.includes(pagePath.replace(".html", ""))
),
};
if (item.parent !== "pages") {
let parentList = item.url.split(`/`);
if (parentList.length > 5) {
item.url = item.url.replace(/\/__plugin__\/[a-z0-9A-Z]+/, "");
obj.subPages = item.url
.split(`/${item.parent}/pages/`)[1]
.split("/")[0];
}
_routerList = routerList.map(item => {
let obj = {}
if (item.parent != '__plugin__') {
obj = {
...item,
isTab: tabBarList.some(({ pagePath }) => item.url.includes(pagePath.replace('.html', '')))
}
if (item.parent !== 'pages') {
let parentList = item.url.split(`/`)
if (parentList.length > 5) {
item.url = item.url.replace(/\/__plugin__\/[a-z0-9A-Z]+/, '')
obj.subPages = item.url.split(`/${item.parent}/pages/`)[1].split('/')[0]
}
}
return obj;
});
}
return obj
})
} catch (err) {}
return _routerList;
};
return _routerList
}
class Router {
[_query] = {};
[_routeHooks] = [];
[_routerList] = [];
[_routerList] = []
constructor(router) {
this[_routerList] = generateRoutList(router);
this[_routerList] = generateRoutList(router)
wx.onAppRoute &&
wx.onAppRoute((e) => {
let thisPage = this.getPageInstance();
wx.onAppRoute(e => {
let thisPage = this.getPageInstance()
if (thisPage) {
if (!wx.$version)
util.getMockConfig().then(({ version }) => {
wx.$version = version || "1.0.0";
wx.$version = version || '1.0.0'
thisPage.setData({
img_version: wx.$version,
});
});
else{
img_version: wx.$version
})
})
else {
thisPage.setData({
img_version: wx.$version,
});
img_version: wx.$version
})
}
thisPage.setData({
IMGURL: wx.$imgUrl,
});
IMGURL: wx.$imgUrl
})
wx.hideHomeButton()
this.setNavigationBarTitleText(thisPage);
let onRoute = thisPage.onRoute;
thisPage.$query = this[_query];
typeof onRoute === "function" && onRoute(this[_query]);
let userInfo = util.getUserInfo();
this.setNavigationBarTitleText(thisPage)
let onRoute = thisPage.onRoute
thisPage.$query = this[_query]
typeof onRoute === 'function' && onRoute(this[_query])
let userInfo = util.getUserInfo()
if (userInfo && userInfo.phone) {
if (wx.$authStatus) {
thisPage.setData({
userInfo: null,
});
userInfo: null
})
} else {
thisPage.setData({
userInfo,
});
if (thisPage.init) thisPage.init(userInfo);
userInfo
})
if (thisPage.init) thisPage.init(userInfo)
}
}
}
this[_routeHooks].forEach((fn) => {
this[_routeHooks].forEach(fn => {
try {
typeof fn === "function" && fn(e, this[_query], this[_routerList]);
typeof fn === 'function' && fn(e, this[_query], this[_routerList])
} catch (err) {
console.log(err);
console.log(err)
}
});
this[_query] = {};
});
})
this[_query] = {}
})
}
/**设置标题栏 */
setNavigationBarTitleText(thisPage) {
let title = wx.$util.getNavigationBarTitleText();
if (wx.$util.getUserInfo()) title = wx.$util.getUserInfo().merchantName;
const router = `${thisPage.__route__}.html`;
let title = wx.$util.getNavigationBarTitleText()
if (wx.$util.getUserInfo()) title = wx.$util.getUserInfo().merchantName
const router = `${thisPage.__route__}.html`
if (__wxConfig && __wxConfig.page && __wxConfig.page[router]) {
let { navigationBarTitleText, navigationStyle } = __wxConfig.page[
router
].window;
if (!title) title = "";
let { navigationBarTitleText, navigationStyle } = __wxConfig.page[router].window
if (!title) title = ''
if (!navigationBarTitleText && !navigationStyle)
wx.setNavigationBarTitle({
title,
});
title
})
}
}
/**获取页面对象实例 */
getPageInstance = (size = 1) => {
const pages = getCurrentPages();
return pages[pages.length - size];
};
const pages = getCurrentPages()
return pages[pages.length - size]
}
checkRouter(route, events) {
this[_query] = events || {}
const [_parent, _name, last_name] = route.split('.')
......@@ -144,87 +138,86 @@ class Router {
/**跳转至H5 */
jumpH5(url) {
wx.navigateTo({
url: `/pages/webView/webView?url=${encodeURIComponent(url)}`,
});
url: `/pages/webView/webView?url=${encodeURIComponent(url)}`
})
}
/**页面跳转
*
*/
jump(e) {
const item = e.currentTarget.dataset;
this.go(item.url, item);
const item = e.currentTarget.dataset
this.go(item.url, item)
}
/**
* 跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面 ||
* 保留当前页面,跳转到应用内的某个页面。但是不能跳到 tabbar 页面。使用 $router.back() 可以返回到原页面。小程序中页面栈最多十层
*/
go(route, events) {
console.log(route, events)
let { routerMapItem, query } = this.checkRouter(route, events);
console.log(routerMapItem)
// console.log(route, events)
let { routerMapItem, query } = this.checkRouter(route, events)
// console.log(routerMapItem)
if (routerMapItem.isTab) {
wx.switchTab({
url: routerMapItem.url,
});
url: routerMapItem.url
})
} else {
wx.navigateTo({
url: `${routerMapItem.url}${query}`,
success: (res) => events && res.eventChannel.emit("getData", events),
});
success: res => events && res.eventChannel.emit('getData', events)
})
}
}
/**关闭所有页面,打开到应用内的某个页面 */
reLaunch(route, events) {
let { routerMapItem, query } = this.checkRouter(route, events);
let { routerMapItem, query } = this.checkRouter(route, events)
wx.reLaunch({
url: `${routerMapItem.url}${query}`,
});
url: `${routerMapItem.url}${query}`
})
}
/**关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面。 */
redirectTo(route, events) {
let { routerMapItem, query } = this.checkRouter(route, events);
let { routerMapItem, query } = this.checkRouter(route, events)
wx.redirectTo({
url: `${routerMapItem.url}${query}`,
});
url: `${routerMapItem.url}${query}`
})
}
/**prevPageSize = 1
* 返回上prevPageSize页
* callBack返回上prevPageSize页对象 */
back(callBack, prevPageSize = 1) {
let prevPage = this.getPageInstance(Number(prevPageSize) + 1);
if (callBack && "function" === typeof callBack) callBack(prevPage);
let prevPage = this.getPageInstance(Number(prevPageSize) + 1)
if (callBack && 'function' === typeof callBack) callBack(prevPage)
wx.navigateBack({
delta: prevPageSize,
}).catch((err) => {
this.goHome();
});
delta: prevPageSize
}).catch(err => {
this.goHome()
})
}
goHome() {
let [index] = this[_routerList];
let [index] = this[_routerList]
wx.switchTab({
url: index.url,
});
url: index.url
})
}
/**获取上一个页面传的数据 */
getData(callBack) {
const data = this.getPageInstance().getOpenerEventChannel();
if (Object.keys(data).length !== 0)
data.on("getData", (res) => callBack(res));
const data = this.getPageInstance().getOpenerEventChannel()
if (Object.keys(data).length !== 0) data.on('getData', res => callBack(res))
}
onRoute(fn) {
this[_routeHooks].push(fn);
this[_routeHooks].push(fn)
return () => {
const i = list.indexOf(fn);
if (i > -1) list.splice(i, 1);
};
const i = list.indexOf(fn)
if (i > -1) list.splice(i, 1)
}
}
async intercept() {
const isAuth = !!wx.$authStatus;
const isAuth = !!wx.$authStatus
this.getPageInstance().setData({
showLogin: isAuth,
});
return isAuth;
showLogin: isAuth
})
return isAuth
}
}
export default Router;
export default Router
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!