common.ts 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. import {defHttp} from '~/utils/http'
  2. import {USER_LATITUDE, USER_LONGITUDE} from "~/constants";
  3. import AmapWx from "~/libs/amap-wx";
  4. import type {ArticleCategoryModel, ArticleModel, ArticleResult} from "~/apis/model/articleModel";
  5. import type {HomeQuickLinkModel} from "~/apis/model/common.model";
  6. import type {IntegralProductModel, IntegralProductParams} from "~/apis/model/integral.model";
  7. import type {AnnouncementResult} from "~/apis/model/announcement.model";
  8. import type {FeedbackRequestModel} from "~/apis/model/feedback.model";
  9. // import {a} from "unocss-preset-weapp/dist/utilities-46c43da7";
  10. // 引入
  11. // import amap from '~/libs/amap-wx.130.js';
  12. // let amapPlugin = new amap.AMapWX({
  13. // key: "e42681aed12886436ed44d6c28aa22c8"
  14. // });
  15. const amap = AmapWx.getInstance({key: "e42681aed12886436ed44d6c28aa22c8"});
  16. enum API {
  17. /**
  18. * // 获取北参堂icon和title
  19. * 首页金刚区
  20. */
  21. HOME_QUICK_LINK = `/api/common/home_quick_link`,
  22. // 积分通兑产品
  23. ENTROPY_PRODUCT_LIST = '/api/entropy/product_lst',
  24. // 帮助中心分类
  25. ARTICLE_CATEGORY_LIST = '/api/article/category/lst/19',
  26. // 文章列表
  27. ARTICLE_LIST = '/api/article/lst',
  28. // 文章详情
  29. ARTICLE_DETAIL = '/api/article/detail',
  30. // 系统公告
  31. NOTICE_LIST = '/api/notice/list',
  32. // 注销接口
  33. USER_LOGOUT = '/gateway/userCenter_service/userCenterService/userLogout',
  34. // 上传图片
  35. UPLOAD_IMAGE_FIELD = '/api/upload/image/field',
  36. // 意见反馈-类型
  37. FEEDBACK_TYPE_NEW = '/api/common/feedback_type_new',
  38. // 意见反馈提交
  39. FEEDBACK = '/api/user/feedback'
  40. }
  41. /**
  42. * 添加反馈
  43. * @param params
  44. */
  45. export function createFeedback(params: FeedbackRequestModel) {
  46. return defHttp.post({
  47. url: API.FEEDBACK,
  48. data: {
  49. ...params
  50. }
  51. })
  52. }
  53. export function getFeedbackType() {
  54. return defHttp.get({
  55. url: API.FEEDBACK_TYPE_NEW,
  56. })
  57. }
  58. /**
  59. * 注销账号
  60. * @param phone
  61. */
  62. export function closeAccount(phone: string) {
  63. return defHttp.post({
  64. url: API.USER_LOGOUT,
  65. })
  66. }
  67. export function getLocal() {
  68. uni.showModal({
  69. title: '提示',
  70. content: '为了您更好的体验,请同意授权位置',
  71. success: (res) => {
  72. if (res.confirm) {
  73. // uni.getLocation({
  74. // type: 'wgs84',
  75. // success(res) {
  76. // uni.setStorageSync(USER_LATITUDE, res.latitude)
  77. // uni.setStorageSync(USER_LONGITUDE, res.longitude)
  78. // getRegeo(res.latitude, res.longitude);
  79. // }
  80. // })
  81. amap.getWxLocation(async (loc) => {
  82. // 获取地址描述数据
  83. const regeoRes = await amap.getRegeo({location: loc});
  84. console.log(regeoRes.data.regeocode.addressComponent)
  85. })
  86. }
  87. }
  88. })
  89. }
  90. export async function getRegeo(latitude: number, longitude: number) {
  91. // amapPlugin.getRegeo
  92. const regeoRes = await amap.getRegeo({
  93. location: '' + longitude + ',' + latitude + '',
  94. })
  95. console.log(regeoRes.data.regeocode.addressComponent.city)
  96. }
  97. /**
  98. * 获取积分通兑产品列表
  99. */
  100. export function getEntropyProductList(params: IntegralProductParams): Promise<Array<IntegralProductModel>> {
  101. return defHttp.get({
  102. url: API.ENTROPY_PRODUCT_LIST,
  103. data: {
  104. ...params
  105. }
  106. })
  107. }
  108. /**
  109. * 获取帮助中心分类
  110. */
  111. export function getArticleCategory(): Promise<ArticleCategoryModel[]> {
  112. return defHttp.get({
  113. url: API.ARTICLE_CATEGORY_LIST,
  114. }, {withToken: false})
  115. }
  116. /**
  117. * 文章列表
  118. */
  119. export function getArticleList(article_category_id: string): Promise<ArticleResult> {
  120. return defHttp.get({
  121. url: `${API.ARTICLE_LIST}/${article_category_id}`,
  122. }, {withToken: false})
  123. }
  124. export function getArticleDetail(article_id: string): Promise<ArticleModel> {
  125. return defHttp.get({
  126. url: `${API.ARTICLE_DETAIL}/${article_id}`,
  127. }, {withToken: false})
  128. }
  129. /**
  130. * 首页金刚区
  131. */
  132. export function getHomeQuickLink(): Promise<Array<HomeQuickLinkModel>> {
  133. return defHttp.get({
  134. url: `${API.HOME_QUICK_LINK}`
  135. })
  136. }
  137. export function getNoticeList(): Promise<AnnouncementResult> {
  138. return defHttp.get({
  139. url: `${API.NOTICE_LIST}`
  140. })
  141. }