| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- import {defHttp} from '~/utils/http'
- import {USER_LATITUDE, USER_LONGITUDE} from "~/constants";
- import AmapWx from "~/libs/amap-wx";
- import type {ArticleCategoryModel, ArticleModel, ArticleResult} from "~/apis/model/articleModel";
- import type {HomeQuickLinkModel} from "~/apis/model/common.model";
- import type {IntegralProductModel, IntegralProductParams} from "~/apis/model/integral.model";
- import type {AnnouncementResult} from "~/apis/model/announcement.model";
- import type {FeedbackRequestModel} from "~/apis/model/feedback.model";
- // import {a} from "unocss-preset-weapp/dist/utilities-46c43da7";
- // 引入
- // import amap from '~/libs/amap-wx.130.js';
- // let amapPlugin = new amap.AMapWX({
- // key: "e42681aed12886436ed44d6c28aa22c8"
- // });
- const amap = AmapWx.getInstance({key: "e42681aed12886436ed44d6c28aa22c8"});
- enum API {
- /**
- * // 获取北参堂icon和title
- * 首页金刚区
- */
- HOME_QUICK_LINK = `/api/common/home_quick_link`,
- // 积分通兑产品
- ENTROPY_PRODUCT_LIST = '/api/entropy/product_lst',
- // 帮助中心分类
- ARTICLE_CATEGORY_LIST = '/api/article/category/lst/19',
- // 文章列表
- ARTICLE_LIST = '/api/article/lst',
- // 文章详情
- ARTICLE_DETAIL = '/api/article/detail',
- // 系统公告
- NOTICE_LIST = '/api/notice/list',
- // 注销接口
- USER_LOGOUT = '/gateway/userCenter_service/userCenterService/userLogout',
- // 上传图片
- UPLOAD_IMAGE_FIELD = '/api/upload/image/field',
- // 意见反馈-类型
- FEEDBACK_TYPE_NEW = '/api/common/feedback_type_new',
- // 意见反馈提交
- FEEDBACK = '/api/user/feedback'
- }
- /**
- * 添加反馈
- * @param params
- */
- export function createFeedback(params: FeedbackRequestModel) {
- return defHttp.post({
- url: API.FEEDBACK,
- data: {
- ...params
- }
- })
- }
- export function getFeedbackType() {
- return defHttp.get({
- url: API.FEEDBACK_TYPE_NEW,
- })
- }
- /**
- * 注销账号
- * @param phone
- */
- export function closeAccount(phone: string) {
- return defHttp.post({
- url: API.USER_LOGOUT,
- })
- }
- export function getLocal() {
- uni.showModal({
- title: '提示',
- content: '为了您更好的体验,请同意授权位置',
- success: (res) => {
- if (res.confirm) {
- // uni.getLocation({
- // type: 'wgs84',
- // success(res) {
- // uni.setStorageSync(USER_LATITUDE, res.latitude)
- // uni.setStorageSync(USER_LONGITUDE, res.longitude)
- // getRegeo(res.latitude, res.longitude);
- // }
- // })
- amap.getWxLocation(async (loc) => {
- // 获取地址描述数据
- const regeoRes = await amap.getRegeo({location: loc});
- console.log(regeoRes.data.regeocode.addressComponent)
- })
- }
- }
- })
- }
- export async function getRegeo(latitude: number, longitude: number) {
- // amapPlugin.getRegeo
- const regeoRes = await amap.getRegeo({
- location: '' + longitude + ',' + latitude + '',
- })
- console.log(regeoRes.data.regeocode.addressComponent.city)
- }
- /**
- * 获取积分通兑产品列表
- */
- export function getEntropyProductList(params: IntegralProductParams): Promise<Array<IntegralProductModel>> {
- return defHttp.get({
- url: API.ENTROPY_PRODUCT_LIST,
- data: {
- ...params
- }
- })
- }
- /**
- * 获取帮助中心分类
- */
- export function getArticleCategory(): Promise<ArticleCategoryModel[]> {
- return defHttp.get({
- url: API.ARTICLE_CATEGORY_LIST,
- }, {withToken: false})
- }
- /**
- * 文章列表
- */
- export function getArticleList(article_category_id: string): Promise<ArticleResult> {
- return defHttp.get({
- url: `${API.ARTICLE_LIST}/${article_category_id}`,
- }, {withToken: false})
- }
- export function getArticleDetail(article_id: string): Promise<ArticleModel> {
- return defHttp.get({
- url: `${API.ARTICLE_DETAIL}/${article_id}`,
- }, {withToken: false})
- }
- /**
- * 首页金刚区
- */
- export function getHomeQuickLink(): Promise<Array<HomeQuickLinkModel>> {
- return defHttp.get({
- url: `${API.HOME_QUICK_LINK}`
- })
- }
- export function getNoticeList(): Promise<AnnouncementResult> {
- return defHttp.get({
- url: `${API.NOTICE_LIST}`
- })
- }
|