作者 xuyangjie

完善登录验证

... ... @@ -98,6 +98,7 @@ App({
globalData: {
baseUrl: "https://english.brofirst.cn/api/",
imgBaseUrl: "https://english.brofirst.cn",
userInfo: null
}
})
\ No newline at end of file
... ...
... ... @@ -77,11 +77,15 @@ Component({
// 密码
gopassword() {
// console.log('111')
var type = 'text'
if(this.data.password){
type = 'safe-password'
}
this.setData({
password: !this.data.password,
type: 'safe-password'
type,
})
},
}
})
\ No newline at end of file
... ...
... ... @@ -9,7 +9,7 @@
<input type="text" placeholder="请输入账号" bindinput="bindadmin" value="{{admin}}" />
</view>
<view class="input">
<input type="{{type}}" placeholder="请输入密码" bindinput="bindpassword" value="{{pwd}}"/>
<input type="{{type}}" password='{{!password}}' placeholder="请输入密码" bindinput="bindpassword" value="{{pwd}}"/>
<image src="/img/ic_eye_s@2x.png" wx:if="{{password}}" bindtap="gopassword"></image>
<image src="/img/ic_eye_n@2x.png" wx:else bindtap="gopassword"></image>
</view>
... ...
... ... @@ -15,10 +15,12 @@ Page({
uploaderNum: 0,
showUpload: true,
imglist: [],
http_url:'',
Count:0,//总题数
current:0,//当前题号
today_id:'',//今日任务id
match_id:'',//比赛任务id
all_data:[],//全部题目
today_data:{
"today_subject_id": 4,//题目ID
... ... @@ -43,30 +45,33 @@ Page({
'type':0,//题目类型:1=用户上传图片,2=用户上传音频,
'file_url': [] //'图片/音频 【多张图 , 分割 拼接字符串】'
},
alterType:false,//弹窗状态
alterData:{},//弹窗数据
taskType:'',//任务类型 比赛任务 今日任务
TodayTaskType:''//1 打卡 0 补卡
},
changePlayState(){
this.selectComponent("audio").changePlayState
PlayState(){
this.selectComponent("#audio").changePlayState()
},
//下一题
gotoday(){
if(this.data.answer.type == 1 || this.data.imglist.length == 0 ){//图片
if(this.data.answer.type == 1 && this.data.imglist.length == 0 ){//图片
wx.showToast({
title: "请上传图片完成答题",
icon: 'none'
})
return;
}
if(this.data.answer.type == 2 || this.data.musicHttp == ''){//录音文件
if(this.data.answer.type == 2 && this.data.musicHttp == ''){//录音文件
wx.showToast({
title: "请录音完成答题",
icon: 'none'
})
return;
}
var index = this.data.current
var current = this.data.current*1+1;//答题题号
var file = [];//答题文件
if(this.data.answer.type == 1){//图片
file = this.data.imglist;
... ... @@ -77,28 +82,41 @@ Page({
this.data.answer.file_url = file
var data = this.data.answer;//当前做完的题目答案
var arr = this.data.allAnswer.push(data)//全部做完的题目答案
this.data.allAnswer.push(data)//全部做完的题目答案
if(this.data.current == this.data.Count){//判断题目是否全部答完
this.TodayTask()
return
}
//下一题答案
let answer = {
'today_subject_id': this.data.all_data[current].today_subject_id, //'题目ID',
'type':0,//题目类型:1=用户上传图片,2=用户上传音频,
'file_url': [] //'图片/音频 【多张图 , 分割 拼接字符串】'
if(this.data.taskType == "today"){ //今日任务
let answer = {
'today_subject_id': this.data.all_data[index].today_subject_id, //'题目ID',
'type':0,//题目类型:1=用户上传图片,2=用户上传音频,
'file_url': [] //'图片/音频 【多张图 , 分割 拼接字符串】'
}
}else if(this.data.taskType == "match"){//比赛任务
let answer = {
'match_subject_id': res.data.List[0].match_subject_id, //'题目ID',
'type':0,//题目类型:1=用户上传图片,2=用户上传音频,
'file_url': [] //'图片/音频 【多张图 , 分割 拼接字符串】'
}
}
if(this.data.all_data[current].type == 2){ // 需要用户上传图片
if(this.data.all_data[index].type == 2){ // 需要用户上传图片
answer.type = 1
}else if(this.data.all_data[current].type == 3){ // 需要用户上传录音
}else if(this.data.all_data[index].type == 3){ // 需要用户上传录音
answer.type = 2
}else{
answer.type = 0
answer.type = ''
}
this.setData({
today_data:this.data.all_data[current],//下一题
today_data:this.data.all_data[index],//下一题
current:current,
answer:answer,
allAnswer:arr,
allAnswer:this.data.allAnswer,
uploaderList:[],//下一题后图片置空
imglist:[],//下一题后图片置空
musicHttp:'',//下一题后录音文件置空
... ... @@ -111,10 +129,27 @@ Page({
//答题提交
TodayTask(){
clearInterval(time)
var temporary = (time_num/60).toFixed(2);
app.post("today/TodayTask", {today_id:this.data.today_id,json:this.data.allAnswer,learn_time:temporary,type:1}).then(res => {
var data = {}//提交参数
var url = '' //接口地址
//判断任务类型
if(this.data.taskType == "today"){ //今日任务
url = 'today/TodayTask'
data = {today_id:this.data.today_id,json:all_data,learn_time:temporary,type:this.data.TodayTaskType}
}else if(this.data.taskType == "match"){//比赛任务
url = 'match/MatchTask'
data = {match_id:this.data.match_id,json:all_data,learn_time:temporary}
}
var temporary = Math.ceil(time_num/60);//学习事件
var all_data = JSON.stringify(this.data.allAnswer)
app.post(url,data ).then(res => {
if(res.code == 1){
console.log(res)
this.TodayTaskWindow()
}else{
wx.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(err => {
wx.showToast({
... ... @@ -127,22 +162,68 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.data.today_id = options.id
this.TodayQuestion()
const innerAudioContext = wx.createInnerAudioContext()
innerAudioContext.autoplay = true
if(options.type == "today"){//今日任务
this.setData({
today_id:options.id,
})
this.TodayQuestion()
}else if(options.type == "match"){//比赛任务
this.setData({
match_id:options.id,
})
this.TodayQuestion()
}
this.setData({
innerAudioContext,
taskType:options.type,
TodayTaskType:options.type,
http_url:app.globalData.imgBaseUrl,
today_id:options.id,
})
var that = this;
time = setInterval(function(){
time_num++
},1000)
},
//提交完成弹窗
TodayTaskWindow(){
var data = {}//提交参数
var url = '' //接口地址
if(this.data.taskType == "today"){ //今日任务
url = 'today/TodayTaskWindow'
data = {TodayClockId:this.data.today_id}
}else if(this.data.taskType == "match"){//比赛任务
url = 'match/MatchTask'
data = {MatchClockId:this.data.match_id}
}
app.post(url,data).then(res => {
if(res.code == 1){
console.log(res)
this.setData({
alterData:res.data
})
this.setData({
alterType:true
})
}
}).catch(err => {
wx.showToast({
title: err.msg,
icon: 'none'
})
})
},
//完成任务返回首页
gototram(){
wx.switchTab({
url: '/pages/index/index',
})
},
//获取今日任务列表
TodayQuestion(){
var that = this;
app.post("today/TodayQuestion", {today_id:this.data.today_id}).then(res => {
app.post("match/MatchQuestion", {today_id:this.data.match_id}).then(res => {
if(res.code == 1){
console.log(res)
... ... @@ -151,13 +232,46 @@ Page({
'type':0,//题目类型:1=用户上传图片,2=用户上传音频,
'file_url': [] //'图片/音频 【多张图 , 分割 拼接字符串】'
}
if( res.data.List[0].type == 2){ // 需要用户上传图片
answer.type = 1
}else if( res.data.List[0].type == 3){ // 需要用户上传录音
answer.type = 2
}else{
answer.type = 0
answer.type = ''
}
this.setData({
today_data:res.data.List[0],//第一题
all_data:res.data.List,//全部题
Count:res.data.Count,//总题数
current:1,//当前题数
answer,
})
}
}).catch(err => {
wx.showToast({
title: err.msg,
icon: 'none'
})
})
},
//比赛任务
TodayQuestion(){
var that = this;
app.post("match/MatchQuestion", {match_id:this.data.today_id}).then(res => {
if(res.code == 1){
console.log(res)
let answer = {
'match_subject_id': res.data.List[0].match_subject_id, //'题目ID',
'type':0,//题目类型:1=用户上传图片,2=用户上传音频,
'file_url': [] //'图片/音频 【多张图 , 分割 拼接字符串】'
}
if( res.data.List[0].type == 2){ // 需要用户上传图片
answer.type = 1
}else if( res.data.List[0].type == 3){ // 需要用户上传录音
answer.type = 2
}else{
answer.type = ''
}
this.setData({
today_data:res.data.List[0],//第一题
... ... @@ -220,7 +334,7 @@ Page({
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
//第三方链接
web_url(e){
... ... @@ -318,9 +432,14 @@ Page({
}
})
},
//上传请求
//文件上传请求
upload_file(data,type){
var that = this;
wx.uploadFile({
header:{
'content-type': 'application/json',
'token': wx.getStorageSync('token') ? wx.getStorageSync('token') : ''
},
url: app.globalData.baseUrl + 'common/upload', //接口地址
filePath: data, //要上传文件资源的路径 (本地路径)
name: 'file', //文件对应的 key,开发者在服务端可以通过这个 key 获取文件的二进制内容
... ... @@ -329,16 +448,17 @@ Page({
},
success(res) {
wx.hideLoading();
console.log(res.data)
var str = res.data
var file = JSON.parse(str);
if(type == 'img'){
let imglist = that.data.imglist.concat(file.data.save_path)
if(type == 'img'){ //图片文件
let imglist = that.data.imglist.concat(file.data.url)
that.setData({
imglist: imglist
})
}else{
}else{//mp3文件
that.setData({
musicHttp: file.data.save_path
musicHttp: file.data.url
})
}
}
... ... @@ -378,12 +498,12 @@ Page({
that.upload_file(res.tempFilePath)//上传录音文件
})
},
//录音播放事件
play_voice(){
// console.log("播放录音")
this.setData({
soundType:3,//录音结束
})
innerAudioContext.src = this.data.musicUrl
innerAudioContext.onPlay(() => { // 监听音频播放事件
console.log('开始播放')
... ... @@ -393,16 +513,17 @@ Page({
console.log(res.errCode)
})
},
//录音暂停事件
pause_voice(){
this.setData({
soundType:2,//录音结束
})
console.log("暂停录音")
InnerAudioContext.pause()
InnerAudioContext.onPause(() => { // 监听音频暂停事件
innerAudioContext.pause()
innerAudioContext.onPause(() => { // 监听音频暂停事件
console.log('暂停播放')
})
InnerAudioContext.offError((res) => { // 取消监听音频加载中事件
innerAudioContext.offError((res) => { // 取消监听音频加载中事件
console.log(res.errMsg)
console.log(res.errCode)
})
... ...
... ... @@ -3,16 +3,16 @@
<video src="{{today_data.video_file}}" loop show-fullscreen-btn="{{false}}"></video>
</view>
<!-- 音频 -->
<view class="audio" wx:if="{{today_data.audio_file}}" id="audio">
<view class="audio" wx:if="{{today_data.audio_file}}" >
<!-- <audio controls src="http://m10.music.126.net/20210728150904/ef325f8ac68a3710a2c7cfec82a70096/ymusic/045e/000b/0f0f/34bf44037a7a4cb160928e5a21c314a0.mp3"></audio> -->
<view style="width:686rpx;margin:0 auto">
<slider-audio audio-src="{{today_data.audio_file}}" audioName="{{today_data.title}}"></slider-audio>
<slider-audio audio-src="{{today_data.audio_file}}" id="audio" audioName="{{today_data.title}}"></slider-audio>
</view>
</view>
<!-- 播放音频 -->
<view class="audio_play" bindtap="changePlayState" wx:if="{{today_data.audio_file && today_data.type != 3}}">
<view class="audio_play" bindtap="PlayState" wx:if="{{today_data.audio_file && today_data.type != 3}}">
<image class="audio_img" src="../../img/ic_voice56@2x.png"></image>
</view>
... ... @@ -38,11 +38,11 @@
</view>
<!-- 音频录制 -->
<view class="recording" wx:if="{{today_data.type == 3}}" >
<view class="recording" wx:if="{{today_data.type == 3}}">
<view class="art">
<!-- //录音状态 0未录音 1开始录音 2录音完成 3播放录音 -->
<view>
<image src="/img/ic_voice40@2x.png" bindtap="changePlayState" wx:if="{{today_data.audio_file && today_data.type == 3}}"></image>
<image src="/img/ic_voice40@2x.png" bindtap="PlayState" wx:if="{{today_data.audio_file && today_data.type == 3}}"></image>
</view>
<image src="/img/ic_rec_n@2x.png" wx:if="{{soundType != 1 }}" bindtap="startRecord"></image>
<image src="/img/ic_rec_s@2x.png" wx:if="{{soundType == 1}}" bindtap="stopRecord"></image>
... ... @@ -74,4 +74,39 @@
<text>{{Count}}</text>
</view>
<view class="box-end" bindtap="gotoday">Next</view>
\ No newline at end of file
<view class="box-end" bindtap="gotoday">{{current == Count ? '完成打卡' : 'Next'}}</view>
<view class="alter" wx:if="{{alterType}}">
<view class="mask">
<image src="/img/img_star@2x.png"></image>
</view>
<view class="denglu" wx:if="alterType">
<view>恭喜你</view>
<view wx:if="{{alterData.score}}">获得积分<text>{{alterData.score}}</text> </view>
<view class="text_bar">
<view>
<view>
<text>{{alterData.score}}</text>
<text>分</text>
</view>
<text>今日学习时长</text>
</view>
<view>
<view>
<text>{{alterData.readwords}}</text>
<text>个</text>
</view>
<text>打卡单词</text>
</view>
<view>
<view>
<text>{{alterData.readbook}}</text>
<text>本</text>
</view>
<text>打卡英语书</text>
</view>
</view>
<text>{{alterData.Happy}}</text>
<view class="button" bindtap="gototram">开心收下</view>
</view>
</view>
\ No newline at end of file
... ...
... ... @@ -45,10 +45,17 @@ swiper{
border-radius: 36rpx;
width: 686rpx;
height:272rpx;
padding: 80rpx 0;
padding: 80rpx 140rpx;
text-align: center;
margin: 0 auto;
margin-top:120rpx;
display: flex;
justify-content: space-between;
align-items: flex-end;
}
.art>view{
width: 80rpx;
height: 80rpx;
}
.art image{
width: 80rpx;
... ... @@ -139,4 +146,82 @@ swiper{
box-shadow: 0rpx 8rpx 18rpx rgb(201, 201, 201);
border-radius: 50%;
margin-top: 54rpx;
}
.essay image{
width: 100%;
}
/* */
.alter{
background: rgba(0, 0, 0, .6);
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.denglu {
position: fixed;
top: 18%;
left: 50%;
transform: translateX(-50%);
text-align: center;
width: 622rpx;
border-radius: 48rpx;
background: #fff;
}
.mask image{
position: absolute;
top: 0;
z-index: 9999;
width: 100%;
height: 750rpx;
}
.denglu{
padding: 100rpx 50rpx 50rpx 50rpx;
}
.denglu>view:nth-child(1) {
font-size: 52rpx;
font-weight: 500;
}
.denglu>view:nth-child(2){
margin-top: 50rpx;
}
.denglu>view:nth-child(2)>text {
font-size: 50rpx;
margin-top: 44rpx;
color: #FD9327;
}
.button {
width: 422rpx;
height: 100rpx;
line-height: 100rpx;
text-align: center;
font-size: 32rpx;
font-weight: 600;
margin: 64rpx auto;
border-radius: 96rpx;
background: rgba(255, 200, 61, 1);
}
.text_bar{
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 88rpx;
}
.text_bar>view{
margin-top: 0;
}
.text_bar>view>view>text:first-child{
font-size: 40rpx;
color: #000;
}
.text_bar>view>view>text:last-child{
font-size: 24rpx;
color: #000;
}
.text_bar>view>text{
font-size: 24rpx;
color: #C4C4C4;
}
\ No newline at end of file
... ...
... ... @@ -7,9 +7,8 @@ Page({
admin: "", // 账号
pwd: "", //密码
login: false,
clockData: "" //打卡数据
clockData: "", //打卡数据
token:''
},
onShow() {
let token = wx.getStorageSync('token')
... ... @@ -18,9 +17,13 @@ Page({
this.setData({
login: true
})
}else{
this.IndexMyData()
}
this.setData({
token
})
this.getlist()
this.IndexMyData()
},
// 关闭
myevent() {
... ... @@ -69,6 +72,12 @@ Page({
// })
// },
bindRask() {
if(!this.data.token){
this.setData({
login:true
})
return
}
wx.navigateTo({
url: '/pages/mission/mission',
})
... ...
... ... @@ -11,15 +11,15 @@
<text class="title">您已坚持打卡{{clockData.clock_number}}天</text>
<view class="box-z">
<view class="box-0">
<view class="box-1">{{clockData.reading}}<text>分</text></view>
<view class="box-1">{{token ? clockData.reading : 0}}<text>分</text></view>
<view class="box-2">阅读时长</view>
</view>
<view class="box-0">
<view class="box-1">{{clockData.readwords}}<text>个</text></view>
<view class="box-1">{{token ? clockData.readwords : 0}}<text>个</text></view>
<view class="box-2">阅读单词</view>
</view>
<view class="box-0">
<view class="box-1">{{clockData.readbook}}<text>本</text></view>
<view class="box-1">{{token ? clockData.readbook : 0}}<text>本</text></view>
<view class="box-2">阅读英语书</view>
</view>
</view>
... ...
... ... @@ -15,8 +15,16 @@ Page({
// 今日
gotoday(e) {
let id = e.currentTarget.dataset.id
let type = e.currentTarget.dataset.type
if(!id){
wx.showToast({
title: "今日已打卡",
icon: 'none'
})
return
}
wx.navigateTo({
url: '/pages/first/first?id=' + id,
url: '/pages/first/first?id=' + id + "&type=1" + "&type=" + type,
})
},
... ... @@ -24,6 +32,13 @@ Page({
goCeping(e) {
console.log(e)
let id = e.currentTarget.dataset.id
if(!id){
wx.showToast({
title: "今日已打卡",
icon: 'none'
})
return
}
wx.navigateTo({
url: '/pages/question/question?id=' + id,
})
... ... @@ -43,7 +58,6 @@ Page({
if (res.code == 1) {
that.setData({
raskData: res.data
})
}
}).catch(err => {
... ... @@ -91,6 +105,24 @@ Page({
* 用户点击右上角分享
*/
onShareAppMessage: function () {
var now = new Date();
var date = now.getFullYear() + "-" +((now.getMonth()+1)<10?"0":"")+(now.getMonth()+1)+"-"+(now.getDate()<10?"0":"")+now.getDate();
var user_id = ''
app.post('index/getUserId',{}).then(res => {
if(res.code == 1){
user_id = res.data.user_id
}
}).catch(err => {
wx.showToast({
title: err.msg,
icon: 'none'
})
})
return {
title: "BC HOUSE",
path:`/pages/partake/partake?date=${date}&user_id=${user_id}`
}
}
})
\ No newline at end of file
... ...
<!--今日任务 -->
<view class="cast" style="background:rgba(113,116,132,1);" bindtap="gotoday" data-id="{{raskData.Today.today_id}}">
<view class="cast" style="background:rgba(113,116,132,1);" bindtap="gotoday" data-type="today" data-id="{{raskData.Today.today_id}}">
<view class="cast-1">今日任务
<view class="cast-2">{{raskData.Today.type==2?'未打卡':'已完成'}}</view>
</view>
... ... @@ -8,11 +8,11 @@
<image src="/img/ic_date_dangri@2x.png"></image>
</view>
<view class="cast-logos">
<image src="/img/ic_date.png" bindtap="goCalend"></image>
<image src="/img/ic_date.png" catchtap="goCalend"></image>
</view>
</view>
<!-- 比赛任务 -->
<view class="cast" style="background:rgba(109,134,157,1);" bindtap="gotoday" data-id="{{raskData.Match.match_id}}">
<view class="cast" style="background:rgba(109,134,157,1);" bindtap="gotoday" data-type="match" data-id="{{raskData.Match.match_id}}">
<view class="cast-1">比赛任务
<view class="cast-2">{{raskData.Match.type==2?'未打卡':'已完成'}}</view>
</view>
... ... @@ -20,8 +20,8 @@
<view class="cast-logo">
<image src="/img/ic_date_bisai@2x.png"></image>
</view>
<view class="cast-logos">
<image src="/img/ic_date.png" bindtap="goCalend"></image>
<view class="cast-logos">
<image src="/img/ic_date.png" catchtap="goCalend"></image>
</view>
</view>
<!-- 测评任务 -->
... ... @@ -34,13 +34,16 @@
<image src="/img/img_ceping@2x.png" style="width:100rpx;height:100rpx"></image>
</view>
<view class="cast-logos">
<image src="/img/ic_date.png" bindtap="goCalend"></image>
<image src="/img/ic_date.png" catchtap="goCalend"></image>
</view>
</view>
<!-- -->
<view class="footer">
<view class="footer" >
分享到
<image src="/img/ic_wechat@2x.png"></image>
<button open-type="share" class="share">
<image src="/img/ic_wechat@2x.png"></image>
</button>
</view>
\ No newline at end of file
... ...
... ... @@ -51,9 +51,19 @@
font-size: 28rpx;
color:rgba(139,139,141,1);
margin-left:-60rpx;
display: flex;
justify-content: center;
align-items: center;
}
.footer image{
width: 80rpx;
height: 80rpx;
vertical-align: middle;
}
.share{
background: none;
width: 80rpx !important;
height: 80rpx;
padding: 0;
margin-left: 20rpx;
}
\ No newline at end of file
... ...
... ... @@ -54,7 +54,12 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.MessageList()
let token = wx.getStorageSync('token')
if (token == '') {
}else{
this.MessageList()
}
},
//获取通知列表
MessageList(){
... ...
// pages/08/08.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
box:[
{
num:221,
box_1:'分',
box_2:'阅读时长'
},
{
num:500,
box_1:'个',
box_2:'阅读单词'
},
{
num:23,
box_1:'本',
box_2:'阅读英语书'
}
]
alterData:{
},
},
gotoday(){
wx.switchTab({
... ... @@ -32,9 +19,24 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.ShareGetUser(options.date,options.user_id)
},
ShareGetUser(date,user_id){
app.post('index/ShareGetUser',{date:'',user_id:user_id}).then(res => {
if(res.code == 1){
console.log(res)
this.setData({
alterData:res.data
})
}
}).catch(err => {
wx.showToast({
title: err.msg,
icon: 'none'
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
... ...
... ... @@ -3,14 +3,22 @@
</view>
<view class="stu-box">
<view class="stu-1">
<image src="/img/99.png"></image>
<image src="{{alterData.UserAvatar}}"></image>
</view>
<view class="title">小丽</view>
<view class="stu-2">2021年05月06日在BC HOUSE学习</view>
<view class="title">{{alterData.UserNickname}}</view>
<view class="stu-2">{{alterData.Date}}在BC HOUSE学习</view>
<view class="box-z">
<view class="box-0" wx:for="{{box}}">
<view class="box-1">{{item.num}}<text>{{item.box_1}}</text></view>
<view class="box-2">{{item.box_2}}</view>
<view class="box-0" >
<view class="box-1">{{alterData.Reading}}<text>分钟</text></view>
<view class="box-2">坚持学习</view>
</view>
<view class="box-0" >
<view class="box-1">{{alterData.Readbook}}<text>本</text></view>
<view class="box-2">阅读英语书</view>
</view>
<view class="box-0" >
<view class="box-1">{{alterData.UserNickname}}<text>分钟</text></view>
<view class="box-2">今日学习</view>
</view>
</view>
... ...
... ... @@ -25,7 +25,8 @@ Page({
admin: "", // 账号
pwd: "", //密码
login: false,
meData:{}
meData:{},
token:''
},
/**
* 生命周期函数--监听页面加载
... ... @@ -36,12 +37,15 @@ Page({
onShow() {
let token = wx.getStorageSync('token')
if (token == '') {
this.setData({
login: true
})
}else{
this.getMe()
}
this.getMe()
this.setData({
token
})
},
// 关闭
myevent() {
... ... @@ -51,11 +55,23 @@ Page({
},
getmy() {
if(!this.data.token){
this.setData({
login:true
})
return
}
wx.navigateTo({
url: '/pages/means/means',
})
},
getmenu(e) {
if(!this.data.token){
this.setData({
login:true
})
return
}
let id = e.currentTarget.dataset.id
var data = JSON.stringify(this.data.meData) // 个人信息转换成字符串
if (id == 1) {
... ...
... ... @@ -3,11 +3,11 @@
</navigator>
<view class="top">
<view class="top-1">
<image src="{{meData.avatar}}"></image>
<image src="{{token ? meData.avatar : '../../img/ic_head@2x.png'}}"></image>
<view class="bigtitle">{{meData.nickname}}</view>
<text class="t3" bindtap="getmy">查看并编辑个人资料</text>
<text class="t3" bindtap="getmy">{{token ? '查看并编辑个人资料' : '您还没有登录,请进行登录'}}</text>
</view>
<view class="right">积分·{{meData.score}}</view>
<view class="right">积分·{{token ? meData.score : '0'}}</view>
</view>
<view class="contents">
<view class="cont" wx:for="{{cont}}" wx:key='key'>
... ...
... ... @@ -46,6 +46,8 @@
"scripts": {},
"isGameTourist": false,
"appid": "wxb717767cdf314ea2",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {
"plugin": {
"list": []
... ...
... ... @@ -13,18 +13,6 @@
"miniprogram": {
"list": [
{
"name": "pages/first/first",
"pathName": "pages/first/first",
"query": "",
"scene": null
},
{
"name": "pages/second/second",
"pathName": "pages/second/second",
"query": "",
"scene": null
},
{
"name": "pages/three/three",
"pathName": "pages/three/three",
"query": "",
... ... @@ -569,6 +557,12 @@
"pathName": "pages/first/first",
"query": "id=1",
"scene": null
},
{
"name": "pages/mission/mission",
"pathName": "pages/mission/mission",
"query": "",
"scene": null
}
]
}
... ...