123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- //index.js
- //获取应用实例
- const app = getApp()
- Page({
- data: {
- spinShow: false,
- groups: [],
- pushPaper: [],
- timeLimitPaper: [],
- userInfo:{},
- taskList: []
- },
- onLoad: function(){
- app.checkLogin( userInfo =>{
- this.setData({userInfo})
- this.indexLoad()
- })
- },
- onPullDownRefresh() {
- if (!this.loading) {
- this.indexLoad( this.stopPullDownRefresh )
- }
- },
- stopPullDownRefresh(){
- wx.stopPullDownRefresh()
- },
- showPhone(){
- wx.showToast({
- title: "手机"+this.data.userInfo.phone,
- type:'success',
- duration:2*1000
- })
- },
- indexLoad: function( cb ) {
- let _this = this
- app.formPost('Exam.index', {}).then(res => {
- if (res.code === 200) {
- _this.setData({
- groups: res.data.groups
- });
- cb&&cb()
- }
- })
- },
- getPhoneNumber (e) {
- if( e.detail.errMsg =="getPhoneNumber:ok"){
- let param = {
- "iv": e.detail.iv,
- "encryptedData":e.detail.encryptedData,
- }
- app.formPost( "User.bindphone", param).then( (res)=>{
- if( res.code == 200){
- this.setData( {userInfo: res.data})
- app.setUserInfo( res.data )
- this.indexLoad()
- }
- })
- }else{
- app.message("绑定失败", 'error')
- }
- },
- gotoHistory: function(){
- wx.navigateTo({
- url: '/pages/record/index',
- })
- },
- gotoExam:function( e ){
- let groupId = e.currentTarget.dataset.id
- wx.navigateTo({
- url: `/pages/exam/do/index?id=${groupId}`
- })
- },
- doWxPay( data ){
- wx.requestPayment({
- timeStamp: data.timeStamp,//记住,这边的timeStamp一定要是字符串类型的,不然会报错
- nonceStr: data.nonceStr,
- package: data.package,
- signType: data.signType,
- paySign: data.paySign,
- success: function (event) {
- console.log(event);
- wx.showToast({title: '支付成功',icon: 'success', duration: 2000 });
- }
- })
- },
- startWxpay(e){
- let groupId = +e.currentTarget.dataset.id
- app.formPost('User.PayExam', {groupId}).then(res => {
- if (res.code === 200) {
- this.doWxPay( res.data )
- }
- })
- },
- gotoError: function(){
- wx.navigateTo({
- url: '/pages/exam/error/index',
- })
- }
- })
|