Commit 5317fc5e authored by hewenhao's avatar hewenhao

Merge branch 'feature/2021_03_12_bonus' of…

Merge branch 'feature/2021_03_12_bonus' of https://dev.jiuaoedu.com/wykolor/GeekBonusH5 into feature/2021_03_12_bonus
parents c41dbd09 bfbe5096
......@@ -118,13 +118,13 @@ function invokeNativeMethod<T = any, P = any>(arg: { type: string; data?: P }):
/**
* 微信登录
*/
export function bindWechat() {
export function bindWeChat() {
return invokeNativeMethod<{ code: string; userId: string }>({ type: "bindWechat" });
}
/**
* 打电话
*/
export function makecall(phone: string) {
export function makeCall(phone: string) {
return invokeNativeMethod<null, string>({ type: "makecall", data: phone });
}
......@@ -87,6 +87,7 @@ import { computed, defineComponent, onMounted, reactive, toRefs } from "vue";
import { bonusModel } from "@/server/api";
import { useStore } from "vuex";
import { useNativeBridge } from "@/util/use-native-bridge";
import { useRoute } from "vue-router";
interface BonusList {
addList: BonusListResponse[];
......@@ -95,6 +96,7 @@ interface BonusList {
const BonusDetail = defineComponent({
setup() {
const store = useStore();
const route = useRoute();
const bonusStoreState = computed(() => store.state.bonus);
const pageAdd = reactive({
pageSize: 10,
......@@ -107,7 +109,7 @@ const BonusDetail = defineComponent({
finished: false
});
const state = reactive({
active: "REDUCE",
active: route.query.active || "REDUCE",
loading: false,
finished: false,
error: false,
......@@ -131,7 +133,7 @@ const BonusDetail = defineComponent({
state.refreshing = false;
}
const params = {
studentId: bonusStoreState.value.studentId,
studentId: route.query.studentId || bonusStoreState.value.studentId,
flowType: state.active === FlowType.ADD ? "ADD" : "REDUCE",
pageSize: state.active === FlowType.ADD ? pageAdd.pageSize : pageReduce.pageSize,
pageNum: state.active === FlowType.ADD ? pageAdd.pageNum : pageReduce.pageNum
......
......@@ -139,7 +139,10 @@
>
<div class="dialog-handle-btns">
<van-button type="default" round @click="showBindWx = false">取消</van-button
><van-button type="primary" round @click="bindWeChat">绑定微信</van-button>
><van-button type="primary" round @click="bindWeiChat" :disabled="binding"
><van-loading v-if="binding" size="20px" color="#ccc">绑定中...</van-loading
><span v-else>绑定微信</span></van-button
>
</div>
</van-dialog>
<van-dialog
......@@ -164,12 +167,12 @@ import { computed, defineComponent, onMounted, reactive, toRefs } from "vue";
import { useRoute, useRouter } from "vue-router";
import { useStore } from "vuex";
import { Dialog, Button, Col, Row, Cell, List, Toast } from "vant";
import { Dialog, Button, Col, Row, Cell, List, Loading } from "vant";
import { BonusAccountResponse, WithdrawListParams, WithdrawListResponse } from "@/model/bonus";
import { bonusModel } from "@/server/api";
import { BonusAccountStatus, ErrCode } from "@/model/bonus/constant";
import { useNativeBridge, makecall } from "@/util/use-native-bridge";
import { bindWeChat, useNativeBridge, makeCall } from "@/util/use-native-bridge";
import { formatBonusTipTxt } from "@/util/formatBonusTipTxt";
interface BonusState {
......@@ -195,17 +198,23 @@ const Bonus = defineComponent({
showBindWx: false,
showDangerous: false,
bonusAccount: null,
binding: false,
BonusAccountStatus,
withdrawList: []
});
const [sendNativeMessage] = useNativeBridge("bindWeChatChange", function() {
state.showBindWx = false;
const [sendNativeMessage] = useNativeBridge("test", function() {
// state.showBindWx = false;
});
// 获取奖励金信息
bonusModel.getBonusAccount(bonusStoreState.value.studentId).then(res => {
const { data } = res;
state.bonusAccount = data;
});
const getBonusAccount = () => {
bonusModel.getBonusAccount(bonusStoreState.value.studentId).then(res => {
const { data } = res;
state.bonusAccount = data;
});
};
getBonusAccount();
const withdrawListParams = reactive<WithdrawListParams>({
pageSize: 10,
pageNum: 1,
......@@ -230,29 +239,32 @@ const Bonus = defineComponent({
onLoad();
});
const withdraw = () => {
if (!state.bonusAccount?.errCode) {
// 都正常的状态
router.push("withdraw");
} else if (state.bonusAccount?.errCode === ErrCode.NOT_BIND) {
state.showBindWx = true;
} else {
state.showDangerous = true;
}
state.showBindWx = true;
// if (!state.bonusAccount?.errCode) {
// // 都正常的状态
// router.push("withdraw");
// } else if (state.bonusAccount?.errCode === ErrCode.NOT_BIND) {
// state.showBindWx = true;
// } else {
// state.showDangerous = true;
// }
};
const withdrawRule = () => {
state.showWithdrawRules = true;
};
const phoneCall = () => {
makecall('400—8777389')
makeCall("400—8777389")
// sendNativeMessage({
// type: "phoneCall",
// data: "400—8777389"
// });
};
const bindWeChat = () => {
sendNativeMessage({
type: "bindWeChat",
data: "bindWeChat"
const bindWeiChat = () => {
state.binding = true;
bindWeChat().then(() => {
state.showBindWx = false;
state.binding = false;
getBonusAccount();
});
};
return {
......@@ -261,7 +273,7 @@ const Bonus = defineComponent({
withdraw,
withdrawRule,
phoneCall,
bindWeChat,
bindWeiChat,
bonusStoreState,
formatBonusTipTxt
};
......@@ -272,7 +284,8 @@ const Bonus = defineComponent({
[Row.name]: Row,
[Cell.name]: Cell,
[List.name]: List,
[Dialog.Component.name]: Dialog.Component
[Dialog.Component.name]: Dialog.Component,
[Loading.name]: Loading
}
});
export default Bonus;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment