1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- import wxRequest from 'wechat-request';
- const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
- const urls = {
- //VR课堂
- getVRCourseList: '/api/show/lesson/pageList',
- //VR课堂详情
- getVRCourseDetail: '/api/show/lesson/detail/',
- // 获取微信用户详情
- getWxUserInfo: "/api/wxUser/getWxUserInfo",
- //微信用户-我的购买
- getMylesson: "/api/show/lesson/getList/",
- //主持人-我的课程
- getMyHostlesson: "/api/show/compere/getLesson/",
- //主持人-我的课程
- getPhone: "/api/wxUser/getPhone",
- updateWxUser: '/api/wxUser/updateWxUser',
- // 新微信登录
- wxLogin: "/api/show/wxLogin/{code}",
- //免费限时
- freeBuy: "/api/payment/freeBuy",
- // 上传
- upload: '/api/wxUser/upload'
- }
- wxRequest.defaults.baseURL = 'https://sit-daikan.4dage.com';
- wxRequest.defaults.headers['Token'] = wx.getStorageSync('token') || "";
- wxRequest.defaults.headers.post['Content-Type'] = 'application/json';
- export async function getVRCourseList(params) {
- return await (await wxRequest.post(urls.getVRCourseList, params)).data;
- }
- export async function getVRCourseDetail(id) {
- return await (await wxRequest.get(urls.getVRCourseDetail + id)).data;
- }
- export async function getWxUserInfo(key) {
- // const url = urls.getWxUserInfo.replace('{sessionKey}', encodeURIComponent(key))
- console.log('getWxUserInfo-key', key)
- return await (await wxRequest.get(urls.getWxUserInfo, {
- params: {
- sessionKey: key
- }
- })).data;
- }
- export async function getMyPaidlesson(wxUserId) {
- return await (await wxRequest.get(urls.getMylesson + wxUserId)).data;
- }
- export async function getMyHostlesson(wxUserId) {
- return await (await wxRequest.get(urls.getMyHostlesson + wxUserId)).data;
- }
- export async function decrptPhone(code) {
- console.log('decrptPhone-params', code, )
- const url = `${urls.getPhone}/${code}`
- console.log('decrptPhone-url', url)
- return await (await wxRequest.get(url)).data;
- }
- export async function updateUserInfo(info) {
- return await (await wxRequest.post(urls.updateWxUser, info)).data;
- }
- export const updateAvatar = async (avatarUrl) => {
- // const WX_UPLOAD_URL = wxRequest.defaults.baseURL + urls.upload
- const WX_UPLOAD_URL = 'https://v4-test.4dkankan.com/takelook/upload/file'
- let url = ''
- wx.uploadFile({
- filePath: avatarUrl,
- name: 'file',
- url: WX_UPLOAD_URL,
- success: async (res) => {
- const data = JSON.parse(res.data)
- console.log('data', data)
- url = data.data
- }
- })
- await sleep(1200)
- return Promise.resolve(url)
- }
- export async function wxUserLogin(code) {
- const url = urls.wxLogin.replace('{code}', code);
- return await (await wxRequest.get(url)).data;
- }
- export async function freeBuy(params) {
- // const url = urls.wxLogin.replace('{code}', code);
- return await (await wxRequest.post(urls.freeBuy, params)).data;
- }
|