Commit 82ee14d0 by luyt

feat:添加看产品首页

1 parent c152eeda
import api from "./request";
const serverApi = {
//生成二维码
createQrCode: "scrm.api.wechat.miniprogram.createQrcode",
// 解析二维码参数
sceneById:'scrm.api.wechat.get.scene.by.id'
};
export const createQrCodeApi = (data) => {
return api.post(
{
method: serverApi.createQrCode,
...data,
},
true
);
};
export const sceneByIdApi = (data) => {
return api.post(
{
method: serverApi.sceneById,
...data,
}
);
};
\ No newline at end of file \ No newline at end of file
...@@ -7,11 +7,20 @@ import { ...@@ -7,11 +7,20 @@ import {
wechatApi wechatApi
} from './api/api' } from './api/api'
import {trackData} from './utils/data' import {trackData} from './utils/data'
import eventbus from './utils/evenbus'
// 实例化对象存储
import { Storage } from './utils/cache/storage'
const $Storage = new Storage()
App({ App({
onLaunch: function (options) { onLaunch: function (options) {
console.log(options) console.log(options)
/**挂载到wx对象 */ /**挂载到wx对象 */
this.autoUpdate() this.autoUpdate()
wx.$storage = $Storage /** 挂载全局缓存方法 */
wx.$eventbus = eventbus
wx.$util = util wx.$util = util
wx.$router = router wx.$router = router
wx.$imgUrl = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/' wx.$imgUrl = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/'
......
...@@ -21,7 +21,9 @@ ...@@ -21,7 +21,9 @@
"pages/activityApplication/activityApplication", "pages/activityApplication/activityApplication",
"pages/newEnergy/newEnergy", "pages/newEnergy/newEnergy",
"pages/measure/measure/measure", "pages/measure/measure/measure",
"pages/measure/measureResult/measureResult" "pages/measure/measureResult/measureResult",
"pages/scene/scene",
"pages/checkProduct/checkProduct"
], ],
"window": { "window": {
"backgroundTextStyle": "light", "backgroundTextStyle": "light",
...@@ -31,7 +33,12 @@ ...@@ -31,7 +33,12 @@
}, },
"usingComponents": { "usingComponents": {
"authorize": "components/Authorize/Authorize", "authorize": "components/Authorize/Authorize",
"phone-number": "components/PhoneNumber/PhoneNumber" "phone-number": "components/PhoneNumber/PhoneNumber",
"tab": "/components/Tab/Tab",
"navigation-bar": "/components/NavigationBar/NavigationBar"
},
"resolveAlias": {
"~/*": "/*"
}, },
"sitemapLocation": "sitemap.json", "sitemapLocation": "sitemap.json",
"lazyCodeLoading": "requiredComponents" "lazyCodeLoading": "requiredComponents"
......
@import "/style/common.wxss";
page {
background-color: #F7F7F7;
color: #282829;
font-size: 28rpx;
--themeColor: #F13C3D;
--btnColor: #3666FE;
--borderRadius: 8rpx;
--margin: 32rpx;
}
image {
width: 100%;
height: 100%;
vertical-align: top;
}
.icon-mine-arrow {
width: 16rpx !important;
height: 28rpx !important;
transform: translateY(7rpx);
}
.box-center{ .box-center{
position: absolute; position: absolute;
top: 50%; top: 50%;
......
// components/navigationBar/navigationBar.js
Component({
/**
* 组件的属性列表
*/
properties: {
navStyle: String,
custom: Boolean,
showBack: Boolean,
pageTitle: {
type: String,
value: '',
observer(n) {
if (n) {
this.title = n
this.setPageTitle()
}
}
}
},
title: '',
/**
* 组件的初始数据
*/
data: {},
/**
* 组件的方法列表
*/
methods: {
setPageTitle() {
let thisPage = wx.$router.getPageInstance()
if (thisPage) thisPage.navigationBarTitleText = this.title
},
init() {
/**
* 获取自定义导航栏信息
*/
wx.getSystemInfo().then(res => {
let {
fontSizeSetting,
statusBarHeight,
screenWidth
} = res
const {
height,
right,
width,
top
} = wx.getMenuButtonBoundingClientRect(),
currentPages = getCurrentPages(), {
showBack
} = this.data
if (showBack && currentPages.length > 1) this.setData({
SHOWBACK: true
})
let navigationBarHeight = height + ((top - statusBarHeight) * 2) + 4 // 4
let navigationBarPadding = screenWidth - right
let navigationBarWidth = screenWidth - (navigationBarPadding * 2 + width) - width
this.setData({
statusBarHeight,
navigationBarHeight,
navigationBarStyle: `font-size:${fontSizeSetting}px;`,
navigationBarTextWidth: `width:${navigationBarWidth}px;padding:0 ${navigationBarPadding}px;`
})
this.emit({
navigationBarHeight,
statusBarHeight
})
})
},
emit({
navigationBarHeight,
statusBarHeight
}) {
let navHeight = navigationBarHeight + statusBarHeight
const thisPage = wx.$router.getPageInstance()
this.triggerEvent('navbarReady', {
height: navHeight,
statusBarHeight
})
this.setData({
showNavBar: true
})
thisPage.setData({
navHeight,
statusBarHeight
})
},
back() {
wx.$router.back()
}
},
lifetimes: {
attached() {
this.init()
this.setPageTitle()
}
}
})
\ No newline at end of file \ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<view class="navigation-bar" id="navigation-bar" style="padding-top:{{statusBarHeight}}px;height:{{navigationBarHeight}}px;{{navStyle}}">
<block wx:if="{{!custom}}">
<view class="navigation-bar-box" wx:if="{{showNavBar}}" style="{{navigationBarStyle}}">
<block wx:if="{{SHOWBACK}}">
<view class="back " bindtap="back">
<image class="img" src="./images/icon-back.png" />
</view>
</block>
<view class="navigation-bar-titleText" style="{{navigationBarTextWidth}}">
<slot/>
</view>
</view>
</block>
<block wx:else>
<slot/>
</block>
</view>
/* components/navigationBar/navigationBar.wxss */
.navigation-bar {
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 99;
background-color: #fff;
transition: all .15s;
}
.navigation-bar-box {
position: relative;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
.navigation-bar-titleText {
color: #333333;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-weight: 500;
box-sizing: border-box;
text-align: center;
letter-spacing: 1rpx;
}
.back-box {
width: 76rpx;
height: 100%;
position: absolute;
left: 0;
top: 0;
}
.back {
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 100rpx;
/* height: 34rpx; */
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.back .img {
width: 16rpx;
height: 34rpx;
}
\ No newline at end of file \ No newline at end of file
// components/Tab/Tab.js
// behaviors: [LocationBehavior],
// import { imgUrlMixin } from '~/mixins/index'
Component({
// behaviors: [imgUrlMixin],
options: {
addGlobalClass: true
},
/**
* 组件的属性列表
*/
properties: {
outClassName:String,
tab: Array,
openScroll: Boolean,
tabHeight: {
type: Boolean,
value: false
},
productHeight: {
type: Boolean,
value: false
},
index: {
type: Number,
observer: function (n) {
this.setData({
count: n,
to: `to-${n}`
})
}
},
itemWidth: String,
align: {
type: String,
value: ''
},
// 是否有红点
unreadClueCount: {
type: Number,
value: 0
},
},
/**
* 组件的初始数据
*/
data: {
count: 0,
to: '',
// IMGURL:
},
// lifetimes:{
// attached: function() {
// console.log('unreadClueCount',this.data.unreadClueCount)
// }
// },
/**
* 组件的方法列表
*/
methods: {
click(e) {
let { count } = e.currentTarget.dataset
this.setData({
count,
to: `to-${count}`,
unreadClueCount:0
})
this.triggerEvent('click', count)
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<wxs src="./Tab.wxs" module="filterUtils" />
<block wx:if="{{openScroll}}">
<scroll-view
class="tab-box {{align}} {{outClassName}}"
style="{{productHeight ? 'height: 72rpx;' : ''}}"
scroll-x
enable-flex
scroll-with-animation
scroll-into-view="{{to}}"
enhanced="{{true}}"
show-scrollbar="{{false}}">
<block wx:for="{{tab}}" wx:key="index">
<view
class="tab {{index==count?'active':''}}"
bindtap="click"
data-count="{{index}}"
id="to-{{index}}"
>
<view class="text" style="{{productHeight ? 'height: 60rpx;' : ''}}">{{item}}</view>
<!-- <view class="text" style="width:{{38 * item.length + 20}}rpx;">{{item}}</view> -->
<view class="line" style="{{productHeight ? 'height: 4rpx;' : ''}}" />
</view>
</block>
</scroll-view>
</block>
<block wx:else>
<view class="tab-box flex" style="{{tabHeight ? 'height: 60rpx;' : ''}}">
<block wx:for="{{tab}}" wx:key="index">
<view
class="tab {{index==count?'active':''}}"
style="width:{{itemWidth}}; {{index == 0 ? 'margin-left: 32rpx;' : ''}}"
bindtap="click"
data-count="{{index}}"
>
<view class="text text-center" style="{{tabHeight ? 'height: 60rpx;' : ''}}">
{{item}}
</view>
<view class="line" style="{{tabHeight ? 'margin-top: 6rpx;' : ''}}" />
<!-- -->
<view wx:if="{{filterUtils.hasRedpoint(unreadClueCount)}}" class="redpoint" />
</view>
</block>
</view>
</block>
var hasRedpoint = function (unreadClueCount) {
// console.log('unreadClueCount: ', unreadClueCount);
if(unreadClueCount>0){
return true
}else{
return false;
}
};
module.exports = {
hasRedpoint: hasRedpoint,
};
/* components/Tab/Tab.wxss */
.tab-box {
display: flex;
/* display: grid; */
width: 100%;
height: 92rpx;
box-sizing: border-box;
}
.tab-box.left {
padding-left: 32rpx;
}
.left .tab {
padding-right: 40rpx;
}
/* .flex .tab {
flex: 1;
} */
.tab {
position: relative;
flex-shrink: 0;
}
.tab .text {
height: 84rpx;
display: flex;
align-items: center;
box-sizing: border-box;
color: #A9A9A9;
justify-content: center;
}
.left .text {
justify-content: flex-start;
}
.flex .tab .text {
padding: 0;
}
.tab.active .text {
/* font-weight: 500; */
font-weight: 600;
font-size: 44rpx;
transition: all .25s;
color: #2C2C2C;
font-family: PingFangSC-S0pxibold;
}
.tab .line {
width: 48rpx;
height: var(--borderRadius);
background: var(--btnColor);
border-radius: 2rpx;
margin: 0 auto;
transform: scale(0);
transition: all .25s;
}
.tab.active .line {
transform: scale(1);
}
.tab-box::-webkit-scrollbar {
display: none;
width: 0;
height: 0;
color: transparent;
}
.active .redpoint{
display: none;
}
.redpoint {
position: absolute;
top: 10px;
right: 5px;
/* top: 8px;
right: 10px; */
width: 10px;
height: 10px;
background: #EB4E4E;
border-radius: 50%;
}
/* 外部出进来的自定义样式 */
.project-tab{
padding-left: 20px;
padding-right: 20px;
}
.project-tab .tab {
margin-right: 28px;
}
.project-tab .tab.active .text {
font-size: 28rpx;
color: var(--btnColor);
}
.project-tab .tab .line{
width:auto;
}
// pages/checkProduct/checkProduct.js
// const navStyle = "background-color: transparent;";
const navStyle = "background-color: #fff";
import { senceData } from "~/pages/scene/constant/data.js";
// import { IMG_URL } from "~/utils/constantData.js";
// import { productBysceneApi } from '~/api/index.js'
import Draw from "~/utils/Draw_new.js";
import { createQrCodeApi, sceneByIdApi } from "~/api/checkProduct.js";
import utils from "~/utils/util.js";
let IMG_URL = wx.$imgUrl
Page({
/**
* 页面的初始数据
*/
noPageAuth: true,
data: {
navStyle,
headerHeight: 0,
senceData,
// 模态框
isShow: false,
// IMG_URL: `${IMG_URL}index`,
btnList: [
{
src: `${IMG_URL}index/down.png`,
name: "下载海报",
},
{
src: `${IMG_URL}index/wechat.png`,
name: "转发给好友",
},
// {
// src: `${IMG_URL}index/moments.png`,
// name: "朋友圈分享",
// },
],
// 4种场景下图片所有的高 (单位 rpx)
imgHeightArr: [
[1110, 1290, 596, 744, 490, 1532],
[2168, 1290, 596, 830, 490, 752],
[1110, 1290, 596, 984, 490],
[678, 1266, 1398, 830, 490, 1666],
],
posterUrl: "", //海报url
noVideoimgList: [],
//分享相关
isShare: false,
// 是否授权昵称
hasUserInfo: false,
phone: "", //授权手机号
userInfo: "",
isAuthphone: true, //授权昵称弹窗显示,更多按钮显示
},
observers: {
actNum: function (actNum) {
let imgList = [
`${IMG_URL}index/scene${actNum + 1}1.png`,
`${IMG_URL}index/scene${actNum + 1}2.png`,
`${IMG_URL}index/scene${actNum + 1}3.png`,
`${IMG_URL}index/scene${actNum + 1}4.png`,
`${IMG_URL}index/scene${actNum + 1}5.png`,
];
this.setData({
noVideoimgList: imgList,
});
if (actNum != 2) {
imgList.push(`${IMG_URL}index/scene${actNum + 1}6.png`);
}
this.setData({
imgList,
});
},
},
// navbar高度设置
navbarReady(e) {
let { height, statusBarHeight } = e.detail;
this.setData({
headerHeight: height / 2 + statusBarHeight,
// headerHeight: height / 2 + statusBarHeight,
// headerHeight: height / 2 + statusBarHeight + 88 * 2,
});
// console.log(e)
// console.log(this.data.headerHeight)
},
// 分项弹框关闭
modelcloseFn(e) {
this.setData({
isShow: false,
});
},
// 分享按钮
sharehandle() {
this.setData({
isShow: true,
});
},
//如果是直接查看页面,获取合成apiData
getData() {
console.log(123456)
// 看产品
this.compositionData(senceData, [])
// productBysceneApi().then(res => {
// let { code, data } = res
// if (code == 0 && data) {
// // this.setData({
// // apiData: data
// // })
// this.compositionData(senceData, data)
// // this.getFirstSenceIndex();
// }
// })
},
//接口数据,本地数据对接
compositionData(localData, apiData) {
localData.forEach((item, index) => {
apiData.forEach((inner, idx) => {
if (item.name == inner.stage) {
item.sceneStatus = inner.sceneStatus
item.productList.forEach((outChild, outIndex) => {
inner.productList.forEach((innerChild, innerIndex) => {
if (outChild.proName == innerChild.productName) {
outChild.productStatus = innerChild.productStatus
}
})
})
}
})
})
// console.log('localData, apiData: ', localData);
this.setData({
senceData: localData
})
},
//接受跳转的路由参数(小程序页面跳转)
onRoute(options) {
console.log("分享options: ", options);
if (!options || utils.isEmptyObj(options)) return;
// if(!Object.keys(options).includes('actNum'))return
let {senceData} = this.data
//选中场景的index,和产品的index
let {
actNum,
activeNavIdx,
// apiData,
outshowVideo,
isShow
// origin //跳转来源 home
} = options;
// if(actNum&&activeNavIdx)return
// 设置标题
let userInfoObj = wx.$storage.get('userInfo')
// #服务商账号#取该分享者商户的联系人字段,无则取商户简称,无则取商户全称
let name
if (userInfoObj.name) {
name = userInfoObj.name
}else if(userInfoObj.merchantName){
name = userInfoObj.merchantName
}else if(userInfoObj.merchantName){
//全称
name = userInfoObj.merchantName
}
this.shareTitle = `${name}给你分享一个活动${senceData[actNum]?.productList[activeNavIdx].proName},戳我参与~`;
this.getImgInfo(actNum)
this.setData({
actNum,
activeNavIdx,
// apiData,
outshowVideo,
isShow
// origin
// isShare
});
// let apiDataJson = JSON.stringify(apiData);
let item = senceData[actNum]?.productList[activeNavIdx];
this.shareQuery = `sceneCode=${senceData[actNum].sceneCode}&productCode=${
item?.productCode
}&isShare=${true}&productDesc=${item?.productName}&category=${
item?.category
}&actNum=${actNum}&activeNavIdx=${activeNavIdx}`;
this.shareTrackData = {
sceneCode: senceData[actNum]?.sceneCode,
productCode: item?.productCode,
productName: item?.productName,
category: item?.category,
productDesc: item?.productName,
// actNum,
// activeNavIdx,
// apiData,
};
},
// 分享按钮
handleClick(e) {
let { index } = e.currentTarget.dataset;
let _this = this
switch (index) {
case 0:
wx.showModal({
content: '确认下载海报?',
success: async (res) => {
if(res.confirm){
// let hasAuth = await _this.toSetting()
// if(hasAuth){
_this.download()
// }
}
},
fail: (res) => {},
complete: (res) => {},
})
// this.download();
break;
case 1:
this.wechatFn();
break;
}
},
//授权添加相册
toSetting(){
return new Promise((resolve,reject)=>{
wx.getSetting({
success: (res)=> {
if(res.authSetting['scope.writePhotosAlbum']){
resolve(true)
}else{
wx.openSetting({
success :(resp)=> {
if(resp.authSetting['scope.writePhotosAlbum']){
resolve(true)
}else{
wx.showToast({
title: "下载海报前需要您授权'添加到相册'权限",
icon: "none",
duration: 2500,
});
}
}
})
}
}
})
})
},
// 微信转发
wechatFn() {
// this.data.onShareAppMessage()
// this.modelcloseFn();
},
// 下载海报
async download() {
let { actNum, activeNavIdx, imgHeightArr ,imgPath} = this.data;
const { appId } = wx.getAccountInfoSync().miniProgram
let { userInfo } = wx.$storage.get()
// let wx_user_info = wx.$storage.get("wx_user_info");
// console.log('wx_user_info: ', wx_user_info.appId);
wx.showLoading({
title: "海报生成中...",
});
let params = {
actNum,
activeNavIdx,
isShare: true,
};
// console.log(' wx_user_info.appId', wx_user_info)
let res = await createQrCodeApi({
appId: appId,
// appId:'wx2c28337db96364d2',
path: "pages/checkProduct/checkProduct",
scene: JSON.stringify(params),
});
let _this = this;
wx.getImageInfo({
src: imgPath,
success: async (respp) => {
let imgW = respp.width/4, imgH =respp.height/4;
let pradH = 288*imgW/1029, qrcodeH = 100;
let drawFun = new Draw({
width: imgW ,
height: imgH + pradH
});
console.log('actNum',actNum)
let qrcodeY = actNum== 2 ? 20 : 0
let arr = [456, 222, 0, 496];
let imgList = [
{
x: 0,
y: 0,
width: imgW,
height: pradH,
url: `${IMG_URL}index/canvas/${senceData[actNum].productList[activeNavIdx].img}.png`,
},
{
x: 0,
y: pradH,
width: imgW,
height: imgH,
url: `https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/index/longpic${
actNum + 1
}.png`,
},
{
// x: 245 * 2,
// y: erCodeHeight + 30,
// width: 120 * 2,
// height: 120 * 2,
x: imgW-qrcodeH,
y: imgH + pradH -qrcodeH -20,
width: qrcodeH,
height: qrcodeH,
url: res.data, //二维码
},
];
let telephone = userInfo.phone?userInfo.phone:''
let textList = [
{
x: 22,
y: imgH + pradH - 25,
text: `联系我:${telephone}`,
color: '#323436',
fontSize: 10
}
]
// console.log(imgList)
let posterUrl = await drawFun.begin({
imageList: imgList,
textList
});
_this.setData({
posterUrl: posterUrl.path,
});
console.log("posterUrl.path", posterUrl.path);
if (_this.data.posterUrl) {
wx.saveImageToPhotosAlbum({
filePath: _this.data.posterUrl, //仅为示例,并非真实的资源
success(res) {
console.log("res: ", res);
wx.$api.showToast("下载成功!");
},
});
}
// _this.modelcloseFn();
wx.hideLoading()
},
});
},
// //模态框关闭
// modelClose() {
// this.triggerEvent("modelclose", false);
// },
// 图片加载事件
// onloadFn(event) {
// // console.log("event.detail", event.detail);
// this.setData({
// imgHeight: event.detail.height / 5,
// imgWidth: event.detail.width / 5,
// });
// },
// 图片视频加载回调拿到url
getImgInfo(actNum){
wx.showLoading({
title: "加载中",
});
let _this = this;
wx.getImageInfo({
src: `https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/index/longpic${
actNum + 1
}.png`,
success: async (res) => {
console.log('res: ', res)
wx.hideLoading()
wx.nextTick(() => {
_this.setData({
// isShow: true,
imgPath:res.path
})
})
}
})
},
// 分享获取懂得用户数
authorizedFn(e) {
let res = e.detail;
this.onLoad(null);
wx.nextTick(() => {
//储存手机号
// console.log("储存手机号",res.phone)
wx.$storage.set("authphone", res.phone);
this.setData({
// isShare: res.isShare,
phone: res.phone,
});
});
},
/**
* 生命周期函数--监听页面加载 (扫码,分享链接)
*/
async onLoad(options) {
await this.getData()
console.log("分享options12255565: ", options);
// actNum,activeNavIdx isShare
if (!options || utils.isEmptyObj(options)) return;
// this.analysisOption();
// 解析二维码参数
if (options.scene) {
this.setData({
isShare: true,
});
let ercodeParams = await this.analysisQRcode(options.scene);
options = JSON.parse(ercodeParams.scene)
}
let {senceData} = this.data
// 扫码进来
let { actNum, activeNavIdx, isShare } = options;
console.log('actNum, activeNavIdx, isShare: ', actNum, activeNavIdx, isShare);
if (isShare) {
this.setData({
isShow: false,
});
} else {
wx.showLoading({
title: "加载图片中",
});
}
this.setData({
actNum,
activeNavIdx,
isShare: true,
outshowVideo: false, //显示视频列表
});
// 发请求
console.log()
let senceItem = senceData[actNum];
let item = senceData[actNum]?.productList[activeNavIdx];
this.shareQuery = `sceneCode=${senceItem?.sceneCode}&productCode=${
item?.productCode
}&isShare=${true}&productDesc=${item?.productName}&category=${
item?.category
}&actNum=${actNum}&activeNavIdx=${activeNavIdx}`;
this.shareTrackData = {
sceneCode: senceItem?.sceneCode,
productCode: item?.productCode,
productName: item?.productName,
category: item?.category,
productDesc: item?.productName,
// actNum,
// activeNavIdx,
};
// 有手机号就不用再一次授权昵称,手机号
let phone = wx.$storage.get("authphone");
console.log("储存手机号", phone);
if (phone) {
this.setData({
isAuthphone: false,
outshowVideo: true,
isShare:false,
});
}
},
// 解析二维码回调
// async analysisOption() {},
// 解析扫码进来参数
async analysisQRcode(str) {
let id = str.split("%3D")[1];
let res = await sceneByIdApi({
id,
});
// console.log('res: ', res);
return res;
},
// 获取用户昵称
getUserProfile(e) {
this.setData({
hasUserInfo: true,
});
let _this = this;
// 推荐使用 wx.getUserProfile 获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
// 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
wx.getUserProfile({
desc: "用于完善资料", // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
// console.log('res: ', res.userInfo.nickName);
// userInfo.nickName
this.setData({
userInfo: res.userInfo,
});
let wx_user_info = wx.$storage.get("wx_user_info");
// console.log('wx_user_info: ', wx_user_info);
let obj = {
...wx_user_info,
nickName: res.userInfo.nickName,
avatarUrl: res.userInfo.avatarUrl,
};
// console.log('obj',obj)
wx.$storage.set("wx_user_info", obj);
_this.onLoad(null);
},
});
},
onPageScroll: (function () {
let timer = null;
return function (e) {
// console.log("在滚动");
// 监听页面的滚动开始和结束
clearTimeout(timer);
timer = setTimeout(() => {
// console.log("滚动结束");
wx.$eventbus.emit('evt_page_scroll',{scrollTop:e.scrollTop})
}, 500);
};
})(),
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow(options) {
// wx.nextTick(()=>{
// let {senceData ,actNum, activeNavIdx} = this.data
// console.log('senceData: ', senceData,actNum,activeNavIdx);
// let item = senceData[actNum]?.productList[activeNavIdx].proName;
// console.log('item: ', item);
// wx.setNavigationBarTitle({
// title: item.proName,
// })
// })
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
let {senceData,actNum,activeNavIdx} = this.data
let product = senceData[actNum]?.productList[activeNavIdx].proName
console.log('product: ', product);
return {
title: `给你分享一个活动${product},戳我参与~`,
}
},
/**
* 浏览埋点
*/
onShareTimeline() {},
onViewTrack: true,
});
{
"usingComponents": {
"product": "../scene/components/product/product"
},
"navigationStyle": "custom",
"onReachBottomDistance": 10,
"enablePullDownRefresh": true
}
/* pages/checkProduct/checkProduct.wxss */
.productCon {
box-sizing: border-box;
padding-top: 88px;
display: block;
}
// 分享模态框
.share-wrap {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 2;
.img-wrap {
position: absolute;
top: 15%;
left: 50%;
transform: translateX(-50%);
// width: 225px;
width: 60%;
height: 54%;
// background-color: red;
overflow: auto;
border-radius: 16rpx;
.prod-item {
background-color: #f5f7fb;
.prod-item {
padding: 0 32rpx 32rpx;
margin: 16rpx auto 0;
// background-color: #f5f7fb;
// border-radius: 48rpx 48rpx 0 0;
}
.prod-card {
display: flex;
height: 120rpx;
background-image: linear-gradient(1deg, #ffffff 10%, #fdfcff 100%);
border: 2rpx solid #ffffff;
// box-shadow: 0 8rpx 20rpx 0 rgba(197, 205, 235, 0.35);
border-radius: 20rpx;
padding: 0 24rpx;
// box-sizing: border-box;
position: relative;
}
.prod-card .card-img {
padding-top: 10rpx;
width: 100rpx;
height: 100rpx;
flex-shrink: 0;
border-radius: 4rpx;
}
.img-desc {
position: absolute;
width: 104rpx;
height: 40rpx;
line-height: 40rpx;
background: #d7f5eb;
border-radius: 4rpx;
font-family: PingFangSC-Medium;
font-weight: 600;
font-size: 24rpx;
color: #24b38c;
letter-spacing: 0;
text-align: center;
}
.prod-info {
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 12rpx 0;
margin-left: 24rpx;
}
.prod-info > text {
display: block;
white-space: nowrap;
// height: 40rpx;
// line-height: 40rpx;
}
.prod-info .title {
font-weight: 500;
font-size: 16rpx;
color: #323436;
}
.prod-info .sale,
.prod-info .earnings {
font-size: 16rpx;
color: #7a8299;
}
.prod-info .sale-num {
font-size: 14rpx;
color: #323436;
}
.prod-info .earnings-num {
font-size: 14rpx;
font-weight: Bold;
color: #f35251;
}
}
.img {
width: 100%;
// height: auto;
// height: 60%;
background-color: #fff;
}
}
}
.btns-wrap {
padding-bottom: 84rpx;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
height: 120rpx;
background: #ffffff;
z-index: 1;
// border-radius: 8px 8px 0 0;
.top {
display: flex;
justify-content: space-around;
.btn {
padding-top: 16px;
}
.img {
display: block;
margin: 0 auto 8px;
width: 40px;
height: 40px;
}
// .name {
// font-size: 12px;
// color: #323436;
// text-align: center;
// }
.name0{
width: 256rpx;
height: 88rpx;
border: 1px solid #EEEEEE;
border-radius: 8rpx;
font-size: 28rpx;
color: #8A8C90;
text-align: center;
line-height:88rpx;
}
.name1{
width: 414rpx;
height: 88rpx;
background: #3666FE;
border-radius: 8rpx;
font-size: 28rpx;
color: #FFFFFF;
line-height:88rpx;
}
.btn-wechat {
width: auto;
margin: 0;
padding: 0;
background-color: #fff;
}
}
.btom {
margin: 18px auto 0;
width: 343px;
height: 44px;
line-height: 44px;
border: 1px solid #eeeeee;
border-radius: 4px;
text-align: center;
}
}
/* 用户授权 */
.user-profile {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 3;
background-color: transparent;
}
<!-- pages/checkProduct/checkProduct.wxml -->
<navigation-bar showBack="{{true}}" bindnavbarReady="navbarReady" navStyle="{{navStyle}}">
{{senceData[actNum].productList[activeNavIdx].proName}}
</navigation-bar>
<!-- <view style="height:{{headerHeight}}px">
</view> -->
<!-- style="padding-top:{{headerHeight}}px" -->
<product stickyTop="{{headerHeight}}" class="productCon" isAuthphone="{{isAuthphone}}" actNum="{{actNum}}" wrapactiveNavIdx="{{activeNavIdx}}" senceData="{{senceData}}" outshowVideo="{{outshowVideo}}" isShare="{{isShare}}" isShow="{{isShow}}" bindauthorized="authorizedFn" />
<!-- 分享弹框 -->
<!-- <view class="share-wrap" wx:if="{{isShow}}">
<view class="img-wrap">
<view class="prod-item">
<view class="prod-card">
<view class="card-img">
<image src="{{IMG_URL}}index/prod/{{senceData[actNum].productList[activeNavIdx].img}}.png" />
</view>
<view class="prod-info">
<text class="title">{{senceData[actNum].productList[activeNavIdx].proName}}</text>
<text class="sale" decode="{{true}}">
{{senceData[actNum]['productList'][activeNavIdx].varType == 1 ? '三年售后存量数':'新车销量'}}&nbsp;
<text class="sale-num">
{{senceData[actNum]['productList'][activeNavIdx].varType == 1? senceData[actNum]['productList'][activeNavIdx].flow : senceData[actNum]['productList'][activeNavIdx].sale}}
</text>
</text>
<text class="earnings" decode="{{true}}">
预估收益&nbsp;
<text class="earnings-num">
{{senceData[actNum]['productList'][activeNavIdx].profit}}
</text>
</text>
</view>
</view>
</view>
</view>
<button></button>
</view> -->
<!-- 用于图片加载事件 -->
<!-- <image class="img" src="{{IMG_URL}}index/longpic{{actNum+1}}.png" bindload="onloadFn" /> -->
<!-- <view class="btns-wrap" wx:if="{{isShow}}">
<view class="top">
<view class="btn" wx:for="{{btnList}}" wx:key="name" bindtap="handleClick" data-index="{{index}}">
<block wx:if="{{index == 1}}">
<button open-type="share" class="btn-wechat">
<view class="name{{index}}">{{item.name}}</view>
</button>
</block>
<block wx:else>
<view class="name{{index}}">{{item.name}}</view>
</block>
</view>
</view>
</view> -->
<!-- 授权昵称 -->
<!-- !hasUserInfo && !isShow -->
<!-- <view wx:if="{{!hasUserInfo && isShare && isAuthphone}}" class="user-profile" bindtap="getUserProfile"></view> -->
\ No newline at end of file \ No newline at end of file
// pages/tab/discovery/components/product/product.js
// import {imgUrlMixin} from '~/mixins/index'
// import { IMG_URL } from "~/utils/constantData.js";
// import USERAPI from "~/api/usersApi/index";
const videoBaseUrl =
"https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/";
let IMG_URL = wx.$imgUrl
Component({
// behaviors: [imgUrlMixin],
/**
* 组件的属性列表
*/
properties: {
stickyTop: Number,
actNum: Number,
wrapactiveNavIdx: Number,
senceData: Object, //本地数据
apiData: Object, //后端接口数据
isShare: {
type: Boolean,
value: false,
},
origin: String, //来源
outshowVideo: {
type: Boolean,
value: true,
}, //显示视频列表
isAuthphone: Boolean,
isShow: {
type: Boolean,
// value: false,
},
},
/**
* 组件的初始数据
*/
data: {
navList: ["360全景导航", "AR实景导航", "座椅通风", "氛围灯", "数字化美容"],
activeNavIdx: 0,
tab: [
"场景说明",
"营销链路",
"项目亮点",
"转化漏斗",
"合作流程",
// "合作案例",
],
heightArr: [],
allHeight: 0,
curTabIdx: 0,
intoViewId: "to-0",
IMGURL: `${IMG_URL}index/`,
videoBaseUrl,
getMoreBtn: false,
showVideo: true, //显示视频列表
imgTopArr: [],
},
lifetimes: {
ready: function () {
this.init();
this.getImgHeight();
console.log("ready");
// //获取当前路径
// let currentUrl = this.getCurrentPageUrl()
// // console.log('currentUrl: ', currentUrl);
// if(currentUrl == '/pages/tab/index/index'){
// this.setData({
// currentUrl:false
// })
// }else{
// let {isShare} = this.data
// console.log(isShare,'isShare')
// if(isShare){
// this.setData({
// currentUrl:false
// })
// }else{
// this.setData({
// currentUrl:true
// })
// }
// }
//监听页面滚动的距离
wx.$eventbus.on("evt_page_scroll", async (e) => {
// console.log(e)
// let heightTop = this.data.stickyTop// 90 场景高度,8 场景margin-bottom
// let prodArr = await this.getHeight('.prod-wrap')
// // console.log('prodArr: ', prodArr);
// heightTop += prodArr[0].height
// let imgArr = await this.getHeight('.img-item')
// // console.log('imgArr: ', imgArr);
// let imgHeightArr = []
// imgArr.reduce((pre,cur,index)=>{
// imgHeightArr.push(pre+cur.height)
// return pre+cur.height
// },heightTop)
let imgTopArr = this.data.imgTopArr;
// console.log('imgTopArr: ', imgTopArr);
if (imgTopArr.length == 0) return;
wx.nextTick(() => {
let idx = imgTopArr.findIndex((item) => item > e.scrollTop);
if (idx > -1) {
this.setData({
curTabIdx: idx,
});
}
});
});
if (!this.data.outshowVideo) {
this.setData({
showVideo: false,
});
}
//如果不是分享,初始化的时候调用函数
if (!this.data.isShare) {
// console.log(131546)
this.getMoreFn();
}
},
},
observers: {
actNum: function (newval, oldval) {
let navList;
let tab = [
"场景说明",
"营销链路",
"项目亮点",
"转化漏斗",
"合作流程",
// "合作案例",
];
let num = this.data.actNum;
switch (num) {
case 0:
navList = ["数字无忧权益卡"];
break;
case 1:
navList = ["汽车太阳膜"];
break;
case 2:
navList = ["漆面保护膜", "改色膜"];
break;
case 3:
navList = [
"数字化美容",
"座椅通风",
"AR导航",
"氛围灯",
"360全景导航",
];
break;
case 4:
navList = ["新能源0元换购"];
break;
}
this.setData({
navList,
tab,
intoViewId: `to-0`,
activeNavIdx: 0,
});
// 每次切换场景,重新获取流程图高度
// this.getImgHeight();
this.getMoreFn();
// this
if (this.data.wrapactiveNavIdx) {
this.setData({
activeNavIdx: this.data.wrapactiveNavIdx,
});
}
},
// isShow: function (newval) {
// let { isShare } = this.data;
// if (newval && !isShare) {
// this.setData({
// currentUrl: true,
// });
// }
// },
},
/**
* 组件的方法列表
*/
methods: {
getCurrentPageUrl() {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
const url = `/${currentPage.route}`;
return url;
},
async init() {
try {
const { data, code, message } = await USERAPI.wxCodeLogin();
if (code == "0") {
this.loginToken = data;
} else this.reLogin(message);
wx.hideLoading();
} catch ({ errMsg }) {
console.error(errMsg);
this.reLogin();
}
},
/**获取loginToken */
reLogin(message) {
wx.showModal({
content: message || "获取loginToken失败",
confirmText: "重试",
confirmColor: "#3666FE",
}).then(({ confirm }) => {
if (confirm) this.init();
});
},
// 视频下载
downVideo(e) {
let { url } = e.target.dataset;
console.log(url);
wx.$api.showToast("正在下载视频...");
wx.downloadFile({
url: url,
success(res) {
// console.log(res,111)
if (res.statusCode === 200) {
wx.saveVideoToPhotosAlbum({
filePath: res.tempFilePath,
success(res) {
setTimeout(() => {
wx.$api.showToast("下载成功!");
}, 2000);
},
});
}
},
});
},
saleTextChange(e) {},
changeTab(e) {
let idx = e.detail;
let { imgTopArr, stickyTop } = this.data;
console.log("idx: ", imgTopArr[idx], stickyTop);
// this.setData({
// intoViewId: `to-${idx}`,
// });
// wx.$eventbus.emit('evt_page_index',idx)
//判断当前路径
let currentUrl = this.getCurrentPageUrl();
console.log('currentUrl: ', currentUrl);
if (currentUrl == "/pages/tab/index/index") {
console.log(123546)
wx.pageScrollTo({ scrollTop: imgTopArr[idx] - stickyTop + 88 + 34 });
// wx.pageScrollTo({ scrollTop: imgTopArr[idx] - stickyTop });
} else {
wx.pageScrollTo({ scrollTop: imgTopArr[idx] - stickyTop });
}
},
// async changeTab(e){
// let idx = e.detail
// this.setData({
// intoViewId: `to-${idx}`
// })
// let heightTop = this.data.headerHeight + 90 - 16 - 46 // 90 场景高度,16 可能是误差 , 46 tab高度
// let prodArr = await this.getHeight('.prod-wrap')
// heightTop += prodArr[0].height
// let imgArr = await this.getHeight('.img-item')
// for(let i=0;i<idx;i++){
// heightTop += imgArr[i].height
// }
// wx.pageScrollTo({
// scrollTop: heightTop,
// duration: 0
// })
// },
getHeight(cla) {
return new Promise((resolve, reject) => {
let query = wx.createSelectorQuery().in(this);
query
.selectAll(cla)
.boundingClientRect((rect) => {
resolve(rect);
})
.exec();
});
},
changeNav(event) {
this.setData({
activeNavIdx: event.target.dataset.index,
});
},
// scrolltoupper(event) {
// console.log(event.detail.scrollHeight,event.detail.scrollTop)
// const idx = this.data.heightArr.findIndex(
// (item) => item > event.detail.scrollHeight
// );
// console.log('idx',idx)
// this.setData({
// curTabIdx: idx,
// });
// // console.log(this.data.curTabIdx1)
// },
getImgHeight() {
let query = wx.createSelectorQuery().in(this);
let heightArr = [];
let imgTopArr = [];
let s = 0;
let top;
let _this = this;
query
.selectAll(".img-item")
.boundingClientRect((react) => {
react.forEach((item, index) => {
// console.log('item: ', item);
// if(index == 0){
// console.log('item top: ', item);
// top = item.top
// }
// s = s +item.height;
s = item.top;
// heightArr.push(s);
imgTopArr.push(s);
});
// heightArr = heightArr.map((item)=>{
// item += top
// return item
// })
// this.data.heightArr = heightArr;
// // console.log(heightArr[heightArr.length-1])
// this.data.allHeight = heightArr[heightArr.length - 1];
// console.log('imgTopArr',imgTopArr)
_this.setData({
imgTopArr,
});
})
.exec();
},
// 获取用户信息
getUserInfo({ detail }) {
// console.log(detail);
if (!detail.code) return;
// this.setBtnLoading()
USERAPI.getUserProfile(this.loginToken, detail)
.then((result) => {
// console.log(result)
let userInfo = wx.$storage.get("wx_user_info");
// console.log('userInfo: ', userInfo);
let { phone } = result;
// console.log('phone: ', phone);
wx.$storage.set("wx_user_info", { ...userInfo, phone });
// }
setTimeout(() => {
this.triggerEvent("authorized", {
phone,
// isShare: false,
});
}, 1e3);
//隐藏更多按钮,显示视频列表
this.setData({
getMoreBtn: true,
isShare: false,
outshowVideo: true,
});
this.getMoreFn();
})
.catch(({ errMsg }) => {
wx.$api.showToast(errMsg || "系统异常");
// this.setBtnLoading(false)
});
},
// 图片流程5 点击往下获取更多
// 没登陆用户(登陆后解锁全部)
getMoreFn() {
let { actNum } = this.data;
// console.log("inactNumdex: ", actNum);
let tab = [
"场景说明",
"营销链路",
"项目亮点",
"转化漏斗",
"合作流程",
// "合作案例",
];
switch (actNum) {
case 0:
tab.push("合作案例");
break;
case 1:
tab.push("合作案例");
break;
case 2:
break;
case 3:
tab.push("合作案例");
break;
}
this.setData({
tab,
});
},
onShareFn() {
// this.triggerEvent('sharehandle')
// wx.$router.go('apply',1235)
let { actNum, activeNavIdx, apiData } = this.data;
console.log(123456)
wx.$router.go("checkProduct", {
actNum,
activeNavIdx,
apiData,
outshowVideo: true,
isShow:true
// origin:'home' //跟首页类似情况
// isShare: true
});
},
},
});
{
"component": true,
"usingComponents": {
"tab": "../../../../components/Tab/Tab"
}
}
\ No newline at end of file \ No newline at end of file
// 特色产品
.prod-wrap {
background-color: #f8fafb;
border-radius: 20rpx 20rpx 0 0;
}
.prod-wrap .big-title {
margin-left: 32rpx;
font-family: PingFangSC-Medium;
font-weight: 600;
font-size: 32rpx;
color: #323436;
padding-top: 32rpx;
}
.prod-wrap .nav-wrap {
white-space: nowrap;
box-sizing: border-box;
margin-top: 28rpx;
margin-bottom: 16rpx;
padding-left: 32rpx;
}
.prod-wrap .nav-wrap .nav {
display: inline-block;
height: 64rpx;
border-radius: 4rpx;
font-size: 24rpx;
letter-spacing: 0;
text-align: center;
font-family: PingFangSC-Regular;
line-height: 64rpx;
margin-right: 16rpx;
background: #ffffff;
border: 2rpx solid #DDE3F0;
color: #323436;
padding: 0 16rpx;
}
.prod-wrap .nav-wrap .active-nav {
color: #ffffff;
font-weight: 500;
// background-image: linear-gradient(0deg, #EBEFFF 8%, #FCFDFF 85%);
background-color: var(--btnColor);
border: 0rpx solid;
// border: 2rpx solid rgba(68,97,240,0.50);
// box-shadow: 0 8rpx 16rpx 0 rgba(175,187,219,0.35);
}
.prod-wrap .nav-wrap .nav:last-child {
margin-right: 0;
}
.prod-item {
padding: 0 32rpx 32rpx;
margin: 16rpx auto 0;
background-color: #f5f7fb;
border-radius: 48rpx 48rpx 0 0;
}
.prod-card {
display: flex;
height: 208rpx;
background-image: linear-gradient(1deg, #ffffff 10%, #fdfcff 100%);
border: 2rpx solid #ffffff;
box-shadow: 0 8rpx 20rpx 0 rgba(197, 205, 235, 0.35);
border-radius: 8rpx;
padding: 20rpx 24rpx;
box-sizing: border-box;
position: relative;
}
.prod-card .card-img {
width: 160rpx;
height: 160rpx;
flex-shrink: 0;
border-radius: 4rpx;
}
.img-desc {
position: absolute;
width: 104rpx;
height: 40rpx;
line-height: 40rpx;
background: #d7f5eb;
border-radius: 4rpx;
font-family: PingFangSC-Medium;
font-weight: 600;
font-size: 24rpx;
color: #24b38c;
letter-spacing: 0;
text-align: center;
}
.prod-info {
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 12rpx 0;
margin-left: 24rpx;
}
.prod-info>text {
display: block;
white-space: nowrap;
height: 40rpx;
line-height: 40rpx;
}
.prod-info .title {
font-family: PingFangSC-Medium;
font-weight: 600;
font-size: 28rpx;
color: #323436;
}
.prod-info .sale,
.prod-info .earnings {
font-size: 26rpx;
color: #7a8299;
}
.prod-info .sale-num {
font-size: 26rpx;
color: #323436;
}
.prod-info .earnings-num {
font-size: 28rpx;
// font-family: DINAlternate-Bold;
font-weight: Bold;
color: #f35251;
}
.share-btn {
height: 56rpx;
line-height: 56rpx;
width: 124rpx;
background: #3666FE;
border-radius: 28rpx;
font-family: PingFangSC-Regular;
font-size: 24rpx;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
position: absolute;
right: 24rpx;
top: 50%;
transform: translateY(-50%);
}
.share-btn .icon {
width: 32rpx;
height: 32rpx;
margin-right: 2rpx;
}
.project-wrap {
background-color: #f5f7fb;
}
.project-img {
// height: 1600rpx;
// white-space: nowrap;
.img-item {
position: relative;
}
.more-btn {
position: absolute;
left: 50%;
bottom: 50px;
transform: translateX(-50%);
width: 311px;
height: 48px;
background-image: url("https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/index/btn.png");
background-size: 100% 100%;
font-weight: 500;
font-size: 16px;
color: #ffffff;
text-align: center;
line-height: 64rpx;
}
}
.stickyTab {
position: sticky;
z-index: 2;
background-color: #f5f7fb;
}
// .out-tab{
// .out-text {
// // color: red !important;
// }
// .out-text{
// color:red;
// }
// .out-line{
// }
// }
// 流程图一
.img-item11 {
width: 100%;
height: 1110rpx;
}
.img-item12 {
width: 100%;
height: 1290rpx;
}
.img-item13 {
width: 100%;
height: 596rpx;
}
.img-item14 {
width: 100%;
height: 744rpx;
}
.img-item15 {
width: 100%;
height: 490rpx;
}
.img-item16 {
width: 100%;
height: 1532rpx;
}
// 流程图二
.img-item21 {
width: 100%;
height: 2168rpx;
}
.img-item22 {
width: 100%;
height: 1290rpx;
}
.img-item23 {
width: 100%;
height: 596rpx;
}
.img-item24 {
width: 100%;
height: 830rpx;
}
.img-item25 {
width: 100%;
height: 490rpx;
}
.img-item26 {
height: 752rpx;
.video-item {
width: 100%;
video {
border-radius: 16rpx;
height: 348rpx;
}
}
}
// 流程图三
.img-item31 {
width: 100%;
height: 1110rpx;
}
.img-item32 {
width: 100%;
height: 1290rpx;
}
.img-item33 {
width: 100%;
height: 596rpx;
}
.img-item34 {
width: 100%;
height: 984rpx;
}
.img-item35 {
width: 100%;
height: 490rpx;
}
// .img-item26 {
// width: 100%;
// height: 752rpx;
// }
// 流程图四
.img-item41 {
width: 100%;
height: 678rpx;
}
.img-item42 {
width: 100%;
height: 1266rpx;
}
.img-item43 {
width: 100%;
height: 1398rpx;
}
.img-item44 {
width: 100%;
height: 830rpx;
}
.img-item45 {
width: 100%;
height: 490rpx;
}
.img-item46 {
width: 100%;
height: 1666rpx;
}
// 流程图5
.img-item51 {
width: 100%;
height: 814rpx;
}
.img-item52 {
width: 100%;
height: 998rpx;
}
.img-item53 {
width: 100%;
height: 596rpx;
}
.img-item54 {
width: 100%;
height: 984rpx;
}
.img-item55 {
width: 100%;
height: 490rpx;
}
/* 案例视频 */
.video-bg {
width: 100%;
position: absolute;
top: 280rpx;
}
.video-title {
position: relative;
padding: 96rpx 0 24rpx;
text-align: center;
font-size: 48rpx;
font-weight: 900;
color: #FFFFFF;
letter-spacing: 0;
line-height: 64rpx;
}
.video-title::after {
content: '';
display: block;
width: 48rpx;
height: 4rpx;
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
background-color: #ffffff;
}
.video-list {
display: flex;
flex-wrap: wrap;
padding: 0rpx 32rpx;
font-size: 0;
}
.check-prod .img-item {
&:last-child{
margin-bottom: 148rpx;
}
}
.video-item {
position: relative;
width: calc(50% - 12rpx);
margin-bottom: 32rpx;
}
.video-item video {
width: 100%;
height: 590rpx;
// border: 1rpx dashed #AFB0B2;
}
.video-item .download {
position: absolute;
top: 0;
right: 2px;
font-size: 26rpx;
color: #666;
z-index: 1;
}
.video-item:nth-child(even) {
margin-left: 22rpx;
}
.video-text {
margin-top: 16rpx;
font-size: 24rpx;
font-weight: 500;
font-size: 24rpx;
color: #343456;
}
.video-tips {
width: 100%;
text-align: center;
font-size: 28rpx;
color: rgba(255, 255, 255, .6);
padding: 16rpx 0 92rpx;
}
\ No newline at end of file \ No newline at end of file
<!-- pages/tab/discovery/components/product/product.wxml -->
<view class="prod-wrap" >
<view class="big-title">特色产品</view>
<scroll-view class="nav-wrap" scroll-x="{{true}}" wx:if="{{!isShare && origin =='home'}}">
<block wx:for="{{navList}}" wx:key="index">
<text class='nav {{activeNavIdx==index ? "active-nav": ""}}' bindtap="changeNav" data-index="{{index}}">{{item}}</text>
</block>
</scroll-view>
<view class="prod-item">
<view class="prod-card">
<view class="card-img">
<!-- <text class="img-desc">轻改类</text>
<image src="{{IMGURL}}discovery_prod1.png" /> -->
<image src="{{IMGURL}}prod/{{senceData[actNum].productList[activeNavIdx].img}}.png" />
</view>
<view class="prod-info">
<text class="title">{{senceData[actNum].productList[activeNavIdx].proName}}</text>
<!-- senceData[actNum]['productList'][activeNavIdx].changeSale || -->
<text class="sale" wx:if="{{ actNum!=4}}" decode="{{true}}">{{senceData[actNum]['productList'][activeNavIdx].varType == 1 ? '三年售后存量数':'新车销量'}}&nbsp;<text class="sale-num">{{senceData[actNum]['productList'][activeNavIdx].varType == 1? senceData[actNum]['productList'][activeNavIdx].flow : senceData[actNum]['productList'][activeNavIdx].sale}}</text>
</text>
<text class="earnings" wx:if="{{ actNum!=4}}" decode="{{true}}">预估收益&nbsp;<text class="earnings-num">¥{{senceData[actNum]['productList'][activeNavIdx].profit}}</text>
</text>
</view>
<view class="share-btn" wx:if="{{!isShare && origin =='home' && actNum!=4}}" bindtap="onShareFn">
<image class="icon" src="{{IMGURL}}share.png" />
<text>分享</text>
</view>
</view>
</view>
</view>
<view class="project-wrap">
<!-- -->
<view class="stickyTab" style="top:{{isShare ? stickyTop+88 : stickyTop}}rpx">
<tab
outClassName="project-tab"
openScroll="{{true}}"
tab="{{tab}}"
index="{{curTabIdx}}"
bindclick="changeTab"
productHeight
/>
</view>
<!-- style="{height:{{allHeight}}px}" scroll-y="{{true}}" bindscroll="scrolltoupper"-->
<scroll-view
class="project-img"
scroll-into-view="{{intoViewId}}"
>
<block wx:for="{{tab}}" wx:key="index">
<!-- wx:if="{{showVideo && index==5 && tab.length < 5}}" -->
<view id="to-{{index}}" class="img-item img-item{{actNum+1}}{{index+1}}" wx:if="{{index != 5}}">
<!-- wx:if="{{index!=5}}" -->
<image class="img-item{{actNum+1}}{{index+1}}" src="{{IMGURL}}scene{{actNum+1}}{{index+1}}.png" />
<view class="video-bg" wx:if="{{!isShare && index==5 && senceData[actNum].videoList.length}}">
<view class="video-list">
<block wx:for="{{senceData[actNum].videoList}}" wx:key="i">
<view class="video-item">
<video poster="{{videoBaseUrl}}video/{{item.posterUrl}}.png?v={{img_version}}" title="{{item.name}}" src="{{videoBaseUrl}}video/{{item.videoUrl}}.mp4?v={{img_version}}" />
<view class="video-text">{{item.name}}</view>
</view>
</block>
<!-- <view class="video-tips">- 如需开通请咨询客服 -</view> -->
</view>
</view>
<!-- wx:if="{{ actNum != 2 && index == 4}}" -->
<!-- wx:if="{{isShare && actNum != 2 && index == 4}}" -->
<!-- wx:if="{{ isShare && actNum != 2 && index == 4}}" -->
<!-- <button
wx:if="{{ isShare && isAuthphone && !getMoreBtn && actNum != 2 && index == 4}}"
class="more-btn"
data-index="{{index}}"
bindgetphonenumber="getUserInfo"
open-type="getPhoneNumber"
>
点击查看更多详情
</button> -->
</view>
<view id="to-{{index}}" class="img-item img-item{{actNum+1}}{{index+1}}" wx:if="{{index == 5 && outshowVideo}}">
<!-- wx:if="{{index!=5}}" -->
<image class="img-item{{actNum+1}}{{index+1}}" src="{{IMGURL}}scene{{actNum+1}}{{index+1}}.png" />
<view class="video-bg" wx:if="{{!isShare && index==5 && senceData[actNum].videoList.length}}">
<view class="video-list">
<block wx:for="{{senceData[actNum].videoList}}" wx:key="i">
<view class="video-item">
<view class="download" bindtap="downVideo" data-url="{{videoBaseUrl}}video/{{item.videoUrl}}.mp4?v={{img_version}}">视频下载</view>
<video poster="{{videoBaseUrl}}video/{{item.posterUrl}}.png?v={{img_version}}" title="{{item.name}}" src="{{videoBaseUrl}}video/{{item.videoUrl}}.mp4?v={{img_version}}" />
<view class="video-text">{{item.name}}</view>
</view>
</block>
</view>
</view>
</view>
</block>
</scroll-view>
</view>
// 1.视频默认进来是true,显示,
// 2.扫码,分享链接进来,不显示
// 3.点击更多详情,隐藏更多按钮,显示视频
// 4.视频的位置最后一个 下标5
// var showVideo = function(index){
// if(index == 5){
// a
// }
// };
// module.exports = {
// showVideo:showVideo
// }
// import { IMG_URL } from "~/utils/constantData.js";
let IMG_URL = wx.$imgUrl
var senceData = [
{
name: '新车洽谈场景',
img: 'scene_talk.png',
active: 'icon-car11',
playImg: 'img1',
src: `${IMG_URL}index/car1.png`,
// name: "新车洽谈场景",
msg: "1.0 新车权益销售",
"sceneCode":"SC001",
productList: [
{
img: 'product-img1',
proName: '数字无忧权益卡',
price: '100',
// profit: '92.4万',
profit: '1200000',
type: 'service',
productType: 'benefitCard',
path: 'equity',
sale:100 ,//销量
varType: 0,
flow:10000,
"productCode":"PC001",
"productName":"数字无忧权益卡",
"category":"服务类",
}
],
videoList: [
{
videoUrl: 'digital_card_30s',
posterUrl: 'digital_card_30s_bitmap',
name: '数字无忧卡服务30秒'
},
{
videoUrl: 'digital_card_money3',
posterUrl: 'digital_card_money3_bitmap',
name: '数字无忧卡3道钱'
},
{
videoUrl: 'digital_card',
posterUrl: 'digital_card_bitmap',
name: '数字无忧卡服务'
},
{
videoUrl: 'digital_card_reason6',
posterUrl: 'digital_card_reason6_bitmap',
name: '数字无忧卡6大理由'
}
]
},
{
name: '新车交付场景',
img: 'scene_delivery.png',
active: 'icon-car21',
playImg: 'img2',
src: `${IMG_URL}index/car2.png`,
// name: "新车交付场景",
msg: "1.1 新车精品升级",
"sceneCode":"SC002",
productList: [
{
img: 'product-img2',
proName: '汽车太阳膜',
price: '100',
profit: '10080000',
type: 'membrane',
productType: 'sunMembrane',
path: 'solarFilm',
sale:100, //销量
varType: 0,
flow:10000,
"productCode":"PC002",
"productName":"汽车太阳膜",
"category":"膜类",
}
],
videoList:[
{
videoUrl: 'solar',
posterUrl: 'solar_bitmap',
name: '太阳膜转化售中案例-门店新增产值12w每月'
}
]
},
{
name: '0-12个月',
img: 'scene_within_12mth.png',
active: 'icon-car21',
playImg: 'img2',
src: `${IMG_URL}index/car3.png`,
// name: "0-12个月",
msg: "1.2 新车线上转化",
"sceneCode":"SC003",
productList: [
{
img: 'product-img3',
proName: '漆面保护膜',
price: '100',
profit: '180000',
type: 'membrane',
productType: 'protectMembrane',
path: 'paintProtect',
sale:100, //销量
varType: 0,
flow:10000,
"productCode":"PC003",
"productName":"漆面保护膜(车衣)",
"category":"膜类",
},
{
img: 'product-img4',
proName: '改色膜',
price: '100',
profit: '300000',
type: 'membrane',
productType: 'colorMembrane',
path: 'changingFilm',
sale:100, //销量
varType: 0,
flow:10000,
"productCode":"PC004",
"productName":"改色膜",
"category":"膜类",
}
]
},
{
name: '12个月以上',
img: 'scene_more_12mth.png',
active: 'icon-car31',
playImg: 'img3',
src: `${IMG_URL}index/car4.png`,
// name: "12个月以上",
msg: "1.3 存量用户众筹",
"sceneCode":"SC004",
productList: [
{
img: 'product-img5',
proName: '数字化美容',
price: '100',
profit: '72000',
type: 'beauty',
productType: 'digitBeauty',
path: 'carBeauty',
sale:100, //销量
varType: 0,
flow:10000,
"productCode":"PC005",
"productName":"数字化美容",
"category":"美容类",
},
{
img: 'product-img6',
proName: '座椅通风',
price: '10000',
profit: '232200',
type: 'light',
productType: 'chair',
path: 'seatVentilate',
sale:10000, //销量
varType: 1,
flow:10000,
"productCode":"PC006",
"productName":"座椅通风",
"category":"轻改类",
},
{
img: 'product-img7',
proName: 'AR导航',
price: '10000',
profit: '226800',
type: 'light',
productType: 'ar',
path: 'arNavigation',
sale:10000, //销量
varType: 1,
flow:10000,
"productCode":"PC007",
"productName":"AR导航",
"category":"轻改类",
},
{
img: 'product-img8',
proName: '氛围灯',
price: '10000',
profit: '361800',
type: 'light',
productType: 'lamp',
path: 'ambientLighting',
sale:10000, //销量
varType: 1,
flow:10000,
"productCode":"PC008",
"productName":"氛围灯",
"category":"轻改类",
},
{
img: 'product-img9',
proName: '360全景导航',
price: '10000',
profit: '388800',
type: 'service',
productType: 'navigation',
path: 'navigationArround',
sale:10000, //销量
varType: 1,
flow:10000,
"productCode":"PC009",
"productName":"360全景导航",
"category":"轻改类",
}
],
videoList: [
{
videoUrl: 'seat',
posterUrl: 'seat_bitmap',
name: '座椅通风系统-新增产值20w'
},
{
videoUrl: 'AR',
posterUrl: 'AR_bitmap',
name: '单品AR导航-新增产值20w+'
},
{
videoUrl: 'light',
posterUrl: 'light_bitmap',
name: '单品类氛围灯-新增产值27w'
},
{
videoUrl: '360_AR',
posterUrl: '360_AR_bitmap',
name: '360全景导航-新增产值57w+'
}
]
},
{
name: '3年以上',
img: 'scene_talk.png',
active: 'icon-car11',
playImg: 'img1',
src: `${IMG_URL}index/car1.png`,
// name: "新车洽谈场景",
msg: "3.1新能源0元购",
"sceneCode":"SC001",
productList: [
{
img: 'product-img9',
proName: '新能源0元换购',
price: '100',
// profit: '92.4万',
profit: '1200000',
type: 'service',
productType: 'benefitCard',
path: 'equity',
sale:100 ,//销量
varType: 0,
flow:10000,
"productCode" : "PC010",
"productName" : "新能源0元换购",
"category":"置换类",
}
]
},
]
module.exports = {
senceData
}
\ No newline at end of file \ No newline at end of file
const navStyle = 'background-color: transparent;'
// import { IMG_URL } from '~/utils/constantData.js'
// wx.$imgUrl = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/'
import { senceData } from './constant/data'
// `${IMG_URL}index/car2.png`,
//本地图片路径
let IMG_URLLocal = '../../../images/'
// import { productBysceneApi, unreadApi, pageApi, readApi, tagApi } from '~/api/index.js'
let IMG_URL = wx.$imgUrl
Page({
// behaviors: [kfMixin],
/**
* 页面的初始数据
*/
data: {
navStyle,
// IMGURL: wx.$imgUrl,
IMG_URL,
// IMG_URLLocal,
actClass: 'right',
guideSrcIndex: 1,
guideShow: false,
dataArr: [
{
src: `${IMG_URL}index/car1.png`,
name: '新车洽谈场景',
msg: '1.0 新车权益销售'
},
{
src: `${IMG_URL}index/car2.png`,
name: '新车交付场景',
msg: '1.1 新车精品升级'
},
{
src: `${IMG_URL}index/car3.png`,
name: '0-12个月',
msg: '1.2 新车线上转化'
},
{
src: `${IMG_URL}index/car4.png`,
name: '12个月以上',
msg: '1.3 存量用户众筹'
}
],
apiData: [],
actNum: 3, //car 场景选择
tabIndx: 1,
navList: ['看线索', '看产品'],
typeList: [
{
0: '无电话',
1: '有电话',
2: '联系电话',
selectIndex: 2,
key: 'hasPhone'
},
{
0: '非意向客户',
1: '是意向客户',
2: '意向客户',
selectIndex: 2,
key: 'starTag'
},
{
0: '来自访客',
1: '来自门店',
2: '线索来源',
selectIndex: 2,
key: 'clueSource'
},
{
2: '重置',
selectIndex: 2
}
],
clueList: [],
// 预估弹框
visible: false,
isReset: false,
formData: {
sales: 100,
flow: 10000
},
lastFormData: {
sales: 100,
flow: 10000
},
isFirst: true,
// tabList: pageData.tabList,
// 定义数据
senceData,
isShow: false,
// 看线索部分
unreadClueCount: 0,
cluePageSize: 10,
clueCurrentPage: 1
},
//引导图
guideFn() {
if (this.data.guideSrcIndex === 5) {
this.setData({
guideShow: false
})
return
}
this.setData({
guideSrcIndex: ++this.data.guideSrcIndex
})
// console.log('guideSrcIndex',this.data.guideSrcIndex)
},
// navbar高度设置
navbarReady(e) {
let { height, statusBarHeight } = e.detail
this.setData({
// tabBarStyle: height / 2 + statusBarHeight,
headerHeight: height / 2 + statusBarHeight + 88,
// headerHeight: height / 2 + statusBarHeight + 88 * 2
})
// console.log(e)
// console.log(this.data.headerHeight)
},
// headTabFn(e){
// // console.log("name",e.currentTarget.dataset.name)
// let name = e.currentTarget.dataset.name
// this.setData({
// actClass:name
// })
// },
// 选车场景切换
selectCar(e) {
console.log('e: ', e)
let { num, scenestatus } = e.currentTarget.dataset
// console.log('actNum: ', actNum);
// if(scenestatus == 1){
// }
this.setData({
actNum: num
})
},
// 头部看线索,产品切换
changeTabIndx(e) {
console.log('e.detail: ', e.detail)
let { sessionId } = wx.$storage.get()
// console.log("sessionId: ", sessionId);
let param = {
sessionId
}
let first = true
this.setData({
tabIndx: e.detail
})
//标记线索已读
if (e.detail == 0 && first) {
first = false
readApi(param)
}
},
gotoApply(e) {
let { type, item } = e.currentTarget.dataset
// let { } = e.currentTarget.dataset
if (type == 'active') {
let { userInfo } = wx.$storage.get()
let pMerchantName = userInfo.subLoginUser.merchantName
let pMerchantId = userInfo.subLoginUser.merchantId
let sceneActive
switch (this.data.actNum) {
case 0:
sceneActive = 1
break
case 1:
sceneActive = 2
break
case 2:
sceneActive = 3
break
case 3:
sceneActive = 4
break
}
// let pMerchantId = userInfo.subLoginUser.merchantId
// console.log("type,item: ", type, item);
const params = {
merchantInfo: {
pMerchantId,
pMerchantName,
merchantId: item.visitList[0].merchantId,
merchantName: item.visitList[0].merchantName
},
sceneActive
// sceneCodeList: ['SC001', 'SC002','SC003','SC004']
}
//申请活动
wx.$router.go('packageOutput.openBusiness', params)
} else {
//申请门店
// let { type, item } = e.currentTarget.dataset
wx.$router.go('apply', item?.clueId || '')
}
// wx.$router.go('apply',1235)
},
getMore(e) {
console.log('显示更多数据')
let index = e.currentTarget.dataset.outidx
console.log('index: ', index)
let completeStatus = `clueList[${index}].getMoreFlag`
this.setData({
[completeStatus]: !this.data.clueList[index].getMoreFlag
})
},
// 跳转咨询页面
goConsult() {
console.log('跳转到咨询页面')
wx.pro.openCustomerServiceChat({
extInfo: { url: 'https://work.weixin.qq.com/kfid/kfcf7b721472201345e' },
corpId: 'ww047bdc0f1e76cc13',
complete: r => {
console.log(r)
}
})
},
// 预估弹框
showCalculate() {
this.setData({
visible: !this.data.visible,
isReset: false
})
},
clickDialog(e) {
console.log(e.changedTouches[0].clientY)
if (e.changedTouches[0].clientY < 352) {
this.setData({
visible: false,
isReset: false,
formData: this.data.lastFormData
})
}
},
// 提交测算
submit(e) {
console.log(e)
let sales = e ? +e.detail.value.sales : this.data.formData.sales
let flow = e ? +e.detail.value.flow : this.data.formData.flow
console.log('flow', sales, flow)
const reg = /^[1-9]\d*$/
console.log(reg.test(sales), flow, '---')
if (!reg.test(sales)) {
wx.showToast({
title: '门店月平均新车销量应为正整数',
icon: 'none',
duration: 2000
})
return
}
if (!reg.test(flow)) {
wx.showToast({
title: '3年内售后存量用户应为正整数',
icon: 'none',
duration: 2000
})
return
}
this.setData({
'lastFormData.sales': sales,
'lastFormData.flow': flow
})
const _this = this
// this.data.tabList.forEach((item, index) => {
// item.productList.forEach((i, lastIndex) => {
// if (i.profit) {
// let name = `tabList[${index}].productList[${lastIndex}].profit`;
// let profit = _this.formula(i.productType, sales, flow);
// console.log(name, profit);
// this.setData({
// [name]: profit,
// });
// }
// });
// });
this.data.senceData.forEach((item, index) => {
item.productList.forEach((i, lastIndex) => {
if (i.profit) {
let sale = `senceData[${index}].productList[${lastIndex}].sale`
let name = `senceData[${index}].productList[${lastIndex}].profit`
let flowKey = `senceData[${index}].productList[${lastIndex}].flow`
let profit = _this.formula(i.productType, sales, flow)
console.log(name, profit)
this.setData({
[name]: profit,
[sale]: sales,
[flowKey]: flow
})
}
})
})
// 触发自定义事件 利润 数量
// this.triggerEvent('countProfit', profit, sales)
// let type = this.getProductType(sceneIndex, tabIndex);
// let profit = this.formula(type, sales, flow);
// console.log('profit: ', profit);
this.setData({
visible: false
})
// this.showCase();
// if (!this.data.isFirst) {
wx.showToast({
title: '测算结果已在页面内同步展示',
icon: 'none',
duration: 2000
})
// } else {
// this.setData({
// isFirst: false
// })
// }
},
// // 获取场景下的产品类型
// getProductType(sceneIndex, tabIndex) {
// let typeArray = [
// ["benefitCard"], //数字无忧权益卡
// ["sunMembrane"], //汽车太阳膜
// ["protectMembrane", "colorMembrane"], //'漆面保护膜','改色膜'
// ["digitBeauty", "chair", "ar", "lamp", "navigation"], //'数字化美容','座椅通风','AR导航','氛围灯','360全景导航'
// ];
// return typeArray[sceneIndex][tabIndex];
// },
// 计算公式,参数:productType
formula(productType, sales, flow) {
let profit = 0
switch (productType) {
case 'benefitCard':
// 数字无忧权益卡
profit = (sales * 0.5 * 2000 * 12).toFixed(0)
break
case 'sunMembrane':
// 汽车太阳膜
profit = (sales * 0.8 * 0.7 * 1500 * 12).toFixed(0)
break
case 'protectMembrane':
// 漆面保护膜
profit = (sales * 0.05 * 3000 * 12).toFixed(0)
break
case 'colorMembrane':
// 改色膜
profit = (sales * 0.05 * 5000 * 12).toFixed(0)
break
case 'digitBeauty':
// 数字化美容
profit = (sales * 0.2 * 300 * 12).toFixed(0)
break
case 'chair':
// 座椅通风
profit = (flow * 2580 * 0.9 * 0.01).toFixed(0)
break
case 'ar':
// AR导航
profit = (flow * 1680 * 0.9 * 0.015).toFixed(0)
break
case 'lamp':
// 氛围灯
profit = (flow * 2680 * 0.9 * 0.015).toFixed(0)
break
case 'navigation':
// 360全景导航
profit = (flow * 2880 * 0.9 * 0.015).toFixed(0)
break
}
console.log(profit.length)
console.log(productType, sales, flow, profit)
if (profit.length > 9) {
return (profit / 10000).toFixed(0) + '万'
} else {
return profit
}
},
reset() {
this.setData({
isReset: false,
formData: {
sales: 100,
flow: 10000
}
})
},
focus() {
this.setData({
isReset: true
})
return false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// console.log('options: ', options);
// let { sessionId } = wx.$storage.get()
// // console.log("sessionId: ", sessionId);
// let param = {
// sessionId
// }
// 看产品
this.compositionData(senceData, [])
// productBysceneApi(param).then(res => {
// let { code, data } = res
// if (code == 0) {
// this.setData({
// apiData: data
// })
// this.compositionData(senceData, this.data.apiData)
// // this.getFirstSenceIndex();
// }
// })
// 看线索
// this.getClueInit()
//第一次进来储缓存,以后不再用引导图
let firstLogin = wx.$storage.get('firstLogin')
if (!firstLogin) {
this.setData({
guideShow: true
})
wx.$storage.set('firstLogin', 'firstLogin')
}
},
//接口数据,本地数据对接
compositionData(localData, apiData) {
localData.forEach((item, index) => {
apiData.forEach((inner, idx) => {
if (item.name == inner.stage) {
item.sceneStatus = inner.sceneStatus
item.productList.forEach((outChild, outIndex) => {
inner.productList.forEach((innerChild, innerIndex) => {
if (outChild.proName == innerChild.productName) {
outChild.productStatus = innerChild.productStatus
}
})
})
}
})
})
// console.log('localData, apiData: ', localData);
this.setData({
senceData: localData
})
},
getFirstSenceIndex(param) {
let actTndex = this.data.apiData.findIndex(item => item.sceneStatus == 1)
// console.log('actTndex: ', actTndex);
this.setData({
actNum: actTndex
})
},
// 看线索相关
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
this.prompt = this.selectComponent('#toast')
},
showToast: function (e) {
let { type, item } = e.currentTarget.dataset
console.log('type,item: ', type, item)
let tipObj = {}
if (item.starTag == 1) {
tipObj = {
type: 'fail',
title: '取消标记为意向客户'
}
} else {
tipObj = {
type: 'success',
title: '成功标记为意向客户'
}
}
this.prompt.showToast({
type: tipObj.type,
title: tipObj.title,
duration: 1000,
compelete: function () {
console.log('toast框隐藏之后,会调用该函数')
//例如:跳转页面wx.navigateTo({ url: 'xxx' });
}
})
//切换收藏标记
let index = e.currentTarget.dataset.outidx
let completeStatus = `clueList[${index}].like`
this.setData({
[completeStatus]: !this.data.clueList[index].like
})
//发请求
let { sessionId } = wx.$storage.get()
let params = {
clueId: item.clueId,
sessionId
}
this.getTagApi(params)
},
filterTypeFn(e) {
let { typeList } = this.data
let index = e.currentTarget.dataset.index
// console.log('index: ', index);
// let itemList = []
// let params = {
// clueSource: '',
// hasPhone: '',
// starTag: ''
// }
// console.log('index: ', index)
// 重置筛选
if (index == 3) {
typeList.forEach(item => {
item.selectIndex = 2
})
this.setData({
typeList
})
return this.getPageApi()
}
let itemList = Object.values(typeList[index]).slice(0, 2)
itemList.push('全部')
let _this = this
wx.pro.showActionSheet({
itemList,
success(res) {
// 选中全部
let selectIndex = res.tapIndex
// console.log('selectIndex: ', selectIndex);
typeList[index].selectIndex = selectIndex
let params = typeList.reduce((obj, item, index) => {
console.log(' item: ', item)
if (item['key']) {
// selectIndex = index == 2 ? selectIndex + 1 : selectIndex
// console.log('selectIndex: ', selectIndex);
let itemIndx = item.selectIndex
// console.log('itemIndx: ', itemIndx);
// key: 'clueSource'
if (item['key'] == 'clueSource') {
itemIndx += 1
}
obj[item['key']] = itemIndx == 2 || itemIndx == 3 ? '' : itemIndx
}
return obj
}, {})
console.log(params)
// let num
// if (index == 2) {
// num = res.tapIndex + 1
// } else {
// num = res.tapIndex
// }
// switch (index) {
// case 0:
// params.hasPhone = num
// break
// case 1:
// params.starTag = num
// break
// case 2:
// params.clueSource = num
// break
// }
_this.setData({ typeList })
_this.getPageApi(params)
},
fail(res) {
console.log(res.errMsg)
}
})
},
// 打电话
phoneCallFn(e) {
let { phone } = e.currentTarget.dataset
console.log('phone: ', phone)
wx.$api.phoneCall(phone)
},
// 复制号码
setCopyDataFn(e) {
let { phone } = e.currentTarget.dataset
wx.$api.setCopyData(phone)
},
getClueInit(param) {
// console.log(22222)
this.getUnreadApi(param)
this.getPageApi(param)
},
//未读消息
async getUnreadApi(param) {
let { code, data } = await unreadApi(param)
if (code == 0) {
this.setData({
unreadClueCount: data.unreadClueCount
})
}
},
//获取浏览线索数据列表
async getPageApi(param) {
let { cluePageSize, clueCurrentPage } = this.data
let params = {
...param,
pageSize: 1000,
currentPage: clueCurrentPage
}
let { code, data } = await pageApi(params)
if (code == 0) {
let arr = data.list.map(item => {
if (item.visitList.length > 5) {
item.getMoreFlag = true
}
return item
})
this.setData({
clueList: arr
})
}
},
//喜欢收藏功能
async getTagApi(param) {
let res = await tagApi(param)
console.log('res: ', res)
this.getPageApi(param)
},
onReachBottom() {
console.log('滑到底部了')
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
// setTimeout(()=>{
// console.log('this.data.tabBarStyle',this.data.tabBarStyle,this.data.headerHeight)
// })
},
onPageScroll: (function () {
let timer = null
return function (e) {
// console.log("在滚动");
// 监听页面的滚动开始和结束
clearTimeout(timer)
timer = setTimeout(() => {
// console.log("滚动结束");
wx.$eventbus.emit('evt_page_scroll', { scrollTop: e.scrollTop })
}, 500)
}
})(),
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {},
onShareTimeline: function () {}
})
{
"usingComponents": {
"product": "./components/product/product"
},
"navigationStyle": "custom",
"onReachBottomDistance":50
}
page {
height: 100vh;
width: 100vw;
background-color: #F2F3F7 !important;
}
.reclaim {
.header-wrap {
position: sticky;
top: 0;
width: 100%;
background-size: 100% 100%;
// margin-bottom: 32rpx;
z-index: 2;
.header {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 88rpx;
display: flex;
justify-content: space-between;
align-items: center;
.tabContainer {
width: 60%;
}
.left {
display: flex;
align-items: center;
.clue {
position: relative;
margin-left: 24px;
margin-right: 24px;
font-weight: 400;
font-size: 14px;
color: #8a8c90;
}
.product {
position: relative;
}
.act {
font-weight: 600;
font-size: 22px;
color: #323436;
&::after {
position: absolute;
left: 50%;
bottom: -6px;
transform: translateX(-50%);
display: block;
content: "";
width: 20px;
height: 4px;
background: var(--btnColor);
border-radius: 2px;
}
}
}
.right {
display: flex;
align-items: center;
.img {
width: 40rpx;
height: 40rpx;
}
.apply {
margin-left: 4px;
margin-right: 16px;
font-weight: 400;
font-size: 28rpx;
color: var(--btnColor);
}
}
}
}
// .content{
// position: relative;
// }
.clue {
padding: 0px 10px 0;
background-color: #f2f3f7;
// margin-top: -16rpx;
.types {
// margin-bottom: 8px;
box-sizing: border-box;
padding: 16rpx 0;
display: flex;
align-items: center;
position: sticky;
top: 280rpx;
z-index: 2;
background-color: #f2f3f7;
margin-top: -32rpx;
.type {
margin-left: 8px;
display: flex;
justify-content: center;
align-items: center;
padding: 0 16rpx;
height: 24px;
line-height: 24px;
background: #ffffff;
border-radius: 14px;
font-size: 12px;
color: #8a8c90;
.point {
margin-left: 2px;
width: 12px;
height: 12px;
}
}
.active {
color: #3964fe;
}
}
.list {
box-sizing: border-box;
// padding-bottom: 8rpx;
.msg {
padding: 10px 16px 16px;
margin-bottom: 8px;
position: relative;
background-color: #fff;
border-radius: 4px;
}
.like {
position: absolute;
right: 12px;
top: 0;
width: 23px;
height: 23px;
}
.name {
display: flex;
align-items: center;
// font-weight: 400;
font-size: 14px;
color: #323436;
.avatar {
margin-left: 2px;
width: 20px;
height: 20px;
}
}
.line {
margin-top: 10px;
margin-bottom: 10px;
height: 0;
border-bottom: #eeeeee 1px dashed;
}
.want-more {
overflow: hidden;
}
.want-btn {
margin-top: 10px;
font-size: 12px;
color: var(--btnColor);
}
.record {
margin-top: 4px;
margin-bottom: 4px;
display: flex;
justify-content: space-between;
align-items: center;
.action-wrap {
display: flex;
align-items: center;
font-size: 12px;
color: #393b3e;
}
// .action{
// }
// .detail{
// }
.time {
font-size: 12px;
color: #8a8c90;
}
}
.info {
margin-top: 10px;
display: flex;
justify-content: space-between;
.phone-wrap {
display: flex;
align-items: center;
}
.phone {
font-size: 12px;
color: #3666fe;
}
.phone-img {
margin-left: 12px;
margin-right: 8px;
width: 20px;
height: 20px;
border-radius: 50%;
}
.copy {
width: 20px;
height: 20px;
border-radius: 50%;
}
.btn {
width: 85px;
height: 24px;
background: var(--btnColor);
border-radius: 12px;
font-size: 12px;
color: #ffffff;
text-align: center;
line-height: 24px;
}
}
.noDataImg {
width: 512rpx;
height: 512rpx;
margin-left: 100rpx;
position: relative;
.noDataTxt {
font-family: PingFangSC-Regular;
font-size: 24rpx;
color: #CCCED1;
position: absolute;
bottom: 32rpx;
left: 50%;
transform: translateX(-50%);
}
}
.shop {
.name-wrap {
display: flex;
justify-content: space-between;
align-items: center;
}
.source {
font-size: 10px;
color: #8a8c90;
}
.btn {
border: 1px solid var(--btnColor);
border-radius: 12px;
background-color: #fff;
font-size: 12px;
color: var(--btnColor);
}
.shop-action-wrap {
display: flex;
justify-content: space-between;
align-items: center;
}
.shop-record {
width: 100%;
}
.shop-source {
margin-top: 4px;
width: 100%;
font-size: 12px;
color: #393b3e;
}
}
.bottomTips {
text-align: center;
color: #393b3e;
font-size: 26rpx;
height: 60rpx;
line-height: 40rpx;
}
}
}
.scene {
// margin-top: 32rpx;
// margin-left: 20rpx;
// margin-right: 20rpx;
// margin-bottom: 10rpx;
margin: 32rpx 32rpx 0;
.scene-wrap {
display: flex;
}
.item-wrap {
margin-right: 16rpx;
margin-bottom: 40rpx;
position: relative;
width: 172rpx;
height: 180rpx;
border-radius: 8rpx;
border: 1px solid #f7f8fc;
box-sizing: border-box;
}
.item {
// padding-top: 10px;
width: 172rpx;
height: 180rpx;
background: #f7f8fc;
border-radius: 8rpx;
box-sizing: border-box;
// border: 1px solid #f7f8fc;
}
.act {
// background-image: url("https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/index/act.png");
// background-size: 100% 100%;
border: 1px solid var(--btnColor);
box-shadow: 0 2rpx 4rpx 0 rgba(180, 186, 204, 0.4);
&::after {
position: absolute;
left: 50%;
bottom: -7px;
display: block;
content: "";
width: 6px;
height: 6px;
border-bottom: 1px solid var(--btnColor);
border-right: 1px solid var(--btnColor);
transform: rotate(45deg) translateX(-50%);
background-color: #fff;
}
.item {
background: transparent;
}
}
.img {
padding-top: 10px;
display: block;
margin: 0 auto 2px;
width: 28px;
height: 28px;
}
.name {
margin-bottom: 2px;
font-weight: 500;
font-size: 12px;
color: #323436;
text-align: center;
}
.msg {
font-weight: 400;
font-size: 9px;
color: #8a8c90;
text-align: center;
}
}
}
.guide {
width: 100%;
height: 100%;
.guide-img {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 3;
}
}
.chat {
position: fixed;
right: -4px;
top: 60%;
width: 64px;
height: 64px;
border-radius: 50%;
z-index: 2;
}
.output-value {
position: fixed;
right: -2px;
top: 70%;
width: 64px;
height: 64px;
// border-radius: 50%;
z-index: 2;
}
/* 测算弹窗 */
.dialog-wrapper {
position: fixed;
height: 100vh;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(45, 45, 51, 0.50);
z-index: 2;
.dialog-box {
position: fixed;
bottom: 0;
width: 100%;
background-color: #fff;
box-shadow: 0 -8rpx 20rpx 0 rgba(180, 186, 204, 0.32);
border-radius: 32rpx 32rpx 0 0;
}
.dialog-header {
display: flex;
justify-content: space-between;
padding: 32rpx 48rpx;
border-bottom: 1rpx solid #eee;
}
.header-btn {
display: inline-block;
font-size: 32rpx;
line-height: 48rpx;
}
.btn-gray {
color: #6C737A;
}
.btn-primary {
background-color: #fff;
border: none;
margin: 0;
padding: 0;
font-weight: 500;
color: #3666FE;
width: auto;
}
.btn-primary::after {
border: none;
}
.dialog-content {
padding: 40rpx 24rpx 60rpx;
}
.dialog-title {
font-weight: 600;
font-size: 36rpx;
color: #333333;
letter-spacing: 0;
text-align: center;
line-height: 56rpx;
margin-bottom: 24rpx;
}
.dialog-form {
width: 100%;
height: 384rpx;
background-image: linear-gradient(179deg, rgba(240, 247, 255, 0.30) 15%, #F0F7FF 100%);
border-radius: 8rpx;
padding: 32rpx;
box-sizing: border-box;
}
.form-item {
display: flex;
align-items: center;
height: 80rpx;
margin-bottom: 24rpx;
justify-content: space-between;
}
.form-label {
width: 256rpx;
font-size: 28rpx;
color: #2D2D33;
}
.form-input {
width: 216rpx;
padding: 16rpx 20rpx;
border: 2rpx solid #E6E6E6;
border-radius: 4rpx;
margin-left: 64rpx;
margin-right: 16rpx;
}
.form-unit {
font-size: 28rpx;
color: #6E6E7A;
}
.dialog-btn {
width: 100%;
padding: 24rpx 0;
box-sizing: border-box;
background: #3666FE;
border-radius: 8rpx;
font-weight: 500;
font-size: 32rpx;
color: #FFFFFF;
letter-spacing: 0.8rpx;
text-align: center;
line-height: 48rpx;
margin-top: 40rpx;
}
}
// .clue {
// flex: 1;
// overflow: hidden;
// }
\ No newline at end of file \ No newline at end of file
<navigation-bar bindnavbarReady="navbarReady" navStyle="{{navStyle}}">拓客户</navigation-bar>
<view class="reclaim" style="{{tabIndx == 1 ? 'background: #fff;' : ''}}">
<!-- 头部 -->
<view class="header-wrap" style="height:{{headerHeight}}rpx; background-image: url('{{IMG_URL}}index/head.png')">
<view class="header">
<!-- <tab
tab="{{navList}}"
itemWidth="{{'35%'}}"
index="{{tabIndx}}"
tabHeight
unreadClueCount="{{unreadClueCount}}"
bindclick="changeTabIndx"
class="tabContainer"
/>
<view class="right" data-type="shop" bindtap="gotoApply">
<image class="img" src="{{IMG_URL}}index/apply.png" />
<view class="apply">申请业务</view>
</view> -->
</view>
</view>
<!-- 托客户内容 -->
<view
class="content"
wx:if="{{tabIndx == 1 }}"
hover-class="none"
hover-stop-propagation="false"
>
<view class="scene">
<!-- wx:if="{{item.sceneStatus == 1}}" -->
<scroll-view scroll-x="{{true}}">
<view class="scene-wrap">
<view
class="item-wrap {{actNum== index ? 'act':''}}"
data-num="{{index}}"
data-scenestatus="{{item.sceneStatus}}"
bindtap="selectCar"
wx:for="{{senceData}}"
wx:key="name"
>
<view class="item">
<image class="img" src="{{item.src}}" />
<view class="name">{{item.name}}</view>
<view class="msg">{{item.msg}}</view>
</view>
</view>
</view>
</scroll-view>
</view>
<product
isShow="{{false}}"
stickyTop="{{headerHeight}}"
actNum="{{actNum}}"
senceData="{{senceData}}"
origin="home"
bindsharehandle="sharehandle"
/>
</view>
</view>
<!-- 收藏、取消提示框 -->
<!-- <vas-toast isShow="{{true}}" id='toast' /> -->
<!-- 引导图 -->
<view class="guide" wx:if="{{guideShow}}" style="overflow-y:hidden;">
<image
webp
bindtap="guideFn"
class="guide-img"
src="{{IMG_URL}}index/guide{{guideSrcIndex}}.png"
/>
</view>
<!-- 在线客服 -->
<image class="chat" src="{{IMG_URL}}index/contact.png" bindtap="goConsult" />
<!-- 预估产值 -->
<image
class="output-value"
bindtap="showCalculate"
src="{{IMG_URL}}index/valuation.png"
wx:if="{{tabIndx == 1}}"
/>
<!-- 预估产值弹框 -->
<view class="dialog-wrapper" bindtap="clickDialog" hidden="{{!visible}}">
<view class="dialog-box">
<form bindsubmit="submit">
<view class="dialog-header">
<view wx:if="{{!isReset}}" class="header-btn btn-gray" bindtap="showCalculate">取消</view>
<view wx:if="{{isReset}}" class="header-btn btn-gray" bindtap="reset">重置</view>
<button class="header-btn btn-primary" form-type="submit">确定</button>
</view>
<view class="dialog-content">
<view class="dialog-title">输入您门店的基本情况</view>
<view class="dialog-form">
<view class="form-item">
<view class="form-label">门店月平均新车销量</view>
<input
class="form-input"
bindfocus="focus"
maxlength="8"
name="sales"
value="{{formData.sales}}"
type="number"
/>
<!-- <view class="form-unit">台</view> -->
</view>
<view class="form-item">
<view class="form-label">3年内售后存量用户</view>
<input
class="form-input"
bindfocus="focus"
maxlength="8"
name="flow"
type="number"
value="{{formData.flow}}"
/>
<!-- <view class="form-unit">人</view> -->
</view>
<button class="dialog-btn" form-type="submit">提交测算</button>
</view>
</view>
</form>
</view>
</view>
...@@ -39,8 +39,10 @@ ...@@ -39,8 +39,10 @@
"disableUseStrict": false, "disableUseStrict": false,
"minifyWXML": true, "minifyWXML": true,
"showES6CompileOption": false, "showES6CompileOption": false,
"useCompilerPlugins": false, "ignoreUploadUnusedFiles": false,
"ignoreUploadUnusedFiles": false "useCompilerPlugins": [
"sass"
]
}, },
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "2.25.4", "libVersion": "2.25.4",
......
...@@ -165,12 +165,21 @@ ...@@ -165,12 +165,21 @@
"query": "", "query": "",
"launchMode": "default", "launchMode": "default",
"scene": null "scene": null
},
{
"name": "",
"pathName": "pages/scene/scene",
"query": "",
"launchMode": "default",
"scene": null
} }
] ]
} }
}, },
"setting": { "setting": {
"urlCheck": false "urlCheck": false,
"compileHotReLoad": true
}, },
"libVersion": "2.26.1" "libVersion": "2.26.1",
"projectname": "ai-card"
} }
\ No newline at end of file \ No newline at end of file
/**app.wxss**/
/*每个页面公共css */
.sticky {
position: sticky;
top: 0;
left: 0;
z-index: 2;
background-color: #fff;
}
.flex-center {
display: flex;
align-items: center;
justify-content: start;
}
.y-center {
top: 50%;
transform: translateY(-50%);
}
.x-center {
left: 50%;
transform: translateX(-50%);
}
.box-center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.text-hide {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.text-two-line {
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 2;
display: -webkit-box;
-webkit-box-orient: vertical;
}
.text-center {
display: flex;
align-items: center;
justify-content: center;
}
.isFullSucreen {
padding-bottom: constant(safe-area-inset-bottom) !important;
padding-bottom: env(safe-area-inset-bottom) !important;
}
.isFullSucreen-bottom {
bottom: constant(safe-area-inset-bottom) !important;
bottom: env(safe-area-inset-bottom) !important;
}
.c-blue {
color: #3666FE;
}
.c-white {
color: #fff;
}
.bgc-blue {
background-color: #3666FE;
}
\ No newline at end of file \ No newline at end of file
No preview for this file type
const _ctx_ = Symbol('_ctx_')
const _pixelRatio_ = Symbol('_pixelRatio_')
const _canvasObject_ = Symbol('_canvasObject_')
const _canvas_ = Symbol('_canvas_')
class Draw {
[_ctx_] = null;
[_pixelRatio_] = null;
[_canvasObject_] = null;
[_canvas_] = null
constructor(canvasObject, isCompInst) {
this[_canvasObject_] = canvasObject
this[_pixelRatio_] = canvasObject.pixelRatio || 2
const height = this.toRpx(canvasObject.height),
width = this.toRpx(canvasObject.width),
canvas = wx.createOffscreenCanvas({
type: '2d',
width,
height,
compInst: isCompInst
}),
ctx = canvas.getContext('2d')
this[_canvas_] = canvas
this[_ctx_] = ctx
this[_ctx_].clearRect(0, 0, width, height)
this.drawFill({
x: 0,
y: 0,
width,
height,
color: canvasObject.backgroundColor || 'rgb(255, 255, 255)'
})
this[_ctx_].save()
}
async drawImages(imageParams, callback) {
this[_ctx_].beginPath()
this[_ctx_].save()
let {
borderRadius,
height,
width,
url,
x,
y
} = imageParams
height = this.toRpx(height)
width = this.toRpx(width)
x = this.toRpx(x)
y = this.toRpx(y)
if (borderRadius) {
this.drawRadiusRect({
borderRadius,
height,
width,
x,
y
})
this[_ctx_].clip()
}
let image = this[_canvas_].createImage()
image.src = `${url}?v=${Date.now()}`
return new Promise(resolve => {
image.onload = () => {
this[_ctx_].drawImage(image, x, y, width, height)
this[_ctx_].restore()
if (callback) callback()
resolve(imageParams)
}
image.onerror = err => {
wx.hideLoading()
wx.showToast({
title: '图片加载失败',
icon: 'error'
})
}
})
}
toRpx(val) {
return this[_pixelRatio_] * val
}
getTextWidth(text, fontSize) {
let font = this[_ctx_].font.split('px')[1]
if (fontSize) this[_ctx_].font = `${fontSize}px${font}`
return this[_ctx_].measureText(text).width
}
drawFill({
x,
y,
width,
height,
color
}) {
height = this.toRpx(height)
width = this.toRpx(width)
x = this.toRpx(x)
y = this.toRpx(y)
this[_ctx_].beginPath()
this[_ctx_].fillStyle = color
this[_ctx_].fillRect(x, y, width, height)
this[_ctx_].stroke()
this[_ctx_].restore()
this[_ctx_].save()
}
drawText(textParams) {
let {
textDecoration,
textBaseline,
lineHeight,
fontWeight,
textAlign,
textWidth,
maxWidth,
fontSize,
lastFont,
opacity,
lineNum,
width,
color,
text,
x,
y
} = textParams,
font = this[_ctx_].font.split('px')[1]
textAlign = textAlign || 'left'
textBaseline = textBaseline || 'normal'
opacity = typeof opacity === 'number' ? opacity : 1
lineHeight = this.toRpx(lineHeight || fontSize || 12)
textWidth = this.toRpx(textWidth || 0)
fontSize = this.toRpx(fontSize || 12)
maxWidth = this.toRpx(maxWidth || width || this[_canvasObject_].width)
width = this.toRpx(width || this[_canvasObject_].width)
x = this.toRpx(x)
y = this.toRpx(y)
let fontX = this.getFontWidth({
textAlign,
fontSize,
text,
x
})
this[_ctx_].beginPath()
this[_ctx_].globalAlpha = opacity
this[_ctx_].font = `${fontWeight || 400} ${fontSize}px${font}`
this[_ctx_].fillStyle = color || '#000'
this[_ctx_].strokeStyle = color || '#000'
this[_ctx_].textBaseline = textBaseline
this[_ctx_].textAlign = textAlign
this[_ctx_].lineWidth = this.toRpx(2)
let text_width = this.getTextWidth(text)
if (textParams.border) this.drawBorder({
text,
x: textParams.x,
y: textParams.y,
fontSize: textParams.fontSize || 12,
...textParams.border
})
const drawOneLineText = () => {
let textArr = text.toString().split(''),
newText = '',
ellipsis = false
try {
textArr.map(e => {
newText += e
if (this.getTextWidth(newText) > width - fontX) throw true
})
} catch (error) {
ellipsis = error
}
if (ellipsis) newText += '…'
if (lastFont) newText += lastFont
this[_ctx_].fillText(newText, x, y, maxWidth)
if (checkTextDecoration(textDecoration)) {
this.drawDecoration({
textDecoration,
textBaseline,
textAlign,
fontSize,
newText,
opacity,
text,
y,
x
})
}
}
if (lineNum > 1) {
let textArr = text.split(''),
textRowArr = [],
currentText = '',
viewWidth = width - fontX
if (text_width > viewWidth) {
textArr.map(e => {
currentText += e
if (this.getTextWidth(currentText) >= viewWidth && textRowArr.length < lineNum - 1) {
textRowArr.push(currentText)
currentText = ''
}
})
if (currentText.length) textRowArr.push(currentText)
textRowArr.map((e, index) => {
if (this.getTextWidth(e) > viewWidth && index == lineNum - 1) {
try {
let lastText = '',
lastArr = e.split('')
lastArr.map(i => {
lastText += i
if (this.getTextWidth(lastText) > width - fontX - this.getTextWidth('…')) throw lastText
})
} catch (error) {
if (lastFont) e = `${error.substring(0, error.length - lastFont.length)}…${lastFont}`
else e = `${error}…`
}
}
if (lastFont && e.indexOf(lastFont) == -1 && textRowArr.length < 2) e = `${e.substring(0, e.length - lastFont.length)}…${lastFont}`
let textHeight = y + index * (lineHeight || fontSize)
this[_ctx_].fillText(e, x, textHeight, maxWidth)
if (checkTextDecoration(textDecoration)) {
this.drawDecoration({
y: textHeight,
textDecoration,
textBaseline,
textAlign,
fontSize,
newText: e,
opacity,
text,
x
})
}
})
} else {
drawOneLineText()
}
} else drawOneLineText()
this[_ctx_].stroke()
}
drawBorder(params) {
let {
x,
y,
text,
color,
width,
radius,
opacity,
padding,
fontSize
} = params
console.log(params)
let topX, topY, rightX, rightY, bottomX, bottomY, leftX, leftY, paddingX, paddingY
// if(padding && padding.length>1)
if (radius) {
}
}
drawLine(lineParams, callback) {
this[_ctx_].beginPath()
let {
opacity,
startX,
startY,
width,
color,
endX,
endY
} = lineParams
startX = this.toRpx(startX)
startY = this.toRpx(startY)
width = this.toRpx(width)
endX = this.toRpx(endX)
endY = this.toRpx(endY)
this[_ctx_].globalAlpha = typeof opacity === 'number' ? opacity : 1
this[_ctx_].strokeStyle = color || '#000'
this[_ctx_].lineWidth = width || this.toRpx(1)
this[_ctx_].moveTo(startX, startY)
this[_ctx_].lineTo(endX, endY)
this[_ctx_].stroke()
this[_ctx_].restore()
this[_ctx_].save()
if (callback) callback()
}
setLineY = params => {
let {
textDecoration,
textBaseline,
fontSize,
y
} = params
let type = {
underline: {
top: y + fontSize,
middle: y + fontSize / 2,
bottom: y,
normal: y
},
overline: {
top: y,
middle: y - fontSize / 2,
bottom: y - fontSize,
normal: y
},
'line-through': {
top: y + fontSize / 2,
middle: y - fontSize / 2,
bottom: y,
normal: y
}
}
return type[textDecoration][textBaseline]
}
setLineX({
textAlign,
text,
x
}) {
let textWidth = this.getTextWidth(text)
let type = {
left: x,
center: x - textWidth / 2,
right: x - textWidth
}
return type[textAlign]
}
drawRadiusRect({
borderRadius,
height,
width,
x,
y
}, callBack) {
let radius = typeof borderRadius === 'string' ? ((Number(borderRadius.split('%')[0]) / 100) * width) / 2 : borderRadius / 2
radius = radius || 0
this[_ctx_].beginPath()
for (let i = 1; i < 5; i++) {
let arcX = i === 1 || i === 4 ? x + width - radius : x + radius
let arcY = i === 1 || i === 2 ? y + height - radius : y + radius
this[_ctx_].arc(arcX, arcY, radius, 2 * Math.PI * ((i - 1) / 4), 2 * Math.PI * (i / 4))
}
if (callBack) callBack()
}
getFontWidth({
textAlign,
fontSize,
text,
x
}) {
let type = {
left: x,
center: x - (fontSize * text.length) / 2,
right: x - fontSize * text.length
}
return type[textAlign] < 0 ? 0 : type[textAlign]
}
drawDecoration(params) {
let {
newText,
opacity,
y,
x
} = params
let lineX = x
let lineY = y
lineX = this.setLineX(params)
lineY = this.setLineY(params)
this[_ctx_].globalAlpha = opacity
this[_ctx_].moveTo(lineX, lineY)
this[_ctx_].lineTo(lineX + this.getTextWidth(newText), lineY)
}
toDataURL(callBack) {
let url = this[_canvas_].toDataURL('image/png')
const base64src = function (base64data) {
return new Promise((resolve, reject) => {
const [a, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(base64data) || []
if (!format) reject(new Error('ERROR_BASE64SRC_PARSE'))
const filePath = `${wx.env.USER_DATA_PATH}/tmp_base64src.${format}`
const buffer = wx.base64ToArrayBuffer(bodyData)
wx.getFileSystemManager().writeFile({
filePath,
data: buffer,
encoding: 'binary',
success() {
resolve(filePath)
},
fail() {
reject(new Error('ERROR_BASE64SRC_WRITE'))
}
})
})
}
base64src(url).then(img => {
createLocalImg(img, callBack)
})
}
async begin(data = {}) {
return new Promise(async (resolve, reject) => {
const drawFun = () => {
data.textList && data.textList.length && data.textList.map(e => {
this.drawText(e)
})
data.lineList && data.lineList.length && data.lineList.map(e => {
this.drawLine(e)
})
wx.nextTick(() => {
this.toDataURL(res => resolve(res))
})
}
if (data.imageList && data.imageList.length) {
await this.drawImages(data.imageList[0])
if (data.imageList.length > 1)
for (let index = 1; index < data.imageList.length; index++) {
await this.drawImages(data.imageList[index])
if (index == data.imageList.length - 1) drawFun()
}
else drawFun()
}
})
}
}
const checkTextDecoration = textDecoration => {
return textDecoration && (textDecoration === 'underline' || textDecoration === 'overline' || textDecoration === 'line-through')
}
/**网络图片转成本地资源 */
const createLocalImg = (url, callBack) => {
wx.getImageInfo({
src: url,
success(res) {
callBack(res)
},
fail() {
wx.showToast({
title: '图片生成失败,请稍后再试',
icon: 'none'
})
wx.hideLoading()
console.error(`图片转换本地失败,${url}`)
}
})
}
export default Draw
\ No newline at end of file \ No newline at end of file
/**
* 微信小程序标准版:统一封装的 storage 操作类
*/
import { DEFAULT_GET_STORAGEKEY, STORAGE_OBJECTkEY } from '../constantData'
class Storage {
types = {
1: 'get', // get
2: 'set', // set
3: 'rm' // rm
}
envVersion = {
develop: '开发版',
trial: '体验版',
release: '正式版'
}
// defaultGetStorageKey = DEFAULT_GET_STORAGEKEY
/** 构造函数 */
constructor() {
/** 获取当前小程序环境变量 */
const accountInfo = wx.getAccountInfoSync()
this.environment = accountInfo?.miniProgram.envVersion || 'release'
}
/**
*
* @param {*} key | 要操作的键值
* @param {*} type | 类型,是 get set rm
* @param {*} emptyFlag | 是否判断为空情况,默认判断 true,false 为不判断
*/
checkKeyType(key, type, emptyFlag = true) {
if (typeof key != 'string') {
throw new Error(`Storage ${this.types[type]} func: key must be string`)
return false
}
if (emptyFlag) {
let tmpKey = key.TrimStr()
if (tmpKey == '') {
throw new Error(`Storage ${this.types[type]} func: key can not be empty`)
return false
}
// if STORAGE_OBJECTkEY[key]
return tmpKey
}
return key
}
/**
*
* @param {*} key | 要操作的键值
* @param {*} syncFlag | 同步状态,默认 false (异步),true 为同步
*/
get = (key, syncFlag = true) => {
// 有值默认取key值
if (key) {
// 判断值是否是指定的对象值
let tmpKey = this.checkKeyType(key, 1)
let isObjectKey = STORAGE_OBJECTkEY[tmpKey]
// console.log(key)
// console.log(isObjectKey)
if (isObjectKey) {
return this.getObjectKeyValue(isObjectKey)
} else {
throw new Error(`Storage ${this.types[1]} ${key}: key must be register`)
}
} else {
return this.getObjectKeyValue(DEFAULT_GET_STORAGEKEY)
}
}
/**
*
* @param {*} 空key返回默认定义数组的值
*/
getObjectKeyValue(key) {
// ObjectList
if (typeof key == 'string') {
key = this.addEvnToKey(key)
let res = wx.getStorageSync(key)
if (res) {
return JSON.parse(res)
} else {
// reject(errMsg)
return ''
}
} else {
let Obj = {}
key.forEach(key => {
let defaultKey = this.addEvnToKey(key)
let res = wx.getStorageSync(defaultKey)
Obj[key] = res ? JSON.parse(res) : ''
})
return Obj
}
}
/**
*
* @param {*} key | 要操作的键值
* @param {*} data | 要存储的值,会转换为 JSON 串进行存储
* @param {*} syncFlag | 同步状态,默认为同步 false (异步),true 为同步
*/
set = (key, data, syncFlag = true) => {
let tmpKey = this.checkKeyType(key, 2)
if (tmpKey) {
tmpKey = this.addEvnToKey(tmpKey)
const sucMsg = 'Storage set: set data successfully'
const errMsg = 'Storage set: failed to set data'
return new Promise((resolve, reject) => {
let tmpData = JSON.stringify(data)
if (syncFlag) {
try {
wx.setStorageSync(tmpKey, tmpData)
resolve(sucMsg)
} catch (err) {
console.log(err)
reject(errMsg)
}
} else {
wx.setStorage({
data: tmpData,
key: tmpKey,
success: () => {
resolve(sucMsg)
},
fail: err => {
console.log(err)
reject(errMsg)
}
})
}
})
}
}
/**
*
* @param {*} key | 要操作的键值,为空则清空所有,有值则清空指定的值
* @param {*} syncFlag | 同步状态,默认 false (异步),true 为同步
*/
rm = (key = '', syncFlag = false) => {
let tmpKey = this.checkKeyType(key, 3, false)
tmpKey = tmpKey.TrimStr()
const sucMsg = 'Storage rm: rm data successfully'
const errMsg = 'Storage rm: failed to rm data'
return new Promise((resolve, reject) => {
if (tmpKey == '') {
if (syncFlag) {
try {
wx.clearStorageSync()
resolve(sucMsg)
} catch (err) {
console.log(err)
reject(errMsg)
}
} else {
wx.clearStorage({
success: res => {
resolve(sucMsg)
},
fail: err => {
console.log(err)
reject(errMsg)
}
})
}
} else {
tmpKey = this.addEvnToKey(tmpKey)
if (syncFlag) {
try {
wx.removeStorageSync(tmpKey)
resolve(sucMsg)
} catch (err) {
console.log(err)
reject(errMsg)
}
} else {
wx.removeStorage({
key: tmpKey,
success: () => {
resolve(sucMsg)
},
fail: err => {
console.log(err)
reject(errMsg)
}
})
}
}
})
}
/**
* @description: key 拼接小程序环境变量
* @param {*} key | 要操作的键值,
* @returns {String} 拼接后的值
*/
addEvnToKey = key => {
// return // console.log(this.environment)
return `${this.environment}_${key}`
}
}
/** 去除前导空格和后导空格 */
String.prototype.TrimStr = function () {
return this.replace(/(^\s*)|(\s*$)/g, '')
}
export { Storage }
// 实例化对象存储
import { Storage } from './storage'
const $Storage = new Storage()
// console.log($Storage)
/** */
export function getSessionId() {
return $Storage.get('sessionId')
}
export function setSessionId(sessionId) {
$Storage.set('sessionId', sessionId)
}
export function getUserInfo() {
return $Storage.get('userInfo')
}
export function setUserInfo(data) {
console.log(data)
$Storage.set('userInfo', data)
}
export function removeSystemStorage() {
// $Storage.rm('srcm_shopmall_user_info')
// $Storage.rm('scrm_shopmall_sessionId')
// $Storage.rm('guest_no')
// $Storage.rm('equity_info')
// $Storage.rm('packageList')
// $Storage.rm('isVIP')
// $Storage.rm('bizjiaUrl')
// $Storage.rm('vip_card_info')
}
export function setStorageSync(key, data) {
$Storage.set(key, JSON.stringify(data))
}
export function getStorageSync(key) {
return $Storage.get(key) || null
// JSON.parse(data)
}
/**设置标题栏 */
export function setNavigationBarTitleText(title) {
$Storage.set('app_title', title)
}
/**获取app标题 */
export function getNavigationBarTitleText() {
return $Storage.get('app_title')
}
/** 存储设备信息 */
export function setSystem_info(that) {
let info = $Storage.get('system_info')
!info &&
wx.getSystemInfo({
success(res) {
// console.log(res)
$Storage.set('system_info', res)
}
})
}
/**获取用户信息 */
export function getUserInfo() {
let user = wx.$storage.get('userInfo') || null
return user
}
/**设置用户信息 */
export function setUserInfo(userInfo) {
wx.$storage.set('userInfo', userInfo)
}
export function isMember(isNeedToHttp, callBack) {
if (isNeedToHttp) {
equityApi.checkOpenMember().then(res => {
let flag = false
if (res.code == 0 && res.data) {
flag = true
}
wx.$storage.set('isVIP', flag)
callBack && callBack(flag, res.data)
})
return
}
return wx.$storage.get('isVIP') || false
}
export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/'
// 缓存get方法为空的默认指定值
export const DEFAULT_GET_STORAGEKEY = ['sessionId', 'merchantId', 'userInfo']
// 缓存get方法key的对应才映射值
export const STORAGE_OBJECTkEY = {
DEFAULT_GET_STORAGEKEY,
sessionId: 'sessionId',
userInfo: 'userInfo',
system_info: 'systemInfo',
app_title: 'appTitle',
auto_login_object: 'auto_login_object',
wx_user_info: 'wx_user_info',
userPhone: 'userPhone',
firstLogin:'firstLogin',
authphone:'authphone'
}
export const IMG_VERSION = () =>{
const accountInfo = wx.getAccountInfoSync()
return accountInfo.miniProgram.version || '1.0.0'
}
\ No newline at end of file \ No newline at end of file
class Bus {
constructor() {
this.events = {}
}
on(Event, cb) {
if(this.events[Event]) {
this.events[Event].push(cb);
} else {
this.events[Event] = [cb];
}
// 如果是匿名函数就给用户个警告
if(!cb.name) {
console.warn('on 接口的 handler 参数推荐使用具名函数。具名函数可以使用 off 接口取消订阅,匿名函数无法取消订阅。')
}
}
emit(Event, obj) {
if(!this.events[Event]) return
this.events[Event].forEach(cb => {
cb(obj)
})
}
off(Event,cb) {
if(!this.events[Event]) return
const index = this.events[Event].findIndex(item => item === cb);
if (index === -1) {
// console.error(new Error('该 handle 没有订阅者,取消订阅失败'));
return;
}
this.events[Event].splice(index, 1);
}
// 给这个类加一个静态方法,用来判断这个类之前有没有生成过对象
static getInstance() {
if (!Bus.instance) {
Bus.instance = new Bus()
}
return Bus.instance;
}
}
// 导出这里返回 Bus 类静态 getInstance 的执行结果
export default Bus.getInstance();
\ No newline at end of file \ No newline at end of file
...@@ -446,6 +446,34 @@ const deepClone = (target) => { ...@@ -446,6 +446,34 @@ const deepClone = (target) => {
return clone(target) return clone(target)
} }
/**
* 判断是否是空对象
* @param {*} obj 传进来的对象
* @returns
*/
const isEmptyObj = (obj) => {
return JSON.stringify(obj) === "{}";
};
// 解析参数成对象 "actNum=1&activeNavIdx=0&isShare=true"
const parseString = (str) => {
// console.log('str: ', str);
if (!str) return;
let obj = {};
let strArr = str.split("&");
// console.log('strArr: ', strArr);
strArr.forEach((item) => {
// console.log("item: ", item);
let keyArr = item.split("=");
obj[keyArr[0]] = keyArr[1];
});
return obj;
};
const Util = { const Util = {
setNavigationBarTitleText, setNavigationBarTitleText,
getNavigationBarTitleText, getNavigationBarTitleText,
...@@ -478,6 +506,8 @@ const Util = { ...@@ -478,6 +506,8 @@ const Util = {
throttle, throttle,
decimal, decimal,
timeago, timeago,
deepClone deepClone,
isEmptyObj,
parseString,
} }
export default Util export default Util
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!