handleDataChange() {
if (this.allquestions < 50) {
this.rank = 1
this.rankpic = 'https://imgs.91yuwen.com/resouse/%E5%BE%BD%E7%AB%A0/11.png'
this.rankrate = Number(this.allquestions) / 50 * 100
console.log('进入1')
this.ranktitle = '刷题萌新'
} else if (this.allquestions > 51 && this.allquestions < 100) {
console.log('进入2')
this.rank = 2
this.rankpic = 'https://imgs.91yuwen.com/resouse/%E5%BE%BD%E7%AB%A0/21.png'
this.rankrate = Number(this.allquestions) / 100 * 100
this.ranktitle = '刷题能手'
} else if (this.allquestions > 101 && this.allquestions < 150) {
console.log('进入3')
this.rank = 3
this.rankpic = 'https://imgs.91yuwen.com/resouse/%E5%BE%BD%E7%AB%A0/31.png'
this.rankrate = Number(this.allquestions) / 150 * 100
this.ranktitle = '刷题达人'
} else if (this.allquestions > 151 && this.allquestions < 200) {
console.log('进入4')
this.rank = 4
this.rankpic = 'https://imgs.91yuwen.com/resouse/%E5%BE%BD%E7%AB%A0/41.png'
this.rankrate = Number(this.allquestions) / 200 * 100
this.ranktitle = '刷题狂人'
} else if (this.allquestions > 201 && this.allquestions < 300) {
this.rank = 5
this.rankpic = 'https://imgs.91yuwen.com/resouse/%E5%BE%BD%E7%AB%A0/51.png'
this.rankrate = Number(this.allquestions) / 300 * 100
this.ranktitle = '刷题大亨'
} else if (this.allquestions > 301 && this.allquestions < 400) {
this.rank = 6
this.rankpic = 'https://imgs.91yuwen.com/resouse/%E5%BE%BD%E7%AB%A0/61.png'
this.rankrate = Number(this.allquestions) / 400 * 100
this.ranktitle = '刷题战神'
} else if (this.allquestions > 401 && this.allquestions < 500) {
this.rank = 7
this.rankpic = 'https://imgs.91yuwen.com/resouse/%E5%BE%BD%E7%AB%A0/71.png'
this.rankrate = Number(this.allquestions) / 500 * 100
this.ranktitle = '刷题魔王'
} else if (this.allquestions > 501 && this.allquestions < 600) {
this.rank = 8
this.rankpic = 'https://imgs.91yuwen.com/resouse/%E5%BE%BD%E7%AB%A0/81.png'
this.rankrate = Number(this.allquestions) / 600 * 100
this.ranktitle = '刷题狂魔'
} else if (this.allquestions > 601 && this.allquestions < 700) {
this.rank = 9
this.rankpic = 'https://imgs.91yuwen.com/resouse/%E5%BE%BD%E7%AB%A0/91.png'
this.rankrate = Number(this.allquestions) / 700 * 100
this.ranktitle = '刷题大师'
} else if (this.allquestions > 701 && this.allquestions < 800) {
this.rank = 10
this.rankpic = 'https://imgs.91yuwen.com/resouse/%E5%BE%BD%E7%AB%A0/101.png'
this.rankrate = Number(this.allquestions) / 800 * 100
this.ranktitle = '刷题宗师'
} else if (this.allquestions > 801 && this.allquestions < 1000) {
this.rank = 11
this.rankpic = 'https://imgs.91yuwen.com/resouse/%E5%BE%BD%E7%AB%A0/111.png'
this.rankrate = Number(this.allquestions) / 1000 * 100
this.ranktitle = '刷题尊者'
} else if (this.allquestions > 1001 && this.allquestions < 1200) {
this.rank = 12
this.rankpic = 'https://imgs.91yuwen.com/resouse/%E5%BE%BD%E7%AB%A0/121.png'
this.rankrate = Number(this.allquestions) / 1200 * 100
this.ranktitle = '刷题仙人'
} else if (this.allquestions > 1201 && this.allquestions < 1400) {
this.rank = 13
this.rankpic = 'https://imgs.91yuwen.com/resouse/%E5%BE%BD%E7%AB%A0/131.png'
this.rankrate = Number(this.allquestions) / 1400 * 100
this.ranktitle = '刷题大神'
} else if (this.allquestions > 1401 && this.allquestions < 1600) {
this.rank = 14
this.rankpic = 'https://imgs.91yuwen.com/resouse/%E5%BE%BD%E7%AB%A0/141.png'
this.rankrate = Number(this.allquestions) / 1600 * 100
this.ranktitle = '刷题大神'
} else if (this.allquestions > 1601 && this.allquestions < 1800) {
this.rank = 15
this.rankpic = 'https://imgs.91yuwen.com/resouse/%E5%BE%BD%E7%AB%A0/151.png'
this.rankrate = Number(this.allquestions) / 1800 * 100
this.ranktitle = '藐视万题'
} else if (this.allquestions > 1801 && this.allquestions < 2000) {
this.rank = 16
this.rankpic = 'https://imgs.91yuwen.com/resouse/%E5%BE%BD%E7%AB%A0/161.png'
this.rankrate = Number(this.allquestions) / 2000 * 100
this.ranktitle = '刷题界传说'
} else {
console.log(1)
}
},
WATCH里数据检测
watch: {
allquestions(newValue, oldValue) {
this.handleDataChange();
}
},
数据传值
getmypersonaldata() {
var that = this
uni.request({
url: 'https://xxx.xxx.com/xxx/getdata/',
method: "POST",
data: {
grade: that.lessonName,
},
success(res) {
that.handleDataChange();
}
})
},
标签:uniapp,https,Watch,E7%,ranktitle,监控,allquestions,100,com
From: https://blog.51cto.com/u_15813778/8862412