Commit bfd48e4f by 李伟康

合并代码

2 parents a8e9746d 8eb22af7
import api from "~/utils/request/request";
const serverApi = {
createQrCode: "scrm.api.busassistant.activity.createQrCode",
};
// 拓客户
export const createQrCodeApi = (data) => {
return api.post(
{
method: serverApi.createQrCode,
...data,
},
true
);
};
\ No newline at end of file
import WxValidate from '../../utils/WxValidate'
import WxValidate from '../../utils/wxValidate'
Page({
/**
* 页面的初始数据
......
// pages/checkProduct/checkProduct.js
// const navStyle = "background-color: transparent;";
import {
IMG_URL
} from "~/utils/constantData.js";
const navStyle = "background-color: #fff";
import {
senceData
} from "~/pages/tab/index/constant/data";
import { senceData } from "~/pages/tab/index/constant/data";
import { IMG_URL } from "~/utils/constantData.js";
import Draw from "~/utils/Draw.js";
import {createQrCodeApi} from '~/api/checkProduct.js'
Page({
/**
* 页面的初始数据
......@@ -17,13 +16,56 @@ Page({
senceData,
// 模态框
isShow: true,
// IMG_URL: `${IMG_URL}index`,
btnList: [
{
src: `${IMG_URL}index/wechat.png`,
name: "微信转发",
},
// {
// src: `${IMG_URL}index/moments.png`,
// name: "朋友圈分享",
// },
{
src: `${IMG_URL}index/down.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,
},
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;
let { height, statusBarHeight } = e.detail;
this.setData({
headerHeight: height / 2 + statusBarHeight,
// headerHeight: height / 2 + statusBarHeight,
......@@ -35,7 +77,7 @@ Page({
// 分项弹框关闭
modelcloseFn(e) {
this.setData({
isShow: e.detail,
isShow: false,
});
},
// 分享按钮
......@@ -48,23 +90,149 @@ Page({
onRoute(options) {
// console.log("options: ", options);
//选中场景的index,和产品的index
let {
actNum,
activeNavIdx
} = options
let { actNum, activeNavIdx } = options;
this.setData({
actNum,
activeNavIdx
activeNavIdx,
});
},
// 分享按钮
handleClick(e) {
let { index } = e.currentTarget.dataset;
switch (index) {
case 0:
this.wechatFn();
break;
case 1:
this.download();
break;
}
},
// 微信转发
wechatFn() {
// this.data.onShareAppMessage()
this.modelcloseFn();
},
// 下载海报
async download() {
let { actNum, activeNavIdx ,imgHeightArr} = this.data;
let res = await createQrCodeApi({
actNum, activeNavIdx,isShare:true
})
// let { actNum, imgHeightArr } = this.data;
//所有的长度
let imgAllHeight = imgHeightArr[actNum].reduce((total, current) => {
return total + current;
});
// 缺少视频的长度(前4张)+二维码的长度 (单位rpx)
let erCodeHeight =
imgHeightArr[actNum].slice(0, 4).reduce((total, current) => {
return total + current;
}) +
98 * 2;
// // console.log("imgAllHeight: ", imgAllHeight);
// let drawFun = new Draw({
// width: 750,
// height: imgAllHeight,
// });
let drawFun = new Draw({
width: this.data.imgWidth,
height: this.data.imgHeight,
});
// let imgList = [
// {
// x: 0,
// y: 0,
// width: 750,
// height: imgAllHeight,
// 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,
// url: `https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/index/discovery_prod1.png`, //二维码
// },
// ];
let arr = [456,222,0,496]
let imgList = [
{
x: 0,
y: 0,
width: this.data.imgWidth,
height: this.data.imgHeight,
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: this.data.imgWidth-64,
y:this.data.imgHeight-arr[actNum]-64,
width: 64,
height: 64,
url: res.data, //二维码
},
];
let posterUrl = await drawFun.begin({
imageList: imgList,
});
this.setData({
posterUrl: posterUrl.path,
});
console.log("posterUrl.path", posterUrl.path);
if (this.data.posterUrl) {
wx.pro.saveImageToPhotosAlbum({
url: this.data.posterUrl, //仅为示例,并非真实的资源
success(res) {
console.log("res: ", res);
},
});
}
this.modelcloseFn();
},
// //模态框关闭
// modelClose() {
// this.triggerEvent("modelclose", false);
// },
// 图片加载事件
onloadFn(event) {
console.log('event.detail',event.detail)
wx.hideLoading()
// this.setData({
// imgHeight: (event.detail.height * 0.2).toFixed(0),
// });
this.setData({
imgHeight:event.detail.height/5,
imgWidth:event.detail.width/5
})
},
// 分享获取懂得用户数
authorizedFn(e){
let res = e.detail
this.setData({
isShare:res.isShare,
phone: res.phone,
})
},
onViewTrack: true, //是否浏览埋点
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// actNum,activeNavIdx isShare
// 禁用分享功能
wx.hideShareMenu()
// actNum,activeNavIdx isShare
wx.showLoading({
title: "加载图片中",
});
},
/**
......@@ -101,4 +269,4 @@ Page({
* 用户点击右上角分享
*/
onShareAppMessage() {},
});
\ No newline at end of file
});
{
"usingComponents": {
"product": "../tab/index/components/product/product",
"shareModel":"../tab/index/components/shareModel/shareModel"
"product": "../tab/index/components/product/product"
},
"navigationStyle": "custom",
"onReachBottomDistance": 10,
......
/* pages/checkProduct/checkProduct.wxss */
\ No newline at end of file
/* pages/checkProduct/checkProduct.wxss */
// 分享模态框
.share-wrap {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 1;
.img-wrap {
position: absolute;
top: 20%;
left: 50%;
transform: translateX(-50%);
// width: 225px;
width: 60%;
height: 311px;
// background-color: red;
overflow: auto;
.img {
width: 100%;
// height: auto;
// height: 60%;
background-color: #fff;
}
}
.btns {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 154px;
background: #ffffff;
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;
}
.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;
}
}
}
......@@ -4,6 +4,33 @@
</view>
<product stickyTop="{{headerHeight}}" actNum="{{actNum}}" senceData="{{senceData}}" isShare="{{true}}"/>
<product stickyTop="{{headerHeight}}" actNum="{{actNum}}" senceData="{{senceData}}" isShare="{{isShare}}" bindauthorized="authorizedFn" />
<!-- 分享弹框 -->
<shareModel actNum="{{actNum}}" isShow="{{isShow}}" bindmodelclose="modelcloseFn" />
<!-- <shareModel actNum="{{actNum}}" isShow="{{isShow}}" bindmodelclose="modelcloseFn" /> -->
<view class="share-wrap" wx:if="{{isShow}}">
{{IMG_URL}}
<view class="img-wrap">
<image class="img" style="height:{{imgHeight}}px" src="{{IMG_URL}}index/longpic{{actNum+1}}.png" bindload="onloadFn" />
<!-- <block wx:for="{{imgList}}" wx:key="*this">
<image mode="widthFix" class="img" src="{{item}}"/>
</block> -->
</view>
<button></button>
<view class="btns">
<view class="top">
<view class="btn" wx:for="{{btnList}}" wx:key="name" bindtap="handleClick" data-index="{{index}}">
<block wx:if="{{index == 0}}">
<button open-type="share" class="btn-wechat">
<image class="img" src="{{item.src}}" />
<view class="name">{{item.name}}</view>
</button>
</block>
<block wx:else>
<image class="img" src="{{item.src}}" />
<view class="name">{{item.name}}</view>
</block>
</view>
</view>
<view class="btom" bindtap="modelcloseFn">取消</view>
</view>
</view>
// 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/'
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/";
Component({
// behaviors: [imgUrlMixin],
......@@ -15,80 +16,86 @@ Component({
senceData: Object,
isShare: {
type: Boolean,
value: false
}
value: false,
},
},
/**
* 组件的初始数据
*/
data: {
navList: ['360全景导航', 'AR实景导航', '座椅通风', '氛围灯', '数字化美容'],
navList: ["360全景导航", "AR实景导航", "座椅通风", "氛围灯", "数字化美容"],
activeNavIdx: 0,
tab: [
'场景说明',
'营销链路',
'项目亮点',
'转化漏斗',
'合作流程'
"场景说明",
"营销链路",
"项目亮点",
"转化漏斗",
"合作流程",
// "合作案例",
],
heightArr: [],
allHeight: 0,
curTabIdx: 0,
intoViewId: 'to-0',
intoViewId: "to-0",
IMGURL: `${IMG_URL}index/`,
videoBaseUrl
videoBaseUrl,
},
lifetimes: {
ready: function () {
this.init()
this.init();
// console.log('stickyTop',this.data.stickyTop)
this.getImgHeight()
this.getImgHeight();
//如果不是分享,初始化的时候调用函数
if (!this.data.isShare) {
// console.log(131546)
this.getMoreFn()
this.getMoreFn();
}
}
},
},
observers: {
actNum: function () {
let navList
let navList;
let tab = [
'场景说明',
'营销链路',
'项目亮点',
'转化漏斗',
'合作流程'
"场景说明",
"营销链路",
"项目亮点",
"转化漏斗",
"合作流程",
// "合作案例",
]
let num = this.data.actNum
];
let num = this.data.actNum;
switch (num) {
case 0:
navList = ['数字无忧权益卡']
break
navList = ["数字无忧权益卡"];
break;
case 1:
navList = ['汽车太阳膜']
break
navList = ["汽车太阳膜"];
break;
case 2:
navList = ['漆面保护膜', '改色膜']
break
navList = ["漆面保护膜", "改色膜"];
break;
case 3:
navList = ['数字化美容', '座椅通风', 'AR导航', '氛围灯', '360全景导航']
break
navList = [
"数字化美容",
"座椅通风",
"AR导航",
"氛围灯",
"360全景导航",
];
break;
}
this.setData({
navList,
tab,
intoViewId: `to-0`,
activeNavIdx: 0
})
activeNavIdx: 0,
});
// 每次切换场景,重新获取流程图高度
this.getImgHeight()
this.getMoreFn()
}
this.getImgHeight();
this.getMoreFn();
},
},
/**
......@@ -97,124 +104,129 @@ Component({
methods: {
async init() {
try {
const { data, code, message } = await USERAPI.wxCodeLogin()
if (code == '0') {
this.loginToken = data
} else this.reLogin(message)
wx.hideLoading()
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()
console.error(errMsg);
this.reLogin();
}
},
/**获取loginToken */
reLogin(message) {
wx.showModal({
content: message || '获取loginToken失败',
confirmText: '重试',
confirmColor: '#3666FE'
content: message || "获取loginToken失败",
confirmText: "重试",
confirmColor: "#3666FE",
}).then(({ confirm }) => {
if (confirm) this.init()
})
if (confirm) this.init();
});
},
saleTextChange(e) {},
changeTab(e) {
let idx = e.detail
let idx = e.detail;
this.setData({
intoViewId: `to-${idx}`
})
intoViewId: `to-${idx}`,
});
},
changeNav(event) {
this.setData({
activeNavIdx: event.target.dataset.index
})
activeNavIdx: event.target.dataset.index,
});
},
scrolltoupper(event) {
const idx = this.data.heightArr.findIndex(item => item > event.detail.scrollTop)
const idx = this.data.heightArr.findIndex(
(item) => item > event.detail.scrollTop
);
this.setData({
curTabIdx: idx
})
curTabIdx: idx,
});
// console.log(this.data.curTabIdx1)
},
getImgHeight() {
let query = wx.createSelectorQuery().in(this)
let heightArr = []
let s = 0
let query = wx.createSelectorQuery().in(this);
let heightArr = [];
let s = 0;
query
.selectAll('.img-item')
.boundingClientRect(react => {
react.forEach(item => {
s += item.height
heightArr.push(s)
})
this.data.heightArr = heightArr
.selectAll(".img-item")
.boundingClientRect((react) => {
react.forEach((item) => {
s += item.height;
heightArr.push(s);
});
this.data.heightArr = heightArr;
// console.log(heightArr[heightArr.length-1])
this.data.allHeight = heightArr[heightArr.length - 1]
this.data.allHeight = heightArr[heightArr.length - 1];
})
.exec()
.exec();
},
// 图片流程5 点击往下获取更多
// 没登陆用户(登陆后解锁全部)
getMoreFn({ detail }) {
console.log(detail)
// 获取用户信息
getUserInfo({ detail }) {
console.log(detail);
if (!detail.code) return
if (!detail.code) return;
// this.setBtnLoading()
USERAPI.getUserProfile(this.loginToken, detail)
.then(result => {
.then((result) => {
// console.log(result)
let { phone } = result
let { phone } = result;
// let {
wx.$storage.set('userPhone', phone)
wx.$storage.set("userPhone", phone);
// }
this.triggerEvent('authorized', {
this.triggerEvent("authorized", {
phone,
isShare: false
})
isShare: false,
});
// this.
this.getMoreFn()
})
.catch(({ errMsg }) => {
wx.$api.showToast(errMsg || '系统异常')
wx.$api.showToast(errMsg || "系统异常");
// this.setBtnLoading(false)
})
let { actNum } = this.data
});
},
// 图片流程5 点击往下获取更多
// 没登陆用户(登陆后解锁全部)
getMoreFn() {
let { actNum } = this.data;
// console.log("inactNumdex: ", actNum);
let tab = [
'场景说明',
'营销链路',
'项目亮点',
'转化漏斗',
'合作流程'
"场景说明",
"营销链路",
"项目亮点",
"转化漏斗",
"合作流程",
// "合作案例",
]
];
switch (actNum) {
case 0:
tab.push('合作案例')
break
tab.push("合作案例");
break;
case 1:
tab.push('合作案例')
break
tab.push("合作案例");
break;
case 2:
break
break;
case 3:
tab.push('合作案例')
break
tab.push("合作案例");
break;
}
this.setData({
tab
})
tab,
});
},
onShareFn() {
// this.triggerEvent('sharehandle')
// wx.$router.go('apply',1235)
let { actNum, activeNavIdx } = this.data
wx.$router.go('checkProduct', {
let { actNum, activeNavIdx } = this.data;
wx.$router.go("checkProduct", {
actNum,
activeNavIdx
})
}
}
})
activeNavIdx,
});
},
},
});
......@@ -65,7 +65,7 @@
wx:if="{{isShare && actNum != 2 && index == 4}}"
class="more-btn"
data-index="{{index}}"
bindgetphonenumber="getMoreFn"
bindgetphonenumber="getUserInfo"
open-type="getPhoneNumber"
>
点击查看更多详情
......
......@@ -61,10 +61,13 @@ Page({
// let { detail } = e || null
// console.log(detail)
if (e) {
let clientModule = this.selectAllComponents('client')
let merchantModule = this.selectAllComponents('merchant')
clientModule.getClientApi()
merchantModule.init()
this.init()
let clientModule = this.selectComponent('#client')
let merchantModule = this.selectComponent('#merchant')
// console.log('clientModule', clientModule)
// console.log()
clientModule.getClientApi && clientModule.getClientApi()
merchantModule.init && merchantModule.init()
}
let { isSuper, userInfo } = this.data
// 判断是超管才需要切换账号
......
......@@ -90,7 +90,7 @@ class Share {
USERINFO
} = that.getCommonData(),
shareInfo = this.options
reportData({
if (shareInfo.shareOpenId) reportData({
openId: WXUSERINFO.openId || '',
unionId: WXUSERINFO.unionId || '',
nickName: WXUSERINFO.nickName || '',
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!