From b7d0a2a0bd0bb80deb2a6d7c0f7dc5837889798c Mon Sep 17 00:00:00 2001 From: Tuisku Date: Fri, 27 May 2022 14:13:05 +0800 Subject: [PATCH 1/3] =?UTF-8?q?token=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/quest/quest.js | 4 +++ .../components/collection/collection.js | 2 +- .../components/collection/collection.wxml | 15 +++++++--- pages/user/subpage/quest.js | 3 +- pages/user/user.js | 2 +- utils/util.js | 29 +++++++++++++------ 6 files changed, 39 insertions(+), 16 deletions(-) diff --git a/pages/quest/quest.js b/pages/quest/quest.js index 769dbc5..fc0261e 100644 --- a/pages/quest/quest.js +++ b/pages/quest/quest.js @@ -1,4 +1,7 @@ // pages/quest/quest.js +import { + http +} from '../../utils/util' Page({ /** @@ -271,6 +274,7 @@ Page({ title: '任务中心', success: function (res) {} }) + http("/task/list", "post", '') }, /** diff --git a/pages/quest/subpage/detail/components/collection/collection.js b/pages/quest/subpage/detail/components/collection/collection.js index 3fae9ca..7f4c1ac 100644 --- a/pages/quest/subpage/detail/components/collection/collection.js +++ b/pages/quest/subpage/detail/components/collection/collection.js @@ -37,7 +37,7 @@ Component({ console.log(e.detail.value) console.log(this.data) this.setData({ - [form.add]: e.detail.value + 'form.add': e.detail.value }) }, } diff --git a/pages/quest/subpage/detail/components/collection/collection.wxml b/pages/quest/subpage/detail/components/collection/collection.wxml index 53d2d07..2dc14a6 100644 --- a/pages/quest/subpage/detail/components/collection/collection.wxml +++ b/pages/quest/subpage/detail/components/collection/collection.wxml @@ -21,8 +21,8 @@ - {{form.add}} - 请选择地区 + {{form.add}} + 请选择地区 @@ -30,7 +30,7 @@ 关注车型 - 请选择关注车型 + 请选择关注车型 @@ -44,4 +44,11 @@ 上传 - \ No newline at end of file + + + + 选择平台 + {{item.name}} + + + \ No newline at end of file diff --git a/pages/user/subpage/quest.js b/pages/user/subpage/quest.js index e9ac3b4..d8945fd 100644 --- a/pages/user/subpage/quest.js +++ b/pages/user/subpage/quest.js @@ -8,11 +8,12 @@ Page({ }, + getlist() { + }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { - }, /** diff --git a/pages/user/user.js b/pages/user/user.js index 3782aec..a5ecfe4 100644 --- a/pages/user/user.js +++ b/pages/user/user.js @@ -67,7 +67,7 @@ Page({ if (res.msg === "未注册!") { this.getUserProfile() } else { - // getApp().globalData.token = res.token + getApp().globalData.token = res.data.token this.setData({ user_avatar:res.data.user.avatar, user_name:res.data.user.name, diff --git a/utils/util.js b/utils/util.js index 3522e9c..2795518 100644 --- a/utils/util.js +++ b/utils/util.js @@ -26,10 +26,21 @@ const http = (url, method, data, isLoading = true) => { } return new Promise(function (resolve, reject) { let token = getApp().globalData.token + // wx.getStorage({ + // key: 'token', + // success (res) { + // // console.log(res.data) + // let token = res.data + // }, + // fail (res) { + // console.log(res) + // wx.hideLoading(); + // } + // }) let header = { - 'Customer-Wxapp-Token': token + 'token': token } - // if (token && uid) { + if (token) { wx.request({ url: host + url, data: data, @@ -55,13 +66,13 @@ const http = (url, method, data, isLoading = true) => { wx.hideLoading(); } }) - // } else { - // wx.showToast({ - // title: '未登录\r\n点击个人中心头像登录', - // icon: 'none', - // duration: 2000 - // }) - // } + } else { + wx.showToast({ + title: '未登录\r\n点击个人中心头像登录', + icon: 'none', + duration: 2000 + }) + } }) } From 7b389c589fceaaeeef1980eee0289e88a5600c6f Mon Sep 17 00:00:00 2001 From: Tuisku Date: Fri, 27 May 2022 14:30:12 +0800 Subject: [PATCH 2/3] =?UTF-8?q?token=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/user/user.js | 4 ---- utils/util.js | 48 +++++++++++++++++++++++++--------------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/pages/user/user.js b/pages/user/user.js index a5ecfe4..f5476a3 100644 --- a/pages/user/user.js +++ b/pages/user/user.js @@ -63,7 +63,6 @@ Page({ http("/user/login", "post", { code: res.code }).then(res => { - console.log(res) if (res.msg === "未注册!") { this.getUserProfile() } else { @@ -84,7 +83,6 @@ Page({ wx.getStorage({ key: 'token', success (res) { - console.log(res.data) } }) } @@ -104,7 +102,6 @@ Page({ wx.getUserProfile({ desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 success: (userRes) => { - console.log(userRes) that.setData({ iv: userRes.iv, encryptedData: userRes.encryptedData, @@ -123,7 +120,6 @@ Page({ phone: false }) let that = this - console.log(that.data.iv) let param = { userinfo: { iv: this.data.iv, diff --git a/utils/util.js b/utils/util.js index 2795518..658c946 100644 --- a/utils/util.js +++ b/utils/util.js @@ -25,22 +25,33 @@ const http = (url, method, data, isLoading = true) => { }); } return new Promise(function (resolve, reject) { - let token = getApp().globalData.token - // wx.getStorage({ - // key: 'token', - // success (res) { - // // console.log(res.data) - // let token = res.data - // }, - // fail (res) { - // console.log(res) - // wx.hideLoading(); - // } - // }) - let header = { - 'token': token + if ( url === '/user/login' || url === '/user/register') { + var header = {} + } else { + wx.getStorage({ + key: 'token', + success (res) { + // console.log(res.data) + let token = res.data + }, + fail(res) { + if (res.errMsg === "getStorage:fail data not found"){ + wx.showToast({ + title: '未登录\r\n点击个人中心头像登录', + icon: 'none', + duration: 2000 + }) + } + wx.hideLoading(); + }, + complete (res) { + console.log(res) + } + }) + var header = { + 'token': token + } } - if (token) { wx.request({ url: host + url, data: data, @@ -66,13 +77,6 @@ const http = (url, method, data, isLoading = true) => { wx.hideLoading(); } }) - } else { - wx.showToast({ - title: '未登录\r\n点击个人中心头像登录', - icon: 'none', - duration: 2000 - }) - } }) } From 0f040b87a68369a550939c048e05144ab70fbed0 Mon Sep 17 00:00:00 2001 From: Tuisku Date: Fri, 27 May 2022 14:32:39 +0800 Subject: [PATCH 3/3] token --- utils/util.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/utils/util.js b/utils/util.js index 658c946..239ba33 100644 --- a/utils/util.js +++ b/utils/util.js @@ -31,8 +31,10 @@ const http = (url, method, data, isLoading = true) => { wx.getStorage({ key: 'token', success (res) { - // console.log(res.data) - let token = res.data + var token = res.data + var header = { + 'token': token + } }, fail(res) { if (res.errMsg === "getStorage:fail data not found"){ @@ -48,9 +50,6 @@ const http = (url, method, data, isLoading = true) => { console.log(res) } }) - var header = { - 'token': token - } } wx.request({ url: host + url,