Zhengxiaowei 5 роки тому
батько
коміт
6c05571e83

+ 21 - 10
src/api/fly.js

@@ -8,41 +8,52 @@
 import fetch from "@system.fetch";
 import Fly from "flyio/dist/npm/hap";
 import apiConfig from "./config";
+import prompt from '@system.prompt';
 import { getToken, clearToken } from "./utils";
 
 var fly = new Fly(fetch);
-
+var qs = require('qs');
 fly.config.baseURL = apiConfig.baseURL;
-fly.config.headers["Content-Type"] = "application/x-www-form-urlencoded;charset=utf-8";
+fly.config.headers["Content-Type"] =
+  "application/x-www-form-urlencoded;charset=utf-8";
 
-const filterNoToken = ["/login"]
+const filterNoToken = ["/login"];
 
 fly.interceptors.request.use(async config => {
-  // 过滤一些不需要登录的路由
+  // 过滤一些不需要登录的路由d
   if (filterNoToken.indexOf(config.url) === -1) {
-    console.log(config);
     let token = await getToken();
     if (config.headers) config.headers.Authorization = token;
     else config.headers = { Authorization: token };
+    if (config.method === "POST") {
+      config.body=qs.stringify(config.body);
+    } 
+    console.log('请求开始!',config);
     return config;
   } else return config;
-})
+});
 
 fly.interceptors.response.use(
   res => {
+    console.log('响应开始',res);
     if (!res.data.code) {
-      return res.data.data
+      return res.data.data;
     } else if (res.data.code === 10023) {
       // token失效
       clearToken();
       return getToken().then(token => {
-        return r(res.config)
+        return r(res.config);
+      });
+    } 
+    else {
+      prompt.showToast({
+        message: res.data.msg
       })
-    } else {
-      return Promise.reject(res)
+      return Promise.reject(res);
     }
   },
   err => {
+    console.log('err',err)
     return Promise.reject(err);
   }
 );

+ 61 - 23
src/api/index.js

@@ -6,76 +6,99 @@
  * @Description: api
  */
 import fly from "./fly";
-import webview from '@system.webview';
 
 // 获取首页数据
-export const getHomeList = (sex) => {
+export const getHomeList = sex => {
   console.log(sex);
   return fly.get(`/books/${sex}/index`);
 };
 
-
 //充值记录
-export const rechargeApi = (params) => {
+export const rechargeApi = params => {
   return fly.get("/order/chargeRecordLists", params);
 };
 
-
 // 获取分类
 export const getCategory = () => {
   return fly.get("/books/getCategory");
-}
+};
 
 // 获取书库
-export const getBooksList = (params) => {
+export const getBooksList = params => {
   return fly.get("/books/library", params);
-}
+};
 
 // 获取图书详情
-export const getBooksInfo = (bid) => {
+export const getBooksInfo = bid => {
   return fly.get(`/book/${bid}`);
-}
+};
 
 // 获取详情页相似数据
 export const getSimilarBooks = (category_id, bid) => {
   return fly.get("/books/similar", {
     category_id,
     bid
-  })
-}
+  });
+};
 
 //获取章节消费记录
-export const chapterApi = (params) => {
+export const chapterApi = params => {
   return fly.get("/order/chapterOrderList", params);
 };
 //获取全本消费记录
-export const bookApi = (params) => {
+export const bookApi = params => {
   return fly.get("/order/bookOrderList", params);
 };
 
-
 // 获取详情页中的目录
-export const getShortCatalog = (bid) => {
-  return fly.get(`/books/${bid}/catalog`, {
-    page_size: 10,
-    page: 1
-  }).then(r => r.list);
-}
+export const getShortCatalog = bid => {
+  return fly
+    .get(`/books/${bid}/catalog`, {
+      page_size: 10,
+      page: 1
+    })
+    .then(r => r.list);
+};
 
 // 获取充值列表
 export const getChargeList = () => {
   return fly.get("/order/chargeList");
-}
+};
+
+// 添加书籍进书架
+export const postUserShelfBooks = params => {
+  return fly.post(`/userShelfBooks`, params);
+};
 
 // 获取书架数据
 export const getUserShelfBooks = () => {
   return fly.get(`/userShelfBooks`);
 };
 
+// 获取章节
+export const getCatalog = params => {
+  return fly.get(`/books/${params.bid}/catalog`, params);
+};
+
+// 获取章节内容
+export const getChapters = params => {
+  return fly.get(`/books/${params.bid}/chapters/${params.chapter_id}`);
+};
+
+// 获取书籍是否在书架
+export const getIsonshelf = params => {
+  return fly.get(`/userShelfBooks/isonshelf`, params);
+};
+
+// 删除书架书籍
+export const deleteShelfBook = params => {
+  return fly.get(`/userShelfBooks/delete`, params);
+};
+
 // 充值
 export const getConfigOfWxPay = (params) => {
   return fly.get("/goToPay", params);
-}
+};
 
 // 支付宝充值
 export const getConfigOfAliPay = (params) => {
@@ -86,3 +109,18 @@ export const getConfigOfAliPay = (params) => {
 export const getUserInfo = () => {
   return fly.get(`/userinfo`);
 };
+
+//发送短信
+export const sendCode = params => {
+  return fly.post(`/user/sendCode`, params);
+};
+
+//用户绑定
+export const userBind = params => {
+  return fly.post(`/user/bindPhone`, params);
+};
+
+//用户签到
+export const userSign = () => {
+  return fly.get(`/sign`);
+};

+ 36 - 4
src/api/utils.js

@@ -3,9 +3,9 @@ import fly from "./fly";
 import qs from "qs";
 import storage from "@system.storage";
 import device from "@system.device";
-import request from '@system.request';
-import media from '@system.media';
-import prompt from '@system.prompt';
+import request from "@system.request";
+import media from "@system.media";
+import prompt from "@system.prompt";
 // 获取token
 let token = null;
 export const getToken = async () => {
@@ -14,7 +14,7 @@ export const getToken = async () => {
   if (!token) token = (await storage.get({ key: "token" })).data;
 
   // token格式化
-  if (token && (typeof token === "string")) token = JSON.parse(token);
+  if (token && typeof token === "string") token = JSON.parse(token);
 
   console.log("checkToken", checkToken(token));
 
@@ -160,3 +160,35 @@ export const downImg = photoPath => {
     fail: () => { }
   });
 };
+//校验手机号
+export const validatePhone = phone => {
+  const VALIDATE_REG = /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[0-9]|18[0-9]|14[57]|19[89])[0-9]{8}$/;
+  const isMobile = VALIDATE_REG.test(phone);
+  return isMobile;
+};
+//存储期限storge
+export const setStore = (key, value) => {
+  if (!key) return;
+  let curTime = new Date().getTime();
+  value = JSON.stringify({ data: value, time: curTime });
+  storage.set({ key: key, value: value });
+};
+
+//取期限storge expDay:storge 几天内有效
+export const getStore = async (key, expDay = 3) => {
+  if (!key) return false;
+  let storgeData = JSON.parse((await storage.get({ key: key })).data);
+  if (isExceedDay(storgeData.time, expDay)) {
+    return false;
+  } else {
+    return storgeData.data;
+  }
+};
+
+function isExceedDay(theDate, expDay) {
+  let date = new Date();
+  let targetTime =
+    new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() -
+    (expDay - 1) * 24 * 3600 * 1000;
+  return theDate < targetTime;
+}

BIN
src/assets/imgs/pop_close.png


BIN
src/assets/imgs/sign_bg.jpg


BIN
src/assets/imgs/sign_checked.jpg


BIN
src/assets/imgs/sign_coin.jpg


BIN
src/assets/imgs/sign_gift.jpg


BIN
src/assets/imgs/sign_show.png


+ 6 - 3
src/assets/less/consume.less

@@ -7,7 +7,7 @@
     align-items: center;
 
     text {
-      color: #333;
+      color: #999;
       font-size: 30px;
     }
 
@@ -25,12 +25,15 @@
         margin-top: 10px;
 
         &--active {
-          background-color: #3284ff;
+          background-color: #EF5952;
+          
         }
       }
       
       .active {
-        color: #3284ff;
+        color: #EF5952;
+        font-size:36px;
+          font-weight: bold;
       }
     }
   }

+ 7 - 0
src/assets/less/index.less

@@ -88,4 +88,11 @@
 
     }
   }
+}
+.sign-icon{
+  position: fixed;
+  width:150px;
+  height:150px;
+  right:20px;
+  bottom: 300px;
 }

+ 40 - 0
src/assets/less/phone.less

@@ -0,0 +1,40 @@
+.phone-wrap {
+  flex-direction: column;
+  .input-content {
+    flex-direction: column;
+    width: 600px;
+    margin: 200px auto 0;
+  }
+  .input-item {
+    background-color: #f7f7f7;
+    border: 1px solid #e6e6e6;
+    border-radius: 4px;
+    height: 90px;
+    margin-bottom: 40px;
+    align-items: center;
+    justify-content: space-between;
+    .input-text {
+      padding: 0 20px;
+      font-size: 28px;
+      border:0;
+      width: 300px;
+    }
+    .send-msg{
+      font-size:24px;
+      color:#EF5952;
+      margin-right:20px;
+    }
+    .disabled{
+      color:#ccc;
+    }
+  }
+  .bind-button{
+    height:90px;
+    line-height: 90px;
+    width:500px;
+    background-color:#EF5952;
+    color:#fff;
+    font-size:30px;
+    margin:40px auto 0;
+  }
+}

+ 37 - 60
src/assets/less/recharge.less

@@ -2,61 +2,44 @@
   flex-direction: column;
 
   .user-account__wrap {
-    flex-direction: column;
-    border-bottom: 12px solid #f7f7f7;
-
-    .title-bar {
-      margin: 35px 0;
-      align-items: center;
-
-      .title {
-        font-size: 28px;
-        color: #3284ff;
+    width: 690px;
+    height: 180px;
+    background: linear-gradient(45deg, #fff2e2, #fff6e2);
+    border-radius: 12px;
+    margin: 20px auto 40px;
+    align-items: center;
+    padding: 0 30px 0 40px;
+    justify-content: space-between;
+    .account-blance {
+      flex-direction: column;
+      .blance-title {
+        font-size: 36px;
+        color: #3d2b15;
+        font-weight: bold;
       }
-
-      .border-bar {
-        width: 6px;
-        height: 100%;
-        background-color: #3284ff;
-        border-radius: 4px;
-        margin-right: 20px;
+      .blance-info {
+        font-size: 30px;
+        color: #ef5952;
       }
     }
-
-    .balance-bar {
-      justify-content: space-between;
-      align-items: center;
-      padding: 0 40px;
-      margin-bottom: 34px;
-
-      .balance {
-        text {
-          font-size: 24px;
-          color: #333;
-        }
-
-        .balance-number {
-          color: #ff6060;
-          font-weight: bold;
-          font-size: 32px;
-        }
-      }
-
-      .pay-btn {
-        background-color: #ff6060;
-        color: #fff;
-        font-size: 26px;
-        text-align: center;
-        width: 180px;
-        height: 60px;
-        line-height: 60px;
-        border-radius: 6px;
-      }
+    .account-pay {
+      border-radius: 26px;
+      background-color: #ef5952;
+      width: 150px;
+      height: 50px;
+      font-size: 24px;
+      color: #fff;
+      line-height: 50px;
+      text-align: center;
     }
   }
-
+  .title-bar {
+    margin: 10px 0 0 24px;
+    font-size: 32px;
+  }
   .recharge-list__wrap {
     border-bottom: 0;
+    flex-direction: column;
   }
 
   .recharge-list {
@@ -65,33 +48,29 @@
     .recharge-item {
       justify-content: space-between;
       align-items: center;
-      margin: 24px 24px 0;
-      border-bottom: 2px solid #f7f7f7;
 
+      padding: 24px 24px 0;
+      border-bottom: 2px solid #f7f7f7;
       .item-info {
         flex: 1;
         flex-direction: column;
         justify-content: flex-start;
         align-items: flex-start;
-
         .item-name,
         .item-number {
           font-size: 24px;
           color: #999;
         }
-
         .item-number {
           margin: 10px 0;
         }
 
         .item-pay {
           padding-bottom: 20px;
-
           text {
             font-size: 24px;
             color: #333;
           }
-
           .pay-number {
             font-size: 36px;
             font-weight: bold;
@@ -99,15 +78,13 @@
           }
         }
       }
-
+      .paid {
+        color: #999;
+      }
       .item-status {
         font-size: 24px;
         color: #ff6060;
       }
-
-      .paid {
-        color: greenyellow;
-      }
     }
   }
-}
+}

+ 23 - 8
src/assets/less/shelf.less

@@ -19,7 +19,7 @@
       }
 
       .cur {
-        color: #EF5952;
+        color: #ef5952;
         font-size: 36px;
         font-weight: bold;
       }
@@ -27,7 +27,7 @@
       .choose-bar {
         width: 38px;
         height: 4px;
-        background-color: #EF5952;
+        background-color: #ef5952;
         border-radius: 2px;
         margin-top: 10px;
       }
@@ -38,7 +38,7 @@
     height: 36px;
     background-color: #f7f7f7;
   }
-  
+
   .shelf-total {
     padding: 32px 22px;
     justify-content: space-between;
@@ -50,11 +50,11 @@
     }
 
     .manager {
-      border: 2px solid #EF5952;
+      border: 2px solid #ef5952;
       border-radius: 6px;
       background-color: #fff;
       font-size: 26px;
-      color: #EF5952;
+      color: #ef5952;
       width: 88px;
       height: 38px;
       text-align: center;
@@ -75,7 +75,7 @@
       margin-right: 50px;
 
       .book-del__wrap {
-        background-color: rgba(255, 255, 255, .6);;
+        background-color: rgba(255, 255, 255, 0.6);
         width: 200px;
         height: 264px;
         border-radius: 6px;
@@ -142,11 +142,26 @@
 
       .shelf-status {
         font-size: 24px;
-        color: #EF5952;
+        color: #ef5952;
         padding: 6px 17px;
         background-color: #f7f7f7;
         border-radius: 24px;
       }
     }
+    .book-del__item {
+      justify-content: center;
+      align-items: center;
+      flex-direction: column;
+      width: 100%;
+      background-color: rgba(255, 255, 255, 0.6);
+      image {
+        width: 40px;
+      }
+
+      text {
+        color: #4d4d4d;
+        margin-top: 20px;
+      }
+    }
   }
-}
+}

+ 48 - 0
src/components/short/index.ux

@@ -0,0 +1,48 @@
+<template>
+	<div class="short-wrap">
+		<div class="short-content" @click="createShortcut">
+			<text class="short-text">保存到手机方便下次阅读>></text>
+		</div>
+	</div>
+</template>
+<script>
+
+export default {
+	data: {
+		
+	},
+	onInit() {
+		
+	},
+	createShortcut(){
+		// 创建快捷方式
+    this.$app.$def.createShortcut()
+	}
+}
+</script>
+
+
+<style lang="less" scoped>
+	.short{
+		&-wrap{
+			position: fixed;
+			bottom: 140px;
+			height: 80px;
+			justify-content: center;
+			width: 100%;
+		}
+		&-content{
+			background-color: #EF5952;
+			border-radius: 40px;
+			width: 600px;
+			align-items: center;
+			justify-content: center;
+		}
+		&-text {
+			color:#fff;
+			font-size: 30px;
+			font-weight: bold;
+			text-align: center;
+		}
+	}
+</style>

+ 124 - 0
src/components/sign/index.ux

@@ -0,0 +1,124 @@
+<template>
+	<div class="sign-wrap">
+		<div class="sign-content">
+			<div class="sign-banner">
+				<text class="sign-banner__text">获得<span class="orange">50</span>书币</text>
+			</div>
+			<div class="sign-line">
+				<div class="sign-line__item" for="{{signList}}">
+					<text class="sign-line__day">{{$item.day}}天</text>
+					<image src="../../assets/imgs/sign_{{$item.iconType}}.jpg"></image>
+					<text class="sign-line__fee">{{$item.fee}}书币</text>
+				</div>
+			</div>
+		</div>
+		<image src="../../assets/imgs/pop_close.png" class="close-icon" @click="setSignPop"></image>
+	</div>
+</template>
+<script>
+import { userSign } from "../../api/index";
+import { setStore } from "../../api/utils";
+export default {
+	data: {
+		signList: [
+			{ day: 1, iconType: 'coin', fee: 50 },
+			{ day: 2, iconType: 'coin', fee: 50 },
+			{ day: 3, iconType: 'gift', fee: 150 },
+			{ day: 4, iconType: 'coin', fee: 50 },
+			{ day: 5, iconType: 'coin', fee: 50 },
+			{ day: 6, iconType: 'coin', fee: 50 },
+			{ day: 7, iconType: 'gift', fee: 150 },
+		],
+		signData: {
+			days: 0,
+			fee: 0
+		}
+	},
+	onInit() {
+		this.sign();
+	},
+	async sign() {
+		let res = await userSign();
+		this.signData = res;
+		this.signList.forEach(item => {
+			if (item.day <= res.days) {
+				item.iconType = 'checked';
+			}
+		});
+	},
+	setSignPop() {
+		this.$dispatch('dispathEvt')
+	}
+}
+</script>
+<style lang="less" scoped>
+.sign {
+  &-wrap {
+    position: fixed;
+    top: 0;
+    bottom: 0;
+    left: 0;
+    right: 0;
+    background-color: rgba(0, 0, 0, 0.56);
+    flex-direction: column;
+		align-items: center;
+		z-index: 2;
+  }
+  &-content {
+    width: 650px;
+    height: 520px;
+    border-radius: 30px;
+    background-color: #fff;
+    margin-top: 240px;
+    flex-direction: column;
+  }
+  &-line {
+    margin-bottom: 20px;
+    margin-top: 10px;
+    height: 140px;
+    &__item {
+      flex: 1;
+      flex-direction: column;
+      align-items: center;
+      justify-content: space-around;
+    }
+    &__day {
+      color: #999;
+      font-size: 22px;
+    }
+    image {
+      width: 40px;
+      height: 40px;
+    }
+    &__fee {
+      font-size: 22px;
+    }
+  }
+  &-banner {
+    background-image: url(../../assets/imgs/sign_bg.jpg);
+    background-size: cover;
+    background-repeat: no-repeat;
+    justify-content: center;
+    width: 100%;
+    height: 350px;
+    border-top-left-radius: 30px;
+    border-top-right-radius: 30px;
+    &__text {
+      font-size: 34px;
+      color: #fff;
+      font-weight: bold;
+      margin-top: 200px;
+      .orange {
+        color: #ffc017;
+        font-size: 46px;
+        padding: 0 6px;
+      }
+    }
+  }
+}
+.close-icon {
+  width: 60px;
+  height: 60px;
+  margin-top: 60px;
+}
+</style>

+ 1 - 1
src/manifest.json

@@ -60,7 +60,7 @@
     "logLevel": "debug"
   },
   "router": {
-    "entry": "views/Pay",
+    "entry": "views/Recharge",
     "pages": {
       "views/Index": {
         "component": "index"

+ 56 - 9
src/views/Catalog/index.ux

@@ -1,11 +1,11 @@
 <template>
   <list id="catalog" class="catalog-wrap" @scrollbottom="loadCatalog" @scrolltop="loadPrev">
     <block for="list">
-      <list-item type="catalog-item" class="catalog-item">
-        <text class="catalog-name {{$idx === 0 ? 'catalog-name__check' : ''}}">第{{$idx + 1}}章</text>
+      <list-item type="catalog-item" class="catalog-item" @click='jumpReader($item)'>
+        <text class="catalog-name {{$idx == chapter_sequence_index ? 'catalog-name__check' : ''}}">{{$item.chapter_name}}</text>
         <div class="target-wrap">
-          <image src="../../assets/imgs/book-vip.png"></image>
-          <text class="border {{$idx === 0 ? 'border-show': ''}}"></text>
+          <image if='$item.chapter_is_vip==1' src="../../assets/imgs/book-vip.png"></image>
+          <text class="border {{$idx == chapter_sequence_index ? 'border-show': ''}}"></text>
         </div>
       </list-item>
     </block>
@@ -13,21 +13,68 @@
 </template>
 
 <script>
+import { getCatalog } from "../../api";
+import router from '@system.router';
+import prompt from '@system.prompt'
+
 export default {
+  protected: {
+    bid: "",
+    chapter_sequence: ""
+  },
   private: {
-    list: []
+    list: [],
+    meta: {},
+    chapter_sequence_index: 0,
+    startpage: 1,
   },
   onInit() {
-    this.list = Array(100).fill(null).map((_, k) => k);
-    setTimeout(() => {
-      this.$element('catalog').scrollTo({ index: 20 });
-    }, 1000);
+    let page = 1
+    var chapter_sequence_index = 1
+    if (this.chapter_sequence) {
+      var chapter_sequence = this.chapter_sequence
+      chapter_sequence_index = chapter_sequence % 15 - 1
+      this.chapter_sequence_index = chapter_sequence_index
+      page = Math.ceil(chapter_sequence / 15)
+    }
+    this.startpage = page
+    getCatalog({ bid: this.bid, page: page }).then(r => {
+      this.list = r.list
+      this.meta = r.meta
+      this.$element('catalog').scrollTo({ index: chapter_sequence_index })
+    })
+    // this.list = Array(100).fill(null).map((_, k) => k);
+    // setTimeout(() => {
+    //   this.$element('catalog').scrollTo({ index: 20 });
+    // }, 1000);
+  },
+  jumpReader(info) {
+    console.log(info)
+    router.push({
+      uri: "/views/Reader",
+      params: {
+        bid: info.bid,
+        chapter_id: info.chapter_id
+      }
+    })
   },
   loadCatalog() {
     console.log("load data");
+    if (this.meta.last_page < (this.meta.current_page + 1)) return prompt.showToast({ message: '已经到底啦' })
+    getCatalog({ bid: '5pNo6A7wqQmB1WgQygDjkOM9VZn2vXeY', page: this.meta.current_page + 1 }).then(r => {
+      console.log(...r.list)
+      this.list.push(...r.list)
+      this.meta = r.meta
+    })
   },
   loadPrev() {
     console.log("get prev catalog");
+    if ((this.startpage - 1) < 1) return prompt.showToast({ message: '已经到顶啦' })
+    getCatalog({ bid: '5pNo6A7wqQmB1WgQygDjkOM9VZn2vXeY', page: this.startpage - 1 }).then(r => {
+      console.log(...r.list)
+      this.list.unshift(...r.list)
+      this.startpage = r.meta.current_page
+    })
   }
 }
 </script>

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

@@ -23,7 +23,7 @@
         <text class="toggle" @click="toggleTextStatus">{{showLongText ? '收起' : '展开'}}</text>
       </stack>
     </div>
-    <text class="lastest-chapter" @click="toRead(book.lastest_id)">最新章节:{{book.last_chapter}}</text>
+    <text class="lastest-chapter" @click="toRead(book.last_cid)">最新章节:{{book.last_chapter}}</text>
     <div class="box-wrap short-chapter__list">
       <div class="small-title">
         <div class="wrap-left">
@@ -87,7 +87,7 @@ export default {
       uri: "/views/Reader",
       params: {
         bid: this.book.book_id,
-        cid: chapter_id
+        chapter_id: chapter_id
       }
     })
   },

+ 20 - 3
src/views/Index/index.ux

@@ -2,7 +2,8 @@
 <import name="category-page" src="../Category/index.ux"></import>
 <import name="shelf-page" src="../Shelf/index.ux"></import>
 <import name="my-page" src="../My/index.ux"></import>
- 
+<import name="sign-page" src="../../components/sign/index.ux"></import>
+<import name="short-page" src="../../components/short/index.ux"></import>
 <template>
   <stack class="stack-wrap">
     <div class="index-wrap">
@@ -26,6 +27,9 @@
         </div>
       </div>
     </div>
+    <image src="../../assets/imgs/sign_show.png" class="sign-icon" @click="changeSignPop"> </image>
+    <sign-page if="{{showSignPop}}" ></sign-page>
+    <short-page if="{{showShortPop}}"></short-page>
     <div class="stack-popup" @click="closeWrap" if="showPopup">
       <div class="customer-popup">
         <text class="title">联系客服</text>
@@ -42,7 +46,7 @@
 <script>
 import clipboard from '@system.clipboard';
 import prompt from '@system.prompt';
-import {downImg} from '../../api/utils.js';
+import { downImg, getStore } from '../../api/utils.js';
 export default {
   private: {
     tabbar: [
@@ -76,7 +80,17 @@ export default {
       }
     ],
     current: 1,
-    showPopup: false
+    showPopup: false,
+    showSignPop: false,
+    showShortPop:false
+  },
+   onInit() {
+    this.$on('dispathEvt', this.changeSignPop);
+    //今日已签到过不在弹框签到
+    if(this.$app.$def.data.backClickCount === 0){
+      this.showShortPop=true;
+    }
+
   },
   onBackPress() {
     // 退出逻辑
@@ -100,6 +114,9 @@ export default {
   pageSwitch() {
     this.current = 1;
   },
+  changeSignPop() {
+    this.showSignPop = !this.showSignPop;
+  },
   closeWrap() {
     this.showPopup = false;
   },

+ 15 - 6
src/views/My/index.ux

@@ -1,17 +1,17 @@
 <template>
   <div class="user-wrap">
     <div class="user-info__wrap">
-      <image src="http://thirdwx.qlogo.cn/mmopen/dOnU7xaqjEYxcrJjHWw4HnyXer3EgjuyibYjzM1ncrtQVpgX8icrXYCnwLpd8htFvg1jrAc88PdE2gVkmKnYByAHrULcMlyOwY/132"></image>
-      <text>ID:123123123</text>
+      <image src="{{user.head_img}}"></image>
+      <text>ID:{{user.id}}</text>
     </div>
     <div class="operator-item__wrap">
       <div class="operator-item">
         <div class="item-name">
           <image src="../../assets/imgs/declining.png"></image>
-          <text>您还剩<span class="red">5000</span>书币</text>
+          <text>您还剩<span class="red">{{user.balance}}</span>书币</text>
         </div>
         <text class="operator-button" @click="pageChange('Pay')">
-         充值
+          充值
         </text>
       </div>
       <div class="operator-item" @click="toUrl('https://sitenlp5w4yepme7xrqz.zhuishuyun.com/sign')">
@@ -66,11 +66,20 @@
 
 <script>
 import router from "@system.router";
-
+import { getUserInfo } from "../../api/index";
 export default {
   props: {},
   data() {
-    return {}
+    return {
+      user: {}
+    }
+  },
+  onInit() {
+    this.getUser();
+  },
+  async getUser() {
+    let user = await getUserInfo();
+    this.user = user;
   },
   showCustomerQrcode() {
     this.$emit('customer');

+ 85 - 1
src/views/Phone/index.ux

@@ -1,5 +1,89 @@
 <template>
   <div class="phone-wrap">
-    <text>绑定手机</text>
+    <div class="input-content">
+      <div class="input-item">
+        <input class="input-text" type="tel" placeholder="请输入手机号" value="{{mobile}}" style="placeholder-color: #CCC" onchange="updateMobile"></input>
+      </div>
+      <div class="input-item">
+        <input class="input-text" type="number" maxlength="6" placeholder="请输入验证码" value="{{code}}" style="placeholder-color: #CCC" onchange="updateMessage"></input>
+        <text class="send-msg" if="{{!hasSend}}" @click="sendMsg">获取验证码</text>
+        <text class="send-msg disabled" else>重新获取{{duration}}</text>
+      </div>
+    </div>
+    <input type="button" value="绑定手机号" class="bind-button" @click="bindUser"> </input>
   </div>
 </template>
+<script>
+import { validatePhone } from '../../api/utils';
+import { sendCode, userBind } from '../../api/index';
+import prompt from '@system.prompt';
+export default {
+  private: {
+    hasSend: false,
+    duration: 60,
+    mobile: null,
+    code: null
+
+  },
+  onInit() {
+
+  },
+  async sendMsg() {
+    let result = validatePhone(this.mobile);
+    if (result) {
+      let res = await sendCode({ phone: this.mobile });
+      this.countDown();
+    } else {
+      prompt.showToast({
+        message: '手机号格式不正确'
+      })
+    }
+  },
+  updateMobile(e) {
+    this.mobile = e.value;
+  },
+  updateMessage(e) {
+    this.code = e.value;
+  },
+  //倒计时
+  countDown() {
+    this.hasSend = true;
+    let time = setInterval(() => {
+      this.duration--;
+      if (this.duration < 1) {
+        clearInterval(time);
+        this.duration = 120;
+        this.hasSend = false;
+      }
+    }, 1000);
+  },
+  //绑定用户
+  async bindUser() {
+    if (!this.mobile || !this.code) {
+      prompt.showToast({
+        message: '请输入手机号和验证码'
+      })
+      return false;
+    }
+    if (!validatePhone(this.mobile)) {
+      prompt.showToast({
+        message: '手机号码格式不正确'
+      })
+      return false;
+    }
+    let params = {
+      phone: this.mobile,
+      code: this.code
+    }
+    let res = await userBind(params);
+    prompt.showToast({
+      message: '绑定成功!'
+    })
+
+  }
+
+}
+</script>
+<style lang="less">
+@import "../../assets/less/phone.less";
+</style>

+ 56 - 27
src/views/Reader/index.ux

@@ -1,50 +1,79 @@
+<import name="short-page" src="../../components/short/index.ux"></import>
 <template>
-  <div class="reader-wrap">
-    <div class="reader-title">
-      <text class="title">第一章 冲头一次吧</text>
-      <!-- <text class="add-shelf" @click="addShelf">加入书架</text> -->
-    </div>
-    <div class="reader-content">
-      <text class="chapter-text">一念的执着,倾世的阑珊。——笛音</text>
-      <text class="chapter-text">H市</text>
-      <text class="chapter-text">晨曦的阳光透过落地窗洒在地板上,卧室内,一室的凌乱,空气中还弥漫着欢-爱之后残余的气息,蚕丝被盖住了床上女人的娇躯,外露的肩头上有着密密匝匝的吻痕,绯色娇嫩美丽的脸蛋上还泛着红晕,此时美丽的容颜上呈现出一分妩媚性感。</text>
-      <text class="chapter-text">但仔细一看,还能够看到女人眼角滑落过泪水的痕迹。</text>
-      <text class="chapter-text">浴室传出哗啦啦的水声,惊扰了正在睡梦中的女人,余阑珊漂亮的眉心紧拧着,缓缓睁开了眼睛,刺眼的光芒直射在她的眼球上,让她抬手挡了一下从窗外照射进来的光线。</text>
-      <text class="chapter-text">身下的酸痛,让她脑海中的记忆纷至沓来。</text>
-      <text class="chapter-text">“顾先生,我们约定的期限到了。”阑珊的声音很轻很轻,轻到她自己都差点没有听清。</text>
-      <text class="chapter-text">男人一双深邃犀利的眸子紧锁在女人垂下脑袋的容颜上,从的视角看不全她的面部,视线落在她光洁的额头、长卷翘的睫毛上,瞬间,一股薄怒从心底滋生,伸手钳住女孩的下颌,逼迫她看着自己,阑珊的下颌被他捏的生疼,眼泪差点奔泻出去,紧咬着自己的唇瓣,不让在自己眼眶中盘旋的泪水滑落。</text>
-      <text class="chapter-text">“再说一遍?”顾念琛低沉带着盛怒的声音在余阑珊的耳边响起。</text>
-      <text class="chapter-text">余阑珊一双染上泪花的水眸对上顾念琛那双淡漠清冷的眸子,艰难的道出:“顾先生,我们约定的期限到了。”</text>
-      <text class="chapter-text">顾念琛带着薄怒连点了几个头,余阑珊以为他同意了,正准备说什么。</text>
-      <text class="chapter-text">便听到顾念琛狠绝伤人的话语从她的头顶砸下来,重重砸在她的心窝上,“余阑珊,很好,既然要离婚,浪费了你三年的青春,今晚我还给你。”</text>
-      <text class="chapter-text">余阑珊惊愕的看着顾念琛那双波澜不惊的眸子,没有明白他话中的意思。</text>
-      <text class="chapter-text">还在错愕之中的人,被嘴唇上传来的疼痛惊醒,熟悉的气息扑鼻而来,看着他近在咫尺的俊脸,余阑珊瞳孔放大,伸手推着身前的人,手却被他一把握住高举过头顶,霸道带着惩罚的吻肆意的掠夺着她的唇。</text>
-    </div>
-    <div class="reader-operator">
-      <text class="operator prev" @click="getPrevChapter">上一章</text>
-      <text class="operator catalog" @click="toCatalog">目录</text>
-      <text class="operator next" @click="getNextChapter">下一章</text>
-    </div>
+  <div id="reader-content">
+    <list class="reader-wrap" id='list'>
+      <list-item type='title' class="reader-title">
+        <text class="title">{{bookinfo.chapter_name}}</text>
+        <!-- <text class="add-shelf" @click="addShelf">加入书架</text> -->
+      </list-item>
+      <list-item type='content' class="reader-content">
+        <text class="chapter-text" for='content'>{{$item}}</text>
+      </list-item>
+      <list-item type='button' class="reader-operator">
+        <text class="operator prev" @click="getPrevChapter">上一章</text>
+        <text class="operator catalog" @click="toCatalog">目录</text>
+        <text class="operator next" @click="getNextChapter">下一章</text>
+      </list-item>
+    </list>
+    <short-page if="{{showShortPop}}"></short-page>
   </div>
+
 </template>
 
 <script>
 import router from "@system.router";
+import { getChapters, getIsonshelf, postUserShelfBooks } from "../../api";
 
 export default {
+  protected: {
+    bid: '',
+    chapter_id: ''
+  },
+  private: {
+    bookinfo: {},
+    content: [],
+    showShortPop: false
+  },
+  onInit() {
+    getChapters({ bid: this.bid, chapter_id: this.chapter_id }).then(r => {
+      this.content = r.chapter_content.trim().split(/\n/)
+      this.bookinfo = r
+    })
+    this.addShelf();
+    if (this.$app.$def.data.backClickCount === 0) {
+      this.showShortPop = true;
+    }
+  },
   addShelf() {
     console.log("add shelf");
+    getIsonshelf({ bid: this.bid }).then(r => {
+      r.is_on ? '' : postUserShelfBooks({ bid: this.bid })
+    })
   },
   toCatalog() {
     router.push({
-      uri: "/views/Catalog"
+      uri: "/views/Catalog",
+      params: {
+        chapter_sequence: this.bookinfo.chapter_sequence,
+        bid: this.bid
+      }
     })
   },
   getPrevChapter() {
     console.log("get prev chapter");
+    getChapters({ bid: this.bookinfo.bid, chapter_id: this.bookinfo.prev_cid }).then(r => {
+      this.content = r.chapter_content.trim().split(/\n/)
+      this.bookinfo = r
+      this.$element('list').scrollTo({ index: 0 })
+    })
   },
   getNextChapter() {
     console.log("get next chapter");
+    getChapters({ bid: this.bookinfo.bid, chapter_id: this.bookinfo.next_cid }).then(r => {
+      this.content = r.chapter_content.trim().split(/\n/)
+      this.bookinfo = r
+      this.$element('list').scrollTo({ index: 0 })
+    })
   }
 }
 </script>

+ 12 - 17
src/views/Recharge/index.ux

@@ -2,38 +2,32 @@
  
 <template>
   <div class="recharge-record__wrap">
-    <div class="user-account__wrap">
-      <div class="title-bar">
-        <text class="border-bar"></text>
-        <text class="title">账户信息</text>
-      </div>
-      <div class="balance-bar">
-        <div class="balance">
-          <text>余额:</text>
-          <text class="balance-number">{{user.balance}}</text>
-          <text>书币</text>
-        </div>
-        <text class="pay-btn" @click="toPay">立即充值</text>
+    <div class="user-account__wrap" if="{{user}}">
+      <div class="account-blance">
+        <text class="blance-title">余额</text>
+        <text class="blance-info">{{user.balance}}书币</text>
       </div>
+      <text class="account-pay" @click="toPay">
+        去充值
+      </text>
     </div>
-    <div class="user-account__wrap recharge-list__wrap">
+
+    <div class=" recharge-list__wrap">
       <div class="title-bar">
-        <text class="border-bar"></text>
         <text class="title">充值订单</text>
       </div>
       <div class="recharge-list">
         <block for="{{rechargeList}}">
           <div class="recharge-item">
             <div class="item-info">
-              <text class="item-name">订单号:</text>
-              <text class="item-number">{{$item.trade_no}}</text>
+              <text class="item-number">订单号:{{$item.trade_no}}</text>
               <div class="item-pay">
                 <text>充值</text>
                 <text class="pay-number">{{$item.price}}</text>
                 <text>元</text>
               </div>
             </div>
-            <text class="item-status">{{$item.status==='UNPAID'?'未支付':'已支付'}}</text>
+            <text class="item-status {{$item.status==='UNPAID'?'':'paid'}}" >{{$item.status==='UNPAID'?'未支付':'已支付'}}</text>
           </div>
         </block>
       </div>
@@ -62,6 +56,7 @@ export default {
   async getUserInfo(){
     let user =await getUserInfo();
     this.user=user;
+    console.log(this.user,'rrrrrrrrrrr')
   },
   async getOrder(page=1,page_size=10) {
     let res= await rechargeApi({page:page,page_size});

+ 32 - 13
src/views/Shelf/index.ux

@@ -19,8 +19,8 @@
         <block for="mockList">
           <div class="book-item__wrap {{(($idx + 1)%3 === 0) ? 'm0' : ''}}">
             <stack>
-              <x-book></x-book>
-              <div class="book-del__wrap" show="{{isDelMode}}">
+              <x-book book='{{$item}}'></x-book>
+              <div class="book-del__wrap" show="{{isDelMode}}" @click='deleteBook($item)'>
                 <image src="https://yueduyun.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/img/delete.png"></image>
                 <text>删除</text>
               </div>
@@ -37,14 +37,20 @@
       <list class="recent-list">
         <block for="mockList">
           <list-item type="recent-item" class="recent-item">
-            <x-book multi="{{true}}" width="{{150}}">
-              <div class="book-info__wrap">
-                <text class="name">爱的邂逅</text>
-                <text class="lastest">最新 第2556章 又来了一个张老三</text>
-                <text class="last-read">上次阅读:第23章 张老三是个蓝精灵</text>
-                <text class="shelf-status">❤️ 已加入书架</text>
+            <stack>
+              <x-book multi="{{true}}" book='{{$item}}' width="{{150}}">
+                <div class="book-info__wrap">
+                  <text class="name">{{$item.book_name}}</text>
+                  <text class="lastest">最新 {{$item.last_chapter}}</text>
+                  <text class="last-read">上次阅读:{{$item.recent_reading_chapter}}</text>
+                  <text class="shelf-status">❤️ 已加入书架</text>
+                </div>
+              </x-book>
+              <div class="book-del__item" show="{{isDelMode}}" @click='deleteBook($item)'>
+                <image src="https://yueduyun.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/img/delete.png"></image>
+                <text>删除</text>
               </div>
-            </x-book>
+            </stack>
           </list-item>
         </block>
       </list>
@@ -53,7 +59,7 @@
 </template>
 
 <script>
-import { getUserShelfBooks } from "../../api";
+import { getUserShelfBooks, deleteShelfBook } from "../../api";
 
 export default {
   props: {},
@@ -62,7 +68,7 @@ export default {
       current: 0,
       isDelMode: false,
       modeText: "管理",
-      mockList: [0, 1, 2, 3, 4],
+      mockList: [],
       typeList: [
         {
           name: "我的书架",
@@ -76,10 +82,22 @@ export default {
     }
   },
   onInit() {
+    this.getUserShelfBooks()
+    this.$watch('isDelMode', 'listenMode')
+  },
+  getUserShelfBooks() {
     getUserShelfBooks().then(r => {
-      console.log(r)
+      r.map(m => {
+        m.cover_url = m.cover
+        delete m.cover
+      })
+      this.mockList = r
+    })
+  },
+  deleteBook(book) {
+    deleteShelfBook({ bid: book.bid }).then(r => {
+      this.getUserShelfBooks()
     })
-    this.$watch('isDelMode', 'listenMode')
   },
   changeMode() {
     this.isDelMode = !this.isDelMode;
@@ -89,6 +107,7 @@ export default {
   },
   toCategory() {
     this.$emit('change');
+
   },
   typeChange(index) {
     this.current = index;