Showing
7 changed files
with
123 additions
and
46 deletions
| ... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
| 2 | * @Author: hookehuyr hookehuyr@gmail.com | 2 | * @Author: hookehuyr hookehuyr@gmail.com |
| 3 | * @Date: 2022-05-27 15:57:59 | 3 | * @Date: 2022-05-27 15:57:59 |
| 4 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 4 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 5 | - * @LastEditTime: 2022-10-10 11:01:04 | 5 | + * @LastEditTime: 2022-10-13 19:16:36 |
| 6 | * @FilePath: /swx/src/app.config.js | 6 | * @FilePath: /swx/src/app.config.js |
| 7 | * @Description: | 7 | * @Description: |
| 8 | */ | 8 | */ |
| ... | @@ -42,6 +42,7 @@ export default { | ... | @@ -42,6 +42,7 @@ export default { |
| 42 | 'pages/userAdd/index', | 42 | 'pages/userAdd/index', |
| 43 | 'pages/userSearch/index', | 43 | 'pages/userSearch/index', |
| 44 | 'pages/editProject/index', | 44 | 'pages/editProject/index', |
| 45 | + 'pages/auth/index', | ||
| 45 | ], | 46 | ], |
| 46 | subpackages: [ // 配置在tabBar中的页面不能分包写到subpackages中去 | 47 | subpackages: [ // 配置在tabBar中的页面不能分包写到subpackages中去 |
| 47 | { | 48 | { | ... | ... |
| 1 | /* | 1 | /* |
| 2 | * @Date: 2022-09-19 14:11:05 | 2 | * @Date: 2022-09-19 14:11:05 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-10-09 18:09:06 | 4 | + * @LastEditTime: 2022-10-13 21:50:48 |
| 5 | * @FilePath: /swx/src/app.js | 5 | * @FilePath: /swx/src/app.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| ... | @@ -11,36 +11,26 @@ import { createPinia } from 'pinia' | ... | @@ -11,36 +11,26 @@ import { createPinia } from 'pinia' |
| 11 | import './app.less' | 11 | import './app.less' |
| 12 | import '@/components/vant-weapp/common/index.wxss' | 12 | import '@/components/vant-weapp/common/index.wxss' |
| 13 | import request from './utils/request'; | 13 | import request from './utils/request'; |
| 14 | +import Taro from '@tarojs/taro' | ||
| 14 | 15 | ||
| 15 | const App = createApp({ | 16 | const App = createApp({ |
| 16 | // 可以使用所有的 Vue 生命周期方法 | 17 | // 可以使用所有的 Vue 生命周期方法 |
| 17 | mounted() { | 18 | mounted() { |
| 18 | - // TODO: 现在先传openid,小程序的密钥还有搞到 | ||
| 19 | - // 保存主办方信息 | ||
| 20 | - request.post('/srv/?a=openid', { | ||
| 21 | - openid: 'wxa2e50e76487d1d7b' | ||
| 22 | - }) | ||
| 23 | - .then(res => { | ||
| 24 | - if (res.data.code) { | ||
| 25 | - // console.warn(res.data.data); | ||
| 26 | - var cookie = res.cookies[0]; | ||
| 27 | - if (cookie != null) { | ||
| 28 | - wx.setStorageSync("sessionid", res.cookies[0]);//服务器返回的 Set-Cookie,保存到本地 | ||
| 29 | - } | ||
| 30 | - } else { | ||
| 31 | - console.warn(res.data.msg); | ||
| 32 | - } | ||
| 33 | - }) | ||
| 34 | - .catch(err => { | ||
| 35 | - console.error(err); | ||
| 36 | - }); | ||
| 37 | }, | 19 | }, |
| 38 | 20 | ||
| 39 | // 对应 onLaunch | 21 | // 对应 onLaunch |
| 40 | - onLaunch() { }, | 22 | + onLaunch() { |
| 23 | + // 未授权状态跳转授权页面 | ||
| 24 | + if (!wx.getStorageSync("sessionid")) { | ||
| 25 | + wx.navigateTo({ | ||
| 26 | + url: './pages/auth/index' | ||
| 27 | + }) | ||
| 28 | + } | ||
| 29 | + }, | ||
| 41 | 30 | ||
| 42 | // 对应 onShow | 31 | // 对应 onShow |
| 43 | - onShow(options) { }, | 32 | + onShow(options) { |
| 33 | + }, | ||
| 44 | 34 | ||
| 45 | // 对应 onHide | 35 | // 对应 onHide |
| 46 | onHide() { }, | 36 | onHide() { }, | ... | ... |
src/pages/auth/index.config.js
0 → 100755
src/pages/auth/index.less
0 → 100644
src/pages/auth/index.vue
0 → 100644
| 1 | +<!-- | ||
| 2 | + * @Date: 2022-09-19 14:11:06 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2022-10-13 21:52:36 | ||
| 5 | + * @FilePath: /swx/src/pages/auth/index.vue | ||
| 6 | + * @Description: 文件描述 | ||
| 7 | +--> | ||
| 8 | +<template> | ||
| 9 | + <div></div> | ||
| 10 | +</template> | ||
| 11 | + | ||
| 12 | +<script setup> | ||
| 13 | +import Taro from '@tarojs/taro' | ||
| 14 | +import { ref } from "vue"; | ||
| 15 | +import request from '../../utils/request'; | ||
| 16 | + | ||
| 17 | +</script> | ||
| 18 | + | ||
| 19 | +<script> | ||
| 20 | +import "./index.less"; | ||
| 21 | +export default { | ||
| 22 | + name: "authPage", | ||
| 23 | + mounted () { | ||
| 24 | + // TODO: 现在先传openid,小程序的密钥还有搞到 | ||
| 25 | + // 小程序预览,接口没有跑起来,真机调试可以运行 | ||
| 26 | + request.post('/srv/?a=openid', { | ||
| 27 | + openid: 'wxa2e50e76487d1d7b' | ||
| 28 | + }) | ||
| 29 | + .then(res => { | ||
| 30 | + if (res.data.code) { | ||
| 31 | + var cookie = res.cookies[0]; | ||
| 32 | + if (cookie != null) { | ||
| 33 | + wx.setStorageSync("sessionid", res.cookies[0]);//服务器返回的 Set-Cookie,保存到本地 | ||
| 34 | + Taro.navigateBack({ | ||
| 35 | + delta: 1 // 返回上一级页面。 | ||
| 36 | + }); | ||
| 37 | + //TAG 小程序绑定cookie | ||
| 38 | + // 修改请求头 | ||
| 39 | + request.defaults.headers.cookie = wx.getStorageSync("sessionid"); | ||
| 40 | + } | ||
| 41 | + } else { | ||
| 42 | + console.warn(res.data.msg); | ||
| 43 | + } | ||
| 44 | + }) | ||
| 45 | + .catch(err => { | ||
| 46 | + console.error(err); | ||
| 47 | + }); | ||
| 48 | + } | ||
| 49 | +}; | ||
| 50 | +</script> |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-09-21 16:04:10 | 2 | * @Date: 2022-09-21 16:04:10 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-09-29 10:16:05 | 4 | + * @LastEditTime: 2022-10-13 21:51:33 |
| 5 | * @FilePath: /swx/src/pages/createActivity/index.vue | 5 | * @FilePath: /swx/src/pages/createActivity/index.vue |
| 6 | * @Description: 创建活动页面 | 6 | * @Description: 创建活动页面 |
| 7 | --> | 7 | --> |
| ... | @@ -12,8 +12,8 @@ | ... | @@ -12,8 +12,8 @@ |
| 12 | :right-icon="icon_sel" placeholder="请选择活动主办方" placeholder-style="color: #999;" customStyle="" inputAlign="" | 12 | :right-icon="icon_sel" placeholder="请选择活动主办方" placeholder-style="color: #999;" customStyle="" inputAlign="" |
| 13 | maxlength="" type="text" @tap="show_org_popup=true" :required="true" :disabled="true" /> | 13 | maxlength="" type="text" @tap="show_org_popup=true" :required="true" :disabled="true" /> |
| 14 | <view class="divide-line"></view> | 14 | <view class="divide-line"></view> |
| 15 | - <van-field :value="message" label-class="label-class" input-class="input-class" label="活动主题" type="textarea" | 15 | + <van-field :value="activity_name" label-class="label-class" input-class="input-class" label="活动主题" type="textarea" |
| 16 | - placeholder="请输入活动主题(最多30个字)" placeholder-style="color: #999;" autosize customStyle="" inputAlign="" | 16 | + placeholder="请输入活动主题(最多30个字)" placeholder-style="color: #999;" :autosize="{ maxHeight: 80, minHeight: 20 }" customStyle="" inputAlign="" |
| 17 | rightIcon="" :required="true" :maxlength="30" :border="false" @change="onChange" /> | 17 | rightIcon="" :required="true" :maxlength="30" :border="false" @change="onChange" /> |
| 18 | <view class="divide-line"></view> | 18 | <view class="divide-line"></view> |
| 19 | <view class="form-item"> | 19 | <view class="form-item"> |
| ... | @@ -279,6 +279,8 @@ import icon_sel from '@/images/icon/sel@2x.png' | ... | @@ -279,6 +279,8 @@ import icon_sel from '@/images/icon/sel@2x.png' |
| 279 | import timePickerData from "@/components/time-picker-data/picker"; | 279 | import timePickerData from "@/components/time-picker-data/picker"; |
| 280 | import activityEditor from "@/components/activity-editor"; | 280 | import activityEditor from "@/components/activity-editor"; |
| 281 | import { getCurrentPageUrl, getCurrentPageParam } from "@/utils/weapp"; | 281 | import { getCurrentPageUrl, getCurrentPageParam } from "@/utils/weapp"; |
| 282 | +import request from '../../utils/request'; | ||
| 283 | +import Taro from '@tarojs/taro' | ||
| 282 | 284 | ||
| 283 | const message = ref(''); | 285 | const message = ref(''); |
| 284 | const message1 = ref(''); | 286 | const message1 = ref(''); |
| ... | @@ -315,6 +317,11 @@ const removeUploadImage = () => { | ... | @@ -315,6 +317,11 @@ const removeUploadImage = () => { |
| 315 | /**********************************/ | 317 | /**********************************/ |
| 316 | 318 | ||
| 317 | onMounted(() => { | 319 | onMounted(() => { |
| 320 | + // if (!wx.getStorageSync("sessionid")) { | ||
| 321 | + // Taro.navigateTo({ | ||
| 322 | + // url: '../auth/index' | ||
| 323 | + // }) | ||
| 324 | + // } | ||
| 318 | if (getCurrentPageParam().type === 'edit') { | 325 | if (getCurrentPageParam().type === 'edit') { |
| 319 | // 动态修改标题 | 326 | // 动态修改标题 |
| 320 | wx.setNavigationBarTitle({ | 327 | wx.setNavigationBarTitle({ |
| ... | @@ -329,13 +336,29 @@ onMounted(() => { | ... | @@ -329,13 +336,29 @@ onMounted(() => { |
| 329 | width: rect[0].width - 8 + 'px' | 336 | width: rect[0].width - 8 + 'px' |
| 330 | } | 337 | } |
| 331 | uploader_width.value = rect[0].width - 8 + 'px'; | 338 | uploader_width.value = rect[0].width - 8 + 'px'; |
| 332 | - }).exec() | 339 | + }).exec(); |
| 333 | - }, 100) | 340 | + }, 500); |
| 334 | }) | 341 | }) |
| 335 | // | 342 | // |
| 336 | startTime = getTime("min", 1); | 343 | startTime = getTime("min", 1); |
| 337 | endTime = getTime("year", 2); | 344 | endTime = getTime("year", 2); |
| 338 | defaultTime = getTime("min", 30); | 345 | defaultTime = getTime("min", 30); |
| 346 | + | ||
| 347 | + // 获取主办方列表信息 | ||
| 348 | + request.get('/srv/?a=host_list') | ||
| 349 | + .then(res => { | ||
| 350 | + if (res.data.code) { | ||
| 351 | + res.data.data.my_hosts.forEach(item => { | ||
| 352 | + item.text = item.name | ||
| 353 | + }) | ||
| 354 | + org_type_columns.value = res.data.data.my_hosts; | ||
| 355 | + } else { | ||
| 356 | + console.warn(res.data.msg); | ||
| 357 | + } | ||
| 358 | + }) | ||
| 359 | + .catch(err => { | ||
| 360 | + console.error(err); | ||
| 361 | + }); | ||
| 339 | }); | 362 | }); |
| 340 | 363 | ||
| 341 | const signInfo = ref([{ | 364 | const signInfo = ref([{ |
| ... | @@ -481,21 +504,28 @@ const onPublicTypeCancel = (event) => { | ... | @@ -481,21 +504,28 @@ const onPublicTypeCancel = (event) => { |
| 481 | show_public_popup.value = false; | 504 | show_public_popup.value = false; |
| 482 | } | 505 | } |
| 483 | 506 | ||
| 507 | +/***** 主办方选择弹框列表 *****/ | ||
| 484 | const show_org_popup = ref(false); | 508 | const show_org_popup = ref(false); |
| 485 | const org_type = ref(''); | 509 | const org_type = ref(''); |
| 486 | -const org_type_columns = ref(['周三读书会', '周四读书会']); | 510 | +const host_id = ref(''); |
| 511 | +const org_type_columns = ref([]); | ||
| 487 | const onOrgTypeChange = (event) => { | 512 | const onOrgTypeChange = (event) => { |
| 488 | - const { picker, value, index } = event.detail; | 513 | + // const { picker, value, index } = event.detail; |
| 489 | - console.warn(value); | 514 | + // console.warn(value); |
| 490 | - console.warn(index); | 515 | + // console.warn(index); |
| 491 | - org_type.value = value; | 516 | + // org_type.value = value.text; |
| 517 | + // host_id.value = value.id; // 主办方ID | ||
| 492 | } | 518 | } |
| 493 | -const onOrgTypeConfirm = (event) => { | 519 | +const onOrgTypeConfirm = (event) => { // 主办方弹框确认按钮回调 |
| 520 | + const detail = event.detail; | ||
| 521 | + org_type.value = detail.value.text; // 主办方名称 | ||
| 522 | + host_id.value = detail.value.id; // 主办方ID | ||
| 494 | show_org_popup.value = false; | 523 | show_org_popup.value = false; |
| 495 | } | 524 | } |
| 496 | const onOrgTypeCancel = (event) => { | 525 | const onOrgTypeCancel = (event) => { |
| 497 | show_org_popup.value = false; | 526 | show_org_popup.value = false; |
| 498 | } | 527 | } |
| 528 | +/******************/ | ||
| 499 | </script> | 529 | </script> |
| 500 | 530 | ||
| 501 | <script> | 531 | <script> |
| ... | @@ -504,13 +534,15 @@ import "./index.less"; | ... | @@ -504,13 +534,15 @@ import "./index.less"; |
| 504 | export default { | 534 | export default { |
| 505 | name: "createActivityPage", | 535 | name: "createActivityPage", |
| 506 | // onLoad (options) { | 536 | // onLoad (options) { |
| 507 | - // //options.参数名就可以取到 | 537 | + //options.参数名就可以取到 |
| 508 | - // if (options.type === 'edit') { | 538 | + // if (options.type === 'edit') { |
| 509 | - // // 动态修改标题 | 539 | + // // 动态修改标题 |
| 510 | - // wx.setNavigationBarTitle({ | 540 | + // wx.setNavigationBarTitle({ |
| 511 | - // title: '修改活动', | 541 | + // title: '修改活动', |
| 512 | - // }) | 542 | + // }) |
| 513 | - // } | 543 | + // } |
| 514 | // }, | 544 | // }, |
| 545 | + onShow () { | ||
| 546 | + } | ||
| 515 | }; | 547 | }; |
| 516 | </script> | 548 | </script> | ... | ... |
| 1 | /* | 1 | /* |
| 2 | * @Date: 2022-09-19 14:11:06 | 2 | * @Date: 2022-09-19 14:11:06 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-10-09 18:21:32 | 4 | + * @LastEditTime: 2022-10-13 21:49:29 |
| 5 | * @FilePath: /swx/src/utils/request.js | 5 | * @FilePath: /swx/src/utils/request.js |
| 6 | * @Description: 简单axios封装,后续按实际处理 | 6 | * @Description: 简单axios封装,后续按实际处理 |
| 7 | */ | 7 | */ |
| ... | @@ -17,10 +17,6 @@ const service = axios.create({ | ... | @@ -17,10 +17,6 @@ const service = axios.create({ |
| 17 | baseURL: BASE_URL, // url = base url + request url | 17 | baseURL: BASE_URL, // url = base url + request url |
| 18 | // withCredentials: true, // send cookies when cross-domain requests | 18 | // withCredentials: true, // send cookies when cross-domain requests |
| 19 | timeout: 5000, // request timeout | 19 | timeout: 5000, // request timeout |
| 20 | - headers: { | ||
| 21 | - //TAG 小程序绑定cookie | ||
| 22 | - 'cookie': wx.getStorageSync("sessionid") //读取本地保存好的上⼀次cookie | ||
| 23 | - } | ||
| 24 | }) | 20 | }) |
| 25 | 21 | ||
| 26 | service.defaults.params = { | 22 | service.defaults.params = { | ... | ... |
-
Please register or login to post a comment