xc-app/API/user.js

394 lines
10 KiB
JavaScript

import {
httpUrlFormat,
ajaxCarryAuthorization,ajaxSync
} from '@/utils/httpUtils.js'
import { ApiVersion,AppVersion } from '@/config/baseConfig.js'
const headerVersion = {
'API-Version': ApiVersion(),
'APP-Version':AppVersion()
}
const _flag = 'apiBaseUrl' // 请求的api空间
const apiUrl = {
'userInfo': httpUrlFormat('/user/info', _flag),//用户信息
'userPoint': httpUrlFormat('/user/point', _flag),//
'favorItemApi': httpUrlFormat('/user/favor/item', _flag),//
'userAddress': httpUrlFormat('/user/address', _flag),//收获地址
'boxCount': httpUrlFormat('/user/box_count', _flag),//
'notice': httpUrlFormat('/misc/notice', _flag),//公告
'noticeTopApi': httpUrlFormat('/misc/notice/top', _flag),//置顶公告
'uploadToken': httpUrlFormat('/user/upload_token', _flag),//上传oss凭证
'feedback': httpUrlFormat('/user/feedback', _flag),//意见反馈
'customer': httpUrlFormat('/misc/customer', _flag),//
'popupAdApi': httpUrlFormat('/misc/popup/ad', _flag),//
'couponApi': httpUrlFormat('/coupon', _flag),//优惠券
'userCouponApi': httpUrlFormat('/user/conpon', _flag),//用户优惠券
'userCouponBatchApi': httpUrlFormat('/user/conpon/reward/batch', _flag),//用户优惠券
'userCouponRewardApi': httpUrlFormat('/user/conpon/reward', _flag),//兑换优惠券
'coinGearApi': httpUrlFormat('/coin/gear', _flag),//代币充值
'coinGearRechargeApi': httpUrlFormat('/coin/gear/recharge', _flag),//代币充值订单
'payMethodApi': httpUrlFormat('/misc/pay/method', _flag),//获取支付方式
'coinPaidApi': httpUrlFormat('/coin/gear/recharge/paid', _flag),//
'couponCountApi': httpUrlFormat('/user/coupon/count', _flag),//
'miscPromptApi': httpUrlFormat('/misc/prompt', _flag),//
'shareApi': httpUrlFormat('/misc/build/share', _flag),//
'updateNickNameApi': httpUrlFormat('/user/update/nickname', _flag),//更新用户昵称
'recordCountApi': httpUrlFormat('/user/box/record/count', _flag),//用户盲盒开奖结果数量
'aliyunUploadTokenApi': httpUrlFormat('/misc/aliyun_upload_token', _flag),//获取oss上传凭证
'updateAvatarApi': httpUrlFormat('/user/update/avatar', _flag),//更新头像
'versionControlApi': httpUrlFormat('/misc/version/control', _flag),//版本控制
'userPromptListApi': httpUrlFormat('/user/prompt', _flag),//版本控制
}
// 更新用户昵称
export function updateNickNameApi(data) {
const headerObj = {...headerVersion,'Content-Type': 'application/x-www-form-urlencoded'}
return ajaxCarryAuthorization({
header: headerObj,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.updateNickNameApi,
method: 'POST',
data: data
})
}
export function favorItemDelApi(data) {
const headerObj = {...headerVersion,'Content-Type': 'application/x-www-form-urlencoded'}
return ajaxCarryAuthorization({
header: headerObj,
url: apiUrl.favorItemApi,
method: 'DELETE',
data: data
})
}
export function favorItemApi(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.favorItemApi,
method: 'GET',
data: data
})
}
export function recordCountApi(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.recordCountApi,
method: 'GET',
data: data
})
}
export function userPoint(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.userPoint,
method: 'GET',
data: data
})
}
export function userInfo(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.userInfo,
method: 'GET',
data: data
})
}
// 收货地址列表
export function userAddress(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.userAddress,
method: 'GET',
data: data
})
}
// 新增收货地址
export function addAddress(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.userAddress,
method: 'POST',
data: data
})
}
// 收货地址详情
export function addressDetail(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: httpUrlFormat(`/user/address/${data}`, _flag),
method: 'GET',
})
}
// 编辑收货地址
export function editAddress(id,data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: httpUrlFormat(`/user/address/${id}`, _flag),
method: 'PUT',
data: data
})
}
// 删除地址
export function delAddress(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: httpUrlFormat(`/user/address?ids=${data.id}`, _flag),
method: 'DELETE',
data,data
})
}
// 礼盒物品数量
export function boxCount(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.boxCount,
method: 'GET',
})
}
// 系统公告
export function notice(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.notice,
method: 'GET',
data,data
})
}
// 系统公告详情
export function noticeDetail(id,data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: httpUrlFormat(`/misc/notice/${id}`, _flag),
method: 'GET',
data,data
})
}
// 系统公告详情
export function uploadToken(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.uploadToken,
method: 'GET',
data,data
})
}
// 意见反馈
export function feedback(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.feedback,
method: 'POST',
data,data
})
}
export function customerApi(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.customer,
method: 'GET',
data,data
})
}
export function noticeTopApi(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.noticeTopApi,
method: 'GET',
data
})
}
export function popupAdApi(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.popupAdApi,
method: 'GET',
data
})
}
export function couponApi(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.couponApi,
method: 'GET',
data
})
}
export function userCouponApi(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.userCouponApi,
method: 'GET',
data
})
}
export function userCouponRewardApi(data) {
const headerObj = {...headerVersion,'Content-Type': 'application/x-www-form-urlencoded'}
return ajaxCarryAuthorization({
header: headerObj,
url: apiUrl.userCouponRewardApi,
method: 'POST',
data: data
})
}
export function coinGearApi(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.coinGearApi,
method: 'GET',
data
})
}
export function payMethodApi(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.payMethodApi,
method: 'GET',
data
})
}
export function coinGearRechargeApi(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.coinGearRechargeApi,
method: 'POST',
data: data
})
}
export function coinPaidApi(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.coinPaidApi,
method: 'GET',
data
})
}
export function userCouponBatchApi(userId,data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: httpUrlFormat(`/user/conpon/reward/batch?userId=${userId}`, _flag),
method: 'POST',
data: data
})
}
export function couponCountApi(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.couponCountApi,
method: 'GET',
data: data
})
}
export function miscPromptApi(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.miscPromptApi,
method: 'GET',
data: data
})
}
export function shareApi(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.shareApi,
method: 'GET',
data: data
})
}
export function aliyunUploadTokenApi(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.aliyunUploadTokenApi,
method: 'GET',
data
})
}
export function updateAvatarApi(data) {
const headerObj = {...headerVersion,'Content-Type': 'application/x-www-form-urlencoded'}
return ajaxCarryAuthorization({
header: headerObj,
url: apiUrl.updateAvatarApi,
method: 'POST',
data: data
})
}
export function versionControlApi(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.versionControlApi,
method: 'POST',
data
})
}
export function userPromptListApi(data) {
return ajaxCarryAuthorization({
header: headerVersion,
// header: {'Content-Type': 'application/x-www-form-urlencoded'},
url: apiUrl.userPromptListApi,
method: 'GET',
data
})
}