123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- // pages/apply/apply.js
- const app = getApp()
- const host = app.globalData.host;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- list:[],
- show:1
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- wx.showLoading({
- title: '',
- })
- this.setData({
- openid: app.globalData.openid
- })
- this.getData();
- wx.getStorage({
- key: 'userInfo',
- success: res=> {
- if(res.data){
- this.setData({show:0})
- }
- },
- })
- },
- getData:function(){
- wx.request({
- url: host+'/api/wx/signup/list',
- header:{
- openid:this.data.openid
- },
- method:'GET',
- success:res=>{
- if (res.statusCode == 403){
- this.save()
- }else{
- wx.hideLoading()
- let data=res.data.data
- for(let i=0;i<data.length;i++){
- data[i].subject_item_1 = data[i].subject_item.split('|')
- }
- this.setData({
- list: data
- })
- }
- }
- })
- },
- save: function () {
- var _this = this
- wx.showLoading({
- title: '正在登录',
- })
- wx.getStorage({
- key: 'userInfo',
- success: function (res) {
- console.log(res)
- wx.request({
- url: host + '/api/wx/auth',
- method: 'POST',
- data: {
- nickname: res.data.nickName,
- avatar: res.data.avatarUrl,
- openid: app.globalData.openid,
- },
- success: res => {
- wx.hideLoading()
- _this.getData();
- }
- })
- },
- })
- },
- pay:function(e){
- wx.navigateTo({
- url: '../pay/pay?id='+e.target.dataset.id,
- })
- },
- onGotUserInfo: function (e) {
- wx.setStorage({
- key: 'userInfo',
- data: e.detail.userInfo,
- })
- console.log(app.globalData.openid)
- wx.request({
- url: host+'/api/wx/auth',
- method:'POST',
- data:{
- nickname: e.detail.userInfo.nickName,
- avatar: e.detail.userInfo.avatarUrl,
- openid: app.globalData.openid,
- },
- success:res=>{
- console.log(res)
- this.setData({
- show:0
- })
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.getData();
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- this.getData();
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|