Commit 29d5d981 by 张立顺

订阅模块功能开发

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