hookehuyr

✨ feat: 调试测试授权相关功能

......@@ -2,7 +2,7 @@
* @Author: hookehuyr hookehuyr@gmail.com
* @Date: 2022-05-27 15:57:59
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-10 11:01:04
* @LastEditTime: 2022-10-13 19:16:36
* @FilePath: /swx/src/app.config.js
* @Description:
*/
......@@ -42,6 +42,7 @@ export default {
'pages/userAdd/index',
'pages/userSearch/index',
'pages/editProject/index',
'pages/auth/index',
],
subpackages: [ // 配置在tabBar中的页面不能分包写到subpackages中去
{
......
/*
* @Date: 2022-09-19 14:11:05
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-09 18:09:06
* @LastEditTime: 2022-10-13 21:50:48
* @FilePath: /swx/src/app.js
* @Description: 文件描述
*/
......@@ -11,36 +11,26 @@ import { createPinia } from 'pinia'
import './app.less'
import '@/components/vant-weapp/common/index.wxss'
import request from './utils/request';
import Taro from '@tarojs/taro'
const App = createApp({
// 可以使用所有的 Vue 生命周期方法
mounted() {
// TODO: 现在先传openid,小程序的密钥还有搞到
// 保存主办方信息
request.post('/srv/?a=openid', {
openid: 'wxa2e50e76487d1d7b'
})
.then(res => {
if (res.data.code) {
// console.warn(res.data.data);
var cookie = res.cookies[0];
if (cookie != null) {
wx.setStorageSync("sessionid", res.cookies[0]);//服务器返回的 Set-Cookie,保存到本地
}
} else {
console.warn(res.data.msg);
}
})
.catch(err => {
console.error(err);
});
},
// 对应 onLaunch
onLaunch() { },
onLaunch() {
// 未授权状态跳转授权页面
if (!wx.getStorageSync("sessionid")) {
wx.navigateTo({
url: './pages/auth/index'
})
}
},
// 对应 onShow
onShow(options) { },
onShow(options) {
},
// 对应 onHide
onHide() { },
......
export default {
navigationBarTitleText: '授权页',
usingComponents: {
},
}
.red {
color: red;
}
<!--
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-13 21:52:36
* @FilePath: /swx/src/pages/auth/index.vue
* @Description: 文件描述
-->
<template>
<div></div>
</template>
<script setup>
import Taro from '@tarojs/taro'
import { ref } from "vue";
import request from '../../utils/request';
</script>
<script>
import "./index.less";
export default {
name: "authPage",
mounted () {
// TODO: 现在先传openid,小程序的密钥还有搞到
// 小程序预览,接口没有跑起来,真机调试可以运行
request.post('/srv/?a=openid', {
openid: 'wxa2e50e76487d1d7b'
})
.then(res => {
if (res.data.code) {
var cookie = res.cookies[0];
if (cookie != null) {
wx.setStorageSync("sessionid", res.cookies[0]);//服务器返回的 Set-Cookie,保存到本地
Taro.navigateBack({
delta: 1 // 返回上一级页面。
});
//TAG 小程序绑定cookie
// 修改请求头
request.defaults.headers.cookie = wx.getStorageSync("sessionid");
}
} else {
console.warn(res.data.msg);
}
})
.catch(err => {
console.error(err);
});
}
};
</script>
<!--
* @Date: 2022-09-21 16:04:10
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-09-29 10:16:05
* @LastEditTime: 2022-10-13 21:51:33
* @FilePath: /swx/src/pages/createActivity/index.vue
* @Description: 创建活动页面
-->
......@@ -12,8 +12,8 @@
:right-icon="icon_sel" placeholder="请选择活动主办方" placeholder-style="color: #999;" customStyle="" inputAlign=""
maxlength="" type="text" @tap="show_org_popup=true" :required="true" :disabled="true" />
<view class="divide-line"></view>
<van-field :value="message" label-class="label-class" input-class="input-class" label="活动主题" type="textarea"
placeholder="请输入活动主题(最多30个字)" placeholder-style="color: #999;" autosize customStyle="" inputAlign=""
<van-field :value="activity_name" label-class="label-class" input-class="input-class" label="活动主题" type="textarea"
placeholder="请输入活动主题(最多30个字)" placeholder-style="color: #999;" :autosize="{ maxHeight: 80, minHeight: 20 }" customStyle="" inputAlign=""
rightIcon="" :required="true" :maxlength="30" :border="false" @change="onChange" />
<view class="divide-line"></view>
<view class="form-item">
......@@ -279,6 +279,8 @@ import icon_sel from '@/images/icon/sel@2x.png'
import timePickerData from "@/components/time-picker-data/picker";
import activityEditor from "@/components/activity-editor";
import { getCurrentPageUrl, getCurrentPageParam } from "@/utils/weapp";
import request from '../../utils/request';
import Taro from '@tarojs/taro'
const message = ref('');
const message1 = ref('');
......@@ -315,6 +317,11 @@ const removeUploadImage = () => {
/**********************************/
onMounted(() => {
// if (!wx.getStorageSync("sessionid")) {
// Taro.navigateTo({
// url: '../auth/index'
// })
// }
if (getCurrentPageParam().type === 'edit') {
// 动态修改标题
wx.setNavigationBarTitle({
......@@ -329,13 +336,29 @@ onMounted(() => {
width: rect[0].width - 8 + 'px'
}
uploader_width.value = rect[0].width - 8 + 'px';
}).exec()
}, 100)
}).exec();
}, 500);
})
//
startTime = getTime("min", 1);
endTime = getTime("year", 2);
defaultTime = getTime("min", 30);
// 获取主办方列表信息
request.get('/srv/?a=host_list')
.then(res => {
if (res.data.code) {
res.data.data.my_hosts.forEach(item => {
item.text = item.name
})
org_type_columns.value = res.data.data.my_hosts;
} else {
console.warn(res.data.msg);
}
})
.catch(err => {
console.error(err);
});
});
const signInfo = ref([{
......@@ -481,21 +504,28 @@ const onPublicTypeCancel = (event) => {
show_public_popup.value = false;
}
/***** 主办方选择弹框列表 *****/
const show_org_popup = ref(false);
const org_type = ref('');
const org_type_columns = ref(['周三读书会', '周四读书会']);
const host_id = ref('');
const org_type_columns = ref([]);
const onOrgTypeChange = (event) => {
const { picker, value, index } = event.detail;
console.warn(value);
console.warn(index);
org_type.value = value;
// const { picker, value, index } = event.detail;
// console.warn(value);
// console.warn(index);
// org_type.value = value.text;
// host_id.value = value.id; // 主办方ID
}
const onOrgTypeConfirm = (event) => {
const onOrgTypeConfirm = (event) => { // 主办方弹框确认按钮回调
const detail = event.detail;
org_type.value = detail.value.text; // 主办方名称
host_id.value = detail.value.id; // 主办方ID
show_org_popup.value = false;
}
const onOrgTypeCancel = (event) => {
show_org_popup.value = false;
}
/******************/
</script>
<script>
......@@ -504,7 +534,7 @@ import "./index.less";
export default {
name: "createActivityPage",
// onLoad (options) {
// //options.参数名就可以取到
//options.参数名就可以取到
// if (options.type === 'edit') {
// // 动态修改标题
// wx.setNavigationBarTitle({
......@@ -512,5 +542,7 @@ export default {
// })
// }
// },
onShow () {
}
};
</script>
......
/*
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-09 18:21:32
* @LastEditTime: 2022-10-13 21:49:29
* @FilePath: /swx/src/utils/request.js
* @Description: 简单axios封装,后续按实际处理
*/
......@@ -17,10 +17,6 @@ const service = axios.create({
baseURL: BASE_URL, // url = base url + request url
// withCredentials: true, // send cookies when cross-domain requests
timeout: 5000, // request timeout
headers: {
//TAG 小程序绑定cookie
'cookie': wx.getStorageSync("sessionid") //读取本地保存好的上⼀次cookie
}
})
service.defaults.params = {
......