123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- import APIConfig from './api.js';
- import efunRequest from '../utils/efunRequest';
- import request from '../utils/request';
- import Loading from '../components/Loading';
- export default class user {
- // 个人中心
- static userMember() {
- return request(`http://ott80test-base.yifangjiaoyu.cn/mobile/user/member`, {
- method: 'get'
- });
- }
- //更新个人信息
- static update_UserInfo(opts) {
- return request(APIConfig.getUserUrl(``), opts);
- }
- /**
- * //上传头像
- * @return 返回Promise
- */
- static async uploadImage(photo_url) {
- Loading.show();
- const file_uid = await getuid();
- let formData = new FormData();
- formData.append('file', {
- uri: photo_url,
- name: file_uid + '.jpg',
- type: 'image/jpeg'
- });
- let options = {};
- options.body = formData;
- options.headers = { 'Content-Type': 'multipart/form-data', uid: file_uid };
- options.method = 'POST';
- return fetch(APIConfig.getUploadImg(), options)
- .then((response) => {
- console.log('res1', response);
- if (response.status >= 200 && response.status < 300) {
- Loading.hide();
- return response;
- }
- const error = new Error(response.statusText);
- error.response = response;
- Loading.hide();
- throw error;
- })
- .then((response) => {
- Loading.hide();
- return response.json();
- })
- .then((data) => {
- console.log('data', data);
- if (!data.success) {
- const code = data;
- }
- Loading.hide();
- return data;
- })
- .catch((err) => {
- console.log('err', err);
- Loading.hide();
- return {
- err
- };
- });
- }
- //绑定微信
- static bind_wechat(opts) {
- return request(APIConfig.getUserUrl(`/wechatBind`), opts);
- }
- //获取验证码
- static getVerificationCode(phone) {
- return request(APIConfig.getUserUrl(`/sendCode?mobile=`) + phone);
- }
- //绑定手机号
- static bind_phone(opts) {
- return request(APIConfig.getUserUrl(`/mobileBind`), opts);
- }
- //手机号登陆注册
- static mobileLoginAndReg(opts) {
- return request(APIConfig.getUserUrl(`/mobileLoginAndReg`), opts);
- }
- //微信登陆
- static wechatLogin(opts) {
- return request(APIConfig.getUserUrl(``), opts);
- }
- //跳过
- static jumpLogin(deviceCode, channel) {
- return request(APIConfig.getIsLogin() + `?deviceCode=` + deviceCode + '&channel=' + channel, { method: 'GET' });
- }
- //登出
- static LoginOut() {
- return request(APIConfig.getUserUrl('/signOut'), { method: 'GET' });
- }
- }
- async function getuid() {
- const uid = await storage
- .load({
- key: 'userInfo'
- })
- .catch((error) => {
- return '';
- });
- if (uid === '') {
- return '';
- }
- return JSON.parse(uid).uid;
- }
|