作者 lihongjuan

ceshi

正在显示 74 个修改的文件 包含 4241 行增加0 行删除
//app.js
App({
onLaunch: function () {
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
// 获取用户信息
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
this.globalData.userInfo = res.userInfo
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
}
})
}
}
})
},
post: function (url, data, headerParams) {
wx.showNavigationBarLoading()
var promise = new Promise((resolve, reject) => {
//init
let that = this;
let postData = data;
let baseUrl = 'https://attention.w.bronet.cn/api/';
//网络请求
let header = {
// 'XX-Device-Type': 'wxapp',
'token': wx.getStorageSync("token") || ''
}
header = Object.assign(header, headerParams)
//网络请求
wx.request({
url: baseUrl + url,
data: postData,
method: headerParams,
header: header,
success: function (res) { //返回取得的数据
if (res.data.code == '1') {
resolve(res.data.data);
} else if (res.data.code == '201') {
resolve(res.data);
} else {
// wx.showToast({
// title: res.data.msg,
// duration: 1200,
// icon: 'none'
// })
reject(res)
}
// else if (res.data.code == '42002') {
// }
// setTimeout(function () {
// wx.hideNavigationBarLoading()
// }, 600)
},
fail: function (e) {
reject('网络出错');
// wx.hideLoading()
wx.hideNavigationBarLoading()
},
complete: function () {
wx.hideNavigationBarLoading()
},
})
});
return promise;
},
globalData: {
userInfo: null
}
})
\ No newline at end of file
... ...
{
"pages": [
"pages/homepage/homepage",
"pages/attentionone/attentionone",
"pages/attentiontwo/attentiontwo",
"pages/parentping/parentping",
"pages/question/question",
"pages/aboutdanke/aboutdanke",
"pages/index/index",
"pages/logs/logs"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "",
"navigationBarTextStyle": "black"
},
"sitemapLocation": "sitemap.json"
}
\ No newline at end of file
... ...
/**app.wxss**/
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}
... ...

549 字节

248.9 KB

490 字节

770 字节

765 字节

1015 字节

1021 字节

1007 字节

972 字节

// pages/aboutdanke/aboutdanke.js
Page({
/**
* 页面的初始数据
*/
data: {
commonnum:'陶姐TAO'
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
// copy(){
// let that=this;
// wx.setClipboardData({
// data: that.data.commonnum,
// success: function (res) {
// wx.showToast({
// title: '复制成功',
// });
// }
// });
// },
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "关于蛋壳"
}
\ No newline at end of file
... ...
<view class="dankepage">
<image src="/img/aboutdanke.png" mode="widthFix"></image>
<view class="dankepageox">
<view class="dankepageboxitem">
<view class="dankepageboxitemleft">
<image src="/img/gongzhong.png"></image>
</view>
<view class="danlepageboxitemright" bindlongtap='copy' data-word="{{commonnum}}">
<text selectable='true'> 关注陶姐公众号:{{commonnum}}</text>
</view>
</view>
<view class="dankepageboxitem">
<view class="dankepageboxitemleft">
<image src="/img/weixin.png"></image>
</view>
<view class="danlepageboxitemright">
<text selectable='true'> 添加陶姐微信: taoma817</text>
</view>
</view>
<view class="dankepageboxitem">
<view class="dankepageboxitemleft">
<image src="/img/douyin.png"></image>
</view>
<view class="danlepageboxitemright">
<text selectable='true'>关注抖音账号:苏州小小蛋壳</text>
</view>
</view>
<view class="dankepageboxitem">
<view class="dankepageboxitemleft">
<image src="/img/taobao.png"></image>
</view>
<view class="danlepageboxitemright">
<text selectable='true'>搜索淘宝店铺:小蛋壳育儿</text>
</view>
</view>
</view>
</view>
... ...
page{
width:750rpx;
height:100%;
overflow-y: hidden;
}
.dankepage{
width:100%;
height:1224rpx;
position: relative;
overflow: hidden;
}
.dankepage image{
width:100%;
height:100%;
}
.dankepageboxitem{
display:flex;
align-items: center;
width:359rpx;
border-bottom:1rpx solid #7D7D7D;
padding: 5rpx 0;
box-sizing: border-box;
}
.dankepageboxitemleft{
width:30rpx;
height:30rpx;
font-size: 0
}
.danlepageboxitemright{
color:#313131;
font-size: 24rpx;
font-weight: bold;
margin-left:10rpx;
}
.dankepageox{
position: absolute;
bottom:306rpx;
left:21rpx;
border-top:1rpx solid #7D7D7D
}
\ No newline at end of file
... ...
// pages/attentionone/attentionone.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
maskHidden: false,
id: '',
description: '',
qrcode: '',
rings: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
this.setData({
id: options.id,
title:""
})
this.getresult()
},
// 获取结果
getresult() {
let that = this;
var url = 'index/answer_log_detail';
var params = {
answer_log_id: that.data.id,
}
app.post(url, params).then((res) => {
console.log(res);
that.setData({
description: res.description,
qrcode: res.qrcode,
rings: res.rings,
title:res.title
})
that.savefilecode()
}).catch((err) => {
})
},
createNewImg: function() {
var that = this;
console.log(9999)
var context = wx.createCanvasContext('mycanvas');
// var img = '/img/no.png';
// context.createPattern(img, 0, 0, 375, 667)
// context.style.background ='/img/tuijianimg1.png'
// context.setFillStyle("#ffe200");
context.fillRect(0, 0, 375, 603);
var path = "/img/attentionsevenone.png";
context.drawImage(path, 0, 0, 375, 603);
// context.drawImage(path, 0, 0, 680, 300);
var path2 = that.data.qrcode;
context.drawImage(path2, 10, 540, 55, 55);
context.setFontSize(20);
context.setFillStyle('#CE6198');
context.setTextAlign('center');
context.fillText(that.data.title, 185, 120);
context.setFontSize(16);
context.setFillStyle('#CE6198');
context.setTextAlign('center');
var str = that.data.description;
var x = 145;
var len = Math.ceil(str.length / 12);
for (var i = 0; i < len; i++) {
var j = i * 12;
var strs = str.substring(j, 12 * (i + 1));
context.fillText(strs, 180, x + 22 * i, 900);
}
context.setFontSize(12);
context.setFillStyle('#EA595D');
context.setTextAlign('center');
context.fillText(that.data.rings[6].sort_name, 140, 220);
context.setFontSize(12);
context.setFillStyle('#EA595D');
context.setTextAlign('center');
context.fillText(that.data.rings[6].percent, 142, 235);
context.setFontSize(12);
context.setFillStyle('#fff');
context.setTextAlign('center');
var str = that.data.rings[6].description;
var x = 260;
var len = Math.ceil(str.length /4);
for (var i = 0; i < len; i++) {
var j = i * 4;
var strs = str.substring(j, 5 * (i + 1));
context.fillText(strs, 150, x + 22 * i, 2000);
}
context.setFontSize(12);
context.setFillStyle('#CE6198');
context.setTextAlign('center');
context.fillText(that.data.rings[5].sort_name, 240, 216);
context.setFontSize(12);
context.setFillStyle('#CE6198');
context.setTextAlign('center');
context.fillText(that.data.rings[5].percent, 242, 232);
context.setFontSize(12);
context.setFillStyle('#fff');
context.setTextAlign('center');
var str = that.data.rings[5].description;
var x = 260;
var len = Math.ceil(str.length / 5);
for (var i = 0; i < len; i++) {
var j = i * 5;
var strs = str.substring(j, 5 * (i + 1));
context.fillText(strs, 235, x + 22 * i, 2000);
}
context.setFontSize(12);
context.setFillStyle('#F49E15');
context.setTextAlign('center');
context.fillText(that.data.rings[0].sort_name, 70, 295);
context.setFontSize(12);
context.setFillStyle('#F49E15');
context.setTextAlign('center');
context.fillText(that.data.rings[0].percent, 72, 310);
context.setFontSize(12);
context.setFillStyle('#fff');
context.setTextAlign('center');
var str = that.data.rings[0].description;
var x = 340;
var len = Math.ceil(str.length / 5);
for (var i = 0; i < len; i++) {
var j = i * 5;
var strs = str.substring(j, 5 * (i + 1));
context.fillText(strs, 95, x + 22 * i, 2000);
}
context.setFontSize(12);
context.setFillStyle('#898989');
context.setTextAlign('center');
context.fillText(that.data.rings[1].sort_name, 68, 460);
context.setFontSize(12);
context.setFillStyle('#898989');
context.setTextAlign('center');
context.fillText(that.data.rings[1].percent, 70, 475);
context.setFontSize(12);
context.setFillStyle('#fff');
context.setTextAlign('center');
var str = that.data.rings[1].description;
var x = 396;
var len = Math.ceil(str.length / 5);
for (var i = 0; i < len; i++) {
var j = i * 5;
var strs = str.substring(j, 5 * (i + 1));
context.fillText(strs, 110, x + 18 * i, 2000);
}
context.setFontSize(12);
context.setFillStyle('#1BB4A5');
context.setTextAlign('center');
context.fillText(that.data.rings[2].sort_name, 190, 489);
context.setFontSize(12);
context.setFillStyle('#1BB4A5');
context.setTextAlign('center');
context.fillText(that.data.rings[2].percent, 192, 505);
context.setFontSize(12);
context.setFillStyle('#fff');
context.setTextAlign('center');
var str = that.data.rings[2].description;
var x = 400;
var len = Math.ceil(str.length / 4);
for (var i = 0; i < len; i++) {
var j = i * 4;
var strs = str.substring(j, 4 * (i + 1));
context.fillText(strs, 190, x + 22 * i, 2000);
}
context.setFontSize(12);
context.setFillStyle('#1A97D0');
context.setTextAlign('center');
context.fillText(that.data.rings[3].sort_name, 306, 459);
context.setFontSize(14);
context.setFillStyle('#1A97D0');
context.setTextAlign('center');
context.fillText(that.data.rings[3].percent, 308, 474);
context.setFontSize(12);
context.setFillStyle('#fff');
context.setTextAlign('center');
var str = that.data.rings[3].description;
var x = 395;
var len = Math.ceil(str.length / 5);
for (var i = 0; i < len; i++) {
var j = i * 5;
var strs = str.substring(j, 5 * (i + 1));
context.fillText(strs, 265, x + 22 * i, 2000);
}
context.setFontSize(12);
context.setFillStyle('#A6639E');
context.setTextAlign('center');
context.fillText('听觉转移', 308, 298);
context.setFontSize(12);
context.setFillStyle('#A6639E');
context.setTextAlign('center');
context.fillText('25%', 312, 312);
context.setFontSize(12);
context.setFillStyle('#fff');
context.setTextAlign('center');
var str = '听见,是我最大的努力';
var x = 338;
var len = Math.ceil(str.length / 5);
for (var i = 0; i < len; i++) {
var j = i * 5;
var strs = str.substring(j, 5 * (i + 1));
context.fillText(strs, 270, x + 22 * i, 2000);
}
// var path2 = that.data.codeurl;
// console.log('888777666554433', path2)
// var path3 = "/img/feihuiyuan.png";
// var path4 = "/img/dali.png";
// var path5 = "/img/tiyanactive.png";
// this.drawCircular(context, 96, 96, this.data.imgwidth * 0.7, this.data.imgheight * 0.7, path2);
context.save(); // 保存当前context的状态
// context.setFontSize(20);
// context.setFillStyle('#78482F');
// context.setTextAlign('center');
// let nickname = wx.getStorageSync("nickname");
// console.log('889900', nickname)
// context.fillText(nickname, 184, 45);
// context.setFontSize(15);
// context.setFillStyle('#78482F');
// context.setTextAlign('center');
// context.fillText('期待你的加入', 185, 75);
// var path1 = that.data.saveimg;
// console.log('头像', path1)
// context.arc(76, 56, 35, 0, 2 * Math.PI) //画出圆
// context.setFillStyle('#ffffff')
// context.strokeStyle = "#ffe200";
// context.clip(); //裁剪上面的圆形00
// context.drawImage(path1, 41, 21, 70, 70); // 在刚刚裁剪的园上画图
context.draw();
//将生成好的图片保存到本地,需要延迟一会,绘制期间耗时
setTimeout(function() {
wx.canvasToTempFilePath({
canvasId: 'mycanvas',
success: function(res) {
console.log(res)
var tempFilePath = res.tempFilePath;
console.log(tempFilePath)
that.setData({
imagePath: tempFilePath,
canvasHidden: true
});
},
fail: function(res) {
console.log(res);
}
});
}, 200);
},
drawCircular(ctx, width, height, x, y, url) {
var avatarurl_width = width;
var avatarurl_heigth = height;
var avatarurl_x = x;
var avatarurl_y = y;
console.log(avatarurl_width);
console.log(avatarurl_heigth);
console.log(avatarurl_x);
console.log(avatarurl_y);
ctx.save();
ctx.beginPath();
ctx.arc(avatarurl_width / 2 + avatarurl_x, avatarurl_heigth / 2 + avatarurl_y, avatarurl_width / 2, 0, Math.PI * 2, false);
ctx.clip();
ctx.drawImage(url, avatarurl_x, avatarurl_y, avatarurl_width, avatarurl_heigth);
ctx.restore();
},
//点击保存到相册
baocun: function() {
console.log(999)
var that = this
wx.getSetting({
success(res) {
if (!res.authSetting['scope.writePhotosAlbum']) {
wx.authorize({
scope: 'scope.writePhotosAlbum',
success() { //这里是用户同意授权后的回调
wx.saveImageToPhotosAlbum({
filePath: that.data.imagePath,
success(res) {
wx.showModal({
content: '图片已保存到相册',
showCancel: false,
confirmText: '好的',
confirmColor: '#333',
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
/* 该隐藏的隐藏 */
that.setData({
maskHidden: false
})
}
},
fail: function(res) {
}
})
}
})
},
fail() { //这里是用户拒绝授权后的回调
// wx.openSetting({
// success: function (data) {
// console.log(data)
// if (data.authSetting["scope.writePhotosAlbum"] === true) {
// console.log("是否授权成功")
// } else {
// applyApi.toast("授权失败");
// }
// }
// })
wx.showModal({
title: '提示',
content: '您取消授权,无法保存图片,点击确定打开权限',
success(res) {
if (res.confirm) {
console.log('用户点击确定')
wx.openSetting({
success(res) {
console.log(res.authSetting)
// res.authSetting = {
// "scope.userInfo": true,
// "scope.userLocation": true
// }
}
})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
}
})
} else { //用户已经授权过了
console.log(that.data.imagePath)
wx.saveImageToPhotosAlbum({
filePath: that.data.imagePath,
success(res) {
wx.showModal({
content: '图片已保存到相册',
showCancel: false,
confirmText: '好的',
confirmColor: '#333',
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
/* 该隐藏的隐藏 */
that.setData({
maskHidden: false
})
}
},
fail: function(res) {
}
})
}
})
}
}
})
},
hideceng() {
this.setData({
maskHidden: false
})
},
savephoto() {
console.log(54683485)
let that = this;
this.setData({
maskHidden: false
});
wx.showToast({
title: '海报生成中',
icon: 'loading',
duration: 1000
});
setTimeout(function() {
wx.hideToast()
that.createNewImg();
that.setData({
maskHidden: true
});
}, 1000)
},
savefilecode() {
let that = this;
console.log(that.data.codeurl)
wx.downloadFile({
url: that.data.qrcode,
header: {},
success: function (res) {
console.log('下载图片下载图片下载图片', res)
var tempFilePath = res.tempFilePath
//console.log('临时文件地址是:' + tempFilePath)
wx.saveFile({
tempFilePath: tempFilePath,
success: function (res) {
console.log(res)
var saveFilePath = res.savedFilePath;
that.setData({
qrcode: res.savedFilePath
})
console.log('123456855555555', that.data.qrcode)
}, //可以将saveFilePath写入到页面数据中
fail: function (res) { },
complete: function (res) {
console.log('complete后的res数据:')
},
}) //,
},
// fail: function (res) {
// wx.showModal({
// title: '下载失败',
// content: '请联系管理员',
// })
// },
complete: function (res) { },
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
// wx.navigateTo({
// url: '/pages/homepage/homepage',
// })
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
let that = this;
return {
title: '我的注意力分享', // 转发后 所显示的title
// path: '/pages/home/buildtextdetail/buildtextdetail?buildid='+buildid+'&gettoken='+newtoken, // 相对的路径
path: '/pages/attentionone/attentionone?id='+that.data.id, //分娩笔记分享2
success: (res) => { // 成功后要做的事情
console.log(res)
},
fail: function (res) {
// 分享失败
console.log(res)
}
}
}
})
\ No newline at end of file
... ...
{
"usingComponents": {}
}
\ No newline at end of file
... ...
<view class="myattention">
<image src="/img/atten.png"></image>
</view>
<view class="noke">[{{title}}]</view>
<view class='noketext'>{{description}}</view>
<!-- <view class="noketext up">每个方向都有同样的上升空间!</view> -->
<!-- <view class='roleone'>
<image src="/img/roleone.png"></image>
<view class="redname">对不起,我可能不配拥有它!</view>
<view class="redkuang">视觉追踪25%</view>
<view class="pink">我听的见但听不懂!</view>
<view class="pinkkuang">视觉追踪25%</view>
<view class="yellowname">说来惭愧我啥也记不住!</view>
<view class="yellowkuang">听觉记忆25%</view>
<view class="purplename">听见,是我最大的努力!</view>
<view class="purplekuang">听觉转移25%</view>
<view class="grayname">好险,我不色弱,也没色盲!</view>
<view class="graykuang">视觉分辨25%</view>
<view class="greenname">请你慢点说再慢点说...</view>
<view class="greenkuang">听觉追踪25%</view>
<view class="bluename">跟我说话,请不要超过5个字</view>
<view class="bluekuang">听觉广度25%</view>
</view> -->
<view class="tupic">
<image src="/img/roleone.png"></image>
<view class="redname">{{rings[6].description}}</view>
<view class="redkuang">{{rings[6].sort_name}}{{rings[6].percent}}</view>
<view class="pink">{{rings[5].description}}</view>
<view class="pinkkuang">{{rings[5].sort_name}}{{rings[5].percent}}</view>
<view class="yellowname">{{rings[0].description}}</view>
<view class="yellowkuang">{{rings[0].sort_name}}{{rings[0].percent}}</view>
<view class="purplename">{{rings[4].description}}</view>
<view class="purplekuang">{{rings[4].sort_name}}{{rings[4].percent}}</view>
<view class="grayname">{{rings[1].description}}</view>
<view class="graykuang">{{rings[1].sort_name}}{{rings[1].percent}}</view>
<view class="greenname">{{rings[2].description}}</view>
<view class="greenkuang">{{rings[2].sort_name}}{{rings[2].percent}}</view>
<view class="bluename">{{rings[3].description}}</view>
<view class="bluekuang">{{rings[3].sort_name}}{{rings[3].percent}}</view>
</view>
<view class="code">
<view class="codeleft">
<image src="{{qrcode}}"></image>
</view>
<view class="coderight">
<view class="coderighttop">长按识别二维码</view>
<view class="coderighttopk">获取你的注意力测验单</view>
</view>
</view>
<view class="sharehai">
<!-- <view class="shareleft">分享给好友</view> -->
<view class="shareright" bindtap="savephoto">生成海报</view>
</view>
<!-- 海报 -->
<view class='pp' bindtap="hideceng">
<view class='imagePathBox' hidden="{{maskHidden == false}}">
<image src="{{imagePath}}" class='shengcheng'></image>
<view class="share">
<button class="shareleft" catchtap="share" open-type='share'>分享给好友</button>
<!-- <button class="lj_share" bindtap="childshare" open-type='share'>分享</button> -->
<view class="shareright" catchtap="baocun">保存到相册</view>
</view>
<!-- <button class='baocun' bindtap='baocun'>保存图片至相册</button> -->
</view>
<view hidden="{{maskHidden == false}}" class="mask"></view>
<view class="canvas-box">
<canvas style="width:375px;height:603px;position:fixed;top:9999px;border-radius:56rpx" canvas-id="mycanvas" />
</view>
</view>
\ No newline at end of file
... ...
.myattention {
width: 750rpx;
height: 170rpx;
font-size: 0;
}
image {
width: 100%;
height: 100%;
}
.noke {
color: #ce6198;
font-size: 42rpx;
font-weight: bold;
margin-top: 12rpx;
text-align: center;
}
.noketext {
color: #ce6198;
font-size: 39rpx;
font-weight: bold;
text-align: center;
margin-top: 15rpx;
}
.up {
margin-top: 10rpx;
}
.roleone {
width: 260rxp;
height: 740rpx;
font-size: 0;
margin: 50rpx auto 0;
}
.roleone image{
width:100%;
height:100%;
}
.redname {
color: #fff;
font-size: 24rpx;
position: absolute;
width: 156rpx;
top: 100rpx;
left: 154rpx;
line-height: 1.8;
}
.redkuang {
color: #ea575d;
font-size: 26rpx;
font-weight: bold;
width: 130rpx;
position: absolute;
top: -25rpx;
left: 117rpx;
background: #fff;
text-align: center;
padding: 10rpx;
border: 1rpx solid #ea575d;
}
.pink {
color: #fff;
font-size: 24rpx;
position: absolute;
width: 135rpx;
top: 100rpx;
left: 338rpx;
line-height: 1.8;
}
.pinkkuang {
color: #ce6198;
font-size: 26rpx;
font-weight: bold;
width: 130rpx;
position: absolute;
top: -25rpx;
left: 353rpx;
background: #fff;
text-align: center;
padding: 10rpx;
border: 1rpx solid #ce6198;
}
.yellowname {
color: #fff;
font-size: 24rpx;
position: absolute;
width: 185rpx;
top: 252rpx;
left: 35rpx;
line-height: 1.8;
text-align: center;
}
.yellowkuang {
color: #f49f19;
font-size: 26rpx;
font-weight: bold;
width: 130rpx;
position: absolute;
top: 146rpx;
left: -26rpx;
background: #fff;
text-align: center;
padding: 10rpx;
border: 1rpx solid #f49f19;
}
.purplename {
color: #fff;
font-size: 24rpx;
position: absolute;
width: 185rpx;
top: 250rpx;
right: 35rpx;
line-height: 1.8;
text-align: center;
}
.purplekuang {
color: #a5639e;
font-size: 26rpx;
font-weight: bold;
width: 130rpx;
position: absolute;
top: 146rpx;
right: -23rpx;
background: #fff;
text-align: center;
padding: 10rpx;
border: 1rpx solid #a5639e;
}
.grayname {
color: #fff;
font-size:24rpx;
position: absolute;
width: 185rpx;
bottom: 168rpx;
left: 67rpx;
line-height: 1.8;
text-align: center;
}
.graykuang {
color: #898989;
font-size: 26rpx;
font-weight: bold;
width: 130rpx;
position: absolute;
bottom: 24rpx;
left: 18rpx;
background: #fff;
text-align: center;
padding: 10rpx;
border: 1rpx solid #898989;
}
.greenname {
color: #fff;
font-size: 22rpx;
position: absolute;
width: 109rpx;
bottom: 95rpx;
left: 254rpx;
line-height: 1.8;
text-align: center;
}
.greenkuang {
color: #14b4a6;
font-size: 26rpx;
font-weight: bold;
width: 130rpx;
position: absolute;
bottom: -20rpx;
left: 227rpx;
background: #fff;
text-align: center;
padding: 10rpx;
border: 1rpx solid #14b4a6;
}
.bluename {
color: #fff;
font-size: 24rpx;
position: absolute;
width: 217rpx;
bottom: 166rpx;
right: 35rpx;
line-height: 1.8;
text-align: center;
}
.bluekuang{
color: #1C96D0;
font-size: 26rpx;
font-weight: bold;
width: 130rpx;
position: absolute;
bottom: 63rpx;
right:17rpx;
background: #fff;
text-align: center;
padding: 10rpx;
border: 1rpx solid #1C96D0;
}
.tupic{
width:613rpx;
height:613rpx;
font-size: 0;
position: relative;
margin:31rpx auto 0;
}
.code {
display: flex;
align-items: center;
width: 613rpx;
height: 128rpx;
margin:10rpx auto 0;
/* position: absolute;
left: 28rpx;
bottom: 122rpx;
*/
padding: 0 16rpx;
box-sizing: border-box;
}
.codeleft {
width: 105rpx;
height: 105rpx;
font-size: 0;
}
.coderight {
margin-left: 17rpx;
}
.coderighttop {
color: #000;
font-size: 28rpx;
}
.coderighttopk {
color: #000;
font-size: 28rpx;
margin-top: 10rpx;
}
.share {
display: flex;
align-items: center;
position: absolute;
top:1138rpx;
z-index:999;
left: 58rpx;
}
.shareleft {
width: 289rpx;
height: 68rpx;
color: #ce6198;
font-size: 28rpx;
text-align: center;
line-height: 68rpx;
background: #f9f9f9;
border-radius: 44rpx;
}
.shareright {
width: 289rpx;
height: 68rpx;
color: #fff;
font-size: 28rpx;
text-align: center;
line-height:68rpx;
background: #ce6198;
border-radius: 44rpx;
margin-left: 57rpx;
}
.imagePathBox{
width: 100%;
height: 100%;
background: rgba(0,0,0,0.7);
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 10;
}
.shengcheng{
width:665rpx;
height:1100rpx;
position: fixed;
left: 50%;
top:30rpx;
transform: translateX(-50%);
/* margin-left: -40%; */
z-index: 10;
}
.baocun{
display: block;
width: 80%;
height: 92rpx;
padding: 0;
line-height: 92rpx;
text-align: center;
position: fixed;
bottom: 12rpx;
left: 10%;
background:linear-gradient(180deg,rgba(252,169,162,1) 0%,rgba(255,119,117,1) 100%);
color: #fff;
font-size: 32rpx;
border-radius: 44rpx;
z-index:999999
}
button[class="baocun"]::after{
border: 0;
}
.canvas-box{
word-break: break-word;
word-wrap: break-word;
}
.pp{
position: relative
}
.sharehai{
width:750rpx;
display:flex;
justify-content: center;
align-items: center;
/* margin-top:8rpx; */
/* position: absolute;
bottom:5rpx; */
}
\ No newline at end of file
... ...
// pages/attentiontwo/attentiontwo.js
const app=getApp()
Page({
/**
* 页面的初始数据
*/
data: {
maskHidden: false,
id:'',
description:'',
qrcode:'',
rings:'',
title:""
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
id: options.id
})
this.getresult()
},
// 获取结果
getresult() {
let that = this;
var url = 'index/answer_log_detail';
var params = {
answer_log_id: that.data.id,
}
app.post(url, params).then((res) => {
console.log(res);
that.setData({
description: res.description,
qrcode: res.qrcode,
rings: res.rings,
title:res.title
})
that.savefilecode()
}).catch((err) => {
})
},
createNewImg: function () {
var that = this;
console.log(9999)
var context = wx.createCanvasContext('mycanvas');
// var img = '/img/no.png';
// context.createPattern(img, 0, 0, 375, 667)
// context.style.background ='/img/tuijianimg1.png'
// context.setFillStyle("#ffe200");
context.fillRect(0, 0, 375, 603);
var path = "/img/attentionsix.png";
context.drawImage(path, 0, 0, 375, 603);
// context.drawImage(path, 0, 0, 680, 300);
var path2 = that.data.qrcode;
context.drawImage(path2, 10, 539, 55, 55);
context.setFontSize(20);
context.setFillStyle('#CE6198');
context.setTextAlign('center');
context.fillText(that.data.title, 185, 120);
context.setFontSize(16);
context.setFillStyle('#CE6198');
context.setTextAlign('center');
var str =that.data.description;
var x = 145;
var len = Math.ceil(str.length / 12);
for (var i = 0; i < len; i++) {
var j = i * 12;
var strs = str.substring(j, 12 * (i + 1));
context.fillText(strs, 180, x + 22 * i,900);
}
context.setFontSize(14);
context.setFillStyle('#EA595D');
context.setTextAlign('center');
context.fillText(that.data.rings[1].sort_name +that.data.rings[1].percent, 114, 220);
context.setFontSize(14);
context.setFillStyle('#fff');
context.setTextAlign('center');
var str = that.data.rings[1].description;
var x = 250;
var len = Math.ceil(str.length / 5);
for (var i = 0; i < len; i++) {
var j = i * 5;
var strs = str.substring(j, 5 * (i + 1));
context.fillText(strs, 140, x + 22 * i, 2000);
}
context.setFontSize(14);
context.setFillStyle('#CE6198');
context.setTextAlign('center');
context.fillText(that.data.rings[0].sort_name + that.data.rings[0].percent, 270, 233);
context.setFontSize(14);
context.setFillStyle('#fff');
context.setTextAlign('center');
var str = that.data.rings[0].description;
var x = 265;
var len = Math.ceil(str.length / 5);
for (var i = 0; i < len; i++) {
var j = i * 5;
var strs = str.substring(j, 5 * (i + 1));
context.fillText(strs, 245, x + 22 * i, 2000);
}
context.setFontSize(14);
context.setFillStyle('#F49E15');
context.setTextAlign('center');
context.fillText(that.data.rings[4].sort_name + that.data.rings[4].percent, 90, 317);
context.setFontSize(14);
context.setFillStyle('#fff');
context.setTextAlign('center');
var str = that.data.rings[4].description;
var x = 345;
var len = Math.ceil(str.length / 5);
for (var i = 0; i < len; i++) {
var j = i * 5;
var strs = str.substring(j, 5 * (i + 1));
context.fillText(strs, 115, x + 22 * i, 2000);
}
context.setFontSize(14);
context.setFillStyle('#A6639E');
context.setTextAlign('center');
context.fillText(that.data.rings[2].sort_name + that.data.rings[2].percent, 280, 397);
context.setFontSize(12);
context.setFillStyle('#fff');
context.setTextAlign('center');
var str = that.data.rings[2].description;
var x = 342;
var len = Math.ceil(str.length / 8);
for (var i = 0; i < len; i++) {
var j = i * 8;
var strs = str.substring(j, 8 * (i + 1));
context.fillText(strs, 288, x + 18 * i, 2000);
}
context.setFontSize(14);
context.setFillStyle('#1BB4A5');
context.setTextAlign('center');
context.fillText(that.data.rings[5].sort_name + that.data.rings[5].percent, 110, 487);
context.setFontSize(14);
context.setFillStyle('#fff');
context.setTextAlign('center');
var str = that.data.rings[5].description;;
var x = 420;
var len = Math.ceil(str.length / 5);
for (var i = 0; i < len; i++) {
var j = i * 5;
var strs = str.substring(j, 5 * (i + 1));
context.fillText(strs, 140, x + 22 * i, 2000);
}
context.setFontSize(14);
context.setFillStyle('#1A97D0');
context.setTextAlign('center');
context.fillText(that.data.rings[3].sort_name + that.data.rings[3].percent, 270, 504);
context.setFontSize(14);
context.setFillStyle('#fff');
context.setTextAlign('center');
var str = that.data.rings[3].description;;
var x = 425;
var len = Math.ceil(str.length / 5);
for (var i = 0; i < len; i++) {
var j = i * 5;
var strs = str.substring(j, 5 * (i + 1));
context.fillText(strs, 240, x + 22 * i, 2000);
}
// var path2 = that.data.codeurl;
// console.log('888777666554433', path2)
// var path3 = "/img/feihuiyuan.png";
// var path4 = "/img/dali.png";
// var path5 = "/img/tiyanactive.png";
// this.drawCircular(context, 96, 96, this.data.imgwidth * 0.7, this.data.imgheight * 0.7, path2);
context.save(); // 保存当前context的状态
// context.setFontSize(20);
// context.setFillStyle('#78482F');
// context.setTextAlign('center');
// let nickname = wx.getStorageSync("nickname");
// console.log('889900', nickname)
// context.fillText(nickname, 184, 45);
// context.setFontSize(15);
// context.setFillStyle('#78482F');
// context.setTextAlign('center');
// context.fillText('期待你的加入', 185, 75);
// var path1 = that.data.saveimg;
// console.log('头像', path1)
// context.arc(76, 56, 35, 0, 2 * Math.PI) //画出圆
// context.setFillStyle('#ffffff')
// context.strokeStyle = "#ffe200";
// context.clip(); //裁剪上面的圆形00
// context.drawImage(path1, 41, 21, 70, 70); // 在刚刚裁剪的园上画图
context.draw();
//将生成好的图片保存到本地,需要延迟一会,绘制期间耗时
setTimeout(function () {
wx.canvasToTempFilePath({
canvasId: 'mycanvas',
success: function (res) {
console.log(res)
var tempFilePath = res.tempFilePath;
console.log(tempFilePath)
that.setData({
imagePath: tempFilePath,
canvasHidden: true
});
},
fail: function (res) {
console.log(res);
}
});
}, 200);
},
drawCircular(ctx, width, height, x, y, url) {
var avatarurl_width = width;
var avatarurl_heigth = height;
var avatarurl_x = x;
var avatarurl_y = y;
console.log(avatarurl_width);
console.log(avatarurl_heigth);
console.log(avatarurl_x);
console.log(avatarurl_y);
ctx.save();
ctx.beginPath();
ctx.arc(avatarurl_width / 2 + avatarurl_x, avatarurl_heigth / 2 + avatarurl_y, avatarurl_width / 2, 0, Math.PI * 2, false);
ctx.clip();
ctx.drawImage(url, avatarurl_x, avatarurl_y, avatarurl_width, avatarurl_heigth);
ctx.restore();
},
//点击保存到相册
baocun: function () {
console.log(999)
var that = this
wx.getSetting({
success(res) {
if (!res.authSetting['scope.writePhotosAlbum']) {
wx.authorize({
scope: 'scope.writePhotosAlbum',
success() { //这里是用户同意授权后的回调
wx.saveImageToPhotosAlbum({
filePath: that.data.imagePath,
success(res) {
wx.showModal({
content: '图片已保存到相册',
showCancel: false,
confirmText: '好的',
confirmColor: '#333',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
/* 该隐藏的隐藏 */
that.setData({
maskHidden: false
})
}
},
fail: function (res) {
}
})
}
})
},
fail() { //这里是用户拒绝授权后的回调
// wx.openSetting({
// success: function (data) {
// console.log(data)
// if (data.authSetting["scope.writePhotosAlbum"] === true) {
// console.log("是否授权成功")
// } else {
// applyApi.toast("授权失败");
// }
// }
// })
wx.showModal({
title: '提示',
content: '您取消授权,无法保存图片,点击确定打开权限',
success(res) {
if (res.confirm) {
console.log('用户点击确定')
wx.openSetting({
success(res) {
console.log(res.authSetting)
// res.authSetting = {
// "scope.userInfo": true,
// "scope.userLocation": true
// }
}
})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
}
})
} else { //用户已经授权过了
console.log(that.data.imagePath)
wx.saveImageToPhotosAlbum({
filePath: that.data.imagePath,
success(res) {
wx.showModal({
content: '图片已保存到相册',
showCancel: false,
confirmText: '好的',
confirmColor: '#333',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
/* 该隐藏的隐藏 */
that.setData({
maskHidden: false
})
}
},
fail: function (res) {
}
})
}
})
}
}
})
},
hideceng() {
this.setData({
maskHidden: false
})
},
savephoto() {
console.log(54683485)
let that = this;
this.setData({
maskHidden: false
});
wx.showToast({
title: '海报生成中',
icon: 'loading',
duration: 1000
});
setTimeout(function () {
wx.hideToast()
that.createNewImg();
that.setData({
maskHidden: true
});
}, 1000)
},
savefilecode() {
let that = this;
console.log(that.data.codeurl)
wx.downloadFile({
url: that.data.qrcode,
header: {},
success: function (res) {
console.log('下载图片下载图片下载图片', res)
var tempFilePath = res.tempFilePath
//console.log('临时文件地址是:' + tempFilePath)
wx.saveFile({
tempFilePath: tempFilePath,
success: function (res) {
console.log(res)
var saveFilePath = res.savedFilePath;
that.setData({
qrcode: res.savedFilePath
})
console.log('123456855555555', that.data.qrcode)
}, //可以将saveFilePath写入到页面数据中
fail: function (res) { },
complete: function (res) {
console.log('complete后的res数据:')
},
}) //,
},
// fail: function (res) {
// wx.showModal({
// title: '下载失败',
// content: '请联系管理员',
// })
// },
complete: function (res) { },
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
// wx.navigateTo({
// url: '/pages/homepage/homepage',
// })
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
let that = this;
return {
title: '我的注意力分享', // 转发后 所显示的title
// path: '/pages/home/buildtextdetail/buildtextdetail?buildid='+buildid+'&gettoken='+newtoken, // 相对的路径
path: '/pages/attentiontwo/attentiontwo?id=' + that.data.id, //分娩笔记分享2
success: (res) => { // 成功后要做的事情
console.log(res)
},
fail: function (res) {
// 分享失败
console.log(res)
}
}
}
})
\ No newline at end of file
... ...
{
"usingComponents": {}
}
\ No newline at end of file
... ...
<view class="myattention">
<image src="/img/atten.png"></image>
</view>
<view class="noke">[{{title}}]</view>
<view class='noketext'>{{description}}</view>
<!-- <view class="noketext up">每个方向都有同样的上升空间!</view> -->
<view class='tupic'>
<image src="/img/roletwo.png"></image>
<view class="redname">{{rings[1].description}}</view>
<view class="redkuang">{{rings[1].sort_name}}{{rings[1].percent}}</view>
<view class="pink">{{rings[0].description}}</view>
<view class="pinkkuang">{{rings[0].sort_name}}{{rings[0].percent}}</view>
<view class="yellowname">{{rings[4].description}}</view>
<view class="yellowkuang">{{rings[4].sort_name}}{{rings[4].percent}}</view>
<view class="purplename">{{rings[2].description}}</view>
<view class="purplekuang">{{rings[2].sort_name}}{{rings[2].percent}}</view>
<view class="greenname">{{rings[5].description}}</view>
<view class="greenkuang">{{rings[5].sort_name}}{{rings[5].percent}}</view>
<view class="bluename">{{rings[3].description}}</view>
<view class="bluekuang">{{rings[3].sort_name}}{{rings[3].percent}}</view>
</view>
<view class="code">
<view class="codeleft">
<image src="{{qrcode}}"></image>
</view>
<view class="coderight">
<view class="coderighttop">长按识别二维码</view>
<view class="coderighttopk">获取你的注意力测验单</view>
</view>
</view>
<view class="sharehai">
<!-- <view class="shareleft">分享给好友</view> -->
<view class="shareright" bindtap="savephoto">生成海报</view>
</view>
<!-- 海报 -->
<view class='pp' bindtap="hideceng">
<view class='imagePathBox' hidden="{{maskHidden == false}}">
<image src="{{imagePath}}" class='shengcheng'></image>
<!-- <button class='baocun' bindtap='baocun'>保存图片至相册</button> -->
<view class="share">
<!-- <view class="shareleft">分享给好友</view> -->
<button class="shareleft" catchtap="share" open-type='share'>分享给好友</button>
<view class="shareright" bindtap="baocun">保存图片</view>
</view>
</view>
<view hidden="{{maskHidden == false}}" class="mask"></view>
<view class="canvas-box">
<canvas style="width:375px;height:603px;position:fixed;top:9999px;border-radius:56rpx" canvas-id="mycanvas" />
</view>
</view>
\ No newline at end of file
... ...
.myattention {
width: 750rpx;
height: 170rpx;
font-size: 0;
}
image {
width: 100%;
height: 100%;
}
.noke {
color: #ce6198;
font-size: 39rpx;
font-weight: bold;
margin-top: 20rpx;
text-align: center;
}
.noketext {
color: #ce6198;
font-size: 30rpx;
font-weight: bold;
text-align: center;
margin-top: 15rpx;
}
.up {
margin-top: 10rpx;
}
.tupic{
width:613rpx;
height:613rpx;
font-size: 0;
position: relative;
margin:36rpx auto 0;
}
.redname {
color: #fff;
font-size: 24rpx;
position: absolute;
width: 172rpx;
top: 72rpx;
left: 127rpx;
line-height: 1.8;
}
.redkuang {
color: #ea575d;
font-size: 26rpx;
font-weight: bold;
width: 220rpx;
position: absolute;
top: -7rpx;
left:23rpx;
background: #fff;
text-align: center;
padding: 10rpx;
border: 1rpx solid #ea575d;
}
.pink {
color: #fff;
font-size: 24rpx;
position: absolute;
width: 135rpx;
top: 84rpx;
left: 367rpx;
line-height: 1.8;
}
.pinkkuang {
color: #ce6198;
font-size: 26rpx;
font-weight: bold;
width: 220rpx;
position: absolute;
top: 14rpx;
left: 345rpx;
background: #fff;
text-align: center;
padding: 10rpx;
border: 1rpx solid #ce6198;
}
.yellowname {
color: #fff;
font-size: 24rpx;
position: absolute;
width: 185rpx;
top: 280rpx;
left: 21rpx;
line-height: 1.8;
text-align: center;
}
.yellowkuang {
color: #f49f19;
font-size: 26rpx;
font-weight: bold;
width: 220rpx;
position: absolute;
top: 202rpx;
left: -28rpx;
background: #fff;
text-align: center;
padding: 10rpx;
border: 1rpx solid #f49f19;
}
.purplename {
color: #fff;
font-size: 22rpx;
position: absolute;
width: 185rpx;
top:265rpx;
right: 35rpx;
line-height: 1.8;
text-align: center;
}
.purplekuang {
color: #a5639e;
font-size: 26rpx;
font-weight: bold;
width: 220rpx;
position: absolute;
top: 334rpx;
right:-23rpx;
background: #fff;
text-align: center;
padding: 10rpx;
border: 1rpx solid #a5639e;
}
.grayname {
color: #fff;
font-size: 30rpx;
position: absolute;
width: 185rpx;
bottom: 185rpx;
left: 92rpx;
line-height: 1.8;
text-align: center;
}
.graykuang {
color: #898989;
font-size: 30rpx;
font-weight: bold;
width: 130rpx;
position: absolute;
bottom: 38rpx;
left: 18rpx;
background: #fff;
text-align: center;
padding: 10rpx;
border: 1rpx solid #898989;
}
.greenname {
color: #fff;
font-size: 24rpx;
position: absolute;
width: 145rpx;
bottom: 112rpx;
left: 130rpx;
line-height: 1.8;
text-align: center;
}
.greenkuang {
color: #14b4a6;
font-size: 26rpx;
font-weight: bold;
width:220rpx;
position: absolute;
bottom: 18rpx;
left: 36rpx;
background: #fff;
text-align: center;
padding: 10rpx;
border: 1rpx solid #14b4a6;
}
.bluename {
color: #fff;
font-size: 24rpx;
position: absolute;
width: 126rpx;
bottom: 78rpx;
right: 135rpx;
line-height: 1.8;
text-align: center;
}
.bluekuang{
color: #1C96D0;
font-size: 26rpx;
font-weight: bold;
width: 220rpx;
position: absolute;
bottom: 12rpx;
right:28rpx;
background: #fff;
text-align: center;
padding: 10rpx;
border: 1rpx solid #1C96D0;
}
.code {
display: flex;
align-items: center;
width: 613rpx;
height: 128rpx;
margin:10rpx auto 0;
/* position: absolute;
left: 28rpx;
bottom: 122rpx;
*/
padding: 0 16rpx;
box-sizing: border-box;
}
.codeleft {
width: 105rpx;
height: 105rpx;
font-size: 0;
}
.coderight {
margin-left: 17rpx;
}
.coderighttop {
color: #000;
font-size: 28rpx;
}
.coderighttopk {
color: #000;
font-size: 28rpx;
margin-top: 10rpx;
}
.share {
display: flex;
align-items: center;
position: absolute;
top:1138rpx;
z-index:999;
left: 58rpx;
}
.shareleft {
width: 289rpx;
height: 68rpx;
color: #ce6198;
font-size: 28rpx;
text-align: center;
line-height: 68rpx;
background: #f9f9f9;
border-radius: 44rpx;
}
.shareright {
width: 289rpx;
height: 68rpx;
color: #fff;
font-size: 28rpx;
text-align: center;
line-height:68rpx;
background: #ce6198;
border-radius: 44rpx;
margin-left: 57rpx;
}
.imagePathBox{
width: 100%;
height: 100%;
background: rgba(0,0,0,0.7);
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 10;
}
.shengcheng{
width:650rpx;
height:1080rpx;
position: fixed;
left: 50%;
top:30rpx;
transform: translateX(-50%);
/* margin-left: -40%; */
z-index: 10;
}
.baocun{
display: block;
width: 80%;
height: 92rpx;
padding: 0;
line-height: 92rpx;
text-align: center;
position: fixed;
bottom: 12rpx;
left: 10%;
background:linear-gradient(180deg,rgba(252,169,162,1) 0%,rgba(255,119,117,1) 100%);
color: #fff;
font-size: 32rpx;
border-radius: 44rpx;
z-index:999999
}
button[class="baocun"]::after{
border: 0;
}
.canvas-box{
word-break: break-word;
word-wrap: break-word;
}
.sharehai{
width:750rpx;
display:flex;
justify-content: center;
align-items: center;
/* margin-top:8rpx; */
/* position: absolute;
bottom:5rpx; */
}
\ No newline at end of file
... ...
// pages/homepage/homepage.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
// 家长评估
jiazhang(){
wx.navigateTo({
url: '/pages/question/question?type=1',
})
},
three(){
wx.navigateTo({
url: '/pages/question/question?type=2',
})
},
seven(){
wx.navigateTo({
url: '/pages/question/question?type=3',
})
},
about(){
wx.navigateTo({
url: '/pages/aboutdanke/aboutdanke',
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "注意力测试"
}
\ No newline at end of file
... ...
<view class="homeimg">
<image src="/img/index.png" mode="widthFix"></image>
<view class="jiazhangkuang" bindtap="jiazhang"></view>
<view class="threetosix" bindtap="three"></view>
<view class="seventotwelve" bindtap="seven"></view>
<view class="aboutdanke" bindtap="about">
<image src="/img/danke.png"></image>
</view>
</view>
\ No newline at end of file
... ...
page {
width: 750rpx;
height: 100%;
overflow-y: hidden;
background: #00BEAE;
}
.homeimg {
width: 100%;
height: 100%;
position: relative
}
image {
width: 100%;
height: 100%;
}
.jiazhangkuang {
width: 211rpx;
height: 255rpx;
border: 1rpx solid transparent;
position: absolute;
top:422rpx;
right:99rpx;
}
.threetosix {
width: 211rpx;
height: 255rpx;
border: 1rpx solid transparent;
position: absolute;
top:641rpx;
right:99rpx;
}
.seventotwelve {
width: 211rpx;
height: 255rpx;
border: 1rpx solid transparent;
position: absolute;
top:861rpx;
right:99rpx;
}
.aboutdanke{
width:182rpx;
height:61rpx;
font-size: 0;
position: absolute;
right:0;
bottom:45rpx;
}
.aboutdanke image{
width:100%;
height:100%;
}
\ No newline at end of file
... ...
//index.js
//获取应用实例
const app = getApp()
Page({
data: {
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo')
},
//事件处理函数
bindViewTap: function() {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad: function () {
if (app.globalData.userInfo) {
this.setData({
userInfo: app.globalData.userInfo,
hasUserInfo: true
})
} else if (this.data.canIUse){
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
app.userInfoReadyCallback = res => {
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
} else {
// 在没有 open-type=getUserInfo 版本的兼容处理
wx.getUserInfo({
success: res => {
app.globalData.userInfo = res.userInfo
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
}
},
getUserInfo: function(e) {
console.log(e)
app.globalData.userInfo = e.detail.userInfo
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
}
})
... ...
{
"usingComponents": {}
}
\ No newline at end of file
... ...
<!--index.wxml-->
<view class="container">
<view class="userinfo">
<button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
<block wx:else>
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
</block>
</view>
<view class="usermotto">
<text class="user-motto">{{motto}}</text>
</view>
</view>
... ...
/**index.wxss**/
.userinfo {
display: flex;
flex-direction: column;
align-items: center;
}
.userinfo-avatar {
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
}
.userinfo-nickname {
color: #aaa;
}
.usermotto {
margin-top: 200px;
}
\ No newline at end of file
... ...
//logs.js
const util = require('../../utils/util.js')
Page({
data: {
logs: []
},
onLoad: function () {
this.setData({
logs: (wx.getStorageSync('logs') || []).map(log => {
return util.formatTime(new Date(log))
})
})
}
})
... ...
{
"navigationBarTitleText": "查看启动日志",
"usingComponents": {}
}
\ No newline at end of file
... ...
<!--logs.wxml-->
<view class="container log-list">
<block wx:for="{{logs}}" wx:for-item="log">
<text class="log-item">{{index + 1}}. {{log}}</text>
</block>
</view>
... ...
.log-list {
display: flex;
flex-direction: column;
padding: 40rpx;
}
.log-item {
margin: 10rpx;
}
... ...
// pages/parentping/parentping.js
const app=getApp()
Page({
/**
* 页面的初始数据
*/
data: {
maskHidden: false,
imgwidth: '',
imgheight: '',
picwidth: '',
pciheight: '',
attenwidth: '',
textheight:'',
codewidth:'',
codeheight:'',
changanwidth:'',
changanheight:'',
cedanwidth:'',
cedanheight:'',
id:'',
star:'',
description:'',
qrcode:'',
title:""
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
this.setData({
id:options.id
})
this.getresult()
},
// 获取结果
getresult(){
let that = this;
var url = 'index/answer_log_detail';
var params = {
answer_log_id: that.data.id,
}
app.post(url, params).then((res) => {
console.log(res);
that.setData({
star:res.star,
description: res.description,
qrcode: res.qrcode,
title:res.title
})
that.savefilecode()
}).catch((err) => {
})
},
createNewImg: function() {
var that = this;
console.log(9999)
var context = wx.createCanvasContext('mycanvas');
// var img = '/img/no.png';
// context.createPattern(img, 0, 0, 375, 667)
// context.style.background ='/img/tuijianimg1.png'
// context.setFillStyle("#ffe200");
context.fillRect(0, 0, 375, 603);
var path = "/img/no.png";
context.drawImage(path, 0, 0, 375, 603);
// context.drawImage(path, 0, 0, 680, 300);
context.setFontSize(26);
context.setFillStyle('#fff');
context.setTextAlign('center');
context.fillText(that.data.title, 190, 50);
var path1 = '';
if(that.data.star==1){
path1 = "/img/onestar.png"
} else if (that.data.star==2){
path1 = "/img/twostar.png"
} else if (that.data.star==3){
path1 = "/img/threestar.png"
} else if (that.data.star == 4) {
path1 = "/img/fourstar.png"
} else if (that.data.star == 5) {
path1 = "/img/fivestar.png"
}
context.drawImage(path1, 125, 60, 110, 16);
context.setFontSize(16);
context.setFillStyle('#333');
context.setTextAlign('left');
// var str = '孩子有较明显的注意力缺陷倾向,基本无法完成学业要求,建议到正规医院和机构进行专业检查。';
var str=that.data.description;
var x = 170;
var len = Math.ceil(str.length / 20);
for (var i = 0; i < len; i++) {
var j = i * 20;
var strs = str.substring(j, 20 * (i + 1));
context.fillText(strs, 25, x + 32 * i, this.data.imgwidth * 0.88);
}
var drawTxt = ''; // 当前绘制的内容
var drawLine = 1; // 第几行开始绘制
var drawIndex = 0; // 当前绘制内容的索引
// var path2 = "/img/code.png";
var path2 = that.data.qrcode
context.drawImage(path2,12,525 , 70, 70);
context.setFontSize(16);
context.setFillStyle('#333');
context.setTextAlign('center');
context.fillText('长按识别二维码', 160,550);
context.setFontSize(16);
context.setFillStyle('#333');
context.setTextAlign('center');
context.fillText('获取你的注意力测验单', 185, 580);
// var path2 = that.data.codeurl;
// console.log('888777666554433', path2)
// var path3 = "/img/feihuiyuan.png";
// var path4 = "/img/dali.png";
// var path5 = "/img/tiyanactive.png";
// this.drawCircular(context, 96, 96, this.data.imgwidth * 0.7, this.data.imgheight * 0.7, path2);
context.save(); // 保存当前context的状态
// context.setFontSize(20);
// context.setFillStyle('#78482F');
// context.setTextAlign('center');
// let nickname = wx.getStorageSync("nickname");
// console.log('889900', nickname)
// context.fillText(nickname, 184, 45);
// context.setFontSize(15);
// context.setFillStyle('#78482F');
// context.setTextAlign('center');
// context.fillText('期待你的加入', 185, 75);
// var path1 = that.data.saveimg;
// console.log('头像', path1)
// context.arc(76, 56, 35, 0, 2 * Math.PI) //画出圆
// context.setFillStyle('#ffffff')
// context.strokeStyle = "#ffe200";
// context.clip(); //裁剪上面的圆形00
// context.drawImage(path1, 41, 21, 70, 70); // 在刚刚裁剪的园上画图
context.draw();
//将生成好的图片保存到本地,需要延迟一会,绘制期间耗时
setTimeout(function() {
wx.canvasToTempFilePath({
canvasId: 'mycanvas',
success: function(res) {
console.log(res)
var tempFilePath = res.tempFilePath;
console.log(tempFilePath)
that.setData({
imagePath: tempFilePath,
canvasHidden: true
});
},
fail: function(res) {
console.log(res);
}
});
}, 200);
},
drawCircular(ctx, width, height, x, y, url) {
var avatarurl_width = width;
var avatarurl_heigth = height;
var avatarurl_x = x;
var avatarurl_y = y;
console.log(avatarurl_width);
console.log(avatarurl_heigth);
console.log(avatarurl_x);
console.log(avatarurl_y);
ctx.save();
ctx.beginPath();
ctx.arc(avatarurl_width / 2 + avatarurl_x, avatarurl_heigth / 2 + avatarurl_y, avatarurl_width / 2, 0, Math.PI * 2, false);
ctx.clip();
ctx.drawImage(url, avatarurl_x, avatarurl_y, avatarurl_width, avatarurl_heigth);
ctx.restore();
},
//点击保存到相册
baocun: function() {
console.log(999)
var that = this
wx.getSetting({
success(res) {
if (!res.authSetting['scope.writePhotosAlbum']) {
wx.authorize({
scope: 'scope.writePhotosAlbum',
success() { //这里是用户同意授权后的回调
wx.saveImageToPhotosAlbum({
filePath: that.data.imagePath,
success(res) {
wx.showModal({
content: '图片已保存到相册',
showCancel: false,
confirmText: '好的',
confirmColor: '#333',
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
/* 该隐藏的隐藏 */
that.setData({
maskHidden: false
})
}
},
fail: function(res) {
}
})
}
})
},
fail() { //这里是用户拒绝授权后的回调
// wx.openSetting({
// success: function (data) {
// console.log(data)
// if (data.authSetting["scope.writePhotosAlbum"] === true) {
// console.log("是否授权成功")
// } else {
// applyApi.toast("授权失败");
// }
// }
// })
wx.showModal({
title: '提示',
content: '您取消授权,无法保存图片,点击确定打开权限',
success(res) {
if (res.confirm) {
console.log('用户点击确定')
wx.openSetting({
success(res) {
console.log(res.authSetting)
// res.authSetting = {
// "scope.userInfo": true,
// "scope.userLocation": true
// }
}
})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
}
})
} else { //用户已经授权过了
console.log(that.data.imagePath)
wx.saveImageToPhotosAlbum({
filePath: that.data.imagePath,
success(res) {
wx.showModal({
content: '图片已保存到相册',
showCancel: false,
confirmText: '好的',
confirmColor: '#333',
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
/* 该隐藏的隐藏 */
that.setData({
maskHidden: false
})
}
},
fail: function(res) {
}
})
}
})
}
}
})
},
hideceng(){
this.setData({
maskHidden:false
})
},
savephoto() {
console.log(54683485)
let that = this;
this.setData({
maskHidden: false
});
wx.showToast({
title: '海报生成中',
icon: 'loading',
duration: 1000
});
setTimeout(function() {
wx.hideToast()
that.createNewImg();
that.setData({
maskHidden: true
});
}, 1000)
},
savefilecode() {
let that = this;
console.log(that.data.codeurl)
wx.downloadFile({
url: that.data.qrcode ,
header: {},
success: function (res) {
console.log('下载图片下载图片下载图片', res)
var tempFilePath = res.tempFilePath
//console.log('临时文件地址是:' + tempFilePath)
wx.saveFile({
tempFilePath: tempFilePath,
success: function (res) {
console.log(res)
var saveFilePath = res.savedFilePath;
that.setData({
qrcode: res.savedFilePath
})
console.log('123456855555555', that.data.qrcode)
}, //可以将saveFilePath写入到页面数据中
fail: function (res) { },
complete: function (res) {
console.log('complete后的res数据:')
},
}) //,
},
// fail: function (res) {
// wx.showModal({
// title: '下载失败',
// content: '请联系管理员',
// })
// },
complete: function (res) { },
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
let width = wx.getSystemInfoSync().windowWidth;
width = width
width = Math.ceil(width)
console.log(width)
let height = wx.getSystemInfoSync().windowHeight;
height = height
height = Math.ceil(height);
console.log(height)
// if (height == 572){
// this.setData({
// pciheight: height * 0.82,
// attenwidth: width * 0.52,
// textheight: height * 0.22,
// codewidth: width * 0.1,
// codeheight: height * 0.68,
// changanwidth: width * 0.5,
// changanheight: height * 0.8,
// cedanwidth: width * 0.57,
// cedanheight: height * 0.77
// })
// }else if (height == 672) {
// console.log(666)
// this.setData({
// pciheight: height * 0.85,
// attenwidth: width * 0.5,
// textheight: height*0.22,
// codewidth:width*0.1,
// codeheight:height*0.73,
// changanwidth:width*0.46,
// changanheight:height*0.85,
// cedanwidth: width * 0.53,
// cedanheight:height*0.81
// })
// } else if (height == 808) {
// console.log(9999)
// this.setData({
// pciheight: height * 0.77,
// attenwidth: width * 0.48,
// textheight: height * 0.22
// })
// } else if (height==724){
// this.setData({
// pciheight: height * 0.82,
// attenwidth: width * 0.52,
// textheight: height * 0.22,
// codewidth: width * 0.1,
// codeheight: height * 0.68,
// codewidth: width * 0.1,
// codeheight: height * 0.71,
// changanwidth: width * 0.47,
// changanheight: height * 0.83,
// cedanwidth: width * 0.54,
// cedanheight: height * 0.79
// })
// }else {
// console.log(888)
// this.setData({
// pciheight: height * 0.82,
// attenwidth: width * 0.52,
// textheight: height * 0.22,
// codewidth: width * 0.1,
// codeheight: height * 0.68,
// codewidth: width * 0.1,
// codeheight: height * 0.73,
// changanwidth: width * 0.46,
// changanheight: height * 0.85,
// cedanwidth: width * 0.53,
// cedanheight: height * 0.81
// })
// }
console.log(this.data.textheight)
this.setData({
imgwidth: width,
imgheight: height
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
// wx.navigateTo({
// url: '/pages/homepage/homepage',
// })
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
let that = this;
return {
title: '我的注意力分享', // 转发后 所显示的title
// path: '/pages/home/buildtextdetail/buildtextdetail?buildid='+buildid+'&gettoken='+newtoken, // 相对的路径
path: '/pages/parentping/parentping?id=' + that.data.id, //分娩笔记分享2
success: (res) => { // 成功后要做的事情
console.log(res)
},
fail: function (res) {
// 分享失败
console.log(res)
}
}
}
})
\ No newline at end of file
... ...
{
}
\ No newline at end of file
... ...
<view class="evalute">
<image src="/img/no.png" mode="widthFix"></image>
<view class="attentionname">{{title}}</view>
<view class="attentionlist">
<view class="attentionlistitem">
<image src="/img/star.png" wx:if="{{star>=1}}"></image>
<image src="/img/starkong.png" wx:else></image>
</view>
<view class="attentionlistitem">
<image src="/img/star.png" wx:if="{{star>=2}}"></image>
<image src="/img/starkong.png" wx:else></image>
</view>
<view class="attentionlistitem">
<image src="/img/star.png" wx:if="{{star>=3}}"></image>
<image src="/img/starkong.png" wx:else></image>
</view>
<view class="attentionlistitem">
<image src="/img/star.png" wx:if="{{star>=4}}"></image>
<image src="/img/starkong.png" wx:else></image>
</view>
<view class="attentionlistitem">
<image src="/img/star.png" wx:if="{{star>=5}}"></image>
<image src="/img/starkong.png" wx:else></image>
</view>
</view>
<view class="attentext">
{{description}}
</view>
<view class="code">
<view class="codeleft">
<image src="{{qrcode}}"></image>
</view>
<view class="coderight">
<view class="coderighttop">长按识别二维码</view>
<view class="coderighttopk">获取你的注意力测验单</view>
</view>
</view>
</view>
<view class="sharehai">
<!-- <view class="shareleft" catchtap="jietu">分享给好友</view> -->
<view class="shareright" catchtap="savephoto">分享海报</view>
</view>
<!-- 海报 -->
<view class='pp' bindtap="hideceng">
<view class='imagePathBox' hidden="{{maskHidden == false}}">
<image src="{{imagePath}}" class='shengcheng'></image>
<!-- <button class='baocun' bindtap='baocun'>保存图片至相册</button> -->
<view class="share">
<!-- <view class="shareleft" catchtap="jietu">分享给好友</view> -->
<button class="shareleft" catchtap="share" open-type='share'>分享给好友</button>
<view class="shareright" catchtap="baocun">保存到相册</view>
</view>
</view>
<view hidden="{{maskHidden == false}}" class="mask"></view>
<view class="canvas-box">
<canvas style="width:375px;height:603px;position:fixed;top:9999px;border-radius:56rpx" canvas-id="mycanvas" />
</view>
</view>
\ No newline at end of file
... ...
page {
background: #eee;
width: 750rpx;
height: 100%;
}
.bigbox {
height: 100%;
}
.evalute {
width: 692rpx;
height: 1110rpx;
margin: 0 atuo;
position: relative;
background: #fff;
left:30rpx;
}
image {
width: 100%;
height: 100%;
}
.attentionname {
color: #fff;
font-size: 45rpx;
font-weight: bold;
position: absolute;
top:44rpx;
left: 249rpx;
}
.attentionlist {
display: flex;
align-items: center;
position: absolute;
top: 120rpx;
left: 249rpx;
}
.attentionlistitem {
width: 26rpx;
height: 26rpx;
font-size: 0;
margin-right: 10rpx;
}
.attentext {
width: 570rpx;
color: #1b1b1b;
font-size: 30rpx;
position: absolute;
top: 245rpx;
left: 68rpx;
font-weight: bold;
line-height: 1.5;
}
.code {
display: flex;
align-items: center;
width: 636rpx;
height: 128rpx;
position: absolute;
left: 28rpx;
bottom:16rpx;
padding: 0 16rpx;
box-sizing: border-box;
}
.codeleft {
width: 105rpx;
height: 105rpx;
font-size: 0;
}
.coderight {
margin-left: 17rpx;
}
.coderighttop {
color: #000;
font-size: 28rpx;
}
.coderighttopk {
color: #000;
font-size: 28rpx;
margin-top: 10rpx;
}
.share {
display: flex;
align-items: center;
justify-content: space-between;
width:657rpx;
margin:20rpx auto 0;
position: absolute;
top:1107rpx;
z-index:999;
left:47rpx;
/* position: fixed;
bottom: 11rpx;
left: 58rpx; */
}
.sharehai{
display: flex;
align-items: center;
justify-content: center;
width:692rpx;
margin:20rpx auto 0;
}
.shareleft {
width: 289rpx;
height:68rpx;
color: #ce6198;
font-size: 28rpx;
text-align: center;
line-height: 68rpx;
background: #fff;
border-radius: 44rpx;
}
.shareright {
width: 289rpx;
height: 68rpx;
color: #fff;
font-size: 28rpx;
text-align: center;
line-height:68rpx;
background: #ce6198;
border-radius: 44rpx;
margin-left: 57rpx;
}
.imagePathBox{
width: 100%;
height: 100%;
background: rgba(0,0,0,0.7);
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 10;
}
.shengcheng{
width:650rpx;
height:1080rpx;
position: fixed;
left: 50%;
top:570rpx;
transform: translate(-50%,-50%);
/* margin-left: -40%; */
z-index: 10;
}
.baocun{
display: block;
width: 80%;
height: 92rpx;
padding: 0;
line-height: 92rpx;
text-align: center;
position: fixed;
bottom: 18rpx;
left: 10%;
background:linear-gradient(180deg,rgba(252,169,162,1) 0%,rgba(255,119,117,1) 100%);
color: #fff;
font-size: 32rpx;
border-radius: 44rpx;
z-index:999999
}
button[class="baocun"]::after{
border: 0;
}
.canvas-box{
word-break: break-word;
word-wrap: break-word;
}
\ No newline at end of file
... ...
// pages/question/question.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
type: 0,
quesname: '',
sela: false,
selb: false,
selc: false,
seld: false,
kxuan: 2,
one: 1,
questionlist: [],
result: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
this.setData({
type: options.type
})
if (options.type == 1) {
this.setData({
quesname: '家长评估'
})
} else if (options.type == 2) {
this.setData({
quesname: '3-6岁测试'
})
} else {
this.setData({
quesname: '7-12岁测试'
})
}
this.getquestionlist()
},
// 获取题目列表
getquestionlist() {
let that = this;
var url = 'index/question';
var params = {
type: that.data.type
}
app.post(url, params).then((res) => {
console.log(res);
that.setData({
questionlist: res.list
})
let newquestionlist = that.data.questionlist;
for (var i = 0; i < newquestionlist.length; i++) {
newquestionlist[i].key = ''
if (i == 0) {
newquestionlist[i].show = true
} else {
newquestionlist[i].show = false
}
}
that.setData({
questionlist: newquestionlist
})
console.log(that.data.questionlist)
}).catch((err) => {
})
},
selyuana(e) {
let that = this;
console.log(e)
this.setData({
sela: !this.data.sela,
selb: false,
selc: false,
seld: false,
})
let id = e.currentTarget.dataset.id;
let daan = e.currentTarget.dataset.answer;
let newquestionlist = that.data.questionlist;
for (var obj of newquestionlist) {
if (obj.id == id) {
obj.key = daan
}
}
that.setData({
questionlist: newquestionlist
})
console.log(this.data.questionlist)
// obj[id] = daan;
// let newresult=this.data.result;
// newresult.push(obj);
// console.log(newresult);
},
selyuanb(e) {
let that = this;
console.log(e)
this.setData({
sela: false,
selb: !this.data.selb,
selc: false,
seld: false,
})
let id = e.currentTarget.dataset.id;
let daan = e.currentTarget.dataset.answer;
let newquestionlist = that.data.questionlist;
for (var obj of newquestionlist) {
if (obj.id == id) {
obj.key = daan
}
}
that.setData({
questionlist: newquestionlist
})
},
selyuanc(e) {
let that = this;
console.log(e)
this.setData({
sela: false,
selb: false,
selc: !this.data.selc,
seld: false,
})
let id = e.currentTarget.dataset.id;
let daan = e.currentTarget.dataset.answer;
let newquestionlist = that.data.questionlist;
for (var obj of newquestionlist) {
if (obj.id == id) {
obj.key = daan
}
}
that.setData({
questionlist: newquestionlist
})
},
selyuand(e) {
console.log(e)
let that = this;
this.setData({
sela: false,
selb: false,
selc: false,
seld: !this.data.seld,
})
let id = e.currentTarget.dataset.id;
let daan = e.currentTarget.dataset.answer;
let newquestionlist = that.data.questionlist;
for (var obj of newquestionlist) {
if (obj.id == id) {
obj.key = daan
}
}
that.setData({
questionlist: newquestionlist
})
},
shang(e) {
let one = this.data.one;
console.log(one)
let that = this;
let preindex = e.currentTarget.dataset.index - 1;
if (preindex==-1){
preindex=0
}
console.log(preindex)
let index = that.data.one;
index = index - 1
this.setData({
kxuan: 1,
one: index,
})
console.log(index)
let newquestionlist = that.data.questionlist;
for (var i = 0; i < newquestionlist.length; i++) {
if (i == preindex) {
newquestionlist[i].show = true;
console.log(newquestionlist[i])
if (newquestionlist[i].key == 'A') {
that.setData({
sela: true,
selb: false,
selc: false,
seld: false,
})
} else if (newquestionlist[i].key == 'B') {
that.setData({
sela: false,
selb: true,
selc: false,
seld: false,
})
} else if (newquestionlist[i].key == 'C') {
that.setData({
sela: false,
selb: false,
selc: true,
seld: false,
})
} else if (newquestionlist[i].key == 'D') {
that.setData({
sela: false,
selb: false,
selc: false,
seld: true,
})
}
} else {
newquestionlist[i].show = false;
}
}
that.setData({
questionlist: newquestionlist
})
if (this.data.one == 0) {
this.setData({
one: 1
})
wx.showToast({
title: '已经是第一道题了',
icon: 'none'
})
}
},
next(e) {
console.log(e)
let that = this;
let preindex = e.currentTarget.dataset.index;
let index = e.currentTarget.dataset.index + 1;
console.log(index);
console.log(preindex)
let newquestionlist = that.data.questionlist;
for (var i = 0; i < newquestionlist.length; i++) {
if (preindex == i) {
if (newquestionlist[i].key == '') {
wx.showToast({
title: '请选择答案',
icon: 'none'
})
return false
}
}
console.log('484884',index)
console.log('484884', that.data.questionlist.length - 1)
if(index==that.data.questionlist.length){
index = that.data.questionlist.length - 1
}
console.log(index)
if (i == index) {
newquestionlist[i].show = true;
console.log(newquestionlist[i])
if (newquestionlist[i].key == 'A') {
that.setData({
sela: true,
selb: false,
selc: false,
seld: false,
})
} else if (newquestionlist[i].key == 'B') {
that.setData({
sela: false,
selb: true,
selc: false,
seld: false,
})
} else if (newquestionlist[i].key == 'C') {
that.setData({
sela: false,
selb: false,
selc: true,
seld: false,
})
} else if (newquestionlist[i].key == 'D') {
that.setData({
sela: false,
selb: false,
selc: false,
seld: true,
})
} else {
that.setData({
sela: false,
selb: false,
selc: false,
seld: false,
})
}
} else {
newquestionlist[i].show = false;
}
}
that.setData({
questionlist: newquestionlist
})
console.log(that.data.questionlist)
if(index<that.data.questionlist.length){
index = index + 1
}
this.setData({
one: index,
kxuan: 2,
// sela: false,
// selb: false,
// selc: false,
// seld: false
})
console.log(that.data.one);
console.log(that.data.questionlist.length)
if (that.data.one == that.data.questionlist.length) {
if (this.data.type == 1) {
let answerobj = {}
let newquestionlist = that.data.questionlist;
console.log(newquestionlist)
for (var obj of newquestionlist) {
answerobj[obj.id] = obj.key;
}
that.setData({
result: answerobj
})
that.dati()
} else if (this.data.type == 2) {
let answerobj = {}
let newquestionlist = that.data.questionlist;
console.log(newquestionlist)
for (var obj of newquestionlist) {
answerobj[obj.id] = obj.key;
}
that.setData({
result: answerobj
})
that.dati()
} else if (this.data.type == 3) {
let answerobj = {}
let newquestionlist = that.data.questionlist;
console.log(newquestionlist)
for (var obj of newquestionlist) {
answerobj[obj.id] = obj.key;
}
that.setData({
result: answerobj
})
that.dati()
// wx.navigateTo({
// url: '/pages/attentiontwo/attentiontwo',
// })
}
}
// if (this.data.one == 3) {
// this.setData({
// one:2
// })
// if (this.data.type == 1) {
// wx.navigateTo({
// url: '/pages/parentping/parentping',
// })
// } else if (this.data.type == 2) {
// wx.navigateTo({
// url: '/pages/attentionone/attentionone',
// })
// } else if (this.data.type == 3) {
// wx.navigateTo({
// url: '/pages/attentiontwo/attentiontwo',
// })
// }
// }
},
dati() {
let that = this;
var url = 'index/add_answer';
var params = {
type: that.data.type,
result: JSON.stringify(that.data.result)
}
app.post(url, params).then((res) => {
console.log(res);
let id = res.answer_log_id
if (that.data.type == 1) {
wx.showToast({
title: '答题完成',
icon:"none"
})
setTimeout(function(){
wx.navigateTo({
url: '/pages/parentping/parentping?id=' + id,
})
},1500)
} else if (that.data.type == 2) {
wx.showToast({
title: '答题完成',
icon: "none"
})
setTimeout(function(){
wx.navigateTo({
url: '/pages/attentiontwo/attentiontwo?id=' + id,
})
},1500)
} else if (that.data.type == 3) {
wx.showToast({
title: '答题完成',
icon:"none"
})
setTimeout(function(){
wx.navigateTo({
url: '/pages/attentionone/attentionone?id=' + id,
})
},1500)
}
}).catch((err) => {
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
})
\ No newline at end of file
... ...
{
}
\ No newline at end of file
... ...
<view class="questop">
{{quesname}}
<view class="topnum">{{one}}/{{questionlist.length}}</view>
</view>
<view class="quesboxpage">
<view class="quesbox" wx:for="{{questionlist}}" wx:key="" wx:if="{{item.show==true}}">
<view class="quesname">{{index+1}}. {{item.title}} <text wx:if="{{item.red_title!=''}}" class="redtitle">{{item.red_title}}</text></view>
<view class="quesimg" wx:if="{{item.image!=''}}">
<image src="{{item.image}}" mode="aspectFit"></image>
</view>
<view class="supply" wx:if="{{item.supply!=''}}">
<text> {{item.supply}}</text>
</view>
<view class="quesboxlist">
<view class="quesboxitem {{sela==true?'quesactive':''}}" bindtap="selyuana" data-id="{{item.id}}" data-answer="A">
<view class="quesboxitemleft" >
<image src="/img/yesa.png" wx:if="{{sela==true}}"></image>
<image src="/img/noa.png" wx:else></image>
</view>
<view class="quesboxitemright {{sela==true?'nametive':''}}">{{item.selectA}}</view>
</view>
<view class="quesboxitem {{selb==true?'quesactive':''}}" bindtap="selyuanb" data-id="{{item.id}}" data-answer="B">
<view class="quesboxitemleft">
<image src="/img/yesb.png" wx:if="{{selb==true}}"></image>
<image src="/img/nob.png" wx:else></image>
</view>
<view class="quesboxitemright {{selb==true?'nametive':''}}">{{item.selectB}}</view>
</view>
<view class="quesboxitem {{selc==true?'quesactive':''}}" bindtap="selyuanc" data-id="{{item.id}}" data-answer="C">
<view class="quesboxitemleft">
<image src="/img/yesc.png" wx:if="{{selc==true}}"></image>
<image src="/img/noc.png" wx:else></image>
</view>
<view class="quesboxitemright {{selc==true?'nametive':''}}">{{item.selectC}}</view>
</view>
<view class="quesboxitem {{seld==true?'quesactive':''}}" bindtap="selyuand" data-id="{{item.id}}" data-answer="D">
<view class="quesboxitemleft">
<image src="/img/yesd.png" wx:if="{{seld==true}}"></image>
<image src="/img/nod.png" wx:else></image>
</view>
<view class="quesboxitemright {{seld==true?'nametive':''}}">{{item.selectD}}</view>
</view>
</view>
<view class="quesfoot">
<view class="quesfootleft lef {{kxuan==1?'kactive':''}} " bindtap="shang" data-index="{{index}}" data-id="{{item.id}}">上一题</view>
<view class="quesfootleft {{kxuan==2?'kactive':''}}" bindtap="next" data-index="{{index}}" data-id="{{item.id}}">下一题</view>
</view>
</view>
</view>
<!-- <view class="quesboxpage" wx:if="{{one==2}}">
<view class="quesbox">
<view class="quesname">2. 经常出现不小心打翻、打烂东西、爬楼梯、走路不小心摔跤现象</view>
<view class="quesboxlist">
<view class="quesboxitem {{sela==true?'quesactive':''}}" bindtap="selyuana" data-id="1">
<view class="quesboxitemleft">
<image src="/img/yesa.png" wx:if="{{sela==true}}"></image>
<image src="/img/noa.png" wx:else></image>
</view>
<view class="quesboxitemright {{sela==true?'nametive':''}}">从不</view>
</view>
<view class="quesboxitem {{selb==true?'quesactive':''}}" bindtap="selyuanb" data-id="2">
<view class="quesboxitemleft">
<image src="/img/yesb.png" wx:if="{{selb==true}}"></image>
<image src="/img/nob.png" wx:else></image>
</view>
<view class="quesboxitemright {{selb==true?'nametive':''}}">偶尔</view>
</view>
<view class="quesboxitem {{selc==true?'quesactive':''}}" bindtap="selyuanc" data-id="3">
<view class="quesboxitemleft">
<image src="/img/yesc.png" wx:if="{{selc==true}}"></image>
<image src="/img/noc.png" wx:else></image>
</view>
<view class="quesboxitemright {{selc==true?'nametive':''}}">经常</view>
</view>
<view class="quesboxitem {{seld==true?'quesactive':''}}" bindtap="selyuand" data-id="4">
<view class="quesboxitemleft">
<image src="/img/yesd.png" wx:if="{{seld==true}}"></image>
<image src="/img/nod.png" wx:else></image>
</view>
<view class="quesboxitemright {{seld==true?'nametive':''}}">总是</view>
</view>
</view>
</view>
</view> -->
\ No newline at end of file
... ...
.questop {
width: 750rpx;
height: 106rpx;
background: rgba(0, 191, 175, 1);
box-shadow: 1px 2px 29px 0px rgba(50, 57, 61, 0.24);
color: #fff;
font-size: 36rpx;
text-align: center;
line-height: 106rpx;
position: relative;
}
.topnum {
color: #fff;
font-size: 36rpx;
position: absolute;
right: 31rpx;
top: 0;
}
.quesname {
/* width: 690rpx; */
color: #1b1b1b;
font-size: 28rpx;
border-bottom: 1rpx solid #d2d2d2;
margin: 55rpx auto 0;
padding-bottom: 33rpx;
box-sizing: border-box;
font-weight: bold;
line-height: 1.5;
}
.quesfoot {
display: flex;
align-items: center;
position: fixed;
bottom: 0;
left: 0;
}
.quesfootleft {
width: 375rpx;
height: 81rpx;
background: rgba(255, 255, 255, 1);
color: #959595;
font-size: 30rpx;
text-align: center;
line-height: 81rpx;
border-top:1rpx solid #DCDCDC;
}
.quesfootright {
width: 375rpx;
height: 81rpx;
background: #00BFAF;
color:#fff;
font-size: 30rpx;
text-align: center;
line-height: 81rpx;
border-top:1rpx solid #00BFAF
}
.kactive{
background: #00BFAF;
color:#fff;
}
.quesbox{
padding: 0 45rpx;
box-sizing: border-box;
margin-top:48rpx;
}
.quesboxitem{
display:flex;
align-items: center;
padding: 20rpx 10rpx;
box-sizing: border-box;
border:2rpx solid #fff;
/* margin-bottom:61rpx; */
}
.quesboxitemleft{
width:42rpx;
height:42rpx;
font-size: 0
}
image{
width:100%;
height:100%;
}
.quesboxitemright{
color:#535353;
font-size: 28rpx;
margin-left:34rpx;
}
.quesactive{
border:2rpx solid rgba(0,191,175,1);
}
.nametive{
color:#00BFAF;
}
.lef{
border-right:1rpx solid #DCDCDC;
}
.quesboxpage{
padding-bottom:150rpx;
}
.quesboxlist{
margin-top:20rpx;
}
.redtitle{
color:#FF5A5F;
font-size: 28rpx;
font-weight: bold;
}
.supply{
color:#1B1B1B;
font-size: 35rpx;
font-weight: bold;
margin-top:20rpx;
}
.quesimg{
width:672rpx;
height:342rpx;
font-size: 0;
margin:20rpx auto 0;
}
\ No newline at end of file
... ...
{
"description": "项目配置文件",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": true,
"es6": true,
"postcss": true,
"minified": true,
"newFeature": true,
"autoAudits": false,
"checkInvalidKey": true
},
"compileType": "miniprogram",
"libVersion": "2.9.4",
"appid": "wx9f9310ed9be8c3e0",
"projectname": "attentionceshi",
"debugOptions": {
"hidedInDevtools": []
},
"isGameTourist": false,
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"plugin": {
"current": -1,
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"miniprogram": {
"current": 5,
"list": [
{
"id": -1,
"name": "关于蛋壳",
"pathName": "pages/aboutdanke/aboutdanke",
"query": "",
"scene": null
},
{
"id": -1,
"name": "结果",
"pathName": "pages/parentping/parentping",
"query": "",
"scene": null
},
{
"id": -1,
"name": "家长",
"pathName": "pages/parentping/parentping",
"query": "",
"scene": null
},
{
"id": -1,
"name": "保存图片",
"pathName": "pages/attentiontwo/attentiontwo",
"query": "",
"scene": null
},
{
"id": -1,
"name": "注意力七",
"pathName": "pages/attentionone/attentionone",
"query": "",
"scene": null
},
{
"id": -1,
"name": "家长测试结果",
"pathName": "pages/parentping/parentping",
"scene": null
}
]
}
}
}
\ No newline at end of file
... ...
{
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
"rules": [{
"action": "allow",
"page": "*"
}]
}
\ No newline at end of file
... ...
const formatTime = date => {
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}
const formatNumber = n => {
n = n.toString()
return n[1] ? n : '0' + n
}
module.exports = {
formatTime: formatTime
}
... ...