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
} }
<!-- 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!