123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338 |
- import Taro from "@tarojs/taro";
- import indexStore from "@src/store/index";
- import { setApp } from "@src/config";
- /**
- * 获取小程序组件配置列表
- * */
- // export function getAppComponent() {
- // return new Promise(async (resolve, reject) => {
- // try {
- // // 初始化
- // Taro.request({
- // url: '/app/appComponent/list',
- // method: 'GET',
- // success: (res) => {
- // resolve(res)
- // },
- // fail: (err) => {
- // reject(err);
- // }
- // })
- // } catch (error) {
- // reject(error);
- // }
- // })
- // }
- /**
- * 获取短篇首页banners列表
- * */
- export function getShortBanners(workDirection) {
- return new Promise(async (resolve, reject) => {
- try {
- // 初始化
- Taro.request({
- url: '/app/appComponent/getBanners',
- method: 'GET',
- data: { workDirection },
- success: (res) => {
- if(JSON.stringify(indexStore.indexBanners) !== JSON.stringify(res.data.data)){
- indexStore.setData({ indexBanners: res.data.data })
- }
- resolve(res)
- },
- fail: (err) => {
- reject(err);
- }
- })
- } catch (error) {
- reject(error);
- }
- })
- }
- /**
- * 获取短篇首页热门分类列表
- * */
- export function getShortHotCategory(workDirection) {
- return new Promise(async (resolve, reject) => {
- try {
- // 初始化
- Taro.request({
- url: '/app/appComponent/getHotCategory',
- method: 'GET',
- data: { workDirection },
- success: (res) => {
- if(JSON.stringify(indexStore.indexHotCategory) !== JSON.stringify(res.data.data)){
- indexStore.setData({ indexHotCategory: res.data.data })
- }
- resolve(res)
- },
- fail: (err) => {
- reject(err);
- }
- })
- } catch (error) {
- reject(error);
- }
- })
- }
- /**
- * 获取重磅新书
- * */
- export function getShortNewBooks(workDirection) {
- return new Promise(async (resolve, reject) => {
- try {
- // 初始化
- Taro.request({
- url: '/app/appComponent/getNewBooks',
- method: 'GET',
- data: { workDirection },
- success: (res) => {
- if(JSON.stringify(indexStore.indexNewBooks) !== JSON.stringify(res.data.data)){
- indexStore.setData({ indexNewBooks: res.data.data })
- }
- resolve(res)
- },
- fail: (err) => {
- reject(err);
- }
- })
- } catch (error) {
- reject(error);
- }
- })
- }
- /**
- * 获取热门推荐
- * */
- export function getShortHotRec(workDirection) {
- return new Promise(async (resolve, reject) => {
- try {
- // 初始化
- Taro.request({
- url: '/app/appComponent/getHotRec',
- method: 'GET',
- data: { workDirection },
- success: (res) => {
- if(JSON.stringify(indexStore.indexHotRec) !== JSON.stringify(res.data.data)){
- indexStore.setData({ indexHotRec: res.data.data })
- }
- resolve(res)
- },
- fail: (err) => {
- reject(err);
- }
- })
- } catch (error) {
- reject(error);
- }
- })
- }
- /**
- * 获取口碑佳作
- * */
- export function getShortBestReviews(workDirection) {
- return new Promise(async (resolve, reject) => {
- try {
- // 初始化
- Taro.request({
- url: '/app/appComponent/getBestReviews',
- method: 'GET',
- data: { workDirection },
- success: (res) => {
- if(JSON.stringify(indexStore.indexBestReviews) !== JSON.stringify(res.data.data)){
- indexStore.setData({ indexBestReviews: res.data.data })
- }
- resolve(res)
- },
- fail: (err) => {
- reject(err);
- }
- })
- } catch (error) {
- reject(error);
- }
- })
- }
- /**
- * 获取经典热书
- * */
- export function getShortClassicBooks(workDirection) {
- return new Promise(async (resolve, reject) => {
- try {
- // 初始化
- Taro.request({
- url: '/app/appComponent/getClassicBooks',
- method: 'GET',
- data: { workDirection },
- success: (res) => {
- if(JSON.stringify(indexStore.indexClassicBooks) !== JSON.stringify(res.data.data)){
- indexStore.setData({ indexClassicBooks: res.data.data })
- }
- resolve(res)
- },
- fail: (err) => {
- reject(err);
- }
- })
- } catch (error) {
- reject(error);
- }
- })
- }
- /**
- * 获取必看
- * */
- export function getShortBestBooks(workDirection) {
- return new Promise(async (resolve, reject) => {
- try {
- // 初始化
- Taro.request({
- url: '/app/appComponent/getBestBooks',
- method: 'GET',
- data: { workDirection },
- success: (res) => {
- if(JSON.stringify(indexStore.indexBestBooks) !== JSON.stringify(res.data.data)){
- indexStore.setData({ indexBestBooks: res.data.data })
- }
- resolve(res)
- },
- fail: (err) => {
- reject(err);
- }
- })
- } catch (error) {
- reject(error);
- }
- })
- }
- /**
- * 猜你喜欢
- * */
- export function getShortGuessLike(data) {
- return new Promise(async (resolve, reject) => {
- try {
- // 初始化
- Taro.request({
- url: '/app/appComponent/getGuessLike',
- method: 'GET',
- data,
- success: (res) => {
- if(JSON.stringify(indexStore.indexGuessLike) !== JSON.stringify(res.data.data)){
- indexStore.setData({ indexGuessLike: res.data.data })
- }
- resolve(res)
- },
- fail: (err) => {
- reject(err);
- }
- })
- } catch (error) {
- reject(error);
- }
- })
- }
- /**
- /**
- *获取短篇首页热门书籍列表
- * */
- export function getShortHotBooks(workDirection) {
- return new Promise(async (resolve, reject) => {
- try {
- // 初始化
- Taro.request({
- url: '/app/appComponent/getHotBooks',
- method: 'GET',
- data: { workDirection },
- success: (res) => {
- if(JSON.stringify(indexStore.indexHotBooks) !== JSON.stringify(res.data.data)){
- indexStore.setData({ indexHotBooks: res.data.data })
- }
- resolve(res)
- },
- fail: (err) => {
- reject(err);
- }
- })
- } catch (error) {
- reject(error);
- }
- })
- }
- /**
- * 获取充值模板配置
- * */
- export function getRechargeTemplate() {
- return new Promise(async (resolve, reject) => {
- try {
- // 初始化
- Taro.request({
- url: '/app/rechargeTemplate/getInfo',
- method: 'GET',
- success: (res) => {
- indexStore.setData({ rechargeTemplate: res.data.data })
- resolve(res)
- },
- fail: (err) => {
- reject(err);
- }
- })
- } catch (error) {
- reject(error);
- }
- })
- }
- /**
- * 获取枚举
- * */
- export function enumDictList() {
- return new Promise(async (resolve, reject) => {
- try {
- // 初始化
- Taro.request({
- url: '/app/enumDict/list',
- method: 'GET',
- success: (res) => {
- let enumList = {}
- Object.values(res.data?.data?.enums).map((item: any) => {
- enumList[item.name] = item
- })
- setApp({ enumDictList: enumList })
- resolve(res)
- },
- fail: (err) => {
- reject(err);
- }
- })
- } catch (error) {
- reject(error);
- }
- })
- }
- /**
- * 分享信息获取
- * @param path 路径
- */
- export function getShareInfo(pagePath:string) {
- return new Promise(async (resolve, reject) => {
- try {
- // 初始化
- Taro.request({
- url: '/app/appPage/getShareInfo',
- method: 'GET',
- data:{pagePath},
- success: (res) => {
- resolve(res)
- },
- fail: (err) => {
- reject(err);
- }
- })
- } catch (error) {
- reject(error);
- }
- })
- }
|