zqwang 2 vuotta sitten
vanhempi
commit
70748697bf

+ 2 - 6
src/api/config.js

@@ -1,9 +1,5 @@
-/*
- * @Author: ZhengXiaowei
- * @Date: 2019-10-15 12:06:24
- * @LastEditors: ZhengXiaowei
- * @LastEditTime: 2019-10-15 14:11:17
- * @Description: api配置文件
+/***
+ * api 配置文件
  */
 const apiConfig = {
   baseURL: 'https://quickapp.leyuee.com/api',

+ 0 - 11
src/api/fly.js

@@ -1,10 +1,3 @@
-/*
- * @Author: ZhengXiaowei
- * @Date: 2019-10-15 12:06:28
- * @LastEditors: ZhengXiaowei
- * @LastEditTime: 2019-10-15 14:32:19
- * @Description: api 配置入口
- */
 import fetch from "@system.fetch";
 import Fly from "flyio/dist/npm/hap";
 import apiConfig from "./config";
@@ -84,9 +77,7 @@ fly.interceptors.response.use(
     } else if (res.data.code === 10023 || res.data.code === 10001) {
       // token失效
       await clearToken();
-      console.log("begin refresh token");
       let refresh_token = await getToken();
-      console.log("refresh token:", refresh_token);
       return fly(res.config);
 
     } else if (res.data.code === 10028) {
@@ -95,12 +86,10 @@ fly.interceptors.response.use(
       prompt.showToast({
         message: res.data.msg
       })
-      // it.errBackTo();
       return Promise.reject(res);
     }
   },
   err => {
-    console.log('err', err)
     return Promise.reject(err);
   }
 );

+ 15 - 29
src/api/index.js

@@ -1,26 +1,22 @@
 /*
- * @Author: ZhengXiaowei
- * @Date: 2019-10-15 14:05:33
- * @LastEditors: ZhengXiaowei
- * @LastEditTime: 2019-10-15 14:05:59
+ *  接口对接文件
  * @Description: api
  */
 import fly from './fly'
 
 // 获取首页数据
-export const getHomeList = sex => {
-  console.log(sex)
+export const getHomeData = sex => {
   return fly.get(`/books/${sex}/index`)
 }
 
 //充值记录
-export const rechargeApi = params => {
+export const rechargeRecord = params => {
   return fly.get('/order/chargeRecordLists', params)
 }
 
 // 获取分类
-export const getCategory = () => {
-  return fly.get('/books/getCategory')
+export const bookCategory = () => {
+  return fly.get('/books/bookCategory')
 }
 
 // 获取书库
@@ -29,7 +25,7 @@ export const booksList = params => {
 }
 
 // 获取图书详情
-export const getBooksInfo = bid => {
+export const booksInfo = bid => {
   return fly.get(`/book/${bid}`)
 }
 
@@ -42,11 +38,11 @@ export const getSimilarBooks = (category_id, bid) => {
 }
 
 //获取章节消费记录
-export const chapterApi = params => {
+export const chapterPayRecord = params => {
   return fly.get('/order/chapterOrderList', params)
 }
 //获取全本消费记录
-export const bookApi = params => {
+export const bookPayRecord = params => {
   return fly.get('/order/bookOrderList', params)
 }
 
@@ -66,12 +62,12 @@ export const getChargeList = () => {
 }
 
 // 添加书籍进书架
-export const postUserShelfBooks = params => {
+export const addToShelfBooks = params => {
   return fly.post(`/userShelfBooks`, params)
 }
 
 // 获取书架数据
-export const getUserShelfBooks = () => {
+export const userShelfBooks = () => {
   return fly.get(`/userShelfBooks`)
 }
 
@@ -100,7 +96,7 @@ export const deleteShelfBook = params => {
 }
 
 // 充值h5
-export const getConfigOfWxH5Pay = params => {
+export const wxH5Pay = params => {
   return fly.get('/goToH5Pay', params)
 }
 
@@ -110,7 +106,7 @@ export const getConfigOfWxAppPay = params => {
 }
 
 // 支付宝充值
-export const getConfigOfAliPay = params => {
+export const qappAliPay  = params => {
   return fly.get('/goToAliPay', params)
 }
 
@@ -205,13 +201,13 @@ export const getRank = sex => {
 }
 
 //获取活动详情
-export const getAcitivity = token => {
+export const acitivityDetail = token => {
   return fly.get('/activity/detail', { token: token })
 }
 
 //获取热词
 
-export const getHotMain = pages => {
+export const hotWords = pages => {
   return fly.get('/books/hotwords', { page: pages })
 }
 
@@ -230,11 +226,6 @@ export const logOff = () => {
   return fly.get(`user/logOff`)
 }
 
-//腾讯广告书籍替换
-export const noAdvBookInfo = (send_order_id) => {
-  return fly.get(`/txAdqNew/noAdvBookInfo`, { send_order_id: send_order_id })
-}
-
 //阅读返回书籍推荐
 export const recommendBooks = (bid) => {
   return fly.get(`/books/recommend_books`, { bid: bid })
@@ -261,7 +252,7 @@ export const advertOrders = (order) => {
 }
 
 // 获取轮播图弹窗参数 1为男频,2为女频,3为书架,4为弹窗,5为充值页返回广告
-export const getBannerData = (release_type) => {
+export const bannerData = (release_type) => {
   return fly.get(`/books/recommendBanners`, { release_type: release_type })
 }
 
@@ -270,10 +261,6 @@ export const checkAdvertisement = (type, id) => {
   return fly.get(`/books/checkAdvertisement`, { type: type, ids: id })
 }
 
-// 广告替换书籍
-export const advReplaceBookInfo = (send_order_id) => {
-  return fly.get("advReplaceBookInfo", { send_order_id: send_order_id });
-}
 
 // 是否有可领取任务(包括未签到)
 /**
@@ -286,7 +273,6 @@ export const hasPendingTask = (params) => {
 }
 
 
-
 // ip 屏蔽或书籍屏蔽后的替换书籍获取
 export const advShield= (send_order_id, platform,checkout_tx) => {
   return fly.get("sendOrder/advShield", { send_order_id: send_order_id,platform:platform,checkout_tx,checkout_tx});

+ 1 - 9
src/api/utils.js

@@ -18,7 +18,6 @@ export const getToken = async () => {
   if (!token) token = (await storage.get({ key: "token" })).data;
   // token格式化
   if (token && typeof token === "string") token = JSON.parse(token);
-  console.log("checkToken", checkToken(token));
   if (!token) getToken.promise = login();
   else if (checkToken(token)) return Promise.resolve(token.token);
   else {
@@ -105,24 +104,18 @@ const refreshToken = () => {
       return r;
     })
     .catch(e => {
-      console.log(e);
-      console.error("刷新token失败");
       return Promise.reject(e);
     });
 };
 
 // 检查token的有效期
 const checkToken = t => {
-  console.log("current timestamp: ", new Date().getTime());
-  console.log("token timestamp: ", t.time);
-  console.log("check time:", new Date().getTime() < t.time)
   return new Date().getTime() < t.time;
 };
 
 // 设置token
 const setToken = async t => {
   token = formatToken(t);
-  await storage.set({ key: "token", value: token });
   return t.token;
 };
 
@@ -130,7 +123,6 @@ const setToken = async t => {
 export const clearToken = async () => {
   token = null;
   await storage.delete({ key: "token" });
-  console.log("clear token done");
 };
 
 // 处理token的格式
@@ -232,7 +224,7 @@ export const getSendOrderId = (fn) => {
       fn && fn(data);
     },
     fail: (data, code) => {
-      console.log(`handling fail, code = ${code}`)
+     
     }
   })
 }

+ 3 - 24
src/helper/index.js

@@ -1,7 +1,7 @@
 
 import wxpay from '@service.wxpay';
 import alipay from '@service.alipay';
-import { getConfigOfWxH5Pay, getConfigOfWxAppPay, getConfigOfAliPay } from "../api";
+import { wxH5Pay, getConfigOfWxAppPay, qappAliPay  } from "../api";
 
 export const pageLoad = (meta, fn, params) => {
   return new Promise(async (resolve, reject) => {
@@ -18,35 +18,14 @@ export const pageLoad = (meta, fn, params) => {
 }
 // 支付配置
 export const configWxPay = async (params) => {
-  //let payType = wxpay.getType();
   let ret = await useWxH5Pay(params);;
-
-  // return;
-  /* switch (payType) {
-    case "APP":
-      try {
-        ret = await useWxAppPay(params);
-      } catch (e) {
-        ret = e;
-      };
-      break;
-    case "MWEB":
-      try {
-        ret = await useWxH5Pay(params);
-      } catch (e) {
-        ret = e;
-      };
-      break;
-    default: ret = "app not install or wx pay is not avaliable";
-  } */
-
   return ret;
 }
 
 // h5支付
 let useWxH5Pay = (params) => {
   return new Promise(async (resolve, reject) => {
-    let config = await getConfigOfWxH5Pay(params);
+    let config = await wxH5Pay(params);
     let extra = {
       mweb_url: config.mweb_url + "&redirect_url=" + encodeURIComponent("https://quickapp.leyuee.com/testp")
     }
@@ -100,7 +79,7 @@ let useWxAppPay = (params) => {
 // 配置支付宝支付
 export const configAliPay = (params) => {
   return new Promise(async (resolve) => {
-    let orderInfo = await getConfigOfAliPay(params);
+    let orderInfo = await qappAliPay (params);
     alipay.pay({
       orderInfo: orderInfo.order_info,
       callback: (ret) => {

+ 2 - 2
src/views/Activity/index.ux

@@ -119,7 +119,7 @@
   import it from '../../helper/interface.js'
 import { configWxPay, configAliPay } from '../../helper'
 import {
-  getAcitivity,
+  acitivityDetail,
   getUserInfo,
   checkWxOrder,
   advertOrders,
@@ -170,7 +170,7 @@ export default {
     this.showPay = false
   },
   async getAcitvy() {
-    let activity = await getAcitivity(this.token)
+    let activity = await acitivityDetail(this.token)
     this.activity = activity
     this.currentProduct = this.activity.products[0]
   },

+ 4 - 4
src/views/Category/index.ux

@@ -75,7 +75,7 @@
 </template>
 
 <script>
-import { getCategory, booksList } from '../../api'
+import { bookCategory, booksList } from '../../api'
 import { pageLoad } from '../../helper'
 import storage from '@system.storage'
 import router from '@system.router'
@@ -114,8 +114,8 @@ export default {
     // 请求更多数据
     this.getBooksList()
   },
-  async getCategory() {
-    this.category = this.initCategory(await getCategory())
+  async bookCategory() {
+    this.category = this.initCategory(await bookCategory())
     console.log("this.category:", this.category);
     await this.initChannel(this.category)
     this.getBooksList()
@@ -184,7 +184,7 @@ export default {
   },
 
   onInit() {
-    this.getCategory()
+    this.bookCategory()
   }
 }
 </script>

+ 3 - 3
src/views/Consume/index.ux

@@ -41,7 +41,7 @@
 </template>
 
 <script>
-import { chapterApi, bookApi } from "../../api/index";
+import { chapterPayRecord, bookPayRecord } from "../../api/index";
 export default {
   private: {
     curTab: 0,
@@ -70,7 +70,7 @@ export default {
     this.getOrderChapter();
   },
   async getOrderChapter(page = 1, page_size = 10) {
-    let res = await chapterApi({ page: page, page_size });
+    let res = await chapterPayRecord({ page: page, page_size });
     let { list, meta } = res;
     let pages = { total: meta.last_page, current: meta.current_page };
     this.chapter = { ...this.chapter, list, page: pages };
@@ -78,7 +78,7 @@ export default {
       this.$element('consume').scrollTo({ index: 0 })
   },
   async getOrderBook(page = 1, page_size = 10) {
-    let res = await bookApi({ page: page, page_size });
+    let res = await bookPayRecord({ page: page, page_size });
     let { list, meta } = res;
     let pages = { total: meta.last_page, current: meta.current_page };
     this.book = { ...this.book, list, page: pages };

+ 6 - 6
src/views/Detail/index.ux

@@ -82,7 +82,7 @@
 </template>
 
 <script>
-import { getBooksInfo, getShortCatalog, getSimilarBooks, postUserShelfBooks } from "../../api";
+import { booksInfo, getShortCatalog, getSimilarBooks, addToShelfBooks } from "../../api";
 import router from '@system.router';
 import prompt from '@system.prompt';
 import storage from "@system.storage";
@@ -108,7 +108,7 @@ export default {
   },
   async addShelf() {
     if (!this.book.is_on_user_shelf) {
-      let ret = await postUserShelfBooks({ bid: this.bid });
+      let ret = await addToShelfBooks({ bid: this.bid });
       if (ret) this.book.is_on_user_shelf = 1, prompt.showToast({ message: "添加成功" });
     }
   },
@@ -145,18 +145,18 @@ export default {
     if (words > 10000) return (words / 10000).toFixed(2) + "万字";
     else return words + "字";
   },
-  async getBooksInfo(bid) {
-    this.book = await getBooksInfo(bid);
+  async booksInfo(bid) {
+    this.book = await booksInfo(bid);
     this.chapters = await getShortCatalog(bid);
     this.similar = await getSimilarBooks(this.book.book_category_id, bid);
   },
   onShow() {
     console.log("book bid", this.bid);
-    this.getBooksInfo(this.bid);
+    this.booksInfo(this.bid);
   },
   async onInit() {
     console.log("book bid", this.bid);
-    // this.getBooksInfo(this.bid);
+    // this.booksInfo(this.bid);
     if (this.push_id) {
       await storage.set({ key: "push_id", value: this.push_id });
     }

+ 3 - 3
src/views/Home/index.ux

@@ -101,7 +101,7 @@
 </template>
 
 <script>
-import { getHomeList , getBannerData,checkAdvertisement} from '../../api'
+import { getHomeData , bannerData,checkAdvertisement} from '../../api'
 
 import storage from '@system.storage'
 import router from '@system.router'
@@ -205,9 +205,9 @@ export default {
   async getCityListByTabChange(index = 1) {
    await storage.set({ key: 'sex', value: index || 0 })
     let sex = index ? 'female' : 'male'
-    let ret = await getHomeList(sex)
+    let ret = await getHomeData(sex)
     this.list = ret.slice(1)
-    let banner = await getBannerData(sex == "female" ? 2 : 1);
+    let banner = await bannerData(sex == "female" ? 2 : 1);
     this.banner = banner;
   }
 }

+ 2 - 2
src/views/Pay/index.ux

@@ -111,7 +111,7 @@ import {
   getUserInfo,
   checkWxOrder,
   advertOrders,
-  getBannerData,
+  bannerData,
   hasPendingTask
 } from '../../api'
 import { configWxPay, configAliPay } from '../../helper'
@@ -414,7 +414,7 @@ export default {
     return true
   },
   async getActivity() {
-    let back = await getBannerData(5)
+    let back = await bannerData(5)
     if (JSON.stringify(back) === '{}') {
       let taht = this
       if (this.isPendingTask) {

+ 3 - 13
src/views/Reader/index.ux

@@ -89,7 +89,7 @@ import router from "@system.router";
 import storage from '@system.storage';
 import pkg from '@system.package'
 import it from "../../helper/interface.js";
-import { getChapters, getIsonshelf, postUserShelfBooks, chapterOrders, userAddDsktop, noAdvBookInfo, recommendBooks, advReplaceBookInfo } from "../../api";
+import { getChapters, getIsonshelf, addToShelfBooks, chapterOrders, userAddDsktop,recommendBooks } from "../../api";
 import { getAppConfig } from '../../api/utils.js';
 let getConfig;
 export default {
@@ -229,17 +229,7 @@ export default {
       } 
 
     } 
-    // else {
-    //   //  如果书籍id为派单书籍id则检测是否需要替换书籍
-    //   if (this.send_order_id > 0 && this.ad_bid == this.bid) {
-    //     let realBook = await advReplaceBookInfo(this.send_order_id);
-    //     // let realBook = {};
-    //     if (realBook && realBook.bid && realBook.bid && realBook.cid) {
-    //       this.bid = realBook.bid;
-    //       this.chapter_id = realBook.cid;
-    //     }
-    //   }
-    // }
+
 
     /* let s = (await storage.get({ key: "send_order_id" })).data;
     console.log("save send_order_id in storage");
@@ -368,7 +358,7 @@ export default {
   addShelf() {
     console.log("add shelf");
     getIsonshelf({ bid: this.bid }).then(r => {
-      r.is_on ? '' : postUserShelfBooks({ bid: this.bid })
+      r.is_on ? '' : addToShelfBooks({ bid: this.bid })
     })
   },
   shortEnd(value) {

+ 2 - 2
src/views/Recharge/index.ux

@@ -39,7 +39,7 @@
 
 <script>
 import router from "@system.router";
-import { rechargeApi, getUserInfo } from "../../api/index";
+import { rechargeRecord, getUserInfo } from "../../api/index";
 export default {
   private: {
     rechargeList: [],
@@ -58,7 +58,7 @@ export default {
     this.user = user;
   },
   async getOrder(page = 1, page_size = 10) {
-    let res = await rechargeApi({ page: page, page_size });
+    let res = await rechargeRecord({ page: page, page_size });
     let { list, meta } = res;
     this.rechargeList = list;
     this.page = {

+ 2 - 2
src/views/Search/index.ux

@@ -84,7 +84,7 @@
   </div>
 </template>
 <script>
-import { booksList, getHotMain, getUserInfo } from "../../api";
+import { booksList, hotWords, getUserInfo } from "../../api";
 import { pageLoad } from "../../helper";
 import storage from '@system.storage';
 import prompt from '@system.prompt';
@@ -131,7 +131,7 @@ export default {
 	},
 	async getData(page = 1) {
 
-		let data = await getHotMain(page);
+		let data = await hotWords(page);
 		this.hotlist = data.list;
 		this.meta = data.meta;
 	},

+ 7 - 7
src/views/Shelf/index.ux

@@ -138,7 +138,7 @@
 </template>
 
 <script>
-import { getUserShelfBooks, deleteShelfBook, getReadrecord } from '../../api'
+import { userShelfBooks, deleteShelfBook, getReadrecord } from '../../api'
 import router from '@system.router'
 export default {
   props: {
@@ -171,7 +171,7 @@ export default {
     }
   },
   onInit() {
-    this.getUserShelfBooks();
+    this.userShelfBooks();
     this.$watch('isDelMode', 'listenMode')
     this.$watch('tabindex', 'watchPropsChange')
     this.$on('refreshData', this.broadevt);
@@ -180,15 +180,15 @@ export default {
   },
   watchPropsChange(newV, oldV) {
     if (newV == 0) {
-      this.getUserShelfBooks()
+      this.userShelfBooks()
     }
   },
   broadevt(evt) {
     if (evt.detail.current == 1) {
-      this.getUserShelfBooks()
+      this.userShelfBooks()
     }
   },
-  getUserShelfBooks(isDel = false) {
+  userShelfBooks(isDel = false) {
     getReadrecord().then(r => {
       if (!isDel) {
         this.isDelMode = false
@@ -212,13 +212,13 @@ export default {
   },
   deleteBook(book) {
     deleteShelfBook({ bid: book.book_id }).then(r => {
-      this.getUserShelfBooks(true);
+      this.userShelfBooks(true);
       Object.keys(this.firstBook) === 0 ? this.isNull = true : this.isNull = false;
     });
   },
   changeMode() {
     this.isDelMode = !this.isDelMode;
-    this.getUserShelfBooks(true)
+    this.userShelfBooks(true)
   },
   listenMode(v) {
     this.modeText = v ? '' : '管理'