Explorar o código

Merge branch 'main' of https://gitlab.com/tea28/client

# Conflicts:
#	src/pages/account/giveAsPresent.vue
DaMoWang %!s(int64=2) %!d(string=hai) anos
pai
achega
62d8106bf6
Modificáronse 2 ficheiros con 214 adicións e 133 borrados
  1. 213 120
      src/pages/account/giveAsPresent.vue
  2. 1 13
      src/pages/my/index.vue

+ 213 - 120
src/pages/account/giveAsPresent.vue

@@ -1,37 +1,57 @@
 <template>
-    <view class="container">
-        <view class="list flex_r flex_ac flex_jb mar_t16">
-            <view class="list_name">赠送类型:</view>
-            <view class="list_text flex_r flex_ac">
-                <uni-data-select v-model="value" :localdata="range" :clear="false" class="type_select"/>
-            </view>
-        </view>
-        <view class="list flex_r flex_ac flex_jb mar_t16" v-if="value == 1">
-            <view class="list_name">当前余额:</view>
-            <view class="list_text"><text>{{ userinfo.user_money }}</text></view>
-        </view>
-        <view class="list flex_r flex_ac flex_jb mar_t16" v-else>
-            <view class="list_name">当前茶宝:</view>
-            <view class="list_text"><text>{{ userinfo.cha_bao }}</text></view>
-        </view>
-        <view class="list flex_r flex_ac flex_jb mar_t16">
-            <view class="list_name">对方账号:</view>
-            <view class="list_text">
-                <input type="text" v-model="id" placeholder="输入对方账号" placeholder-style="color:#ddd;" />
-            </view>
-        </view>
-        <view class="list flex_r flex_ac flex_jb mar_t16">
-            <view class="list_name">赠送数量:</view>
-            <view class="list_text">
-                <input type="text" v-model="give_num" placeholder="自定义赠送数量" placeholder-style="color:#ddd;" />
-            </view>
-        </view>
-        <view class="list flex_r flex_ac flex_jb mar_t16">
-            <view class="list_name">手续费:</view>
-            <view class="list_text ">20%</view>
-        </view>
-        <view class="btn flex_r flex_ac flex_jc" @tap="giveIntegral">立即赠送</view>
+  <view class="container">
+    <view class="list flex_r flex_ac flex_jb mar_t16">
+      <view class="list_name">赠送类型:</view>
+      <view class="list_text flex_r flex_ac">
+        <uni-data-select
+          v-model="value"
+          :localdata="range"
+          :clear="false"
+          class="type_select"
+        />
+      </view>
     </view>
+    <view class="list flex_r flex_ac flex_jb mar_t16" v-if="value == 0">
+      <view class="list_name">当前余额:</view>
+      <view class="list_text"
+        ><text>{{ userinfo.user_money }}</text></view
+      >
+    </view>
+    <view class="list flex_r flex_ac flex_jb mar_t16" v-else>
+      <view class="list_name">当前茶宝:</view>
+      <view class="list_text"
+        ><text>{{ userinfo.cha_bao }}</text></view
+      >
+    </view>
+    <view class="list flex_r flex_ac flex_jb mar_t16">
+      <view class="list_name">对方账号:</view>
+      <view class="list_text">
+        <input
+          type="text"
+          v-model="id"
+          placeholder="输入对方账号"
+          placeholder-style="color:#ddd;"
+        />
+      </view>
+    </view>
+    <view class="list flex_r flex_ac flex_jb mar_t16">
+      <view class="list_name">赠送数量:</view>
+      <view class="list_text">
+        <input
+          type="text"
+          v-model="give_num"
+          placeholder="自定义赠送数量"
+          placeholder-style="color:#ddd;"
+        />
+      </view>
+    </view>
+    <view class="list flex_r flex_ac flex_jb mar_t16">
+      <view class="list_name">手续费:</view>
+      <view class="list_text">{{ list[value].fee * 100 }}%</view>
+    </view>
+    <view class="tips">{{ list[value].tips }}</view>
+    <view class="btn flex_r flex_ac flex_jc" @tap="give">立即赠送</view>
+  </view>
 </template>
 <script>
 let page = 1;
@@ -39,126 +59,199 @@ let app = getApp();
 var appEv = app.$vm.$options;
 import { get, post } from "@/request/api.js";
 export default {
-    data() {
-        return {
-            id: "",
-            give_num: "",
-            curren: 1,
-            surplus: 0,
-            list: [],
-            userinfo: undefined, // 获取用户信息
+  data() {
+    return {
+      id: "",
+      give_num: "",
+      userinfo: undefined, // 获取用户信息
 
-            value: 1,
-            range: [
-                { value: 1, text: "余额" },
-                { value: 2, text: "茶宝" },
-            ],
-        };
-    },
-    onLoad() {
-        this.userinfo = uni.getStorageSync("userinfo");
+      value: 0,
+      range: [
+        { value: 0, text: "余额" },
+        { value: 1, text: "茶宝" },
+      ],
+      list: [],
+    };
+  },
+  onLoad() {
+    this.userinfo = uni.getStorageSync("userinfo");
+    this.getGiveList();
+  },
+  methods: {
+    getGiveList() {
+      post("giveRate").then((res) => {
+        this.list = res.data.data;
+      });
     },
-    methods: {
-        setCurren(e) {
-            this.surplus = 0;
-            this.curren = e;
-            this.giveUserIntegral();
-        },
-        // 赠送
-        giveIntegral() {
-            if (this.give_num == 0) {
-                appEv.errTips("赠送数量不得为0");
-                return;
-            } else if (this.give_num > Number(this.userinfo.cha_bao)) {
-                appEv.errTips("赠送数量不得超过茶宝余额");
-                return;
-            } else if (this.id == "") {
-                appEv.errTips("请输入赠送账号");
-                return;
+    give() {
+      if (this.give_num == 0) {
+        appEv.errTips("赠送数量不得为0");
+        return;
+      } else if (
+        this.give_num > Number(this.userinfo.cha_bao) &&
+        this.value == 1
+      ) {
+        appEv.errTips("赠送数量不得超过茶宝余额");
+        return;
+      } else if (
+        this.give_num > Number(this.userinfo.user_money) &&
+        this.value == 0
+      ) {
+        appEv.errTips("赠送数量不得超过余额");
+        return;
+      } else if (this.id == "") {
+        appEv.errTips("请输入赠送账号");
+        return;
+      } else {
+        let content = "";
+        if (this.value == 0) {
+          content = `你将赠送给${this.id}余额${
+            this.give_num
+          },扣除手续费后对方将收到${
+            this.give_num * (1 - this.list[this.value].fee)
+          }余额`;
+        } else {
+          content = `你将赠送给${this.id}茶宝${
+            this.give_num
+          },扣除手续费后对方将收到${
+            this.give_num * (1 - this.list[this.value].fee)
+          }茶宝`;
+        }
+        let that = this
+        uni.showModal({
+          title: "提示",
+          content: content,
+          showCancel: true,
+          success: function (res) {
+            if (res.confirm) {
+              if (that.value == 0) {
+                that.giveMoney();
+              } else {
+                that.giveIntegral();
+              }
             } else {
-                let data = {
-                    mobile: this.id,
-                    number: this.give_num,
-                };
-                post("my/give", data).then((res) => {
-                    if (res.code === 0) {
-                        this.give_num = 0;
-                        this.id = ''
-                        appEv.errTips(res.msg);
-                    } else {
-                        appEv.errTips(res.msg);
-                    }
-                });
             }
-        },
+          },
+        });
+      }
+    },
+    // 赠送茶宝
+    giveIntegral() {
+      let data = {
+        mobile: this.id,
+        number: this.give_num,
+      };
+      post("my/give", data).then((res) => {
+        if (res.code === 0) {
+          this.give_num = 0;
+          this.id = "";
+          this.getuserInfo();
+          appEv.errTips(res.msg);
+        } else {
+          appEv.errTips(res.msg);
+        }
+      });
     },
+
+    giveMoney() {
+      let data = {
+        mobile: this.id,
+        number: this.give_num,
+      };
+      post("my/moneyGive", data).then((res) => {
+        if (res.code === 0) {
+          this.give_num = 0;
+          this.id = "";
+          appEv.errTips(res.msg);
+          this.getuserInfo();
+        } else {
+          appEv.errTips(res.msg);
+        }
+      });
+    },
+
+    getuserInfo() {
+      post("/user/userinfo").then((res) => {
+        if (res.code === 0) {
+          uni.setStorageSync("userinfo", res.data.data);
+          this.userinfo = res.data.data;
+          this.isShiMing = this.userinfo.is_authentication == 0 ? true : false;
+        }
+      });
+    },
+  },
 };
 </script>
 <style lang="scss">
 // 页面配置
 page {
-    background: #f4f4f4;
+  background: #f4f4f4;
 }
 
 // 页面配置-end
 
-
 .list {
-    width: 100%;
-    height: 86rpx;
-    padding: 0 36rpx;
-    box-sizing: border-box;
-    background: #fff;
+  width: 100%;
+  height: 86rpx;
+  padding: 0 30rpx;
+  box-sizing: border-box;
+  background: #fff;
 }
 
 .list_text {
-    flex: 1;
-    font-family: "SourceHanSansCN-Bold";
-    text-align: right;
+  flex: 1;
+  font-family: "SourceHanSansCN-Bold";
+  text-align: right;
 }
 
 .list_name {
-    flex: 1;
-    color: #333333;
-    font-size: 28rpx;
-    font-family: "SourceHanSansCN-Medium";
-    font-weight: 500;
+  flex: 1;
+  color: #333333;
+  font-size: 28rpx;
+  font-family: "SourceHanSansCN-Medium";
+  font-weight: 500;
 }
 
 .list_text input {
-    font-size: 30rpx;
-    color: #333;
-    text-align: right;
-    font-weight: bold;
-    // margin-left: 20rpx;
+  font-size: 30rpx;
+  color: #333;
+  text-align: right;
+  font-weight: bold;
+  // margin-left: 20rpx;
 }
 
 .list_text text {
-    font-family: "SourceHanSansCN-Medium";
-    font-size: 36rpx;
-    font-weight: bold;
-    color: #17bb87;
+  font-family: "SourceHanSansCN-Medium";
+  font-size: 36rpx;
+  font-weight: bold;
+  color: #17bb87;
+}
+
+.tips {
+  margin-top: 100rpx;
+  text-align: center;
+  color: #999;
+  font-size: 30rpx;
 }
 
 .btn {
-    // width: 689rpx;
-    width: calc(100% - 72rpx);
-    height: 92rpx;
-    background: #17bb87;
-    color: #fff;
-    font-size: 42rpx;
-    font-family: "SourceHanSansCN-Medium";
-    font-weight: 500;
-    margin: 132rpx auto 0;
-    border-radius: 10rpx;
+  width: 689rpx;
+  height: 92rpx;
+  background: #17bb87;
+  color: #fff;
+  font-size: 42rpx;
+  font-family: "SourceHanSansCN-Medium";
+  font-weight: 500;
+  margin: 20rpx auto 0;
+  border-radius: 10rpx;
 }
-.type_select{
-    text-align: right;
+.type_select {
+  text-align: right;
 }
-::v-deep .uni-select{
-    border: 0;
+::v-deep .uni-select {
+  border: 0;
 }
-::v-deep .uni-select__input-text{
-    padding-right: 16rpx;
+::v-deep .uni-select__input-text {
+  padding-right: 16rpx;
 }
 </style>

+ 1 - 13
src/pages/my/index.vue

@@ -415,18 +415,6 @@ export default {
       updataUserimg: {},
 
       allChaYou: "",
-	  list:[{
-		name:'茶宝',
-		balance:'余额',
-		fee:'费率',
-		tip:"提示"
-	  },
-	  {
-		name:'余额',
-		balance:'余额',
-		fee:'费率',
-		tip:"提示"
-	  }]
     };
   },
   onLoad: function (options) {
@@ -437,7 +425,7 @@ export default {
     }
     post("/my/chayou").then((res) => {
       if (res.code === 0) {
-		this.allChaYou = res.data.data.below + res.data.data.lower_level;
+        this.allChaYou = res.data.data.below + res.data.data.lower_level;
       }
     });
   },