This commit is contained in:
zmj 2024-07-04 13:46:05 +08:00
parent c899d8f472
commit ec33cc6119
2 changed files with 293 additions and 289 deletions

View File

@ -760,7 +760,7 @@
} }
if (type == 2) { if (type == 2) {
if (!formData2.mobile) return uni.$u.toast('请填写电话号码'); if (!formData2.mobile) return uni.$u.toast('请填写电话号码');
if (formData2.price < formData2.label_limit) return uni.$u.toast( if (Number(formData2.price) < Number(formData2.label_limit)) return uni.$u.toast(
`${formData2.label_name}角色最低金额不能低于${formData2.label_limit}`); `${formData2.label_name}角色最低金额不能低于${formData2.label_limit}`);
formData2.store_id = STORE_INFO.id formData2.store_id = STORE_INFO.id
// formData2.recharge_type = 'INDUSTRYMEMBERS' // formData2.recharge_type = 'INDUSTRYMEMBERS'
@ -800,9 +800,13 @@
if (!formData.code) return uni.$u.toast('请输入短信验证码'); if (!formData.code) return uni.$u.toast('请输入短信验证码');
if (!formData.address) return uni.$u.toast('请选择地址'); if (!formData.address) return uni.$u.toast('请选择地址');
if (!formData.label_id) return uni.$u.toast('请选择用户身份'); if (!formData.label_id) return uni.$u.toast('请选择用户身份');
if (formData.price < formData.label_limit) return uni.$u.toast( if (Number(formData.price) < Number(formData.label_limit)) {
`${formData.label_name}角色最低金额不能低于${formData.label_limit}`); return uni.$u.toast(
formData.store_id = STORE_INFO.id `${formData.label_name}角色最低金额不能低于${formData.label_limit}`);
formData.store_id = STORE_INFO.id
}
if (Role.value == 1) { if (Role.value == 1) {
// formData.recharge_type = 'INDUSTRYMEMBERS' // formData.recharge_type = 'INDUSTRYMEMBERS'
// formData.user_ship = formData.label_id // formData.user_ship = formData.label_id

View File

@ -16,7 +16,7 @@
<up-button @click="weixinLogin" color="#20B128" size="large"><up-icon color="#fff" <up-button @click="weixinLogin" color="#20B128" size="large"><up-icon color="#fff"
size="28"></up-icon></up-button> size="28"></up-icon></up-button>
</view> </view>
<!-- <view class="btn"> <!-- <view class="btn">
<up-button @click="navgo('/pages/login/test')" color="#20B128" size="large"><up-icon <up-button @click="navgo('/pages/login/test')" color="#20B128" size="large"><up-icon
name="account-fill" color="#fff" size="28"></up-icon>-</up-button> name="account-fill" color="#fff" size="28"></up-icon>-</up-button>
</view> --> </view> -->
@ -34,8 +34,8 @@
<up-transition :show="!showWeixin"> <up-transition :show="!showWeixin">
<view class="form"> <view class="form">
<view class="input"> <view class="input">
<up-input :customStyle="{ height: '100%' }" v-model="loginForm.phone" placeholderClass="place" <up-input :customStyle="{ height: '100%' }" v-model="loginForm.phone"
border="none" placeholder="请输入手机号" type="number"> placeholderClass="place" border="none" placeholder="请输入手机号" type="number">
<template #prefix> <template #prefix>
<image style="height: 40rpx;width: 40rpx;margin-top: 6rpx;" <image style="height: 40rpx;width: 40rpx;margin-top: 6rpx;"
src="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/48491202404281006484208.png"> src="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/48491202404281006484208.png">
@ -81,318 +81,318 @@
</template> </template>
<script setup> <script setup>
import { import {
onBackPress onBackPress
} from "@dcloudio/uni-app" } from "@dcloudio/uni-app"
import { import {
ref ref
} from "vue" } from "vue"
import { import {
userLoginApi, userLoginApi,
userLoginWeixinApi, userLoginWeixinApi,
getMobileByMnpApi, getMobileByMnpApi,
getStoreInfo getStoreInfo
} from "@/api/user.js"; } from "@/api/user.js";
import useUserStore from "@/store/user.js" import useUserStore from "@/store/user.js"
import bindPhone from "@/components/bindPhone.vue" import bindPhone from "@/components/bindPhone.vue"
import modal from "@/components/modal.vue" import modal from "@/components/modal.vue"
import { import {
config config
} from "@/config/app.js" } from "@/config/app.js"
const showOfficial = ref(false); const showOfficial = ref(false);
const navToIndex = () => { const navToIndex = () => {
if (userStore.userInfo && userStore.token) uni.reLaunch({ if (userStore.userInfo && userStore.token) uni.reLaunch({
url: '/pages/index/index' url: '/pages/index/index'
})
// if (!userStore.userInfo.supplier) uni.reLaunch({
// url: '/pages/index/index'
// })
// else if (userStore.userInfo.supplier && !userStore.userInfo.supplier.openid) {
// return showOfficial.value = true;
// } else {
// uni.reLaunch({
// url: '/pageQuota/quotation/index'
// })
// }
}
//
const officialCode = () => {
console.log("jinfas")
return
uni.navigateTo({
url: `/pages/code/code?id=${userStore.userInfo.id}`,
success: () => {
let user = userStore.userInfo;
user.supplier ? user.supplier.openid = 1 : user.supplier = {};
userStore.setUserInfo(user);
}
})
}
const userStore = useUserStore(); //使pinia
if (userStore.userInfo && userStore.userInfo.mobile) {
navToIndex();
} else {
userStore.setToken('');
userStore.setUserInfo({});
}
const showWeixin = ref(true); //
const isAgree = ref(false); //
const weixinLogin = () => {
if (!isAgree.value) {
uni.$u.sleep(1000).then(res => {
isAgree.value = true;
}) })
return uni.$u.toast('请先阅读并同意协议'); // if (!userStore.userInfo.supplier) uni.reLaunch({
// url: '/pages/index/index'
// })
// else if (userStore.userInfo.supplier && !userStore.userInfo.supplier.openid) {
// return showOfficial.value = true;
// } else {
// uni.reLaunch({
// url: '/pageQuota/quotation/index'
// })
// }
} }
uni.showLoading({
title: '登录中'
})
uni.login({
provider: 'weixin',
success: (res) => {
userLoginWeixinApi({
code: res.code
}).then(res => {
uni.hideLoading();
userStore.setToken(res.data.token);
getStoreInfo().then(res => {
uni.setStorageSync("STORE_INFO", JSON.stringify(res.data))
})
if (!res.data.mobile) { // //
return showBind.value = true; const officialCode = () => {
} else { console.log("jinfas")
userStore.setUserInfo(res.data); return
//
// uni.navigateTo({
if (res.data.is_staff == 1) { url: `/pages/code/code?id=${userStore.userInfo.id}`,
userStore.setUserInfo(res.data); success: () => {
uni.reLaunch({ let user = userStore.userInfo;
url: "/multipleShop/verificationOrder/index" user.supplier ? user.supplier.openid = 1 : user.supplier = {};
}) userStore.setUserInfo(user);
}
})
}
const userStore = useUserStore(); //使pinia
if (userStore.userInfo && userStore.userInfo.mobile) {
navToIndex();
} else {
userStore.setToken('');
userStore.setUserInfo({});
}
const showWeixin = ref(true); //
const isAgree = ref(false); //
const weixinLogin = () => {
if (!isAgree.value) {
uni.$u.sleep(1000).then(res => {
isAgree.value = true;
})
return uni.$u.toast('请先阅读并同意协议');
}
uni.showLoading({
title: '登录中'
})
uni.login({
provider: 'weixin',
success: (res) => {
userLoginWeixinApi({
code: res.code
}).then(res => {
uni.hideLoading();
userStore.setToken(res.data.token);
getStoreInfo().then(res => {
uni.setStorageSync("STORE_INFO", JSON.stringify(res.data))
})
if (!res.data.mobile) { //
return showBind.value = true;
} else { } else {
// , userStore.setUserInfo(res.data);
let storeInfo = uni.getStorageSync('STORE_INFO'); //
if (storeInfo) { //
storeInfo = JSON.parse(storeInfo); if (res.data.is_staff == 1) {
// userStore.setUserInfo(res.data);
uni.reLaunch({ uni.reLaunch({
url: "/pages/index/index?id=" + storeInfo.id url: "/multipleShop/verificationOrder/index"
}) })
} else { } else {
// // ,
uni.reLaunch({ let storeInfo = uni.getStorageSync('STORE_INFO');
url: "/pages/index/index?id=" + storeInfo.id if (storeInfo) {
}) storeInfo = JSON.parse(storeInfo);
//
uni.reLaunch({
url: "/pages/index/index?id=" + storeInfo.id
})
} else {
//
uni.reLaunch({
url: "/pages/index/index?id=" + storeInfo.id
})
}
} }
} }
})
},
fail: (err) => {
console.log(err);
uni.$u.toast('登录失败');
}
})
}
const showBind = ref(false); //
const getPhoneNumber = (e) => {
if (e.detail?.errMsg == 'getPhoneNumber:ok') {
getMobileByMnpApi({
code: e.detail.code
}).then(res => {
// token
userStore.setUserInfo(res.data);
userStore.setToken(res.data.token);
//
if (res.is_staff == 1) {
userStore.setUserInfo(res.data);
uni.reLaunch({
url: "/multipleShop/verificationOrder/index"
})
} else {
// ,
let storeInfo = uni.getStorageSync('STORE_INFO');
if (storeInfo) {
storeInfo = JSON.parse(storeInfo);
//
uni.reLaunch({
url: "/pages/index/index?id=" + storeInfo.id
})
} else {
//
uni.reLaunch({
url: "/multipleShop/index/index"
})
}
} }
}) })
}, } else {
fail: (err) => { console.log("用户拒绝授权");
console.log(err); return uni.$u.toast('您拒绝了授权');
uni.$u.toast('登录失败');
} }
})
}
const showBind = ref(false); //
const getPhoneNumber = (e) => {
if (e.detail?.errMsg == 'getPhoneNumber:ok') {
getMobileByMnpApi({
code: e.detail.code
}).then(res => {
// token
userStore.setUserInfo(res.data);
userStore.setToken(res.data.token);
//
if (res.is_staff == 1) {
userStore.setUserInfo(res.data);
uni.reLaunch({
url: "/multipleShop/verificationOrder/index"
})
} else {
// ,
let storeInfo = uni.getStorageSync('STORE_INFO');
if (storeInfo) {
storeInfo = JSON.parse(storeInfo);
//
uni.reLaunch({
url: "/pages/index/index?id=" + storeInfo.id
})
} else {
//
uni.reLaunch({
url: "/multipleShop/index/index"
})
}
}
})
} else {
console.log("用户拒绝授权");
return uni.$u.toast('您拒绝了授权');
} }
}
const loginForm = ref({ const loginForm = ref({
phone: '15366662222', phone: '15366662222',
code: '' code: ''
})
const isPhone = () => { //
loginForm.value.phone = loginForm.value.phone.replace(/\s*/g, ""); //
return !/^1[3456789]\d{9}$/.test(loginForm.value.phone);
}
const codeLogin = () => {
if (!isAgree.value) return uni.$u.toast('请先阅读并同意协议');
//
if (isPhone()) return uni.$u.toast('请输入正确的手机号码');
console.log('登录');
userLoginApi({
account: '17811111111',
password: '1111',
terminal: 3,
scene: 1
}).then(res => {
console.log(res);
}) })
} const isPhone = () => { //
loginForm.value.phone = loginForm.value.phone.replace(/\s*/g, ""); //
const tips = ref(''); return !/^1[3456789]\d{9}$/.test(loginForm.value.phone);
const seconds = ref(60); }
const uCodeRef = ref(null); const codeLogin = () => {
if (!isAgree.value) return uni.$u.toast('请先阅读并同意协议');
const codeChange = (text) => { //
tips.value = text;
};
const getCode = () => {
if (!isAgree.value) return uni.$u.toast('请先阅读并同意协议');
if (uCodeRef.value.canGetCode) {
if (isPhone()) return uni.$u.toast('请输入正确的手机号码'); if (isPhone()) return uni.$u.toast('请输入正确的手机号码');
// console.log('登录');
uni.showLoading({ userLoginApi({
title: '正在获取验证码', account: '17811111111',
}); password: '1111',
setTimeout(() => { terminal: 3,
uni.hideLoading(); scene: 1
// start() }).then(res => {
uni.$u.toast('验证码已发送'); console.log(res);
// })
uCodeRef.value.start();
}, 2000);
} else {
uni.$u.toast('倒计时结束后再发送');
} }
};
// 使 const tips = ref('');
const navBack = () => { const seconds = ref(60);
if (showWeixin.value == false) { const uCodeRef = ref(null);
showWeixin.value = true;
return true; const codeChange = (text) => {
} else uni.navigateBack(); tips.value = text;
} };
const navgo = (url) => {
uni.navigateTo({ const getCode = () => {
url if (!isAgree.value) return uni.$u.toast('请先阅读并同意协议');
}) if (uCodeRef.value.canGetCode) {
} if (isPhone()) return uni.$u.toast('请输入正确的手机号码');
//
uni.showLoading({
title: '正在获取验证码',
});
setTimeout(() => {
uni.hideLoading();
// start()
uni.$u.toast('验证码已发送');
//
uCodeRef.value.start();
}, 2000);
} else {
uni.$u.toast('倒计时结束后再发送');
}
};
// 使
const navBack = () => {
if (showWeixin.value == false) {
showWeixin.value = true;
return true;
} else uni.navigateBack();
}
const navgo = (url) => {
uni.navigateTo({
url
})
}
</script> </script>
<style lang="scss"> <style lang="scss">
page { page {
background-color: #fff; background-color: #fff;
}
.login-box {
width: 700rpx;
height: 80vh;
margin: 0 auto;
box-sizing: border-box;
display: flex;
flex-direction: column;
align-items: center;
padding-top: 10vh;
position: relative;
.logo {
height: 152rpx;
width: 152rpx;
} }
.tips { .login-box {
color: #444444; width: 700rpx;
font-size: 28rpx; height: 80vh;
margin: 30rpx 0; margin: 0 auto;
} box-sizing: border-box;
.btn {
width: 600rpx;
margin-top: 40rpx;
font-size: 32rpx !important;
}
.form {
.input {
background-color: #ECFFEE;
width: 600rpx;
height: 90rpx;
box-sizing: border-box;
padding: 0 20rpx;
margin-bottom: 40rpx;
.place {
color: #333;
}
.customStyle {
color: red;
}
}
}
.wx-login {
width: 200rpx;
text-align: center;
padding: 20rpx;
border-radius: 100rpx;
background-color: #EFEFEF;
position: absolute;
bottom: 80rpx;
left: 50%;
transform: translateX(-50%);
}
.wx-login:active {
background-color: #ECFFEE;
}
.agreement {
position: absolute;
bottom: 0rpx;
left: 0;
width: 100%;
display: flex; display: flex;
justify-content: center; flex-direction: column;
align-items: center; align-items: center;
color: #444; padding-top: 10vh;
position: relative;
image { .logo {
width: 40rpx; height: 152rpx;
height: 40rpx; width: 152rpx;
margin-right: 10rpx;
} }
text { .tips {
color: #20B128; color: #444444;
font-size: 28rpx;
margin: 30rpx 0;
}
.btn {
width: 600rpx;
margin-top: 40rpx;
font-size: 32rpx !important;
}
.form {
.input {
background-color: #ECFFEE;
width: 600rpx;
height: 90rpx;
box-sizing: border-box;
padding: 0 20rpx;
margin-bottom: 40rpx;
.place {
color: #333;
}
.customStyle {
color: red;
}
}
}
.wx-login {
width: 200rpx;
text-align: center;
padding: 20rpx;
border-radius: 100rpx;
background-color: #EFEFEF;
position: absolute;
bottom: 80rpx;
left: 50%;
transform: translateX(-50%);
}
.wx-login:active {
background-color: #ECFFEE;
}
.agreement {
position: absolute;
bottom: 0rpx;
left: 0;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
color: #444;
image {
width: 40rpx;
height: 40rpx;
margin-right: 10rpx;
}
text {
color: #20B128;
}
} }
} }
}
</style> </style>