1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- import wxRequest from 'wechat-request';
- 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/{sessionKey}",
- }
- 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) {
- return await (await wxRequest.get(urls.getWxUserInfo + 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) {
- const sessionKey = wx.getStorageSync('sessionKey')
- if (sessionKey) {
- const url = urls.updateWxUser.replace('{sessionKey}', sessionKey)
- return await (await wxRequest.post(url, info)).data;
- }
- }
- export const updateAvatar = async (avatarUrl) => {
- const WX_UPLOAD_URL = ''
- 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)
- }
|