提交 de7eb7d3 编写于 作者: W weixin_47563380

Tue Aug 27 13:49:00 CST 2024 inscode

上级 b1040fdf
// app.js
App({ App({
onLaunch() { globalData: {
// 展示本地存储能力 navHeight: 0,
const logs = wx.getStorageSync('logs') || [] navTop: 0,
logs.unshift(Date.now()) windowHeight: 0
wx.setStorageSync('logs', logs) },
onLaunch: function (options) {
// 登录 var _this = this;
wx.login({ let menuButtonObject = wx.getMenuButtonBoundingClientRect();
wx.getSystemInfo({
success: res => { success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId //导航高度
} let statusBarHeight = res.statusBarHeight,
navTop = menuButtonObject.top,
navHeight = statusBarHeight + menuButtonObject.height + (menuButtonObject.top - statusBarHeight) * 2;
this.globalData.navHeight = navHeight;
this.globalData.navTop = navTop; //navTop
this.globalData.windowHeight = res.windowHeight;
},
fail(err) {
console.log(err);
},
}) })
}, },
globalData: { })
userInfo: null \ No newline at end of file
}
})
{ {
"pages": [ "pages": [
"pages/test5/test5", "pages/testnav/testnav",
"pages/test4/test4", "components/customtabbar/index",
"pages/test3/test3", "pages/testtar/testtar",
"pages/test2/test2", "pages/message/message",
"pages/test1/test1", "pages/home/home",
"pages/test/test", "pages/test7/test7",
"pages/index/index", "pages/quxiantu1/quxiantu1",
"pages/logs/logs" "pages/contact/contact",
], "pages/mulbutton/mulbutton",
"window": { "pages/testview/testview",
"navigationBarTextStyle": "black", "pages/checkbox/checkbox",
"navigationBarTitleText": "林涛测试用", "pages/quxiantu/quxiantu",
"navigationBarBackgroundColor": "#ffffff" "pages/droplist/droplist",
}, "pages/perinfochart/perinfochart",
"style": "v2", "pages/test10/test10",
"componentFramework": "glass-easel", "pages/test9/test9",
"sitemapLocation": "sitemap.json", "pages/test8/test8",
"lazyCodeLoading": "requiredComponents" "pages/test6/test6",
} "pages/test5/test5",
"pages/test4/test4",
"pages/test3/test3",
"pages/test2/test2",
"pages/test1/test1",
"pages/test/test",
"pages/index/index",
"pages/productSearch/index",
"pages/logs/logs"
],
"window": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "林涛测试用",
"navigationBarBackgroundColor": "#ffffff"
},
"tabBar": {
"list": [
{
"pagePath": "pages/home/home",
"text": "首页",
"iconPath": "/images/icon_API.png",
"selectedIconPath": "/images/icon_API_HL.png"
},
{
"pagePath": "pages/message/message",
"text": "消息",
"iconPath": "/images/icon_API.png",
"selectedIconPath": "/images/icon_API_HL.png"
},
{
"pagePath": "pages/contact/contact",
"text": "联系我们",
"iconPath": "/images/icon_API.png",
"selectedIconPath": "/images/icon_API_HL.png"
}
]
},
"style": "v2",
"componentFramework": "glass-easel",
"sitemapLocation": "sitemap.json",
"lazyCodeLoading": "requiredComponents"
}
\ No newline at end of file
// components/footerbutton.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
handleClick: function (e) {
const index = e.currentTarget.dataset.index;
// 这里可以添加点击按钮时的逻辑
console.log('按钮被点击了:' + index);
this.triggerEvent('navigatetonewpage', { url: '/pages/home/home' });
// 如果需要向父页面传递数据或事件,可以使用this.triggerEvent('eventName', detail)
}
}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<!--components/footerbutton.wxml-->
<text>components/footerbutton.wxml</text>
<view class="footer-button">
<button bindtap="handleClick">点击我</button>
</view>
\ No newline at end of file
/* components/footerbutton.wxss */
.footer-button {
position: fixed;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
width: 100px;
height: 50px;
background-color: #1aad19;
color: #ffffff;
border-radius: 8px;
display: flex;
justify-content: center;
align-items: center;
}
\ No newline at end of file
// components/mytabbar/mytabbar.json.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
<!--components/mytabbar/mytabbar.json.wxml-->
<text>components/mytabbar/mytabbar.json.wxml</text>
\ No newline at end of file
// index.ts
Component({
data: {
selected: 0,
color: "#7A7E83",
selectedColor: "#3cc51f",
list: [
{
"pagePath": "/pages/home/home",
"iconPath": "/image/icon_component.png",
"selectedIconPath": "/image/icon_component_HL.png",
"text": "首页"
},
{
"pagePath": "/pages/calender/calender",
"iconPath": "/image/icon_API.png",
"selectedIconPath": "../image/icon_API_HL.png",
"text": "日历"
},
{
"pagePath": "/pages/my/my",
"iconPath": "/image/icon_API.png",
"selectedIconPath": "/image/icon_API_HL.png",
"text": "我的"
}
]
},
attached() {
},
methods: {
switchTab(e: any) {
const data = e.currentTarget.dataset
const url = data.path
wx.switchTab({ url: url })
this.setData({
selected: data.index
})
}
}
})
<!--miniprogram/custom-tab-bar/index.wxml-->
<view class="tab-bar">
<view class="tab-bar-border"></view>
<view wx:for="{{list}}" wx:key="index" class="tab-bar-item" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab">
<image class="tab-bar-item-image" src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></image>
<view class="tab-bar-item-view" style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</view>
</view>
</view>
.tab-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 48px;
background: white;
display: flex;
padding-bottom: env(safe-area-inset-bottom);
}
.tab-bar-border {
background-color: rgba(0, 0, 0, 0.33);
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 1px;
transform: scaleY(0.5);
}
.tab-bar-item {
flex: 1;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.tab-bar-item-image {
width: 27px;
height: 27px;
}
.tab-bar-item-view {
font-size: 10px;
}
const app = getApp()
Page({
data: {
//设置单选内容
items: [{
name: 'male',
value: '',
checked: "true" //设置默认值
},
{
name: 'famale',
value: ''
},
]
},
//单选
radioChange: function (e) {
//获取单选数据
console.log(e.detail.value) //输出的是{{item.name}}的值
// var 示例
if (true) {
var a = 10;
}
console.log(a); // 输出 10,因为 var 声明的变量具有函数作用域(在这里是全局作用域)
// let 示例
if (true) {
let b = 20;
console.log(b); // 报错 ReferenceError: b is not defined,因为 let 声明的变量具有块级作用域,只在大括号内有用。
}
// const 示例
const PI = 3.14;
//PI = 3.14159; // 报错 TypeError: Assignment to constant variable.,因为 const 声明的常量不能被重新赋值
},
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<view class="pop_line">
<view class="pop_left">性别</view>
<view class="pop_right">
<radio-group bindchange="radioChange">
<label wx:for-items="{{items}}" wx:key="index">
<radio color="#74bfe7" style="transform:scale(0.8);" value="{{item.name}}" checked="{{item.checked}}" />
{{item.value}}
</label>
</radio-group>
</view>
</view>
\ No newline at end of file
/* pages/checkbox/checkbox.wxss *//* 行信息 */
.pop_line{
display: flex;
width:90%;
margin:4%;
}
.pop_left{
width:30%;
}
.pop_right{
width:70%;
text-align: left;
}
\ No newline at end of file
// pages/contact/contact.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<!--pages/contact/contact.wxml-->
<text>pages/contact/contact.wxml</text>
\ No newline at end of file
/* pages/contact/contact.wxss */
\ No newline at end of file
Page({
/**
* 页面的初始数据
*/
data: {
tihuoWay: "门店自提",
select: false,
},
// swiperChange: function (e) {
// // console.log(e)
// if (e) {
// let current = e.detail.current;
// let source = e.detail.source;
// if (source === "touch") {
// this.setData({
// index: current,
// });
// }
// }
// console.log(this.data.index)
// },
bindShowMsg() {
this.setData({
select: !this.data.select,
});
},
mySelect(e) {
var name = e.currentTarget.dataset.name;
this.setData({
tihuoWay: name,
select: false,
});
},
});
{
"usingComponents": {}
}
\ No newline at end of file
<view class='list-msg'>
<view>下拉框</view>
<view class='list-msg2' bindtap='bindShowMsg'>
<text>{{tihuoWay}}</text>
</view>
<view class="select_box" wx:if="{{select}}">
<view class="select_one" bindtap="mySelect" data-name="重庆分店">重庆分店</view>
<view class="select_one" bindtap="mySelect" data-name="东莞南城分店">东莞南城分店</view>
<view class="select_one" bindtap="mySelect" data-name="东莞总店">东莞总店</view>
</view>
</view>
<text>文件基本原理在</text>
<!-- <view class='list-msg'>
<view class="select_box" wx:if="{{select}}">
<view class="select_one" bindtap="mySelect" data-name="重庆分店">重庆分店</view>
<view class="select_one" bindtap="mySelect" data-name="东莞南城分店">东莞南城分店</view>
<view class="select_one" bindtap="mySelect" data-name="东莞总店">东莞总店</view>
</view>
</view> -->
.list-msg {
display: flex;
padding: 0 20rpx;
background-color: #fff;
position: relative;
}
.list-msg1 {
height: 60rpx;
display: flex;
align-items: center;
justify-content: space-between;
}
.list-msg .list-msg2 {
height: 60rpx;
display: flex;
align-items: center;
justify-content: space-between;
border: 1px solid #ccc;
padding: 0 10rpx;
}
.select_box {
background-color: #eee;
padding: 0 10rpx;
width: 93%;
position: absolute;
top: 130rpx;
z-index: 1;
overflow: hidden;
animation: myfirst 0.5s;
}
.select_one {
height: 60rpx;
line-height: 60rpx;
border-bottom: 1px solid #ccc;
}
// pages/home/home.js
Page({
/**
* 页面的初始数据
*/
data: {
},
toTestnav(){
wx.navigateTo({
url: '/pages/testnav/testnav',
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<!--pages/home/home.wxml-->
<text>pages/home/home.wxml</text>
<view bind:tap="toTestnav">跳转到toTestnav</view>
\ No newline at end of file
/* pages/home/home.wxss */
\ No newline at end of file
// pages/message/message.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<!--pages/message/message.wxml-->
<text>pages/message/message.wxml</text>
\ No newline at end of file
/* pages/message/message.wxss */
\ No newline at end of file
// pages/experience/tests/tests.js
let curve = {
mW: 345, //canvas宽
mH: 250, //canvas高
mCenter: 180, //中心点
hCenter: 125, //中心点
points: []
};
Page({
/**
* 页面的初始数据
*/
data: {
// 数字提示
numShiow: false,
tipLeft: 10, //提示的x坐标
tipHeight: 10, //提示线条的高度
curveColText: ['140','120','100', '80', '60', '40', '20', '0'], //y轴
// 主要数据
curve: {
bgColor: "#ffffff",
date: ["09-08", "09-09", "09-11", "09-12", "09-14", "09-16", "09-17", "09-18", "09-28"],
lineColor: "#050505",
list: [62, 67, 76, 70, 76, 85, 85, 88, 57],
name: "血压",
xData: [],
},
tipIndex: 0,
whatShow: false,
getshow: false,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let {curveColText } = this.data //y坐标
let {bgColor,date,lineColor,list,xData } = this.data.curve //y坐标
let curveCanvas = wx.createCanvasContext('curveCanvas');
let lines = wx.createCanvasContext('lines');
this.drawLines(list, lines);
this.drawCurve(curveCanvas, curveColText, date, list, xData, lineColor, bgColor);
},
// gundong
scrollCanvas: function (e) {
console.log(e);
let index = e.currentTarget.dataset.index
var canvasLen = e.detail.scrollLeft;
this.setData({
indexScroll: index,
canvasLen: canvasLen
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
// 获取坐标
getZuoBiao(e) {
let indexs = e.currentTarget.dataset.indexs
let index = e.target.dataset.index
let x = e.detail.x
this.setData({
tipIndexs: indexs,
tipIndex: index
})
console.log(e)
let tipHeight =this.data.curve.xData[index].y
let tipLeft =this.data.curve.xData[index].x
console.log('x坐标',x)
console.log(tipHeight)
this.setData({
numShiow: true,
tipLeft:tipLeft-10,
tipHeight:tipHeight
})
let score = this.data.curve.list[index]
console.log(this.data.curve.list[index])
console.log(this.data.curve.date[index])
this.setData({
score: score,
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
//
// 曲线
drawCurve(curveCtx, curveColText, curveText, curveData, xData, LineColor, colorEnd) {
this.drawLineBg(curveCtx); //画横纵坐标框架
this.drawLineColText(curveColText, curveCtx); //绘制纵坐标文字
this.drawLineRowText(curveText, curveCtx, xData); //绘制横坐标文字
this.drawCurveCtx(curveData, curveCtx, xData, LineColor, colorEnd); //绘制曲线
curveCtx.draw();
},
// 阴影
drawLines(curveData, curveCtx) {
this.drawCurveCtxs(curveData, curveCtx); //绘制曲线
curveCtx.draw();
},
drawCurveCtx(mData, lineCtx, xData, LineColor, colorEnd) {
curve.points = [];
for (let i = 0; i < mData.length; i++) {
curve.points.push({
x: 29.5 + i * 52,
y: 200 - mData[i] / 100 * 150
});
}
this.drawCurvePath(curve.points, lineCtx, LineColor, colorEnd);
// 获取y轴做线条高度
curve.points.forEach((v, i) => {
xData[i].y = v.y
})
},
// 阴影
drawCurveCtxs(mData, lineCtx) {
curve.points = [];
for (let i = 0; i < mData.length; i++) {
curve.points.push({
x: 29.5 + i * 52,
y: 200 - mData[i] / 100 * 150
});
}
this.drawCurvePaths(curve.points, lineCtx);
},
// 绘制曲线背景
drawCurvePath(path, ctx, LineColor, colorEnd) {
var point = getControlPoint(path);
ctx.beginPath();
const grd = ctx.createLinearGradient(174, 180, 200, 0);
grd.addColorStop(0, '#ffffff');//曲线下部背景色
//grd.addColorStop(0.8, colorEnd);
//grd.addColorStop(1, colorEnd);
ctx.setFillStyle(grd);
ctx.setGlobalAlpha(0.8);
ctx.beginPath();
ctx.moveTo(29, 200);
ctx.lineTo(curve.points[0].x, curve.points[0].y);
var int = 0;
for (let i = 0; i < curve.points.length; i++) {
if (i == 0) {
ctx.quadraticCurveTo(point[0].x, point[0].y, curve.points[1].x, curve.points[1].y);
int = int + 1;
} else if (i < curve.points.length - 2) {
ctx.bezierCurveTo(point[int].x, point[int].y, point[int + 1].x, point[int + 1].y, curve.points[i + 1].x, curve.points[i + 1].y);
int += 2;
} else if (i == curve.points.length - 2) {
ctx.quadraticCurveTo(point[point.length - 1].x, point[point.length - 1].y, curve.points[curve.points.length - 1].x, curve.points[curve.points.length - 1].y);
}
}
ctx.lineTo(curve.points[curve.points.length - 1].x, 200);
ctx.fill();
ctx.closePath();
//this.drawCurveSign(point, ctx, LineColor)
this.drawCurveSign(point, ctx, '#000000')//曲线的颜色。#000000是黑色。
},
// 绘制点加线
drawCurveSign(point, ctx, LineColor) {
// 绘制线
ctx.beginPath();
//ctx.setStrokeStyle(LineColor);
ctx.setStrokeStyle('#000000');
ctx.setGlobalAlpha(1);
ctx.setLineWidth(4);
var int = 0;
ctx.moveTo(curve.points[0].x - 20, curve.points[0].y);
for (var i = 0; i < curve.points.length; i++) {
if (i == 0) {
ctx.quadraticCurveTo(point[0].x, point[0].y, curve.points[1].x, curve.points[1].y);
int = int + 1;
} else if (i < curve.points.length - 2) {
ctx.bezierCurveTo(point[int].x, point[int].y, point[int + 1].x, point[int + 1].y, curve.points[i + 1].x, curve.points[i + 1].y);
int += 2;
} else if (i == curve.points.length - 2) {
ctx.quadraticCurveTo(point[point.length - 1].x, point[point.length - 1].y, curve.points[curve.points.length - 1].x, curve.points[curve.points.length - 1].y);
}
}
ctx.stroke();
// 绘制点
// ctx.beginPath();
// ctx.setGlobalAlpha(1);
// for (let i = 0; i < curve.points.length; i++) {
// ctx.beginPath();
// ctx.arc(curve.points[i].x, curve.points[i].y, 5, 0, 2 * Math.PI);
// console.log('点',curve.points[i].x, curve.points[i].y, 5, 0, 2 * Math.PI)
// ctx.setFillStyle("#3388FF");
// ctx.fill();
// ctx.closePath();
// }
},
// 阴影
// 绘制曲线背景
drawCurvePaths(path, ctx) {
var point = getControlPoint(path);
ctx.beginPath();
this.drawCurveSigns(point, ctx)
},
drawCurveSigns(point, ctx) {
// 绘制线
ctx.beginPath();
//ctx.setStrokeStyle("rgba(0,0,0,0.05)");
ctx.setStrokeStyle('#ffffff');
// ctx.setStrokeStyle("red");
ctx.setGlobalAlpha(1);
ctx.setLineWidth(4);
var int = 0;
ctx.moveTo(curve.points[0].x - 20, curve.points[0].y);
for (var i = 0; i < curve.points.length; i++) {
if (i == 0) {
ctx.quadraticCurveTo(point[0].x, point[0].y, curve.points[1].x, curve.points[1].y);
int = int + 1;
} else if (i < curve.points.length - 2) {
ctx.bezierCurveTo(point[int].x, point[int].y, point[int + 1].x, point[int + 1].y, curve.points[i + 1].x, curve.points[i + 1].y);
int += 2;
} else if (i == curve.points.length - 2) {
ctx.quadraticCurveTo(point[point.length - 1].x, point[point.length - 1].y, curve.points[curve.points.length - 1].x, curve.points[curve.points.length - 1].y);
}
}
ctx.stroke();
},
// 画横坐标
drawLineBg(lineCtx) {
lineCtx.setStrokeStyle("#ece8d1");//横线颜色。
for (let i = 0; i < 6; i++) {
lineCtx.moveTo(curve.mCenter - 160, 50 + 30 * i);
lineCtx.lineTo(curve.mCenter + 160, 50 + 30 * i);
lineCtx.stroke();
}
},
// 绘制横坐标文字
drawLineRowText(mData, lineCtx, xData) {
console.log('mData:'+mData[1])
lineCtx.setFillStyle("#000000");
lineCtx.setFontSize(12); //设置字体
for (let i = 0; i < mData.length; i++) {
if (mData.length >= 3 && mData[1] != '') {
lineCtx.fillText(mData[i], 20 + i * 49, 220);
xData.push({
tiem: mData[i],
x: 20 + i * 49,
y: 0
})
// lineCtx.fillText(mData[i][1], 15 + i * 65, 235);
} else if (mData[1] == '') {
// 数据小于等于2的时候的坐标
lineCtx.fillText(mData[i], 60 + i * 90, 220);
// lineCtx.fillText(mData[i][1], 35 + i * 80, 235);
xData.push({
tiem: mData[i],
x: 20 + i * 49,
y: 0
})
} else if (mData[2] == '') {
// 数据小于等于1的时候的坐标
lineCtx.fillText(mData[i], 20 + i * 90, 220);
// lineCtx.fillText(mData[i][1], 35 + i * 80, 235);
xData.push({
tiem: mData[i],
x: 20 + i * 49,
y: 0
})
}
}
// this.setData({
// xData: xData
// })
},
// 绘制纵坐标文字
drawLineColText(mData, lineCtx) {
lineCtx.beginPath();
lineCtx.setFillStyle("#000000");
for (let i = 0; i < 6; i++) {
lineCtx.fillText(mData[i], 10, 55 + 30 * i);
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
// 日历
onDayClick: function (event) {
console.log(event.detail)
wx.showToast({
title: '日期被点击,具体信息请看Console信息',
icon: 'none'
})
},
onRangeComplete: function (event) {
console.log(event.detail)
var begin = new Date(event.detail.begin);
var end = new Date(event.detail.end);
// + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds()
var begintime = begin.getFullYear() + '-' + (begin.getMonth() + 1) + '-' + begin.getDate();
var endtime = end.getFullYear() + '-' + (end.getMonth() + 1) + '-' + end.getDate();
console.log(begintime)
console.log(endtime)
this.setData({
beginDate: begintime,
endDate: endtime
})
this.getJieGuo(begintime, endtime)
},
onMonthChange: function (event) {
console.log(event.detail)
wx.showToast({
title: '月份变换,具体信息请看Console信息',
icon: 'none'
})
},
})
// quxian
// 折线变曲线
let Vector2 = function (x, y) {
this.x = x;
this.y = y;
};
Vector2.prototype = {
"length": function () {
return Math.sqrt(this.x * this.x + this.y * this.y);
},
"normalize": function () {
let inv = 1 / this.length() == Infinity ? 0 : 1 / this.length();
return new Vector2(this.x * inv, this.y * inv);
},
"add": function (v) {
return new Vector2(this.x + v.x, this.y + v.y);
},
"multiply": function (f) {
return new Vector2(this.x * f, this.y * f);
},
"dot": function (v) {
return this.x * v.x + this.y * v.y;
},
"angle": function (v) {
return Math.acos(this.dot(v) / (this.length() * v.length())) * 180 / Math.PI;
}
};
function getControlPoint(path) {
let rt = 0.3;
let count = path.length - 2;
let arr = [];
for (let i = 0; i < count; i++) {
let a = path[i];
let b = path[i + 1];
let c = path[i + 2];
let v1 = new Vector2(a.x - b.x, a.y - b.y);
let v2 = new Vector2(c.x - b.x, c.y - b.y);
let v1Len = v1.length();
let v2Len = v2.length();
let centerV = v1.normalize().add(v2.normalize()).normalize();
let ncp1 = new Vector2(centerV.y, centerV.x * -1);
let ncp2 = new Vector2(centerV.y * -1, centerV.x);
if (ncp1.angle(v1) < 90) {
let p1 = ncp1.multiply(v1Len * rt).add(b);
let p2 = ncp2.multiply(v2Len * rt).add(b);
arr.push(p1, p2);
} else {
let p1 = ncp1.multiply(v2Len * rt).add(b);
let p2 = ncp2.multiply(v1Len * rt).add(b);
arr.push(p2, p1);
}
}
return arr;
};
{
"usingComponents": {}
}
\ No newline at end of file
<!--pages/perinfochart/perinfochart.wxml-->
<view class="efficacy">
<!-- 曲线 -->
<view class="chartsBox">
<view style="display:flex;justify-content: space-between;">
<view class="efficacyName" style="color:{{curve.lineColor}}">{{curve.name}}
<view style="background:{{curve.lineColor}}"></view>
</view>
</view>
<view class="canvasBox">
<scroll-view class="temp_day_box" scroll-x bindscroll='scrollCanvas'>
<canvas canvas-id='curveCanvas' id='curveCanvas' class='curveCanvas'> </canvas>
<canvas canvas-id='lines' id='lines' class='lines'> </canvas>
<view class="xCoordinate" bindtap="getZuoBiao" >
<view class="xCoordinateTime{{index}} xCoordinateTime" wx:for="{{curve.date}}" wx:key="index" data-index="{{index}}" >
{{item}}
<!-- 分数提示线 -->
<cover-view class="scoreTip" wx-if="{{numShiow&&index==tipIndex}}">
<cover-view class="scoreBg" style="height:{{144}}px;">
<cover-view class="score" style="top:-{{180-tipHeight}}px;color:{{curve.lineColor}}">{{score}}</cover-view>
<cover-view class="scoreBox" style="top:-{{174-tipHeight}}px;background:{{curve.lineColor}}"></cover-view>
</cover-view>
<cover-view class="scoreLine" style="height:{{190-tipHeight}}px;background:{{curve.lineColor}}"></cover-view>
</cover-view>
</view>
</view>
</scroll-view>
</view>
</view>
</view>
/* pages/perinfochart/perinfochart.wxss */
/* pages/curveCharts/curveCharts.wxss *//* pages/experience/tests/tests.wxss */
.efficacy{
/* width: 100%; */
/* height: 1000px; */
background: #ffffff;
padding:30rpx;
}
/* 曲线 */
.efficacyName {
color: #ffffff;
font-size: 26rpx;
font-weight: bold;
display: flex;
margin-bottom: 30rpx;
line-height: 30rpx;
}
.efficacyName>view {
width: 26rpx;
height: 26rpx;
margin-left: 10rpx;
border-radius: 4rpx;
}
.chartsBox{
position: relative;
width: 100%;
margin-bottom:40rpx;
}
.canvasBox{
width:690rpx;
height:420rpx;
position: relative;
background: rgb(255, 255, 255);
border-radius: 30rpx;
box-shadow: 0 10px 15px rgba(0,0,0,0.1);
overflow: auto;
overflow-y:hidden;
/* overflow-x:scroll; */
}
.curveCanvas{
/* width:100%; */
width:450px;
height:500rpx;
position: relative;
left: -10px;
top: -28px;
}
.xCoordinate{
position: absolute;
top: 0;
/* left:30rpx; */
display: flex;
/* width: 690rpx; */
height: 100%;
overflow: auto;
}
.xCoordinateTime{
padding-left:4rpx;
font-size:20rpx;
color: #fff;
/* color: red; */
width: 98rpx;
}
.lines{
/* width:100%; */
width:450px;
position: absolute;
top: -21px;
left: -10px;
}
canvas{
width:none;
height: none;
}
.scoreTip{
position: absolute;
top:0;
height:345rpx;
}
.scoreBg{
width:80rpx;
height:170rpx;
background: #ffffff;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-end;
position: relative;
}
.score{
color: #ffffff;
font-size: 20rpx;
position: relative;
bottom: 10rpx;
top: 10rpx;
}
.scoreBox{
width: 12rpx;
height: 12rpx;
background:#ffffff;
border-radius: 50%;
position: relative;
bottom: 10rpx;
top: 10rpx;
}
.scoreLine{
width:8rpx;
height:119px;
background:#ece8d1;
border-radius:3rpx;
position: absolute;
left:0;
right: 0;
bottom:8rpx;
margin:auto;
}
// pages/productSearch/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<!--pages/productSearch/index.wxml-->
<text>pages/productSearch/index.wxml</text>
\ No newline at end of file
/* pages/productSearch/index.wxss */
\ No newline at end of file
var wxCharts = require('../../utils/wxcharts');
var app = getApp();
var lineChart = null;
Page({
data: {
},
touchHandler: function (e) {
console.log(lineChart.getCurrentDataIndex(e));
lineChart.showToolTip(e, {
// background: '#7cb5ec'
});
},
createSimulationData: function () {
var categories = [];
var data = [];
for (var i = 0; i < 10; i++) {
categories.push('AA-' + (i + 1));
data.push(Math.random()*(20-10)+10);
}
// data[4] = null;
return {
categories: categories,
data: data
}
},
updateData: function () {
var simulationData = this.createSimulationData();
var series = [{
name: '身高',
data: simulationData.data,
format: function (val, name) {
return val.toFixed(2) + '';
}
}];
lineChart.updateData({
categories: simulationData.categories,
series: series
});
},
onLoad: function (e) {
var windowWidth = 320;
try {
var res = wx.getSystemInfoSync();
windowWidth = res.windowWidth;
console.log('windowWidth:'+windowWidth)
} catch (e) {
console.error('getSystemInfoSync failed!');
}
var simulationData = this.createSimulationData();
lineChart = new wxCharts({
canvasId: 'lineCanvas',
type: 'line',
categories: simulationData.categories,
animation: true,
background: '#f5f5f5',
series: [{
name: '高量1',
data: simulationData.data,
format: function (val, name) {
return val.toFixed(2) + '';
}
}, {
name: '低量2',
data: [11, 24, 29, 15, null, 21, 32, 23, 45, 21],
format: function (val, name) {
return val.toFixed(2) + '';
}
}],
xAxis: {
disableGrid: true
},
yAxis: {
title: '体重 (公斤 KG)',
format: function (val) {
return val.toFixed(2);
},
min: 0
},
width: windowWidth,
height: 200,
dataLabel: false,
dataPointShape: true,
extra: {
lineStyle: 'curve'
}
});
}
});
{
"usingComponents": {}
}
\ No newline at end of file
<view>
<button type="primary" bindtap="updateData">更新数据</button>
</view>
<view class="container">
<canvas canvas-id="lineCanvas" disable-scroll="true" class="canvas" bindtouchstart="touchHandler"></canvas>
</view>
// pages/test10/test10.js
Page({
/**
* 页面的初始数据
*/
data: {
date: '2021-01-01',
},
bindDateChange: function (e) {
console.log('picker发送选择改变,携带值为', e.detail.value)
this.setData({
date: e.detail.value
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// 获取当前日期,并格式化为YYYY-MM-DD
let today = new Date().toISOString().split('T')[0];
this.setData({
date: today
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<!--pages/test10/test10.wxml-->
<picker mode="date" header-text="选择时间" value="{{date}}" bindchange="bindDateChange">
<view class="font30">
<text class="color3">填报时间:</text>
<text class="separatetype">空空</text>
<text class="color6">{{date}}</text>
</view>
</picker>
\ No newline at end of file
/* pages/test10/test10.wxss */
.separatetype{
width: 100px;
color: white;
font-size: 10px;
}
\ No newline at end of file
...@@ -44,10 +44,10 @@ Page({ ...@@ -44,10 +44,10 @@ Page({
age: 99 age: 99
}); // 增加新记录 }); // 增加新记录
obj.records.push({ /* obj.records.push({
name: '222', name: '222',
age: 129 age: 129
}); // 增加新记录 }); // 增加新记录 */
// 第三步:存回对象 // 第三步:存回对象
wx.setStorageSync('obj', obj); wx.setStorageSync('obj', obj);
}, },
......
...@@ -12,7 +12,8 @@ Page({ ...@@ -12,7 +12,8 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
console.log('test6 onLoad')
console.log(options.searchstr)
}, },
/** /**
......
// pages/commodity/commodity-search/index.js
const App = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
// 自定义顶部导航
navHeight: App.globalData.navHeight,
navTop: App.globalData.navTop,
// 图标
leftIcon: "/images/banner1.jpg",
searchIcon: "/images/icon_API.png",
upperLeftArrow: "/images/icon_API.png",
recommend: [ //热门推荐
{
title: "冰箱"
},
{
title: "红魔手机"
},
{
title: "洗衣机"
},
{
title: "电视机"
},
{
title: "冰箱 双门"
},
{
title: "海尔洗衣机 滚筒"
},
{
title: "手机自营"
},
{
title: "小天鹅洗衣机全自动"
},
{
title: "手机"
},
{
title: "笔记本"
}
],
historyStorage: [], //历史搜索
historyStorageShow: false,
hotsearch1: [{ title: "林涛" }, { title: "背带裙" }, { title: "牛仔裤男" }, { title: "运动 休闲男鞋" }, { title: "蕾丝连衣裙" }, { title: "电视" }, { title: "长裙" }, { title: "oppo" }, { title: "蓝牙耳机" }, { title: "女包" }, { title: "格力空调" }, { title: "魅族" }],
inputValue: "", //输入框输入的值
replaceValue: "", //替换输入框的值
eye: true, //显示隐藏
searchresult: false,
// searchResult: [{ result: "苹果手机" }, { result: "手机支架" }, { result: "手机自营" }, { result: "手机套" }, { result: "手机膜" }, { result: "手机卡" }, { result: "手机报" }, { result: "苹果手机壳" }, { result: "手机车载支架" }]//虚拟的查询结果
},
// 点击返回上一级
goBack: function () {
// let pages = getCurrentPages(); //获取小程序页面栈
// let beforePage = pages[pages.length - 2]; //获取上个页面的实例对象
// beforePage.setData({
// txt: "修改数据了"
// })
// beforePage.goUpdate(); //触发上个页面自定义的go_update()方法
wx.navigateBack({
delta: 1
})
},
/**
* 获取顶部固定高度
*/
attached: function () {
this.setData({
navHeight: App.globalData.navHeight,
navTop: App.globalData.navTop,
})
},
/**
* 热门搜索显示隐藏
*/
reye: function () {
this.setData({
eye: !this.data.eye
})
},
/**
* 清除
*/
remove: function () {
var _this = this
wx: wx.showModal({
content: '确认清除所有历史记录?',
success: function (res) {
if (res.confirm) {
wx: wx.removeStorage({
key: 'historyStorage',
success: function (res) {
_this.setData({
historyStorage: []
})
wx.setStorageSync("historyStorage", [])
},
})
} else {
console.log("点击取消")
}
},
})
},
/**
* 获取input的值
*/
getInputValue(e) {
// console.log("获取到了", e.currentTarget.dataset.value)
// console.log("获取value值",e.detail) // {value: "ff", cursor: 2}
this.setData({
inputValue: e.detail.value
})
// this.setData({
// searchresult: true,
// })
},
/**
* 点击搜索提交跳转并存储历史记录
*/
searchbegin: function (e) {
let _this = this
var data = e.currentTarget.dataset;
_this.data.replaceValue = e.currentTarget.dataset.postname
// _this.data.replaceValue =
wx: wx.setStorage({
key: 'historyStorage',
data: _this.data.historyStorage.concat(_this.data.inputValue).reverse(),
data: _this.data.historyStorage.concat(_this.data.replaceValue).reverse()
})
// console.log(_this.data.inputValue)
// console.log(_this.data.historyStorage)
// console.log(data['postname'])
if (data['postname'] == '') {
wx.showToast({
title: '请先输入品牌或商品',
icon: 'none'
})
} else {
console.log('redirectTo:'+data['postname'])
wx.redirectTo({
url: '/pages/test6/test6?searchstr='+data['postname']
})
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// 历史搜索
let that = this;
that.searchtype = options.searchtype;
wx.getStorage({
key: 'historyStorage',
success: function (res) {
// console.log(res.data)
that.setData({
historyStorageShow: true,
historyStorage: res.data
})
}
})
this.setData({
inputValue: options.inputValue
})
this.data.inputValue = options.inputValue
// console.log(this.data.inputValue)
},
goUpdate: function () {
this.onLoad()
// console.log("我更新啦")
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"navigationStyle": "custom",
"usingComponents": {}
}
\ No newline at end of file
<!--pages/test7/test7.wxml-->
<!--pages/commodity/commodity-search/index.wxml-->
<!-- 自定义顶部导航 S -->
<view class="navbar custom-class" style='height:{{navHeight}}px;'>
<view class="navbar-action-wrap navbar-action-group row item-center" style='top:{{navTop}}px;'>
<image style="width: 17.5px; height: 18px; padding-top: 3px;" src="{{leftIcon}}" catchtap="goBack"></image>
</view>
<view class='navbar-title' style='top:{{navTop}}px'>
<view class="search-input">
<span class="search-con">
<view class="center-30f2b4d">
<!-- 自定义区域 -->
<image class="icon" src="{{searchIcon}}" catchtap="searchbegin" data-postname="{{inputValue}}"></image>
<input class="search-size" confirm-type="search" value="{{inputValue}}" type="text" bindinput="getInputValue" placeholder="搜索品牌或商品 林涛" placeholder-class="phcolor" bindconfirm="searchbegin" data-postname="{{inputValue}}"></input>
</view>
</span>
</view>
</view>
</view>
<!-- 自定义顶部导航 E -->
<view class="read-in" style="margin-top: {{navHeight}}px">
<!-- 最近搜索 S -->
<view class="headline" wx:if="{{historyStorage.length!=0}}" hidden="{{historyStorageShow?false:true}}">
<view class="head-headline justify">
<view class="headline-size">搜索历史</view>
<view class="icon-right size" catchtap="remove"><image src="/images/icon_component.png"></image></view>
</view>
<!-- 最近搜索内容 S -->
<view class="lately-main">
<view class="chunk" wx:for="{{historyStorage}}" wx:key="index" bindtap='searchbegin' data-index='{{index}}' data-postname="{{item}}">
<text>{{item}}</text>
</view>
</view>
<!-- 最近搜索内容 E -->
</view>
<!-- 最近搜索 E -->
<!-- 热门搜索 S -->
<view class="headline">
<view class="head-headline">
<view class="headline-size">搜索发现</view>
</view>
<!-- 热门推荐内容 S -->
<view class="lately-main">
<view class="chunk" wx:for="{{hotsearch1}}" wx:key="index" catchtap="searchbegin" bindtap="getInputValue" data-postname="{{item.title}}">
<text>{{item.title}}</text>
</view>
</view>
<!-- 热门推荐内容 E -->
</view>
<!-- 热门搜索 E -->
</view>
<!--搜索结果-->
<view class="searchresult" wx:if="{{inputValue != ''}}" hidden="{{searchresult}}" >
<view class="result" wx:for="{{searchResult}}" catchtap="searchbegin" wx:key="index" bindtap="getInputValue" data-postname="{{item.result}}">
<view>{{item.result}}</view>
<image src="{{upperLeftArrow}}"></image>
</view>
</view>
<view class="searchresult" wx:if="{{inputValue != ''}}" hidden="{{searchresult?false:true}}" >
<view class="result" wx:for="{{searchResult}}" catchtap="searchbegin" wx:key="index" bindtap="getInputValue" data-postname="{{item.result}}">
<view>{{item.result}}</view>
<image src="{{upperLeftArrow}}"></image>
</view>
</view>
\ No newline at end of file
/* pages/commodity/commodity-search/index.wxss */
page {
background: white;
}
.navbar {
width: 100%;
overflow: hidden;
position: fixed;
top: 0;
left: 0;
z-index: 10;
flex-shrink: 0;
}
.navbar-title {
width: 100%;
box-sizing: border-box;
padding-left: 40px;
padding-right: 120px;
height: 33px;
line-height: 33px;
position: fixed;
left: 0;
z-index: 10;
color: #333;
font-size: 16px;
font-weight: bold;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
display: flex;
align-items: center;
}
.navbar-action-wrap {
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
left: 10px;
z-index: 11;
line-height: 1;
padding-top: 4px;
padding-bottom: 4px;
position: fixed;
}
.navbar-action-group {
border-radius: 20px;
overflow: hidden;
}
.navbar-action_item {
padding: 3px 0;
color: #333;
}
.navbar-action-group .navbar-action_item {
border-right: 1px solid #f0f0f0;
padding: 3px 14px;
}
.icon-right image {
width: 25rpx;
height: 26rpx;
}
.navbar-action-group .last {
border-right: none;
}
.navbar-title-size {
font-size: 10px;
margin-right: 20rpx;
align-self: center;
margin: 0 auto;
}
.navbar-title-size.active {
color: red;
border-bottom: 2px solid red;
}
.scroll-box {
position: absolute;
height: 100%;
}
.search-input {
width: 100%;
height: 28px;
line-height: 28px;
background: #f6f6f6;
border-radius: 30rpx;
/* margin-top: 2px; */
font-size: 25rpx;
}
.search-con {
display: flex;
align-items: center;
}
.search-con .center-30f2b4d {
height: 28px;
line-height: 28px;
flex: 1;
display: flex;
align-items: center;
}
.search-con .center-30f2b4d .icon {
width: 15px;
height: 15px;
align-self: center;
margin: 0 10px;
}
.search-con .center-30f2b4d .search-size {
width: 70%;
font-size: 12px;
font-family: "微软雅黑";
}
.phcolor {
color: #999999;
}
/* nav E */
/* 标题部分 */
.read-in {
padding: 0 40rpx;
}
.headline {
padding-top: .5rem;
}
.head-headline {
width: 100%;
height: 45rpx;
position: relative;
display: flex;
font-size: 28rpx;
font-weight: bold;
align-items: center;
justify-content: space-between;
}
/* 内容部分 */
.lately-main {
margin-top: 20rpx;
overflow: hidden;
}
.lately-main .chunk {
display: inline-block;
font-size: 24rpx;
line-height: 20rpx;
padding: 10rpx 21rpx;
background: #f5f5f5;
margin-right: 20rpx;
border: 1px solid #DCDCDC;
border-radius: 18.5rpx;
color: #666666;
margin-bottom: 26rpx;
/* float: left; */
}
.searchresult {
margin-top: 20px;
position: absolute;
top: 55px;
left: 0;
width: 100%;
background: #fff;
}
.result {
height: 50px;
line-height: 50px;
text-align: left;
border-bottom: 1px solid #eee;
padding: 0 30rpx;
color: #333;
font-family: "微软雅黑";
font-size: 30rpx;
display: flex;
align-items: center;
justify-content: space-between;
}
.result image {
width: 50rpx;
height: 50rpx;
}
\ No newline at end of file
// pages/test8/test8.js
Page({
/**
* 页面的初始数据
*/
data:{
multiIndex: [],
multiArrayStr: [],
datearr: [],
hourarr: ["0", '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'],
timearr: ["00", "05", '10', '15', '20', '25', '30', '35', '40', '45', '50', '55']
},
bindMultiPickerChange: function (e) {
var that = this
that.setData({
multiIndex: e.detail.value,
mrstreservedate: that.data.multiArray[0][e.detail.value[0]] + " " + that.data.multiArray[1][e.detail.value[1]] + ":" + that.data.multiArray[2][e.detail.value[2]]
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
//计算预约时间
var self = this
var edays = 8//从sdays起到第几天
var sdays = 0
var datearr = [];
var datearrStr = [];
var date = new Date();
var curdate = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
var hour = date.getHours();
var days = 0;
for (var i = 0; i < edays + 1; i++) {
if (i >= sdays) {
if (i == 0) {
datearrStr.push('今天')
} else
if (i == 1) {
datearrStr.push('明天')
} else
if (i == 2) {
datearrStr.push('后天')
} else {
datearrStr.push(self.addDate(curdate.replace("-", "/").replace("-", "/"), i))
}
datearr.push(self.addDate(curdate.replace("-", "/").replace("-", "/"), i))
}
}
if (hour <= 22) {
hour += 1;
} else {
if (datearrStr.length > 1) {
days = 1;
}
hour = 10;
}
self.setData({
multiIndex: [days, hour, 0],
multiArray: [datearr, self.data.hourarr, self.data.timearr],
multiArrayStr: [datearrStr, self.data.hourarr, self.data.timearr]
})
//计算预约时间结束
},
// 计算方法
addDate: function (date, days) {
var d = new Date(date);
d.setDate(d.getDate() + days);
var month = d.getMonth() + 1;
var day = d.getDate();
if (month < 10) {
month = "0" + month;
}
if (day < 10) {
day = "0" + day;
}
var val = d.getFullYear() + "-" + month + "-" + day;
return val;
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<!--pages/test8/test8.wxml-->
<text>日期</text>
<picker mode="multiSelector" bindchange="bindMultiPickerChange" bindcolumnchange="bindMultiPickerColumnChange" value="{{multiIndex}}" range="{{multiArrayStr}}">
<view class="picker">
{{multiArrayStr[0][multiIndex[0]]}} {{multiArrayStr[1][multiIndex[1]]}}:{{multiArrayStr[2][multiIndex[2]]}}
</view>
</picker>
\ No newline at end of file
/* pages/test8/test8.wxss */
\ No newline at end of file
// pages/test9/test9.js
Page({
/**
* 页面的初始数据
*/
data: {
pickerIndexList: [0, 0, 0],//日期选择器下标
isShowDateLayer: false,//是否显示日期弹层
txtDate: '請选择提貨日期',//选中日期
isSeltDate: false,//是否选择日期
},
// 截获竖向滑动
catchTouchMove: function (res) {
return true;
},
//获取天数列表
getDayList: function (year, month) {
var that = this;
var dayList;
switch (month + 1) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: dayList = that.getDayNum(31);
break;
case 4:
case 6:
case 9:
case 11: dayList = that.getDayNum(30);
break;
case 2: dayList = that.getDayNum((that.data.yearList[year] % 4 == 0 && that.data.yearList[year] % 100 != 0 || that.data.yearList[year] % 400 == 0) ? 29 : 28);
break;
}
return dayList;
},
//获取天数
getDayNum: function (num) {
var dayList = [];
for (var i = 1; i <= num; i++) {
dayList.push(i);
}
return dayList;
},
//打开选择日期弹层
bindOpenDateLayer: function (e) {
var that = this;
var pickerIndexList = that.data.pickerIndexList;
that.setData({
isShowDateLayer: !that.data.isShowDateLayer,
dayList: that.getDayList(pickerIndexList[0], pickerIndexList[1]),
})
},
//日期选择改变事件
bindChangeDate: function (e) {
var that = this;
var pickerColumnList = e.detail.value;
that.setData({
dayList: that.getDayList(pickerColumnList[0], pickerColumnList[1]),
pickerIndexList: pickerColumnList,
})
},
//选择日期弹层确定按钮
bindConfirmDate: function (e) {
var that = this;
var pickerIndexList = that.data.pickerIndexList;
var txtDate = that.data.yearList[pickerIndexList[0]] + '-' + that.data.monthList[pickerIndexList[1]] + '-' + that.data.dayList[pickerIndexList[2]];
that.setData({
isShowDateLayer: false,
pickerIndexList,
txtDate,
isSeltDate: true,
})
},
//选择日期弹层取消按钮
bindCancelDate: function (e) {
var that = this;
var pickerIndexList = that.data.pickerIndexList;
that.setData({
isShowDateLayer: !that.data.isShowDateLayer,
})
var yearList = that.data.yearList;
var monthList = that.data.monthList;
var txtDate = that.data.txtDate;
var yearIndex = yearList.findIndex(o => o == parseInt(txtDate.slice(0, txtDate.indexOf('-'))));//年份下标
var monthIndex = monthList.findIndex(o => o == parseInt(txtDate.slice(txtDate.indexOf('-') + 1, txtDate.lastIndexOf('-'))));//月份下标
var dayList = that.getDayList(yearIndex, monthIndex);//天数
if (that.data.isSeltDate) {//选择过日期
if (txtDate == (yearList[pickerIndexList[0]] + '-' + monthList[pickerIndexList[1]] + '-' + dayList[pickerIndexList[2]]))
that.setData({ pickerIndexList })
else
that.setData({ pickerIndexList: [yearIndex, monthIndex, dayList.findIndex(o => o == parseInt(txtDate.slice(txtDate.lastIndexOf('-') + 1, txtDate.length)))] })
} else {//未选择过日期
that.setData({
pickerIndexList: app.globalData.dateIndexList,
})
}
},
//阻止冒泡事件
catchLayer: function (e) { },
//獲取當前日期
getCurrentDate: function (e) {
var that = this;
var yearList = [], monthList = [], dayList = [];
for (var i = new Date().getFullYear(); i <= 2050; i++) {//年份
yearList.push(i);
}
for (var i = 1; i <= 12; i++) {//月份
monthList.push(i);
}
var myDate = new Date();
var currentYearIndex = yearList.findIndex(o => o == myDate.getFullYear());
var currentMonthIndex = monthList.findIndex(o => o == myDate.getMonth() + 1);
var dayList = that.getDayList(currentYearIndex, currentMonthIndex);//天
var currentDayIndex = dayList.findIndex(o => o == myDate.getDate());
var pickerIndexList = that.data.pickerIndexList;
pickerIndexList[0] = currentYearIndex;
pickerIndexList[1] = currentMonthIndex;
pickerIndexList[2] = currentDayIndex;
app.globalData.dateIndexList = pickerIndexList;
that.setData({
yearList,
monthList,
dayList,
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that = this;
that.getCurrentDate();//獲取當前時間
that.setData({
pickerIndexList: that.data.pickerIndexList
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<!-- 自定义选择日期层 start -->
<view class="date-layer" wx:if="{{isShowDateLayer}}" catchtouchmove="catchTouchMove">
<view class="layer-box">
<view class="box-top">
<!-- 选中行背景色 start-->
<view class="top-background">
<view></view>
<view></view>
<view></view>
</view>
<!-- 选中行背景色 end-->
<picker-view indicator-class="picker-indicator" value="{{pickerIndexList}}" bindchange="bindChangeDate">
<picker-view-column>
<view wx:for="{{yearList}}" wx:key="index" class="{{pickerIndexList[0]==index?'txt-active':''}}">{{item}}年</view>
</picker-view-column>
<picker-view-column>
<view wx:for="{{monthList}}" wx:key="index" class="{{pickerIndexList[1]==index?'txt-active':''}}">{{item}}月</view>
</picker-view-column>
<picker-view-column>
<view wx:for="{{dayList}}" wx:key="index" class="{{pickerIndexList[2]==index?'txt-active':''}}">{{item}}日</view>
</picker-view-column>
</picker-view>
</view>
<view class="box-bottom">
<button class="btn-confirm" bindtap="bindConfirmDate">確定</button>
<button class="btn-cancel" bindtap="bindCancelDate">取消</button>
</view>
</view>
</view>
<!-- 选择日期层 end -->
/* 日期选择弹框 start */
.main .date-layer {
height: 100%;
width: 100%;
background: rgba(0, 0, 0, 0.65);
position: fixed;
top: 0;
z-index: 20;
}
.date-layer .layer-box {
position: fixed;
bottom: 0;
width: 100%;
background: #fff;
border-top-left-radius: 24rpx;
border-top-right-radius: 24rpx;
}
.date-layer .layer-box .box-top {
padding: 30rpx 0;
position: relative;
}
.date-layer .layer-box picker-view {
height: 120px;
width: 88%;
margin: 0 auto;
}
.date-layer .layer-box .picker-indicator {
height: 40px;
line-height: 40px;
}
.date-layer .layer-box picker-view-column view {
line-height: 42px;
text-align: center;
width: 96%;
margin: 0 auto;
}
.date-layer .layer-box .box-top .top-background {
height: 80rpx;
width: 88%;
margin: 0 auto;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
}
.layer-box .box-top .top-background view {
height: 100%;
width: 96%;
margin: 0 auto;
background: rgba(195, 218, 49, 0.12);
border-top: 2rpx solid #D9E87D;
border-bottom: 2rpx solid #C3DA31;
margin: 0 4rpx;
box-sizing: border-box;
}
.date-layer .layer-box .box-bottom {
display: flex;
}
.date-layer .layer-box .box-bottom button {
margin: 0;
padding: 0;
width: 50%;
border-radius: 0;
border: none;
background: #fff;
height: 100rpx;
line-height: 100rpx;
font-size: 34rpx;
border-top: 2rpx solid #D8D8D8;
}
.date-layer .layer-box .box-bottom .btn-confirm {
border-right: 1rpx solid #D8D8D8;
color: #C3DA31;
}
.date-layer .layer-box .box-bottom .btn-cancel {
border-left: 1rpx solid #D8D8D8;
color: #B1B1B4;
}
/* 日期选择弹框 end */
// pages/testnav/testnav.js
Page({
/**
* 页面的初始数据
*/
data: {
},
// 监听自定义事件
onMyComponentTap: function(e) {
// 从事件的数据中获取目标页面路径
console.log('onMyComponentTap')
const url = e.detail.url;
console.log('url:'+url)
// 执行页面跳转
/* wx.navigateTo({
url: url
}); */
wx.switchTab({
url: url
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
{
"usingComponents": {
"footer-button": "../../components/footerbuton/footerbutton",
"customtabbar":"../../components/customtabbar/index"
}
}
\ No newline at end of file
<!--pages/testnav/testnav.wxml-->
<view>
<navigator url="../testtar/testtar?userId=123&type=admin">跳转到目标页面</navigator>
<navigator url="/pages/droplist/droplist">跳转到home页面</navigator>
</view>
<view class="container">
<view bind:tap="handleClick">bindnavigatetonewpage</view>
<!-- 页面内容 -->
<footer-button bindnavigatetonewpage="onMyComponentTap"/>
<customtabbar bindnavigatetonewpage="onMyComponentTap"/>
</view>
\ No newline at end of file
/* pages/testnav/testnav.wxss */
\ No newline at end of file
Page({
onLoad: function(options) {
// 获取传递过来的参数
var userId = options.userId; // 值为 "123"
var type = options.type; // 值为 "admin"
// 使用这些参数进行后续操作...
console.log('UserID:', userId);
console.log('Type:', type);
}
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<!--pages/testtar/testtar.wxml-->
<text>pages/testtar/testtar.wxml</text>
\ No newline at end of file
/* pages/testtar/testtar.wxss */
\ No newline at end of file
// pages/testview/testview.js
Page({
/**
* 页面的初始数据
*/
data: {
isHidden:true,
scrollTop:false,
scrollLeft:true,
selectable:true,
},
handleTap:function(event){
console.log(event.currentTarget.dataset.num)
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<!--pages/testview/testview.wxml-->
<text>pages/testview/testview.wxml</text>
<view enable-flex>
<view style="flex: 1;">Flex Item 1</view>
<view style="flex: 2;">Flex Item 2</view>
</view>
<!--点击后会变样式-->
<view class="basclass" hover-class="hover-class" hover-start-time="50" hover-stay-time="200">Hover me</view>
<!--data-xxx: 自定义数据属性,可以在 JavaScript 中通过 event.currentTarget.dataset.xxx 访问。-->
<view data-num="123" bindtap="handleTap">Custom data</view>
<view hidden="{{isHidden}}">Hidden view</view>
<scroll-view scroll-top="{{scrollTop}}" scroll-left="{{scrollLeft}}" scroll-into-view="targetView" scroll-with-animation="true">
<view>1111111</view>
<view>2222222</view>
<view>3333333</view>
<view id="targetView">Target View</view>
</scroll-view>
<view selectable="{{selectable}}">Selectable text</view>
<scroll-view scroll-y style="height: 300px;">
<view>1111111</view>
<view>2222222</view>
<view>3333333</view>
<view>Target View</view>
</scroll-view>
\ No newline at end of file
/* pages/testview/testview.wxss */
.hover-class{
color: rgb(177, 72, 31);
}
.basclass{
background-color: aquamarine;
}
\ No newline at end of file
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册