Commit 99b3633a by 前端

Merge branch 'zq_dev_3.0' into 'v3.0'

Zq dev 3.0

See merge request !29
2 parents 4269c4cd dc62b5f8
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
"pages/authentication/registerSuccess/registerSuccess", "pages/authentication/registerSuccess/registerSuccess",
"pages/authentication/registerInfo/registerInfo", "pages/authentication/registerInfo/registerInfo",
"pages/authentication/accountItems/accountItems", "pages/authentication/accountItems/accountItems",
"pages/authentication/customerService/customerService" "pages/authentication/customerService/customerService",
"pages/checkProduct/checkProduct"
], ],
"requiredPrivateInfos": [ "requiredPrivateInfos": [
"getLocation" "getLocation"
......
const navStyle = 'background-color: transparent;' const navStyle = "background-color: transparent;";
import USERAPI from '~/api/usersApi/index' import USERAPI from '~/api/usersApi/index'
import WxValidate from '~/utils/wxValidate' import WxValidate from '~/utils/WxValidate'
import { selectAccountLogin, setLoginInfo } from '../lib/index' import {
selectAccountLogin,
setLoginInfo
} from '../lib/index'
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
navStyle, navStyle,
padHeight: 0, padHeight:0,
headerHeight: 0, headerHeight: 0,
loginMethod: 0, loginMethod: 0,
formData: { formData:{
phone: '', phone:'',
code: '' code:''
}, },
authorized: false, authorized: false,
phoneReady: false, phoneReady: false,
disabled: true disabled: true
}, },
navbarReady(e) { navbarReady(e) {
let { height } = e.detail let {
height
} = e.detail;
this.setData({ this.setData({
headerHeight: height headerHeight: height,
}) });
}, },
/** /**
...@@ -38,12 +44,18 @@ Page({ ...@@ -38,12 +44,18 @@ Page({
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()
} }
...@@ -54,7 +66,9 @@ Page({ ...@@ -54,7 +66,9 @@ Page({
content: message || '获取loginToken失败', content: message || '获取loginToken失败',
confirmText: '重试', confirmText: '重试',
confirmColor: '#3666FE' confirmColor: '#3666FE'
}).then(({ confirm }) => { }).then(({
confirm
}) => {
if (confirm) this.init() if (confirm) this.init()
}) })
}, },
...@@ -71,7 +85,7 @@ Page({ ...@@ -71,7 +85,7 @@ Page({
// padHeight: 0 // padHeight: 0
// }) // })
// }, // },
// pageScrollToBottom() { // pageScrollToBottom() {
// wx.createSelectorQuery().select('.container').boundingClientRect(function(rect) { // wx.createSelectorQuery().select('.container').boundingClientRect(function(rect) {
// // 使页面滚动到底部 // // 使页面滚动到底部
// wx.pageScrollTo({ // wx.pageScrollTo({
...@@ -79,166 +93,197 @@ Page({ ...@@ -79,166 +93,197 @@ Page({
// }) // })
// }).exec() // }).exec()
// }, // },
handleLogin() { handleLogin(){
const { formData } = this.data, const {
obj = { formData
mobile: formData.phone, } = this.data,
code: formData.code obj = {
} mobile: formData.phone,
if (this.data.showLoading) return code: formData.code
}
if(this.data.showLoading) return;
this.setShowLoading(true) this.setShowLoading(true)
USERAPI.phoneSmsLogin(obj) USERAPI.phoneSmsLogin(obj).then(({
.then(({ code, data, message, errId }) => { code,
this.setShowLoading(false) data,
if (code == '0') { message,
this.checkLoginUserInfo(data) errId
} else if (errId == '30990103') { }) => {
this.setData({ this.setShowLoading(false)
authorized: true if (code == '0') {
}) this.checkLoginUserInfo(data)
} else { } else if(errId=='30990103') {
wx.$api.showToast(message || '系统异常') this.setData({
} authorized:true
}) })
.catch(err => { }else{
this.setShowLoading(false) wx.$api.showToast(message || '系统异常')
wx.$api.showToast('系统异常') }
}) }).catch(err => {
this.setShowLoading(false)
wx.$api.showToast('系统异常')
})
}, },
/**手机号&微信登录:是否跳转登录列表页 */ /**手机号&微信登录:是否跳转登录列表页 */
checkLoginUserInfo({ loginUserInfoList, sessionId }) { checkLoginUserInfo({
loginUserInfoList,
sessionId
}) {
/**多个账号 */ /**多个账号 */
console.log(loginUserInfoList, 'loginUserInfoList') console.log(loginUserInfoList,'loginUserInfoList')
if (loginUserInfoList.length > 1) if (loginUserInfoList.length > 1) wx.$router.go('/pages/authentication/accountItems/accountItems', {
wx.$router.go('/pages/authentication/accountItems/accountItems', { sessionId,
sessionId, ...this.options
...this.options })
}) /**只有一个账号 */
/**只有一个账号 */ else else selectAccountLogin({
selectAccountLogin({ id: loginUserInfoList[0].uuid,
id: loginUserInfoList[0].uuid, sessionId
sessionId })
})
}, },
switchLoginMethod(e) { switchLoginMethod(e){
const { type } = e.target.dataset const {type} = e.target.dataset
this.setData({ this.setData({
loginMethod: type loginMethod: type
}) })
}, },
input(e) { input(e){
const { value } = e.detail const {value} = e.detail
const { name } = e.target.dataset const {name} = e.target.dataset
console.log(e, this.data.formData, '88') console.log(e,this.data.formData,'88')
this.setData({ this.setData({
[`formData.${name}`]: value [`formData.${name}`] : value
}) })
this.checkInfo() this.checkInfo()
}, },
checkInfo() { checkInfo(){
this.setData({ this.setData({
phoneReady: this.validate.methods.tel(this.data.formData.phone), phoneReady: this.validate.methods.tel(this.data.formData.phone),
disabled: !this.validate.methods.tel(this.data.formData.phone) || this.data.formData?.code?.length != 4 disabled: !this.validate.methods.tel(this.data.formData.phone) || this.data.formData?.code?.length !=4
}) })
}, },
/**获取验证码 */ /**获取验证码 */
getSmsCode() { getSmsCode() {
const { phoneReady, formData, count } = this.data, const {
phoneReady,
formData,
count
} = this.data,
countDown = 60 countDown = 60
if (count || !this.data.phoneReady) return if (count || !this.data.phoneReady) return
// this.setData({ // this.setData({
// smsLoading: true // smsLoading: true
// }) // })
USERAPI.getSmsCode(formData.phone) USERAPI.getSmsCode(formData.phone).then(({
.then(({ code, message }) => { code,
// this.setData({ message
// smsLoading: false }) => {
// }) // this.setData({
if (code == '0') this.countDown(countDown) // smsLoading: false
else wx.$api.showToast(message || '发送验证码失败') // })
}) if (code == '0') this.countDown(countDown)
.catch(err => { else wx.$api.showToast(message || '发送验证码失败')
// this.setData({ }).catch(err => {
// smsLoading: false // this.setData({
// }) // smsLoading: false
wx.$api.showToast(err || '发送验证码失败') // })
}) wx.$api.showToast(err || '发送验证码失败')
})
}, },
/**验证码倒计时 */ /**验证码倒计时 */
countDown(countDown) { countDown(countDown) {
if (countDown) if (countDown) this.setData({
this.setData({ count: countDown
count: countDown })
})
setTimeout(() => { setTimeout(() => {
let { count } = this.data let {
count
} = this.data
this.setData({ this.setData({
count: --count count: --count
}) })
if (count > 0) this.countDown() if (count > 0) this.countDown()
else else this.setData({
this.setData({ count: null
count: null })
})
}, 1e3) }, 1e3)
}, },
setShowLoading(val) { setShowLoading(val){
this.setData({ this.setData({
showLoading: val showLoading: val
}) })
}, },
wxLogin({ detail }) { wxLogin({
detail
}) {
if (!detail.code || this.data.showLoading) return if (!detail.code || this.data.showLoading) return
this.setShowLoading(true) this.setShowLoading(true)
USERAPI.authUserPhone(detail, this.loginToken) USERAPI.authUserPhone(detail, this.loginToken).then(({
.then(({ code, data, message, errId }) => { code,
this.setShowLoading(false) data,
if (code == '0') { message,
this.checkLoginUserInfo(data) errId
} else if (errId == '30990103') { }) => {
this.setData({ this.setShowLoading(false)
authorized: true if (code == '0'){
}) this.checkLoginUserInfo(data)
} else { }else if(errId=='30990103'){
wx.$api.showToast(message || '系统异常') this.setData({
} authorized:true
}) })
.catch(({ errMsg }) => { }else{
this.setShowLoading(false) wx.$api.showToast(message || '系统异常')
wx.$api.showToast('系统异常') }
}) }).catch(({
errMsg
}) => {
this.setShowLoading(false)
wx.$api.showToast('系统异常')
})
}, },
goServicePage() { goServicePage(){
wx.$router.go('/pages/authentication/customerService/customerService') wx.$router.go('/pages/authentication/customerService/customerService')
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() {}, onShow() {
},
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide() {}, onHide() {
},
/** /**
* 生命周期函数--监听页面卸载 * 生命周期函数--监听页面卸载
*/ */
onUnload() {}, onUnload() {
},
/** /**
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh() {}, onPullDownRefresh() {
},
/** /**
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom() {}, onReachBottom() {
},
/** /**
* 用户点击右上角分享 * 用户点击右上角分享
*/ */
onShareAppMessage() {} onShareAppMessage() {
})
}
})
\ No newline at end of file \ No newline at end of file
// 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/discovery/constant/data";
Page({
/**
* 页面的初始数据
*/
data: {
navStyle,
headerHeight: 0,
senceData,
// 模态框
isShow: true,
},
navbarReady(e) {
let {
height
} = e.detail;
this.setData({
headerHeight: height,
});
},
onPageScroll({
scrollTop
}) {
let opacity = scrollTop / 100
let color = `rgba(255,255,255${opacity > 1 ? 1 : opacity})`
this.setData({
navStyle: scrollTop == 0 ? navStyle : `background-color:${color};`
})
},
modelcloseFn(e) {
this.setData({
isShow: e.detail,
});
},
// 分享按钮
sharehandle() {
this.setData({
isShow: true,
});
},
onRouter(options) {
console.log("options: ", options);
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// actNum,activeNavIdx
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow(options) {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {},
});
{
"usingComponents": {
"product": "../tab/discovery/components/product/product",
"shareModel":"../tab/discovery/components/shareModel/shareModel"
},
"navigationBarTitleText": "特色产品",
"onReachBottomDistance": 10,
"backgroundColor": "#FC5B32",
"enablePullDownRefresh": true
}
/* pages/checkProduct/checkProduct.wxss */
page{
background-color: #fff;
}
\ No newline at end of file \ No newline at end of file
<!--pages/checkProduct/checkProduct.wxml-->
<!-- <navigation-bar showBack="{{true}}" bindnavbarReady="navbarReady" navStyle="{{navStyle}}">特色产品</navigation-bar>
<view style="height:{{headerHeight}}px">
</view> -->
<product actNum="{{actNum}}" senceData="{{senceData}}" isShare="{{true}}"/>
<!-- 分享弹框 -->
<shareModel actNum="{{actNum}}" isShow="{{isShow}}" bindmodelclose="modelcloseFn" />
// pages/tab/discovery/components/product/product.js
import {imgUrlMixin} from '~/mixins/index' import {imgUrlMixin} from '~/mixins/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],
/**
* 组件的属性列表
*/
properties: { properties: {
headerHeight: Number, headerHeight: Number,
senceData:Object, senceData:Object,
actNum: Number,
isShare:{
type: Boolean,
value: false
}
}, },
/**
* 组件的初始数据
*/
data: { data: {
videoBaseUrl, videoBaseUrl,
// senceData:['scene_talk.png','scene_delivery.png','scene_within_12mth.png','scene_more_12mth.png'],
navList:['数字无忧权益卡'], navList:['数字无忧权益卡'],
activeNavIdx: 0, //特色产品 activeNavIdx: 0, //特色产品
tab:['适用场景','营销链路','项目亮点','转化漏斗','合作流程','合作案例'], tab:['适用场景','营销链路','项目亮点','转化漏斗','合作流程','合作案例'],
...@@ -31,16 +29,12 @@ Component({ ...@@ -31,16 +29,12 @@ Component({
}, },
}, },
/** observers: {
* 组件的方法列表 actNum: function () {
*/ let num = this.data.actNum;
methods: {
changeSwiper(e){
console.log(e)
let actNum = e.detail.current
let navList = [] let navList = []
let tab = ['适用场景','营销链路','项目亮点','转化漏斗','合作流程'] let tab = ['适用场景','营销链路','项目亮点','转化漏斗','合作流程']
switch (actNum) { switch (num) {
case 0: case 0:
navList = ["数字无忧权益卡"]; navList = ["数字无忧权益卡"];
tab.push("合作案例"); tab.push("合作案例");
...@@ -65,13 +59,15 @@ Component({ ...@@ -65,13 +59,15 @@ Component({
} }
this.setData({ this.setData({
navList, navList,
actNum,
intoViewId: `to-0`, intoViewId: `to-0`,
activeNavIdx: 0, activeNavIdx: 0,
tab tab
}) })
this.getImgHeight(); this.getImgHeight();
}, },
},
methods: {
changeTab(e){ changeTab(e){
let idx = e.detail let idx = e.detail
this.setData({ this.setData({
...@@ -88,7 +84,6 @@ Component({ ...@@ -88,7 +84,6 @@ Component({
this.setData({ this.setData({
curTabIdx: idx curTabIdx: idx
}) })
console.log(this.data.curTabIdx1)
}, },
getImgHeight(){ getImgHeight(){
let query = wx.createSelectorQuery().in(this) let query = wx.createSelectorQuery().in(this)
...@@ -115,10 +110,13 @@ Component({ ...@@ -115,10 +110,13 @@ Component({
heightArr.push(s); heightArr.push(s);
}); });
this.data.heightArr = heightArr; 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();
} },
onShareFn() {
let { actNum, activeNavIdx ,senceData} = this.data;
wx.$router.go("checkProduct", { actNum, activeNavIdx ,senceData});
},
} }
}) })
.scene-wrap {
white-space: nowrap;
height: 180rpx;
margin-bottom: 16rpx;
.scene-img {
width: 100%;
}
}
// 特色产品 // 特色产品
.prod-wrap .big-title { .prod-wrap .big-title {
......
<view class="header">
<swiper bindchange="changeSwiper" class="scene-wrap" circular="{{true}}" previousMargin="40rpx" nextMargin="40rpx">
<block wx:for="{{senceData}}" wx:key="index">
<swiper-item>
<image class="scene-img" src="{{IMGURL}}{{item.img}}"></image>
</swiper-item>
</block>
</swiper>
</view>
<view class="prod-wrap"> <view class="prod-wrap">
<text class="big-title">特色产品</text> <text class="big-title">特色产品</text>
<scroll-view enhanced="{{true}}" show-scrollbar="{{false}}" class="nav-wrap" scroll-x="{{true}}"> <scroll-view enhanced="{{true}}" show-scrollbar="{{false}}" class="nav-wrap" scroll-x="{{true}}">
...@@ -29,7 +20,7 @@ ...@@ -29,7 +20,7 @@
</text> </text>
</view> </view>
<view class="share-btn"> <view class="share-btn" wx:if="{{!isShare}}" bindtap="onShareFn">
<image class="icon" src="{{IMGURL}}share.png"></image> <image class="icon" src="{{IMGURL}}share.png"></image>
<text>分享</text> <text>分享</text>
</view> </view>
...@@ -37,7 +28,7 @@ ...@@ -37,7 +28,7 @@
</view> </view>
</view> </view>
<view class="project-wrap"> <view class="project-wrap">
<view style="position: sticky;top: {{headerHeight}}px ;z-index: 1;"> <view style="position: sticky;top: {{headerHeight}}px ;z-index: 1;background-color: #F5F7FB;">
<tab openScroll="{{true}}" tab="{{tab}}" index="{{curTabIdx}}" bindclick="changeTab"></tab> <tab openScroll="{{true}}" tab="{{tab}}" index="{{curTabIdx}}" bindclick="changeTab"></tab>
</view> </view>
<scroll-view class="project-img" scroll-into-view="{{intoViewId}}" bindscroll="scrolltoupper" scroll-y="{{true}}"> <scroll-view class="project-img" scroll-into-view="{{intoViewId}}" bindscroll="scrolltoupper" scroll-y="{{true}}">
...@@ -52,7 +43,6 @@ ...@@ -52,7 +43,6 @@
<view class="video-text">{{item.name}}</view> <view class="video-text">{{item.name}}</view>
</view> </view>
</block> </block>
<!-- <view class="video-tips">- 如需开通请咨询客服 -</view> -->
</view> </view>
</view> </view>
</view> </view>
......
// pages/tab/index/components/shareModel/shareModel.js
import { IMG_URL } from "~/utils/constantData.js";
const IMGURL = IMG_URL
import Draw from "~/utils/Draw.js";
import {imgUrlMixin} from '~/mixins/index'
Component({
behaviors: [imgUrlMixin],
/**
* 组件的属性列表
*/
properties: {
actNum: Number, //场景选择
isShow: Boolean,
// //分享方法
// onShareAppMessage:Function,
// onShareTimeline:Function,
},
/**
* 组件的初始数据
*/
data: {
btnList: [
{
src: `${IMGURL}wechat.png`,
name: "微信转发",
},
// {
// src: `${IMGURL}index/moments.png`,
// name: "朋友圈分享",
// },
{
src: `${IMGURL}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
// imgList
// imgList:[
// {
// src:`${IMGURL}index/scene${actNum}1.png`,
// },
// ]
},
observers: {
actNum: function (actNum) {
let imgList = [
`${IMGURL}index/scene${actNum + 1}1.png`,
`${IMGURL}index/scene${actNum + 1}2.png`,
`${IMGURL}index/scene${actNum + 1}3.png`,
`${IMGURL}index/scene${actNum + 1}4.png`,
`${IMGURL}index/scene${actNum + 1}5.png`,
];
if (actNum != 2) {
imgList.push(`${IMGURL}index/scene${actNum + 1}6.png`);
}
this.setData({
imgList,
});
},
},
/**
* 组件的方法列表
*/
methods: {
// 分享按钮
handleClick(e) {
let { index } = e.currentTarget.dataset;
switch (index) {
case 0:
this.wechatFn();
break;
case 1:
this.download();
break;
}
},
// 微信转发
wechatFn() {
// this.data.onShareAppMessage()
this.modelClose();
},
// 下载海报
async download() {
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 imgList = [
{
x: 0,
y: 0,
width: 750,
height: imgAllHeight,
url: `${IMGURL}scene/longpic${
actNum + 1
}.png`,
},
{
x: 245*2,
y: erCodeHeight-11,
width: 120*2,
height: 120*2,
url: `https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/index/discovery_prod1.png`, //二维码
},
];
let posterUrl = await drawFun.begin({
imageList: imgList,
});
this.setData({
posterUrl: posterUrl.path,
});
console.log('posterUrl.path',posterUrl.path,wx.pro)
if(this.data.posterUrl){
wx.downloadFile({
url: this.data.posterUrl, //仅为示例,并非真实的资源
success (res) {
console.log('res: ', res);
}
})
}
this.modelClose();
},
//模态框关闭
modelClose() {
this.triggerEvent("modelclose", false);
},
// 图片加载事件
onloadFn(event) {
// console.log('event.detail',event.detail)
this.setData({
imgHeight: (event.detail.height * 0.2).toFixed(0),
});
},
},
});
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
/* pages/tab/index/components/shareModel/shareModel.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;
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;
line-height: 32rpx;
}
.btn-wechat{
width: auto;
margin: 0;
padding: 0;
background-color: #fff;
&::after{
border:none;
}
}
}
.btom {
margin: 18px auto 0;
width: 343px;
height: 44px;
line-height: 44px;
border: 1px solid #eeeeee;
border-radius: 4px;
text-align: center;
}
}
}
<!-- pages/tab/index/components/shareModel/shareModel.wxml -->
<view class="share-wrap" wx:if="{{isShow}}">
<view class="img-wrap">
<image class="img" style="height:{{imgHeight}}px" src="{{IMGURL}}scene/longpic{{actNum+1}}.png" bindload="onloadFn" />
<!-- <block wx:for="{{imgList}}" wx:key="*this">
<image 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="modelClose">取消</view>
</view>
</view>
\ No newline at end of file \ No newline at end of file
...@@ -9,6 +9,7 @@ Page({ ...@@ -9,6 +9,7 @@ Page({
data: { data: {
senceData, senceData,
headerHeight: 0, headerHeight: 0,
actNum: 0,
navStyle, navStyle,
// 预估弹框 // 预估弹框
visible: false, visible: false,
...@@ -22,8 +23,7 @@ Page({ ...@@ -22,8 +23,7 @@ Page({
flow: 10000, flow: 10000,
}, },
isFirst: true, isFirst: true,
// tabList: pageData.tabList, changeSale: 0,
changeSale: 0, //每次改变的销量
}, },
navbarReady(e) { navbarReady(e) {
let { let {
...@@ -43,6 +43,12 @@ Page({ ...@@ -43,6 +43,12 @@ Page({
}) })
}, },
changeSwiper(e){
this.setData({
actNum:e.detail.current,
});
},
// 跳转咨询页面 // 跳转咨询页面
goConsult() { goConsult() {
wx.pro.openCustomerServiceChat({ wx.pro.openCustomerServiceChat({
......
...@@ -2,6 +2,15 @@ ...@@ -2,6 +2,15 @@
.container{ .container{
position: relative; position: relative;
.scene-wrap {
white-space: nowrap;
height: 180rpx;
margin-bottom: 16rpx;
.scene-img {
width: 100%;
}
}
.bg-img{ .bg-img{
position: absolute; position: absolute;
top: 0; top: 0;
......
...@@ -5,7 +5,16 @@ ...@@ -5,7 +5,16 @@
</navigation-bar> </navigation-bar>
<view style="padding-top: {{headerHeight}}px;"> <view style="padding-top: {{headerHeight}}px;">
<product senceData="{{senceData}}" headerHeight="{{headerHeight}}"></product> <view class="header">
<swiper bindchange="changeSwiper" class="scene-wrap" circular="{{true}}" previousMargin="40rpx" nextMargin="40rpx">
<block wx:for="{{senceData}}" wx:key="index">
<swiper-item>
<image class="scene-img" src="{{IMGURL}}{{item.img}}"></image>
</swiper-item>
</block>
</swiper>
</view>
<product senceData="{{senceData}}" actNum="{{actNum}}" headerHeight="{{headerHeight}}"></product>
</view> </view>
</view> </view>
......
{ {
"setting": { "setting": {
"compileHotReLoad": false, "compileHotReLoad": false,
"urlCheck": true, "urlCheck": false,
"lazyloadPlaceholderEnable": false "lazyloadPlaceholderEnable": true
},
"condition": {
"miniprogram": {
"list": [
{
"name": "个人中心",
"pathName": "pages/tab/mine/mine",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "编辑",
"pathName": "packageMine/pages/editBasicInfo/index",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/authentication/login/login",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/authentication/register/register",
"query": "data=%7B%22staffName%22%3A%22%E6%81%92%E6%B2%B3%E7%8C%B4%22%2C%22merchantId%22%3A44184606%2C%22fileUrl%22%3A%22https%3A%2F%2Fimg1.baidu.com%2Fit%2Fu%3D1755961019%2C1690032781%26fm%3D253%26app%3D138%26size%3Dw931%26n%3D0%26f%3DJPEG%26fmt%3Dauto%3Fsec%3D1665766800%26t%3D0b9617eab6fe013e35dc2e491e2e2100%22%7D",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/authentication/registerSuccess/registerSuccess",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/authentication/registerInfo/registerInfo",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/authentication/customerService/customerService",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/visitor/visitor",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/visitor/visitor",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/visitor/visitor",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/order/order",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/taskDetail/taskDetail",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/taskDetail/taskDetail",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/applyActivity/applyActivity",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/taskDetail/taskDetail",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/taskDetail/taskDetail",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/applySuccess/applySuccess",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/taskDetail/taskDetail",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "发现页",
"pathName": "pages/tab/discovery/discovery",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "模拟分享",
"pathName": "pages/authentication/loading/loading",
"query": "url=%2Fpages%2Ftab%2Fdiscovery%2Fdiscovery",
"launchMode": "default",
"scene": null
},
{
"name": "申请活动",
"pathName": "packageActivity/pages/applyActivity/applyActivity",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "分享页",
"pathName": "pages/checkProduct/checkProduct",
"query": "",
"launchMode": "default",
"scene": null
}
]
}
}, },
"condition": {},
"projectname": "store-assistant", "projectname": "store-assistant",
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"libVersion": "2.26.1" "libVersion": "2.26.1"
......
...@@ -7,36 +7,41 @@ class Draw { ...@@ -7,36 +7,41 @@ class Draw {
[_pixelRatio_] = null; [_pixelRatio_] = null;
[_canvasObject_] = null; [_canvasObject_] = null;
[_canvas_] = null [_canvas_] = null
constructor(canvasObject) { constructor(canvasObject, isCompInst) {
wx.getSystemInfo().then(({ pixelRatio }) => { this[_canvasObject_] = canvasObject
// console.log(pixelRatio) this[_pixelRatio_] = canvasObject.pixelRatio || 2
this[_canvasObject_] = canvasObject const height = this.toRpx(canvasObject.height),
this[_pixelRatio_] = canvasObject.pixelRatio || pixelRatio || 2 width = this.toRpx(canvasObject.width),
const height = this.toRpx(canvasObject.height), canvas = wx.createOffscreenCanvas({
width = this.toRpx(canvasObject.width), type: '2d',
canvas = wx.createOffscreenCanvas({
type: '2d',
width,
height
}),
ctx = canvas.getContext('2d')
this[_canvas_] = canvas
this[_ctx_] = ctx
this[_ctx_].clearRect(0, 0, width, height)
this.drawFill({
x: 0,
y: 0,
width, width,
height, height,
color: canvasObject.backgroundColor || 'rgb(255, 255, 255)' compInst:isCompInst
}) }),
this[_ctx_].save() 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()
} }
drawImages(imageParams, callback) { async drawImages(imageParams, callback) {
this[_ctx_].beginPath() this[_ctx_].beginPath()
this[_ctx_].save() this[_ctx_].save()
let { borderRadius, height, width, url, x, y } = imageParams let {
borderRadius,
height,
width,
url,
x,
y
} = imageParams
height = this.toRpx(height) height = this.toRpx(height)
width = this.toRpx(width) width = this.toRpx(width)
x = this.toRpx(x) x = this.toRpx(x)
...@@ -52,13 +57,14 @@ class Draw { ...@@ -52,13 +57,14 @@ class Draw {
this[_ctx_].clip() this[_ctx_].clip()
} }
let image = this[_canvas_].createImage() let image = this[_canvas_].createImage()
new Promise(resolve => { image.src = `${url}?v=${Date.now()}`
image.onload = resolve return new Promise(resolve => {
image.src = `${url}?v=${Date.now()}` image.onload = () => {
}).then(() => { this[_ctx_].drawImage(image, x, y, width, height)
this[_ctx_].drawImage(image, x, y, width, height) this[_ctx_].restore()
this[_ctx_].restore() if (callback) callback()
if (callback) callback() resolve(imageParams)
}
}) })
} }
toRpx(val) { toRpx(val) {
...@@ -69,7 +75,13 @@ class Draw { ...@@ -69,7 +75,13 @@ class Draw {
if (fontSize) this[_ctx_].font = `${fontSize}px${font}` if (fontSize) this[_ctx_].font = `${fontSize}px${font}`
return this[_ctx_].measureText(text).width return this[_ctx_].measureText(text).width
} }
drawFill({ x, y, width, height, color }) { drawFill({
x,
y,
width,
height,
color
}) {
height = this.toRpx(height) height = this.toRpx(height)
width = this.toRpx(width) width = this.toRpx(width)
x = this.toRpx(x) x = this.toRpx(x)
...@@ -82,8 +94,25 @@ class Draw { ...@@ -82,8 +94,25 @@ class Draw {
this[_ctx_].save() this[_ctx_].save()
} }
drawText(textParams) { drawText(textParams) {
let { textDecoration, textBaseline, lineHeight, fontWeight, textAlign, textWidth, maxWidth, fontSize, lastFont, opacity, lineNum, width, color, text, x, y } = textParams, let {
font = this[_ctx_].font.split('px')[1] 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' textAlign = textAlign || 'left'
textBaseline = textBaseline || 'normal' textBaseline = textBaseline || 'normal'
opacity = typeof opacity === 'number' ? opacity : 1 opacity = typeof opacity === 'number' ? opacity : 1
...@@ -140,6 +169,7 @@ class Draw { ...@@ -140,6 +169,7 @@ class Draw {
height: boxHeight, height: boxHeight,
color: textParams.background color: textParams.background
}) })
} }
const drawOneLineText = () => { const drawOneLineText = () => {
let textArr = text.toString().split(''), let textArr = text.toString().split(''),
...@@ -218,15 +248,20 @@ class Draw { ...@@ -218,15 +248,20 @@ class Draw {
} else { } else {
drawOneLineText() drawOneLineText()
} }
} else { } else drawOneLineText()
drawOneLineText()
}
this[_ctx_].stroke() this[_ctx_].stroke()
} }
drawLine(lineParams, callback) { drawLine(lineParams, callback) {
this[_ctx_].beginPath() this[_ctx_].beginPath()
let { opacity, startX, startY, width, color, endX, endY } = lineParams let {
opacity,
startX,
startY,
width,
color,
endX,
endY
} = lineParams
startX = this.toRpx(startX) startX = this.toRpx(startX)
startY = this.toRpx(startY) startY = this.toRpx(startY)
width = this.toRpx(width) width = this.toRpx(width)
...@@ -243,7 +278,12 @@ class Draw { ...@@ -243,7 +278,12 @@ class Draw {
if (callback) callback() if (callback) callback()
} }
setLineY = params => { setLineY = params => {
let { textDecoration, textBaseline, fontSize, y } = params let {
textDecoration,
textBaseline,
fontSize,
y
} = params
let type = { let type = {
underline: { underline: {
top: y + fontSize, top: y + fontSize,
...@@ -266,8 +306,11 @@ class Draw { ...@@ -266,8 +306,11 @@ class Draw {
} }
return type[textDecoration][textBaseline] return type[textDecoration][textBaseline]
} }
setLineX({
setLineX({ textAlign, text, x }) { textAlign,
text,
x
}) {
let textWidth = this.getTextWidth(text) let textWidth = this.getTextWidth(text)
let type = { let type = {
left: x, left: x,
...@@ -276,8 +319,13 @@ class Draw { ...@@ -276,8 +319,13 @@ class Draw {
} }
return type[textAlign] return type[textAlign]
} }
drawRadiusRect({
drawRadiusRect({ borderRadius, height, width, x, y }, callBack) { borderRadius,
height,
width,
x,
y
}, callBack) {
let radius = typeof borderRadius === 'string' ? ((Number(borderRadius.split('%')[0]) / 100) * width) / 2 : borderRadius / 2 let radius = typeof borderRadius === 'string' ? ((Number(borderRadius.split('%')[0]) / 100) * width) / 2 : borderRadius / 2
radius = radius || 0 radius = radius || 0
this[_ctx_].beginPath() this[_ctx_].beginPath()
...@@ -288,7 +336,12 @@ class Draw { ...@@ -288,7 +336,12 @@ class Draw {
} }
if (callBack) callBack() if (callBack) callBack()
} }
getFontWidth({ textAlign, fontSize, text, x }) { getFontWidth({
textAlign,
fontSize,
text,
x
}) {
let type = { let type = {
left: x, left: x,
center: x - (fontSize * text.length) / 2, center: x - (fontSize * text.length) / 2,
...@@ -298,7 +351,12 @@ class Draw { ...@@ -298,7 +351,12 @@ class Draw {
} }
drawDecoration(params) { drawDecoration(params) {
let { newText, opacity, y, x } = params let {
newText,
opacity,
y,
x
} = params
let lineX = x let lineX = x
let lineY = y let lineY = y
lineX = this.setLineX(params) lineX = this.setLineX(params)
...@@ -329,10 +387,33 @@ class Draw { ...@@ -329,10 +387,33 @@ class Draw {
}) })
} }
base64src(url).then(img => { base64src(url).then(img => {
console.log('img', img)
createLocalImg(img, callBack) 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 => { const checkTextDecoration = textDecoration => {
return textDecoration && (textDecoration === 'underline' || textDecoration === 'overline' || textDecoration === 'line-through') return textDecoration && (textDecoration === 'underline' || textDecoration === 'overline' || textDecoration === 'line-through')
...@@ -355,4 +436,4 @@ const createLocalImg = (url, callBack) => { ...@@ -355,4 +436,4 @@ const createLocalImg = (url, callBack) => {
} }
}) })
} }
export default Draw export default Draw
\ 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!