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 \ No newline at end of file
import WxValidate from '../../utils/WxValidate' import WxValidate from '../../utils/wxValidate'
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
......
// pages/checkProduct/checkProduct.js // pages/checkProduct/checkProduct.js
// const navStyle = "background-color: transparent;"; // const navStyle = "background-color: transparent;";
import {
IMG_URL
} from "~/utils/constantData.js";
const navStyle = "background-color: #fff"; const navStyle = "background-color: #fff";
import { import { senceData } from "~/pages/tab/index/constant/data";
senceData import { IMG_URL } from "~/utils/constantData.js";
} from "~/pages/tab/index/constant/data"; import Draw from "~/utils/Draw.js";
import {createQrCodeApi} from '~/api/checkProduct.js'
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
...@@ -17,13 +16,56 @@ Page({ ...@@ -17,13 +16,56 @@ Page({
senceData, senceData,
// 模态框 // 模态框
isShow: true, 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高度设置 // navbar高度设置
navbarReady(e) { navbarReady(e) {
let { let { height, statusBarHeight } = e.detail;
height,
statusBarHeight
} = e.detail;
this.setData({ this.setData({
headerHeight: height / 2 + statusBarHeight, headerHeight: height / 2 + statusBarHeight,
// headerHeight: height / 2 + statusBarHeight, // headerHeight: height / 2 + statusBarHeight,
...@@ -35,7 +77,7 @@ Page({ ...@@ -35,7 +77,7 @@ Page({
// 分项弹框关闭 // 分项弹框关闭
modelcloseFn(e) { modelcloseFn(e) {
this.setData({ this.setData({
isShow: e.detail, isShow: false,
}); });
}, },
// 分享按钮 // 分享按钮
...@@ -48,23 +90,149 @@ Page({ ...@@ -48,23 +90,149 @@ Page({
onRoute(options) { onRoute(options) {
// console.log("options: ", options); // console.log("options: ", options);
//选中场景的index,和产品的index //选中场景的index,和产品的index
let { let { actNum, activeNavIdx } = options;
actNum,
activeNavIdx
} = options
this.setData({ this.setData({
actNum, 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) { onLoad(options) {
// actNum,activeNavIdx isShare // actNum,activeNavIdx isShare
// 禁用分享功能 wx.showLoading({
wx.hideShareMenu() title: "加载图片中",
});
}, },
/** /**
......
{ {
"usingComponents": { "usingComponents": {
"product": "../tab/index/components/product/product", "product": "../tab/index/components/product/product"
"shareModel":"../tab/index/components/shareModel/shareModel"
}, },
"navigationStyle": "custom", "navigationStyle": "custom",
"onReachBottomDistance": 10, "onReachBottomDistance": 10,
......
/* pages/checkProduct/checkProduct.wxss */ /* 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 @@ ...@@ -4,6 +4,33 @@
</view> </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 // pages/tab/discovery/components/product/product.js
// import {imgUrlMixin} from '~/mixins/index' // import {imgUrlMixin} from '~/mixins/index'
import { IMG_URL } from '~/utils/constantData.js' import { IMG_URL } from "~/utils/constantData.js";
import USERAPI from '~/api/usersApi/index' import USERAPI from "~/api/usersApi/index";
const videoBaseUrl = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/' const videoBaseUrl =
"https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/";
Component({ Component({
// behaviors: [imgUrlMixin], // behaviors: [imgUrlMixin],
...@@ -15,80 +16,86 @@ Component({ ...@@ -15,80 +16,86 @@ Component({
senceData: Object, senceData: Object,
isShare: { isShare: {
type: Boolean, type: Boolean,
value: false value: false,
} },
}, },
/** /**
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {
navList: ['360全景导航', 'AR实景导航', '座椅通风', '氛围灯', '数字化美容'], navList: ["360全景导航", "AR实景导航", "座椅通风", "氛围灯", "数字化美容"],
activeNavIdx: 0, activeNavIdx: 0,
tab: [ tab: [
'场景说明', "场景说明",
'营销链路', "营销链路",
'项目亮点', "项目亮点",
'转化漏斗', "转化漏斗",
'合作流程' "合作流程",
// "合作案例", // "合作案例",
], ],
heightArr: [], heightArr: [],
allHeight: 0, allHeight: 0,
curTabIdx: 0, curTabIdx: 0,
intoViewId: 'to-0', intoViewId: "to-0",
IMGURL: `${IMG_URL}index/`, IMGURL: `${IMG_URL}index/`,
videoBaseUrl videoBaseUrl,
}, },
lifetimes: { lifetimes: {
ready: function () { ready: function () {
this.init() this.init();
// console.log('stickyTop',this.data.stickyTop) // console.log('stickyTop',this.data.stickyTop)
this.getImgHeight() this.getImgHeight();
//如果不是分享,初始化的时候调用函数 //如果不是分享,初始化的时候调用函数
if (!this.data.isShare) { if (!this.data.isShare) {
// console.log(131546) // console.log(131546)
this.getMoreFn() this.getMoreFn();
}
} }
}, },
},
observers: { observers: {
actNum: function () { actNum: function () {
let navList let navList;
let tab = [ let tab = [
'场景说明', "场景说明",
'营销链路', "营销链路",
'项目亮点', "项目亮点",
'转化漏斗', "转化漏斗",
'合作流程' "合作流程",
// "合作案例", // "合作案例",
] ];
let num = this.data.actNum let num = this.data.actNum;
switch (num) { switch (num) {
case 0: case 0:
navList = ['数字无忧权益卡'] navList = ["数字无忧权益卡"];
break break;
case 1: case 1:
navList = ['汽车太阳膜'] navList = ["汽车太阳膜"];
break break;
case 2: case 2:
navList = ['漆面保护膜', '改色膜'] navList = ["漆面保护膜", "改色膜"];
break break;
case 3: case 3:
navList = ['数字化美容', '座椅通风', 'AR导航', '氛围灯', '360全景导航'] navList = [
break "数字化美容",
"座椅通风",
"AR导航",
"氛围灯",
"360全景导航",
];
break;
} }
this.setData({ this.setData({
navList, navList,
tab, tab,
intoViewId: `to-0`, intoViewId: `to-0`,
activeNavIdx: 0 activeNavIdx: 0,
}) });
// 每次切换场景,重新获取流程图高度 // 每次切换场景,重新获取流程图高度
this.getImgHeight() this.getImgHeight();
this.getMoreFn() this.getMoreFn();
} },
}, },
/** /**
...@@ -97,124 +104,129 @@ Component({ ...@@ -97,124 +104,129 @@ Component({
methods: { methods: {
async init() { async init() {
try { try {
const { data, code, message } = await USERAPI.wxCodeLogin() const { data, code, message } = await USERAPI.wxCodeLogin();
if (code == '0') { if (code == "0") {
this.loginToken = data this.loginToken = data;
} else this.reLogin(message) } else this.reLogin(message);
wx.hideLoading() wx.hideLoading();
} catch ({ errMsg }) { } catch ({ errMsg }) {
console.error(errMsg) console.error(errMsg);
this.reLogin() this.reLogin();
} }
}, },
/**获取loginToken */ /**获取loginToken */
reLogin(message) { reLogin(message) {
wx.showModal({ wx.showModal({
content: message || '获取loginToken失败', content: message || "获取loginToken失败",
confirmText: '重试', confirmText: "重试",
confirmColor: '#3666FE' confirmColor: "#3666FE",
}).then(({ confirm }) => { }).then(({ confirm }) => {
if (confirm) this.init() if (confirm) this.init();
}) });
}, },
saleTextChange(e) {}, saleTextChange(e) {},
changeTab(e) { changeTab(e) {
let idx = e.detail let idx = e.detail;
this.setData({ this.setData({
intoViewId: `to-${idx}` intoViewId: `to-${idx}`,
}) });
}, },
changeNav(event) { changeNav(event) {
this.setData({ this.setData({
activeNavIdx: event.target.dataset.index activeNavIdx: event.target.dataset.index,
}) });
}, },
scrolltoupper(event) { 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({ this.setData({
curTabIdx: idx curTabIdx: idx,
}) });
// console.log(this.data.curTabIdx1) // console.log(this.data.curTabIdx1)
}, },
getImgHeight() { getImgHeight() {
let query = wx.createSelectorQuery().in(this) let query = wx.createSelectorQuery().in(this);
let heightArr = [] let heightArr = [];
let s = 0 let s = 0;
query query
.selectAll('.img-item') .selectAll(".img-item")
.boundingClientRect(react => { .boundingClientRect((react) => {
react.forEach(item => { react.forEach((item) => {
s += item.height s += item.height;
heightArr.push(s) heightArr.push(s);
}) });
this.data.heightArr = heightArr this.data.heightArr = heightArr;
// console.log(heightArr[heightArr.length-1]) // console.log(heightArr[heightArr.length-1])
this.data.allHeight = heightArr[heightArr.length - 1] this.data.allHeight = heightArr[heightArr.length - 1];
}) })
.exec() .exec();
}, },
// 图片流程5 点击往下获取更多 // 获取用户信息
// 没登陆用户(登陆后解锁全部) getUserInfo({ detail }) {
getMoreFn({ detail }) { console.log(detail);
console.log(detail)
if (!detail.code) return if (!detail.code) return;
// this.setBtnLoading() // this.setBtnLoading()
USERAPI.getUserProfile(this.loginToken, detail) USERAPI.getUserProfile(this.loginToken, detail)
.then(result => { .then((result) => {
// console.log(result) // console.log(result)
let { phone } = result let { phone } = result;
// let { // let {
wx.$storage.set('userPhone', phone) wx.$storage.set("userPhone", phone);
// } // }
this.triggerEvent('authorized', { this.triggerEvent("authorized", {
phone, phone,
isShare: false isShare: false,
}) });
// this. // this.
this.getMoreFn()
}) })
.catch(({ errMsg }) => { .catch(({ errMsg }) => {
wx.$api.showToast(errMsg || '系统异常') wx.$api.showToast(errMsg || "系统异常");
// this.setBtnLoading(false) // this.setBtnLoading(false)
}) });
},
let { actNum } = this.data // 图片流程5 点击往下获取更多
// 没登陆用户(登陆后解锁全部)
getMoreFn() {
let { actNum } = this.data;
// console.log("inactNumdex: ", actNum); // console.log("inactNumdex: ", actNum);
let tab = [ let tab = [
'场景说明', "场景说明",
'营销链路', "营销链路",
'项目亮点', "项目亮点",
'转化漏斗', "转化漏斗",
'合作流程' "合作流程",
// "合作案例", // "合作案例",
] ];
switch (actNum) { switch (actNum) {
case 0: case 0:
tab.push('合作案例') tab.push("合作案例");
break break;
case 1: case 1:
tab.push('合作案例') tab.push("合作案例");
break break;
case 2: case 2:
break break;
case 3: case 3:
tab.push('合作案例') tab.push("合作案例");
break break;
} }
this.setData({ this.setData({
tab tab,
}) });
}, },
onShareFn() { onShareFn() {
// this.triggerEvent('sharehandle') // this.triggerEvent('sharehandle')
// wx.$router.go('apply',1235) // wx.$router.go('apply',1235)
let { actNum, activeNavIdx } = this.data let { actNum, activeNavIdx } = this.data;
wx.$router.go('checkProduct', { wx.$router.go("checkProduct", {
actNum, actNum,
activeNavIdx activeNavIdx,
}) });
} },
} },
}) });
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
wx:if="{{isShare && actNum != 2 && index == 4}}" wx:if="{{isShare && actNum != 2 && index == 4}}"
class="more-btn" class="more-btn"
data-index="{{index}}" data-index="{{index}}"
bindgetphonenumber="getMoreFn" bindgetphonenumber="getUserInfo"
open-type="getPhoneNumber" open-type="getPhoneNumber"
> >
点击查看更多详情 点击查看更多详情
......
...@@ -61,10 +61,13 @@ Page({ ...@@ -61,10 +61,13 @@ Page({
// let { detail } = e || null // let { detail } = e || null
// console.log(detail) // console.log(detail)
if (e) { if (e) {
let clientModule = this.selectAllComponents('client') this.init()
let merchantModule = this.selectAllComponents('merchant') let clientModule = this.selectComponent('#client')
clientModule.getClientApi() let merchantModule = this.selectComponent('#merchant')
merchantModule.init() // console.log('clientModule', clientModule)
// console.log()
clientModule.getClientApi && clientModule.getClientApi()
merchantModule.init && merchantModule.init()
} }
let { isSuper, userInfo } = this.data let { isSuper, userInfo } = this.data
// 判断是超管才需要切换账号 // 判断是超管才需要切换账号
......
...@@ -90,7 +90,7 @@ class Share { ...@@ -90,7 +90,7 @@ class Share {
USERINFO USERINFO
} = that.getCommonData(), } = that.getCommonData(),
shareInfo = this.options shareInfo = this.options
reportData({ if (shareInfo.shareOpenId) reportData({
openId: WXUSERINFO.openId || '', openId: WXUSERINFO.openId || '',
unionId: WXUSERINFO.unionId || '', unionId: WXUSERINFO.unionId || '',
nickName: WXUSERINFO.nickName || '', nickName: WXUSERINFO.nickName || '',
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!