|
- const Http = require("../../utils/HttpBasics");
- const config = require("../../config/config");
- let app = getApp();
- Page({
- data: {
- market: app.globalData.market,
- list: [],
- swiperCurrent: 0,
- scrollTop: 0
- },
- swiperChange: function(e) {
- this.setData({
- swiperCurrent: e.detail.current
- });
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onShow: function(options) {
- console.log("0000");
- console.log(app.globalData.token);
- },
- onLoad: function(options) {
- var that = this;
- var scene = decodeURIComponent(options.scene);
- if (app.globalData.token && app.globalData.token != null) {
- console.log("index ++ " + app.globalData.token);
- } else {
- // 由于是网络请求,可能会在 Page.onLoad 之后才返回
- // 所以此处加入 callback 以防止这种情况
- wx.login({
- success: ({ code }) => {
- console.log(code);
- Http.post({
- url: config.api.login,
- data: {
- appId: config.weapp.AppId,
- code: code,
- sceneAddress: app.globalData.sceneAddress
- }
- }).then(res => {
- //banner
- console.log(res);
- app.globalData.token = res.data.token;
- console.log(app.globalData.token)
- Http.setToken(res.data.token);
- if (res.code == 200) {
- Http.get({
- url: config.api.bannerlist,
- data: {
- pageNum: 1,
- pageSize: 10
- }
- }).then(res => {
- console.log(res);
- that.setData({
- list: res.data.list
- })
- console.log(res.data.list);
- });
- }
- })
- }
- })
- }
- wx.showLoading({
- title: "加载中"
- });
- setTimeout(function() {
- wx.hideLoading();
- }, 2200);
- },
-
- // 用户点击右上角分享
- onShareAppMessage: function() {
- return {
- title: "富茂链客",
- desc: "分享个小程序,希望你喜欢",
- success: function(res) {
- wx.showToast({
- title: "分享成功",
- duration: 1000,
- icon: "success"
- });
- }
- };
- }
- });
|