refactor(custom): 完善活动页细节
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -95,11 +95,10 @@ Taro.useReachBottom(() => {
|
||||
});
|
||||
|
||||
const toPay = async item => {
|
||||
console.log(item);
|
||||
const tk = Taro.getStorageSync('token');
|
||||
if (!tk) {
|
||||
Taro.navigateTo({
|
||||
url: '/pages/users/login/index',
|
||||
url: '/pages/users/login/index?isBack=1',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import Taro from "@tarojs/taro";
|
||||
import UserModal from "@/components/UserModal.vue";
|
||||
import { ref } from "vue";
|
||||
import { getPhone, login } from "@/api/user";
|
||||
import logoImg from "../../../static/logo.jpg";
|
||||
import Taro from '@tarojs/taro';
|
||||
import UserModal from '@/components/UserModal.vue';
|
||||
import {ref} from 'vue';
|
||||
import {getPhone, login, getPersonalInfo} from '@/api/user';
|
||||
import logoImg from '../../../static/logo.jpg';
|
||||
|
||||
const isShow = ref(false);
|
||||
|
||||
@@ -12,17 +12,17 @@ const val = ref(false);
|
||||
const getCode = () => {
|
||||
if (!val.value)
|
||||
return Taro.showToast({
|
||||
title: "请先阅读并同意用户协议&隐私政策&积分使用规则",
|
||||
icon: "none",
|
||||
title: '请先阅读并同意用户协议&隐私政策&积分使用规则',
|
||||
icon: 'none',
|
||||
});
|
||||
Taro.showLoading({
|
||||
title: "授权中...",
|
||||
title: '授权中...',
|
||||
mask: true,
|
||||
});
|
||||
Taro.login({
|
||||
success: (res) => {
|
||||
success: res => {
|
||||
console.log(res);
|
||||
Taro.setStorageSync("wx_code", res.code);
|
||||
Taro.setStorageSync('wx_code', res.code);
|
||||
isShow.value = true;
|
||||
},
|
||||
complete: () => {
|
||||
@@ -32,51 +32,64 @@ const getCode = () => {
|
||||
};
|
||||
|
||||
const userInfo = ref({
|
||||
phone: "",
|
||||
phone: '',
|
||||
});
|
||||
|
||||
const optData = ref({});
|
||||
|
||||
Taro.useLoad(opt => {
|
||||
optData.value = opt;
|
||||
});
|
||||
|
||||
const getPhoneNumber = async (e: any) => {
|
||||
if (!val.value) {
|
||||
Taro.showToast({
|
||||
title: "请先阅读并同意用户协议&隐私政策&积分使用规则",
|
||||
icon: "none",
|
||||
title: '请先阅读并同意用户协议&隐私政策&积分使用规则',
|
||||
icon: 'none',
|
||||
});
|
||||
} else {
|
||||
Taro.showLoading({
|
||||
title: "授权手机号中",
|
||||
title: '授权手机号中',
|
||||
mask: true,
|
||||
});
|
||||
const { code } = e.detail;
|
||||
const {code} = e.detail;
|
||||
const res = await getPhone({
|
||||
code: code,
|
||||
});
|
||||
userInfo.value.phone = res.data.phone;
|
||||
if (!res.data.phone)
|
||||
return Taro.showToast({
|
||||
title: "手机号获取失败",
|
||||
icon: "none",
|
||||
title: '手机号获取失败',
|
||||
icon: 'none',
|
||||
});
|
||||
Taro.login({
|
||||
success: async (res) => {
|
||||
Taro.setStorageSync("wx_code", res.code);
|
||||
success: async res => {
|
||||
Taro.setStorageSync('wx_code', res.code);
|
||||
const ress = await login({
|
||||
Code: Taro.getStorageSync("wx_code"),
|
||||
Code: Taro.getStorageSync('wx_code'),
|
||||
Phone: userInfo.value.phone,
|
||||
Referee: Taro.getStorageSync("bind_id") || "",
|
||||
Referee: Taro.getStorageSync('bind_id') || '',
|
||||
});
|
||||
Taro.showToast({
|
||||
title: ress.msg,
|
||||
icon: "success",
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
});
|
||||
Taro.setStorageSync("token", ress.data.token);
|
||||
setTimeout(() => {
|
||||
Taro.removeStorageSync("wx_code");
|
||||
Taro.removeStorageSync("bind_id");
|
||||
Taro.switchTab({
|
||||
url: "/pages/user/index",
|
||||
Taro.setStorageSync('token', ress.data.token);
|
||||
if (optData.value.isBack) {
|
||||
await getUserInfo();
|
||||
Taro.navigateBack({
|
||||
delta: 1,
|
||||
});
|
||||
}, 2000);
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
Taro.removeStorageSync('wx_code');
|
||||
Taro.removeStorageSync('bind_id');
|
||||
Taro.switchTab({
|
||||
url: '/pages/user/index',
|
||||
});
|
||||
}, 2000);
|
||||
}
|
||||
},
|
||||
complete: () => {
|
||||
Taro.hideLoading();
|
||||
@@ -85,14 +98,28 @@ const getPhoneNumber = async (e: any) => {
|
||||
}
|
||||
};
|
||||
|
||||
const getUserInfo = async () => {
|
||||
const res = await getPersonalInfo();
|
||||
const userInfo = {
|
||||
...res.data,
|
||||
data: {
|
||||
...res.data.data,
|
||||
permission: res.data.data.permission
|
||||
? JSON.parse(res.data.data.permission)
|
||||
: {},
|
||||
},
|
||||
};
|
||||
Taro.setStorageSync('userInfo', userInfo);
|
||||
};
|
||||
|
||||
const toPage = () => {
|
||||
if (!val.value)
|
||||
return Taro.showToast({
|
||||
title: "请先阅读并同意用户协议&隐私政策&积分使用规则",
|
||||
icon: "none",
|
||||
title: '请先阅读并同意用户协议&隐私政策&积分使用规则',
|
||||
icon: 'none',
|
||||
});
|
||||
Taro.navigateTo({
|
||||
url: "/pages/users/bindPhone/index?type=1",
|
||||
url: '/pages/users/bindPhone/index?type=1',
|
||||
});
|
||||
};
|
||||
|
||||
@@ -132,8 +159,7 @@ const clickText = (type: number, text: string) => {
|
||||
隐私政策 </view
|
||||
>&<view
|
||||
style="color: #fa2c1a"
|
||||
@click.stop="clickText(3, '积分使用规则')"
|
||||
>
|
||||
@click.stop="clickText(3, '积分使用规则')">
|
||||
积分使用规则
|
||||
</view>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user