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

View File

@ -16,7 +16,7 @@
<up-button @click="weixinLogin" color="#20B128" size="large"><up-icon color="#fff"
size="28"></up-icon></up-button>
</view>
<!-- <view class="btn">
<!-- <view class="btn">
<up-button @click="navgo('/pages/login/test')" color="#20B128" size="large"><up-icon
name="account-fill" color="#fff" size="28"></up-icon>-</up-button>
</view> -->
@ -34,8 +34,8 @@
<up-transition :show="!showWeixin">
<view class="form">
<view class="input">
<up-input :customStyle="{ height: '100%' }" v-model="loginForm.phone" placeholderClass="place"
border="none" placeholder="请输入手机号" type="number">
<up-input :customStyle="{ height: '100%' }" v-model="loginForm.phone"
placeholderClass="place" border="none" placeholder="请输入手机号" type="number">
<template #prefix>
<image style="height: 40rpx;width: 40rpx;margin-top: 6rpx;"
src="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/48491202404281006484208.png">
@ -81,318 +81,318 @@
</template>
<script setup>
import {
onBackPress
} from "@dcloudio/uni-app"
import {
ref
} from "vue"
import {
userLoginApi,
userLoginWeixinApi,
getMobileByMnpApi,
getStoreInfo
} from "@/api/user.js";
import useUserStore from "@/store/user.js"
import bindPhone from "@/components/bindPhone.vue"
import modal from "@/components/modal.vue"
import {
config
} from "@/config/app.js"
import {
onBackPress
} from "@dcloudio/uni-app"
import {
ref
} from "vue"
import {
userLoginApi,
userLoginWeixinApi,
getMobileByMnpApi,
getStoreInfo
} from "@/api/user.js";
import useUserStore from "@/store/user.js"
import bindPhone from "@/components/bindPhone.vue"
import modal from "@/components/modal.vue"
import {
config
} from "@/config/app.js"
const showOfficial = ref(false);
const navToIndex = () => {
if (userStore.userInfo && userStore.token) uni.reLaunch({
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;
const showOfficial = ref(false);
const navToIndex = () => {
if (userStore.userInfo && userStore.token) uni.reLaunch({
url: '/pages/index/index'
})
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;
} else {
userStore.setUserInfo(res.data);
//
//
if (res.data.is_staff == 1) {
userStore.setUserInfo(res.data);
uni.reLaunch({
url: "/multipleShop/verificationOrder/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('请先阅读并同意协议');
}
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 {
// ,
let storeInfo = uni.getStorageSync('STORE_INFO');
if (storeInfo) {
storeInfo = JSON.parse(storeInfo);
//
userStore.setUserInfo(res.data);
//
//
if (res.data.is_staff == 1) {
userStore.setUserInfo(res.data);
uni.reLaunch({
url: "/pages/index/index?id=" + storeInfo.id
url: "/multipleShop/verificationOrder/index"
})
} else {
//
uni.reLaunch({
url: "/pages/index/index?id=" + storeInfo.id
})
// ,
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: "/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"
})
}
}
})
},
fail: (err) => {
console.log(err);
uni.$u.toast('登录失败');
} else {
console.log("用户拒绝授权");
return 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({
phone: '15366662222',
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 loginForm = ref({
phone: '15366662222',
code: ''
})
}
const tips = ref('');
const seconds = ref(60);
const uCodeRef = ref(null);
const codeChange = (text) => {
tips.value = text;
};
const getCode = () => {
if (!isAgree.value) return uni.$u.toast('请先阅读并同意协议');
if (uCodeRef.value.canGetCode) {
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('请输入正确的手机号码');
//
uni.showLoading({
title: '正在获取验证码',
});
setTimeout(() => {
uni.hideLoading();
// start()
uni.$u.toast('验证码已发送');
//
uCodeRef.value.start();
}, 2000);
} else {
uni.$u.toast('倒计时结束后再发送');
console.log('登录');
userLoginApi({
account: '17811111111',
password: '1111',
terminal: 3,
scene: 1
}).then(res => {
console.log(res);
})
}
};
// 使
const navBack = () => {
if (showWeixin.value == false) {
showWeixin.value = true;
return true;
} else uni.navigateBack();
}
const navgo = (url) => {
uni.navigateTo({
url
})
}
const tips = ref('');
const seconds = ref(60);
const uCodeRef = ref(null);
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('请输入正确的手机号码');
//
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>
<style lang="scss">
page {
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;
page {
background-color: #fff;
}
.tips {
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%;
.login-box {
width: 700rpx;
height: 80vh;
margin: 0 auto;
box-sizing: border-box;
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
color: #444;
padding-top: 10vh;
position: relative;
image {
width: 40rpx;
height: 40rpx;
margin-right: 10rpx;
.logo {
height: 152rpx;
width: 152rpx;
}
text {
color: #20B128;
.tips {
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>