diff --git a/pages/home/me/indexx.js b/pages/home/me/indexx.js
index e7b84aa..e4bf7cc 100644
--- a/pages/home/me/indexx.js
+++ b/pages/home/me/indexx.js
@@ -1,5 +1,6 @@
// pages/home/me/indexx.js
import Toast from 'tdesign-miniprogram/toast/index';
+import Dialog from 'tdesign-miniprogram/dialog/index';
const app = getApp();//新建页面时 默认引入
const req = app.xzjlReq();//初始化一个的request() 实例
Page({
@@ -8,6 +9,7 @@ Page({
* 页面的初始数据
*/
data: {
+ showConfirm: false
},
ReqData(){
@@ -87,5 +89,41 @@ Page({
ljXzjl(){
console.log(app.globalData.xx)
- }
+ },
+ logout() {
+ const dialogConfig = {
+ context: this,
+ title: '退出登录',
+ content: '星座精灵是一款快速能够让你快速了解自己的星座特征以及星座运势,确定需要退出吗?',
+ confirmBtn: '确定',
+ cancelBtn: '取消',
+ };
+
+ Dialog.confirm(dialogConfig)
+ .then(() => {
+ req.deleteRequest('/api/user/logout',{}).then((res)=>{
+ if(res.data.code===200){
+ wx.navigateTo({
+ url: '/pages/index/index'
+ })
+ Toast({
+ context: this,
+ selector: '#t-toast',
+ message: '退出成功!',
+ });
+ }
+ }).catch((err)=>{
+ Toast({
+ context: this,
+ selector: '#t-toast',
+ message: '退出失败!',
+ });
+ })
+
+ })
+ .catch(() => console.log('点击了取消'))
+ .finally(() => {
+ wx.setStorageSync('token', '')
+ Dialog.close()});
+ },
})
\ No newline at end of file
diff --git a/pages/home/me/indexx.json b/pages/home/me/indexx.json
index c24414c..fd94b68 100644
--- a/pages/home/me/indexx.json
+++ b/pages/home/me/indexx.json
@@ -2,6 +2,7 @@
"usingComponents": {
"t-cell": "tdesign-miniprogram/cell/cell",
"t-icon": "tdesign-miniprogram/icon/icon",
- "t-toast": "tdesign-miniprogram/toast/toast"
+ "t-toast": "tdesign-miniprogram/toast/toast",
+ "t-dialog": "tdesign-miniprogram/dialog/dialog"
}
}
\ No newline at end of file
diff --git a/pages/home/me/indexx.wxml b/pages/home/me/indexx.wxml
index 0016214..40ed9f5 100644
--- a/pages/home/me/indexx.wxml
+++ b/pages/home/me/indexx.wxml
@@ -52,9 +52,11 @@
小程序版本
V1.0
-
+
退出登录
+
+
diff --git a/pages/index/index.js b/pages/index/index.js
index a8b5438..7db75a4 100644
--- a/pages/index/index.js
+++ b/pages/index/index.js
@@ -81,8 +81,27 @@ Page({
},
scanCodeEvent(){
var that = this;
- // 暂时注释掉扫码的
var DEV_CODE = "34ADE4201285"
+ //扫码代码
+ wx.scanCode({
+ onlyFromCamera: true,// 只允许从相机扫码
+ success(res){
+ console.log("扫码成功:"+JSON.stringify(res))
+ DEV_CODE = res.result
+ },
+ fail (err) {
+ // console.log(err)
+ wx.showToast({
+ title:'扫描失败',
+ icon: 'none',
+ duration: 1000
+ })
+ }
+ })
+
+
+
+
var PUBLIC_KEY = ""
req.getRequest('/api/dict/value/login-public-key',{}).then((res)=>{
if(res.data.code==200){//扫码登录成功
@@ -98,7 +117,7 @@ Page({
// 此处执行登录获取token操作
req.postRequest('/api/user/login',{'mac':mac}).then((res)=>{
wx.setStorageSync('token', res.data.data)
- console.log(res)
+ console.log('token是:'+res.data.data)
wx.showToast({
title:'扫描登录成功',
icon: 'none',
diff --git a/project.config.json b/project.config.json
index 1bad225..e9bf0bc 100644
--- a/project.config.json
+++ b/project.config.json
@@ -44,7 +44,7 @@
},
"compileType": "miniprogram",
"libVersion": "2.19.4",
- "appid": "wx0a5f61e439e70c4a",
+ "appid": "wxa0d7db44777041f7",
"projectname": "miniprogram-92",
"condition": {},
"editorSetting": {
diff --git a/utils/request.js b/utils/request.js
index a2b0bd0..06535fb 100644
--- a/utils/request.js
+++ b/utils/request.js
@@ -2,7 +2,7 @@ class request {
constructor() {
this._baseUrl = 'https://xzjl-api.windymuse.cn';
this._token = wx.getStorageSync('token');
- this._header = {'Authorization': 'Bearer ' + this._token}
+ this._header = {'Authorization': this._token}
}
/**
@@ -41,7 +41,7 @@ class request {
wx.request({
url: this._baseUrl + url,
data: data,
- header: header,
+ header: {'Authorization': wx.getStorageSync('token')},
method: method,
success: (res => {
if (res.statusCode === 200) {