Showing
10 changed files
with
263 additions
and
26 deletions
src/api/Host/index.js
0 → 100644
| 1 | +/* | ||
| 2 | + * @Date: 2022-10-14 17:26:56 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2022-10-14 17:31:38 | ||
| 5 | + * @FilePath: /swx/src/api/Host/index.js | ||
| 6 | + * @Description: 文件描述 | ||
| 7 | + */ | ||
| 8 | +import { fn, fetch } from '../fn'; | ||
| 9 | + | ||
| 10 | +const Api = { | ||
| 11 | + HOST_LIST: '/srv/?a=host_list', | ||
| 12 | +} | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * @description: 主办方列表 | ||
| 16 | + * @returns | ||
| 17 | + */ | ||
| 18 | +export const hostListAPI = (params) => fn(fetch.post(Api.HOST_LIST, params)); |
src/api/common.js
0 → 100644
| 1 | +/* | ||
| 2 | + * @Date: 2022-06-17 14:54:29 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2022-06-18 22:18:46 | ||
| 5 | + * @FilePath: /tswj/src/api/common.js | ||
| 6 | + * @Description: 通用接口 | ||
| 7 | + */ | ||
| 8 | +import { fn, fetch, uploadFn } from '@/api/fn'; | ||
| 9 | + | ||
| 10 | +const Api = { | ||
| 11 | + SMS: '/srv/?a=sms', | ||
| 12 | + TOKEN: '/srv/?a=upload', | ||
| 13 | + SAVE_FILE: '/srv/?a=upload&t=save_file', | ||
| 14 | +} | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * @description: 发送验证码 | ||
| 18 | + * @param {*} phone 手机号码 | ||
| 19 | + * @returns | ||
| 20 | + */ | ||
| 21 | +export const smsAPI = (params) => fn(fetch.post(Api.SMS, params)); | ||
| 22 | + | ||
| 23 | +/** | ||
| 24 | + * @description: 获取七牛token | ||
| 25 | + * @param {*} filename 文件名 | ||
| 26 | + * @param {*} file 图片base64 | ||
| 27 | + * @returns | ||
| 28 | + */ | ||
| 29 | +export const qiniuTokenAPI = (params) => fn(fetch.stringifyPost(Api.TOKEN, params)); | ||
| 30 | + | ||
| 31 | +/** | ||
| 32 | + * @description: 上传七牛 | ||
| 33 | + * @param {*} | ||
| 34 | + * @returns | ||
| 35 | + */ | ||
| 36 | +export const qiniuUploadAPI = (url, data, config) => uploadFn(fetch.basePost(url, data, config)); | ||
| 37 | + | ||
| 38 | +/** | ||
| 39 | + * @description: 保存图片 | ||
| 40 | + * @param {*} format | ||
| 41 | + * @param {*} hash | ||
| 42 | + * @param {*} height | ||
| 43 | + * @param {*} width | ||
| 44 | + * @param {*} filekey | ||
| 45 | + * @returns | ||
| 46 | + */ | ||
| 47 | +export const saveFileAPI = (params) => fn(fetch.stringifyPost(Api.SAVE_FILE, params)); |
src/api/fn.js
0 → 100644
| 1 | +/* | ||
| 2 | + * @Date: 2022-05-18 22:56:08 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2022-10-14 17:33:20 | ||
| 5 | + * @FilePath: /swx/src/api/fn.js | ||
| 6 | + * @Description: 文件描述 | ||
| 7 | + */ | ||
| 8 | +import axios from '../utils/request'; | ||
| 9 | +import Toast from '../components/vant-weapp/toast/toast'; | ||
| 10 | +import qs from 'Qs' | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 网络请求功能函数 | ||
| 14 | + * @param {*} api 请求axios接口 | ||
| 15 | + * @returns 请求成功后,获取数据 | ||
| 16 | + */ | ||
| 17 | +export const fn = (api) => { | ||
| 18 | + return api | ||
| 19 | + .then(res => { | ||
| 20 | + if (res.data.code === 1) { | ||
| 21 | + return res.data || true; | ||
| 22 | + } else { | ||
| 23 | + // tslint:disable-next-line: no-console | ||
| 24 | + console.warn(res); | ||
| 25 | + if (!res.data.show) return false; | ||
| 26 | + Toast.fail(res.data.msg); | ||
| 27 | + return false; | ||
| 28 | + } | ||
| 29 | + }) | ||
| 30 | + .catch(err => { | ||
| 31 | + // tslint:disable-next-line: no-console | ||
| 32 | + console.error(err); | ||
| 33 | + return false; | ||
| 34 | + }) | ||
| 35 | + .finally(() => { // 最终执行 | ||
| 36 | + }) | ||
| 37 | +} | ||
| 38 | + | ||
| 39 | +/** | ||
| 40 | + * 七牛返回格式 | ||
| 41 | + * @param {*} api | ||
| 42 | + * @returns | ||
| 43 | + */ | ||
| 44 | +export const uploadFn = (api) => { | ||
| 45 | + return api | ||
| 46 | + .then(res => { | ||
| 47 | + if (res.statusText === 'OK') { | ||
| 48 | + return res.data || true; | ||
| 49 | + } else { | ||
| 50 | + // tslint:disable-next-line: no-console | ||
| 51 | + console.warn(res); | ||
| 52 | + if (!res.data.show) return false; | ||
| 53 | + Toast.fail(res.data.msg); | ||
| 54 | + return false; | ||
| 55 | + } | ||
| 56 | + }) | ||
| 57 | + .catch(err => { | ||
| 58 | + // tslint:disable-next-line: no-console | ||
| 59 | + console.error(err); | ||
| 60 | + return false; | ||
| 61 | + }) | ||
| 62 | +} | ||
| 63 | + | ||
| 64 | +/** | ||
| 65 | + * 统一 GET/POST 不同传参形式 | ||
| 66 | + */ | ||
| 67 | +export const fetch = { | ||
| 68 | + get: function (api, params) { | ||
| 69 | + return axios.get(api, { params }) | ||
| 70 | + }, | ||
| 71 | + post: function (api, params) { | ||
| 72 | + return axios.post(api, params) | ||
| 73 | + }, | ||
| 74 | + stringifyPost: function (api, params) { | ||
| 75 | + return axios.post(api, qs.stringify(params)) | ||
| 76 | + }, | ||
| 77 | + basePost: function (url, data, config) { | ||
| 78 | + return axios.post(url, data, config) | ||
| 79 | + } | ||
| 80 | +} |
src/api/wx/config.js
0 → 100644
| 1 | +/* | ||
| 2 | + * @Author: hookehuyr hookehuyr@gmail.com | ||
| 3 | + * @Date: 2022-06-09 13:32:44 | ||
| 4 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 5 | + * @LastEditTime: 2022-06-14 14:47:01 | ||
| 6 | + * @FilePath: /tswj/src/api/wx/config.js | ||
| 7 | + * @Description: | ||
| 8 | + */ | ||
| 9 | +import { fn, fetch } from '@/api/fn'; | ||
| 10 | + | ||
| 11 | +const Api = { | ||
| 12 | + WX_JSAPI: '/srv/?a=wx_share', | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * @description 获取微信CONFIG配置文件 | ||
| 17 | + * @param {*} url | ||
| 18 | + * @returns {*} cfg | ||
| 19 | + */ | ||
| 20 | +export const wxJsAPI = (params) => fn(fetch.get(Api.WX_JSAPI, params)); |
src/api/wx/jsApiList.js
0 → 100644
| 1 | +/* | ||
| 2 | + * @Date: 2022-06-13 14:18:57 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2022-06-13 14:27:21 | ||
| 5 | + * @FilePath: /tswj/src/api/wx/jsApiList.js | ||
| 6 | + * @Description: 文件描述 | ||
| 7 | + */ | ||
| 8 | +export const apiList = [ | ||
| 9 | + "updateAppMessageShareData", | ||
| 10 | + "updateTimelineShareData", | ||
| 11 | + "onMenuShareTimeline", | ||
| 12 | + "onMenuShareAppMessage", | ||
| 13 | + "onMenuShareQQ", | ||
| 14 | + "onMenuShareWeibo", | ||
| 15 | + "onMenuShareQZone", | ||
| 16 | + "startRecord", | ||
| 17 | + "stopRecord", | ||
| 18 | + "onVoiceRecordEnd", | ||
| 19 | + "playVoice", | ||
| 20 | + "pauseVoice", | ||
| 21 | + "stopVoice", | ||
| 22 | + "onVoicePlayEnd", | ||
| 23 | + "uploadVoice", | ||
| 24 | + "downloadVoice", | ||
| 25 | + "chooseImage", | ||
| 26 | + "previewImage", | ||
| 27 | + "uploadImage", | ||
| 28 | + "downloadImage", | ||
| 29 | + "translateVoice", | ||
| 30 | + "getNetworkType", | ||
| 31 | + "openLocation", | ||
| 32 | + "getLocation", | ||
| 33 | + "hideOptionMenu", | ||
| 34 | + "showOptionMenu", | ||
| 35 | + "hideMenuItems", | ||
| 36 | + "showMenuItems", | ||
| 37 | + "hideAllNonBaseMenuItem", | ||
| 38 | + "showAllNonBaseMenuItem", | ||
| 39 | + "closeWindow", | ||
| 40 | + "scanQRCode", | ||
| 41 | + "chooseWXPay", | ||
| 42 | + "openProductSpecificView", | ||
| 43 | + "addCard", | ||
| 44 | + "chooseCard", | ||
| 45 | + "openCard" | ||
| 46 | +] |
src/api/wx/pay.js
0 → 100644
| 1 | +/* | ||
| 2 | + * @Author: hookehuyr hookehuyr@gmail.com | ||
| 3 | + * @Date: 2022-06-09 13:32:44 | ||
| 4 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 5 | + * @LastEditTime: 2022-06-09 13:42:06 | ||
| 6 | + * @FilePath: /tswj/src/api/wx/config.js | ||
| 7 | + * @Description: | ||
| 8 | + */ | ||
| 9 | +import { fn, fetch } from '@/api/fn'; | ||
| 10 | + | ||
| 11 | +const Api = { | ||
| 12 | + WX_PAY: 'c/bill_paymentForBill.do', | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * @description 微信支付接口 | ||
| 17 | + * @param {*} | ||
| 18 | + * @returns {*} | ||
| 19 | + */ | ||
| 20 | +export const wxPayAPI = (params) => fn(fetch.get(Api.WX_PAY, params)); |
| 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 22:47:04 | 4 | + * @LastEditTime: 2022-10-13 23:00:28 |
| 5 | * @FilePath: /swx/src/pages/auth/index.vue | 5 | * @FilePath: /swx/src/pages/auth/index.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -33,7 +33,7 @@ export default { | ... | @@ -33,7 +33,7 @@ export default { |
| 33 | wx.setStorageSync("sessionid", res.cookies[0]);//服务器返回的 Set-Cookie,保存到本地 | 33 | wx.setStorageSync("sessionid", res.cookies[0]);//服务器返回的 Set-Cookie,保存到本地 |
| 34 | //TAG 小程序绑定cookie | 34 | //TAG 小程序绑定cookie |
| 35 | // 修改请求头 | 35 | // 修改请求头 |
| 36 | - // request.defaults.headers.cookie = res.cookies[0]; | 36 | + request.defaults.headers.cookie = res.cookies[0]; |
| 37 | Taro.navigateBack({ | 37 | Taro.navigateBack({ |
| 38 | delta: 1 // 返回上一级页面。 | 38 | delta: 1 // 返回上一级页面。 |
| 39 | }); | 39 | }); | ... | ... |
| 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 22:46:15 | 4 | + * @LastEditTime: 2022-10-14 17:35:45 |
| 5 | * @FilePath: /swx/src/pages/createActivity/index.vue | 5 | * @FilePath: /swx/src/pages/createActivity/index.vue |
| 6 | * @Description: 创建活动页面 | 6 | * @Description: 创建活动页面 |
| 7 | --> | 7 | --> |
| ... | @@ -333,28 +333,12 @@ onMounted(() => { | ... | @@ -333,28 +333,12 @@ onMounted(() => { |
| 333 | } | 333 | } |
| 334 | uploader_width.value = rect[0].width - 8 + 'px'; | 334 | uploader_width.value = rect[0].width - 8 + 'px'; |
| 335 | }).exec(); | 335 | }).exec(); |
| 336 | - }, 500); | 336 | + }, 300); |
| 337 | }) | 337 | }) |
| 338 | // | 338 | // |
| 339 | startTime = getTime("min", 1); | 339 | startTime = getTime("min", 1); |
| 340 | endTime = getTime("year", 2); | 340 | endTime = getTime("year", 2); |
| 341 | defaultTime = getTime("min", 30); | 341 | defaultTime = getTime("min", 30); |
| 342 | - | ||
| 343 | - // 获取主办方列表信息 | ||
| 344 | - request.get('/srv/?a=host_list') | ||
| 345 | - .then(res => { | ||
| 346 | - if (res.data.code) { | ||
| 347 | - res.data.data.my_hosts.forEach(item => { | ||
| 348 | - item.text = item.name | ||
| 349 | - }) | ||
| 350 | - org_type_columns.value = res.data.data.my_hosts; | ||
| 351 | - } else { | ||
| 352 | - console.warn(res.data.msg); | ||
| 353 | - } | ||
| 354 | - }) | ||
| 355 | - .catch(err => { | ||
| 356 | - console.error(err); | ||
| 357 | - }); | ||
| 358 | }); | 342 | }); |
| 359 | 343 | ||
| 360 | const signInfo = ref([{ | 344 | const signInfo = ref([{ |
| ... | @@ -504,7 +488,7 @@ const onPublicTypeCancel = (event) => { | ... | @@ -504,7 +488,7 @@ const onPublicTypeCancel = (event) => { |
| 504 | const show_org_popup = ref(false); | 488 | const show_org_popup = ref(false); |
| 505 | const org_type = ref(''); | 489 | const org_type = ref(''); |
| 506 | const host_id = ref(''); | 490 | const host_id = ref(''); |
| 507 | -const org_type_columns = ref([]); | 491 | +// const org_type_columns = ref([]); |
| 508 | const onOrgTypeChange = (event) => { | 492 | const onOrgTypeChange = (event) => { |
| 509 | // const { picker, value, index } = event.detail; | 493 | // const { picker, value, index } = event.detail; |
| 510 | // console.warn(value); | 494 | // console.warn(value); |
| ... | @@ -526,10 +510,16 @@ const onOrgTypeCancel = (event) => { | ... | @@ -526,10 +510,16 @@ const onOrgTypeCancel = (event) => { |
| 526 | 510 | ||
| 527 | <script> | 511 | <script> |
| 528 | import "./index.less"; | 512 | import "./index.less"; |
| 513 | +import { hostListAPI } from '../../api/Host/index' | ||
| 529 | 514 | ||
| 530 | export default { | 515 | export default { |
| 531 | name: "createActivityPage", | 516 | name: "createActivityPage", |
| 532 | - mixins: [mixin.init], | 517 | + data () { |
| 518 | + return { | ||
| 519 | + org_type_columns: [] | ||
| 520 | + } | ||
| 521 | + }, | ||
| 522 | + // mixins: [mixin.init], | ||
| 533 | // onLoad (options) { | 523 | // onLoad (options) { |
| 534 | //options.参数名就可以取到 | 524 | //options.参数名就可以取到 |
| 535 | // if (options.type === 'edit') { | 525 | // if (options.type === 'edit') { |
| ... | @@ -539,7 +529,13 @@ export default { | ... | @@ -539,7 +529,13 @@ export default { |
| 539 | // }) | 529 | // }) |
| 540 | // } | 530 | // } |
| 541 | // }, | 531 | // }, |
| 542 | - onShow () { | 532 | + async onShow () { |
| 533 | + // 获取主办方列表信息 | ||
| 534 | + const { data } = await hostListAPI(); | ||
| 535 | + data.my_hosts.forEach(item => { | ||
| 536 | + item.text = item.name | ||
| 537 | + }) | ||
| 538 | + this.org_type_columns = data.my_hosts; | ||
| 543 | } | 539 | } |
| 544 | }; | 540 | }; |
| 545 | </script> | 541 | </script> | ... | ... |
| 1 | /* | 1 | /* |
| 2 | * @Date: 2022-10-13 22:36:08 | 2 | * @Date: 2022-10-13 22:36:08 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-10-13 22:43:46 | 4 | + * @LastEditTime: 2022-10-14 10:32:20 |
| 5 | * @FilePath: /swx/src/utils/mixin.js | 5 | * @FilePath: /swx/src/utils/mixin.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ | ... | ... |
| 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:49:29 | 4 | + * @LastEditTime: 2022-10-14 17:36:27 |
| 5 | * @FilePath: /swx/src/utils/request.js | 5 | * @FilePath: /swx/src/utils/request.js |
| 6 | * @Description: 简单axios封装,后续按实际处理 | 6 | * @Description: 简单axios封装,后续按实际处理 |
| 7 | */ | 7 | */ |
| 8 | // import axios from 'axios' | 8 | // import axios from 'axios' |
| 9 | import axios from 'axios-miniprogram'; | 9 | import axios from 'axios-miniprogram'; |
| 10 | -// import Toast from '../components/vant-weapp/toast/toast'; | 10 | +import Taro from '@tarojs/taro' |
| 11 | +import Toast from '../components/vant-weapp/toast/toast'; | ||
| 11 | // import { ProgressStart, ProgressEnd } from '@/components/axios-progress/progress'; | 12 | // import { ProgressStart, ProgressEnd } from '@/components/axios-progress/progress'; |
| 12 | // import store from '@/store' | 13 | // import store from '@/store' |
| 13 | // import { getToken } from '@/utils/auth' | 14 | // import { getToken } from '@/utils/auth' |
| ... | @@ -80,6 +81,15 @@ service.interceptors.response.use( | ... | @@ -80,6 +81,15 @@ service.interceptors.response.use( |
| 80 | // } else { | 81 | // } else { |
| 81 | // return res | 82 | // return res |
| 82 | // } | 83 | // } |
| 84 | + if (response.data.code === 401) { | ||
| 85 | + /** | ||
| 86 | + * 未授权跳转登录页 | ||
| 87 | + * 授权完成后 返回当前页面 | ||
| 88 | + */ | ||
| 89 | + Taro.navigateTo({ | ||
| 90 | + url: '../../pages/auth/index' | ||
| 91 | + }) | ||
| 92 | + } | ||
| 83 | return response | 93 | return response |
| 84 | }, | 94 | }, |
| 85 | error => { | 95 | error => { | ... | ... |
-
Please register or login to post a comment