Showing
4 changed files
with
38 additions
and
19 deletions
| 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-13 21:52:36 | 4 | + * @LastEditTime: 2022-10-13 22:47:04 |
| 5 | * @FilePath: /swx/src/pages/auth/index.vue | 5 | * @FilePath: /swx/src/pages/auth/index.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -31,12 +31,12 @@ export default { | ... | @@ -31,12 +31,12 @@ export default { |
| 31 | var cookie = res.cookies[0]; | 31 | var cookie = res.cookies[0]; |
| 32 | if (cookie != null) { | 32 | if (cookie != null) { |
| 33 | wx.setStorageSync("sessionid", res.cookies[0]);//服务器返回的 Set-Cookie,保存到本地 | 33 | wx.setStorageSync("sessionid", res.cookies[0]);//服务器返回的 Set-Cookie,保存到本地 |
| 34 | + //TAG 小程序绑定cookie | ||
| 35 | + // 修改请求头 | ||
| 36 | + // request.defaults.headers.cookie = res.cookies[0]; | ||
| 34 | Taro.navigateBack({ | 37 | Taro.navigateBack({ |
| 35 | delta: 1 // 返回上一级页面。 | 38 | delta: 1 // 返回上一级页面。 |
| 36 | }); | 39 | }); |
| 37 | - //TAG 小程序绑定cookie | ||
| 38 | - // 修改请求头 | ||
| 39 | - request.defaults.headers.cookie = wx.getStorageSync("sessionid"); | ||
| 40 | } | 40 | } |
| 41 | } else { | 41 | } else { |
| 42 | console.warn(res.data.msg); | 42 | console.warn(res.data.msg); | ... | ... |
| 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-10-13 21:51:33 | 4 | + * @LastEditTime: 2022-10-13 22:46:15 |
| 5 | * @FilePath: /swx/src/pages/createActivity/index.vue | 5 | * @FilePath: /swx/src/pages/createActivity/index.vue |
| 6 | * @Description: 创建活动页面 | 6 | * @Description: 创建活动页面 |
| 7 | --> | 7 | --> |
| ... | @@ -281,6 +281,7 @@ import activityEditor from "@/components/activity-editor"; | ... | @@ -281,6 +281,7 @@ 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'; | 282 | import request from '../../utils/request'; |
| 283 | import Taro from '@tarojs/taro' | 283 | import Taro from '@tarojs/taro' |
| 284 | +import mixin from '../../utils/mixin'; | ||
| 284 | 285 | ||
| 285 | const message = ref(''); | 286 | const message = ref(''); |
| 286 | const message1 = ref(''); | 287 | const message1 = ref(''); |
| ... | @@ -317,11 +318,6 @@ const removeUploadImage = () => { | ... | @@ -317,11 +318,6 @@ const removeUploadImage = () => { |
| 317 | /**********************************/ | 318 | /**********************************/ |
| 318 | 319 | ||
| 319 | onMounted(() => { | 320 | onMounted(() => { |
| 320 | - // if (!wx.getStorageSync("sessionid")) { | ||
| 321 | - // Taro.navigateTo({ | ||
| 322 | - // url: '../auth/index' | ||
| 323 | - // }) | ||
| 324 | - // } | ||
| 325 | if (getCurrentPageParam().type === 'edit') { | 321 | if (getCurrentPageParam().type === 'edit') { |
| 326 | // 动态修改标题 | 322 | // 动态修改标题 |
| 327 | wx.setNavigationBarTitle({ | 323 | wx.setNavigationBarTitle({ |
| ... | @@ -533,6 +529,7 @@ import "./index.less"; | ... | @@ -533,6 +529,7 @@ import "./index.less"; |
| 533 | 529 | ||
| 534 | export default { | 530 | export default { |
| 535 | name: "createActivityPage", | 531 | name: "createActivityPage", |
| 532 | + mixins: [mixin.init], | ||
| 536 | // onLoad (options) { | 533 | // onLoad (options) { |
| 537 | //options.参数名就可以取到 | 534 | //options.参数名就可以取到 |
| 538 | // if (options.type === 'edit') { | 535 | // if (options.type === 'edit') { | ... | ... |
| 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-08 10:10:20 | 4 | + * @LastEditTime: 2022-10-13 22:30:46 |
| 5 | * @FilePath: /swx/src/pages/index/index.vue | 5 | * @FilePath: /swx/src/pages/index/index.vue |
| 6 | * @Description: 首页 | 6 | * @Description: 首页 |
| 7 | --> | 7 | --> |
| ... | @@ -27,18 +27,20 @@ | ... | @@ -27,18 +27,20 @@ |
| 27 | 27 | ||
| 28 | <script setup> | 28 | <script setup> |
| 29 | import Taro from '@tarojs/taro' | 29 | import Taro from '@tarojs/taro' |
| 30 | -import { ref } from 'vue'; | 30 | +import { ref, onMounted } from 'vue'; |
| 31 | import activityCard from '@/components/activity-card.vue' | 31 | import activityCard from '@/components/activity-card.vue' |
| 32 | import navbar from '@/components/navbar.vue' | 32 | import navbar from '@/components/navbar.vue' |
| 33 | import request from '../../utils/request'; | 33 | import request from '../../utils/request'; |
| 34 | 34 | ||
| 35 | -// request.get('/srv/?a=activity_app_homepage') | 35 | +onMounted(() => { |
| 36 | -// .then(res => { | 36 | + request.get('/srv/?a=activity_app_homepage') |
| 37 | -// console.warn(res); | 37 | + .then(res => { |
| 38 | -// }) | 38 | + // console.warn(res); |
| 39 | -// .catch(err => { | 39 | + }) |
| 40 | -// console.error(err); | 40 | + .catch(err => { |
| 41 | -// }) | 41 | + console.error(err); |
| 42 | + }) | ||
| 43 | +}) | ||
| 42 | 44 | ||
| 43 | const activity_list = ref([{ | 45 | const activity_list = ref([{ |
| 44 | title: '智慧没有烦恼', | 46 | title: '智慧没有烦恼', | ... | ... |
src/utils/mixin.js
0 → 100644
| 1 | +/* | ||
| 2 | + * @Date: 2022-10-13 22:36:08 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2022-10-13 22:43:46 | ||
| 5 | + * @FilePath: /swx/src/utils/mixin.js | ||
| 6 | + * @Description: 文件描述 | ||
| 7 | + */ | ||
| 8 | +import request from './request'; | ||
| 9 | + | ||
| 10 | +export default { | ||
| 11 | + // 初始化设置 | ||
| 12 | + init: { | ||
| 13 | + created () { | ||
| 14 | + // 绑定cookie | ||
| 15 | + if (wx.getStorageSync("sessionid")) { | ||
| 16 | + request.defaults.headers.cookie = wx.getStorageSync("sessionid"); | ||
| 17 | + } | ||
| 18 | + } | ||
| 19 | + } | ||
| 20 | +}; |
-
Please register or login to post a comment