注册调整
This commit is contained in:
parent
b7461002dc
commit
0c0d5e55d5
604
pnpm-lock.yaml
604
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -31,16 +31,19 @@ import { showToast } from '@/utils';
|
|||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const isAgreePrivacy = ref(false);
|
const isAgreePrivacy = ref(false);
|
||||||
|
|
||||||
function wechatLogin() {
|
async function wechatLogin() {
|
||||||
if(!isAgreePrivacy.value) {
|
if(!isAgreePrivacy.value) {
|
||||||
showToast('请先阅读并同意小程序隐私保护协议');
|
showToast('请先阅读并同意小程序隐私保护协议');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uni.showLoading();
|
await uni.showLoading();
|
||||||
userStore.authLogin().then(() => {
|
const result = await userStore.login();
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
uni.reLaunch({ url: '/pages/home/index' });
|
if(result) {
|
||||||
});
|
await uni.reLaunch({ url: '/pages/home/index' });
|
||||||
|
} else {
|
||||||
|
await uni.navigateTo({ url: '/pages/common/register/index' });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const bindCheck = () => {
|
const bindCheck = () => {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class='content'>
|
<view class='content'>
|
||||||
<image class='bg-image' :src='assetsUrl("bg_register.png")' />
|
<image class='bg-image' :src='assetsUrl("bg_register.png")' />
|
||||||
|
|
||||||
<image :src='assetsUrl("ic_register_gift_text.png")'
|
<image :src='assetsUrl("ic_register_gift_text.png")'
|
||||||
style='align-self: center;position: relative;width: 356rpx;height: 124rpx;margin-top: 70rpx' />
|
style='align-self: center;position: relative;width: 356rpx;height: 124rpx;margin-top: 70rpx' />
|
||||||
|
|
||||||
<view class='card-view'>
|
<view class='card-view'>
|
||||||
<view class='mobile-view c-flex-row' style='display: none'>
|
<view class='mobile-view c-flex-row' >
|
||||||
<image :src='assetsUrl("ic_register_mobile.png")' />
|
<image :src='assetsUrl("ic_register_mobile.png")' />
|
||||||
<input placeholder='请输入手机号' inputmode='number' maxLength='11' />
|
<input placeholder='请输入手机号' inputmode='number' maxLength='11' />
|
||||||
</view>
|
</view>
|
||||||
@ -18,61 +18,15 @@
|
|||||||
<text @click.stop='startCountdown'>{{ countdown }}</text>
|
<text @click.stop='startCountdown'>{{ countdown }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<text class='btn_register' style='display: none' @click.stop='register'>注册领券</text>
|
<text class='btn_register' @click.stop='register'>注册领券</text>
|
||||||
|
|
||||||
<image :src='companyConfigInfo.regqrcode||defaultImage' :show-menu-by-longpress='true' mode='aspectFill'
|
|
||||||
style='width: 439rpx;height: 439rpx;align-self: center' />
|
|
||||||
<text style='font-size: 26rpx;
|
|
||||||
margin-top: 10rpx;
|
|
||||||
align-self: center;color: #666666;'>长按扫码注册
|
|
||||||
</text>
|
|
||||||
|
|
||||||
<template v-if='couponBean&&couponBean.status==0'>
|
|
||||||
<view class='divider' />
|
|
||||||
<view class='coupon c-flex-column' @click.stop='goPath("/pages/mine/subs/coupon/index")'>
|
|
||||||
<view class='c-flex-row'>
|
|
||||||
<text class='coupon-name'>{{ couponBean.title }}</text>
|
|
||||||
<image :src='assetsUrl("ic_arrow_right_gray.png")' />
|
|
||||||
</view>
|
|
||||||
<text class='expired-time'>
|
|
||||||
有效期至{{ dayjs(Date.now()).add(couponBean.triggerEndDay, 'day').format('YYYY.MM.DD') }}
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class='divider' />
|
|
||||||
|
|
||||||
<text style='font-size: 28rpx;
|
|
||||||
font-weight: bold;
|
|
||||||
color: #333333;margin-top: 20rpx'>福利详情
|
|
||||||
</text>
|
|
||||||
<text style='font-size: 28rpx;
|
|
||||||
color: #333333;margin-top: 14rpx'>1.优惠金额{{ couponBean.reduce }}元\n
|
|
||||||
2.满{{ couponBean.threshold }}减{{ couponBean.reduce }}\n
|
|
||||||
3.赠送{{ couponBean.publicNum }}张
|
|
||||||
</text>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<text style='font-size: 28rpx;
|
|
||||||
font-weight: bold;
|
|
||||||
color: #333333;margin-top: 20rpx'>
|
|
||||||
微信扫一扫领取会员卡
|
|
||||||
</text>
|
|
||||||
<text style='font-size: 28rpx;
|
|
||||||
color: #333333;margin-top: 14rpx'>
|
|
||||||
1、及时接受消费小票\n
|
|
||||||
2、随时查询消费记录\n
|
|
||||||
3、及时接收优惠信息
|
|
||||||
</text>
|
|
||||||
</template>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang='ts' setup>
|
<script lang='ts' setup>
|
||||||
import { assetsUrl, defaultImage } from '@/utils/assets';
|
import { assetsUrl } from '@/utils/assets';
|
||||||
import { useUserStore } from '@/store';
|
import { useUserStore } from '@/store';
|
||||||
import { goPath } from '@/utils';
|
|
||||||
import { getRegisterCoupon } from '@/api/user';
|
import { getRegisterCoupon } from '@/api/user';
|
||||||
import dayjs from 'dayjs';
|
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const { companyConfigInfo } = storeToRefs(userStore);
|
const { companyConfigInfo } = storeToRefs(userStore);
|
||||||
|
@ -161,14 +161,6 @@ const fetchCompanyList = (fn: any = undefined) => {
|
|||||||
userStore.setUserInfo(userList.value[index]);
|
userStore.setUserInfo(userList.value[index]);
|
||||||
userStore.setCompanyInfo(companyList.value[index]);
|
userStore.setCompanyInfo(companyList.value[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// uni.showActionSheet({
|
|
||||||
// itemList: companyList.map((res: { companyName: string }) => res.companyName),
|
|
||||||
// success: (res) => {
|
|
||||||
// userStore.setUserInfo(userList[res.tapIndex]);
|
|
||||||
// userStore.setCompanyInfo(companyList[res.tapIndex]);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -104,8 +104,9 @@ const useUserStore = defineStore('user', {
|
|||||||
this.companyConfigInfo = await getCompanyInfo();
|
this.companyConfigInfo = await getCompanyInfo();
|
||||||
},
|
},
|
||||||
|
|
||||||
checkUserRegisterStatus() {
|
async checkUserRegisterStatus() {
|
||||||
|
const userBean = await this.login();
|
||||||
|
return !!userBean;
|
||||||
},
|
},
|
||||||
|
|
||||||
userRegister(registerForm: RegisterParams) {
|
userRegister(registerForm: RegisterParams) {
|
||||||
@ -126,6 +127,45 @@ const useUserStore = defineStore('user', {
|
|||||||
clearToken();
|
clearToken();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async login() {
|
||||||
|
return new Promise<UserBean>((resolve, reject) => {
|
||||||
|
uni.login({
|
||||||
|
provider: 'weixin',
|
||||||
|
success: async (result: UniApp.LoginRes) => {
|
||||||
|
if(result.code) {
|
||||||
|
const wechatUserInfo = await uni.getUserInfo();
|
||||||
|
const userInfo = {
|
||||||
|
...wechatUserInfo.userInfo,
|
||||||
|
encryptedData: wechatUserInfo?.encryptedData,
|
||||||
|
rawData: JSON.parse(wechatUserInfo?.rawData),
|
||||||
|
signature: wechatUserInfo?.signature,
|
||||||
|
iv: wechatUserInfo.iv
|
||||||
|
};
|
||||||
|
getApp().globalData?.logger.info('login params: ', userInfo);
|
||||||
|
const res = await login({
|
||||||
|
code: result.code,
|
||||||
|
userInfo: userInfo,
|
||||||
|
storeId: getRegisterStoreId()
|
||||||
|
// referrerUserId: '1727303781559697409'
|
||||||
|
// referrerUserId: getReferrerUserId()
|
||||||
|
});
|
||||||
|
if(res.token) {
|
||||||
|
setToken(res.token);
|
||||||
|
}
|
||||||
|
if(res.user) {
|
||||||
|
await this.getProfile();
|
||||||
|
resolve(res.user);
|
||||||
|
} else {
|
||||||
|
reject(res);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
reject(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
// 小程序授权登录
|
// 小程序授权登录
|
||||||
authLogin(provider: providerType = 'weixin') {
|
authLogin(provider: providerType = 'weixin') {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
@ -99,6 +99,8 @@ function responseInterceptors() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
(response: HttpError) => {
|
(response: HttpError) => {
|
||||||
|
/* 对响应错误做点什么 (statusCode !== 200)*/
|
||||||
|
getApp().globalData?.logger.info('request error : ', response);
|
||||||
if(response.statusCode) {
|
if(response.statusCode) {
|
||||||
// 请求已发出,但是不在2xx的范围
|
// 请求已发出,但是不在2xx的范围
|
||||||
showMessage(response.statusCode);
|
showMessage(response.statusCode);
|
||||||
|
Loading…
Reference in New Issue
Block a user