xiabx 5 년 전
부모
커밋
7f4136626d

+ 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);
   }
 );

+ 5 - 4
src/api/index.js

@@ -82,11 +82,12 @@ export const getUserInfo = () => {
 };
 
 //发送短信
-export const sendCode = (phone) => {
-  return fly.post(`/user/sendCode`,{phone:phone});
+export const sendCode = (params) => {
+  return fly.post(`/user/sendCode`,params);
 };
 
 //用户绑定
 export const userBind = (params) => {
-  return fly.post(`/bindPhone`,params);
-};
+  return fly.post(`/user/bindPhone`,params);
+};
+

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


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

@@ -0,0 +1,109 @@
+<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>
+// 子组件
+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 },
+		]
+	},
+	onInit() {
+
+	},
+	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;
+  }
+  &-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

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

+ 10 - 2
src/views/Index/index.ux

@@ -2,7 +2,7 @@
 <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>
 <template>
   <stack class="stack-wrap">
     <div class="index-wrap">
@@ -26,6 +26,7 @@
         </div>
       </div>
     </div>
+    <sign-page if="{{showSignPop}}" onemitEvt="emitEvt"></sign-page>
     <div class="stack-popup" @click="closeWrap" if="showPopup">
       <div class="customer-popup">
         <text class="title">联系客服</text>
@@ -76,8 +77,12 @@ export default {
       }
     ],
     current: 1,
-    showPopup: false
+    showPopup: false,
+    showSignPop:true
   },
+  onInit(){
+      this.$on('dispathEvt',this.changeSignPop)
+    },
   onBackPress() {
     // 退出逻辑
     if (this.$app.$def.data.backClickCount === 0) {
@@ -100,6 +105,9 @@ export default {
   pageSwitch() {
     this.current = 1;
   },
+  changeSignPop() {
+    this.showSignPop = false;
+  },
   closeWrap() {
     this.showPopup = false;
   },

+ 0 - 1
src/views/My/index.ux

@@ -80,7 +80,6 @@ export default {
   async getUser(){
   let user =await getUserInfo();
     this.user=user;
-    console.log(this.user,'aaaaaaaaaaaaaaa')
   },
   showCustomerQrcode() {
     this.$emit('customer');

+ 16 - 10
src/views/Phone/index.ux

@@ -31,7 +31,7 @@ export default {
   async sendMsg() {
     let result = validatePhone(this.mobile);
     if (result) {
-      let res = await sendCode(this.mobile);
+      let res = await sendCode({ phone: this.mobile });
       this.countDown();
     } else {
       prompt.showToast({
@@ -52,27 +52,33 @@ export default {
       this.duration--;
       if (this.duration < 1) {
         clearInterval(time);
-        this.duration = 60;
+        this.duration = 120;
         this.hasSend = false;
       }
     }, 1000);
   },
   //绑定用户
-  async bindUser(){
-    if(!this.mobile || !this.code){
+  async bindUser() {
+    if (!this.mobile || !this.code) {
       prompt.showToast({
-        message: '请输入手机号码和验证码'
+        message: '请输入手机号和验证码'
+      })
+      return false;
+    }
+    if (!validatePhone(this.mobile)) {
+      prompt.showToast({
+        message: '手机号码格式不正确'
       })
       return false;
     }
     let params = {
-      phone:this.mobile,
-      code:this.code
+      phone: this.mobile,
+      code: this.code
     }
-    let res= await userBind(params);
+    let res = await userBind(params);
     prompt.showToast({
-        message: '绑定成功!'
-      })
+      message: '绑定成功!'
+    })
 
   }