|
|
|
@ -1,97 +1,109 @@
|
|
|
|
|
<template>
|
|
|
|
|
<view>
|
|
|
|
|
<up-navbar title="登录" :autoBack="false" placeholder bgColor="rgba(0,0,0,0)">
|
|
|
|
|
<template #left>
|
|
|
|
|
<up-icon v-if="!showWeixin" name="arrow-left" @click="navBack" size="20"></up-icon>
|
|
|
|
|
<view v-else></view>
|
|
|
|
|
</template>
|
|
|
|
|
</up-navbar>
|
|
|
|
|
<view class="login-box">
|
|
|
|
|
<image class="logo" src="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/35adb202404271727457954.png">
|
|
|
|
|
</image>
|
|
|
|
|
<view class="tips">欢迎登录惠农批发</view>
|
|
|
|
|
<block v-if="showWeixin">
|
|
|
|
|
<up-transition :show="showWeixin">
|
|
|
|
|
<view class="btn">
|
|
|
|
|
<up-button @click="weixinLogin" color="#20B128" size="large"><up-icon name="weixin-fill"
|
|
|
|
|
color="#fff" size="28"></up-icon>微信快捷登录</up-button>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="btn">
|
|
|
|
|
<up-button color="#ECFFEE" @click="showWeixin=false" size="large"><text
|
|
|
|
|
style="color: #20B128;">使用短信验证登录</text></up-button>
|
|
|
|
|
</view>
|
|
|
|
|
</up-transition>
|
|
|
|
|
</block>
|
|
|
|
|
<block v-else>
|
|
|
|
|
<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">
|
|
|
|
|
<template #prefix>
|
|
|
|
|
<image style="height: 40rpx;width: 40rpx;margin-top: 6rpx;"
|
|
|
|
|
src="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/48491202404281006484208.png">
|
|
|
|
|
</image>
|
|
|
|
|
</template>
|
|
|
|
|
</up-input>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="input">
|
|
|
|
|
<up-input :customStyle="{height: '100%'}" v-model="loginForm.code" :maxlength="4"
|
|
|
|
|
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/3a42f202404281007454918.png">
|
|
|
|
|
</image>
|
|
|
|
|
</template>
|
|
|
|
|
<template #suffix>
|
|
|
|
|
<up-code :seconds="seconds" ref="uCodeRef" @change="codeChange"></up-code>
|
|
|
|
|
<view style="color: #20B128;" @click="getCode">{{tips}}</view>
|
|
|
|
|
</template>
|
|
|
|
|
</up-input>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="btn">
|
|
|
|
|
<up-button color="#20B128" size="large" @click="codeLogin">登录</up-button>
|
|
|
|
|
</view>
|
|
|
|
|
</up-transition>
|
|
|
|
|
</block>
|
|
|
|
|
<view class="agreement">
|
|
|
|
|
<image v-if="!isAgree" @click="isAgree=true" src="@/static/icon/n-check.png"></image>
|
|
|
|
|
<image v-else @click="isAgree=false" src="@/static/icon/check.png"></image>
|
|
|
|
|
<view>
|
|
|
|
|
我已同意<text>《用户协议》</text>与<text>《隐私政策》</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<bindPhone :show="showBind" @close="showBind = false" @change="getPhoneNumber" />
|
|
|
|
|
</view>
|
|
|
|
|
<view>
|
|
|
|
|
<up-navbar title="登录" :autoBack="false" placeholder bgColor="rgba(0,0,0,0)">
|
|
|
|
|
<template #left>
|
|
|
|
|
<up-icon v-if="!showWeixin" name="arrow-left" @click="navBack" size="20"></up-icon>
|
|
|
|
|
<view v-else></view>
|
|
|
|
|
</template>
|
|
|
|
|
</up-navbar>
|
|
|
|
|
<view class="login-box">
|
|
|
|
|
<image class="logo" src="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/35adb202404271727457954.png"></image>
|
|
|
|
|
<view class="tips">欢迎登录惠农批发</view>
|
|
|
|
|
<block v-if="showWeixin">
|
|
|
|
|
<up-transition :show="showWeixin">
|
|
|
|
|
<view class="btn">
|
|
|
|
|
<up-button @click="weixinLogin" color="#20B128" size="large"><up-icon name="weixin-fill" color="#fff"
|
|
|
|
|
size="28"></up-icon>微信快捷登录</up-button>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- <view class="btn">
|
|
|
|
|
<up-button @click="officialCode" color="#20B128" size="large"><up-icon name="weixin-fill" color="#fff"
|
|
|
|
|
size="28"></up-icon>公众号授权</up-button>
|
|
|
|
|
</view> -->
|
|
|
|
|
<view class="btn">
|
|
|
|
|
<up-button color="#ECFFEE" @click="showWeixin=false" size="large"><text
|
|
|
|
|
style="color: #20B128;">使用短信验证登录</text></up-button>
|
|
|
|
|
</view>
|
|
|
|
|
</up-transition>
|
|
|
|
|
</block>
|
|
|
|
|
<block v-else>
|
|
|
|
|
<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">
|
|
|
|
|
<template #prefix>
|
|
|
|
|
<image style="height: 40rpx;width: 40rpx;margin-top: 6rpx;"
|
|
|
|
|
src="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/48491202404281006484208.png"></image>
|
|
|
|
|
</template>
|
|
|
|
|
</up-input>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="input">
|
|
|
|
|
<up-input :customStyle="{height: '100%'}" v-model="loginForm.code" :maxlength="4" 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/3a42f202404281007454918.png"></image>
|
|
|
|
|
</template>
|
|
|
|
|
<template #suffix>
|
|
|
|
|
<up-code :seconds="seconds" ref="uCodeRef" @change="codeChange"></up-code>
|
|
|
|
|
<view style="color: #20B128;" @click="getCode">{{tips}}</view>
|
|
|
|
|
</template>
|
|
|
|
|
</up-input>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="btn">
|
|
|
|
|
<up-button color="#20B128" size="large" @click="codeLogin">登录</up-button>
|
|
|
|
|
</view>
|
|
|
|
|
</up-transition>
|
|
|
|
|
</block>
|
|
|
|
|
<view class="agreement">
|
|
|
|
|
<image v-if="!isAgree" @click="isAgree=true" src="@/static/icon/n-check.png"></image>
|
|
|
|
|
<image v-else @click="isAgree=false" src="@/static/icon/check.png"></image>
|
|
|
|
|
<view>
|
|
|
|
|
我已同意<text>《用户协议》</text>与<text>《隐私政策》</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<bindPhone :show="showBind" @close="showBind = false" @change="getPhoneNumber" />
|
|
|
|
|
<modal :show="showOfficial" @close="showOfficial = false" @change="officialCode()" />
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import {
|
|
|
|
|
onBackPress
|
|
|
|
|
} from "@dcloudio/uni-app"
|
|
|
|
|
import {
|
|
|
|
|
ref
|
|
|
|
|
} from "vue"
|
|
|
|
|
import {
|
|
|
|
|
userLoginApi,
|
|
|
|
|
userLoginWeixinApi,
|
|
|
|
|
getMobileByMnpApi
|
|
|
|
|
} from "@/api/user.js";
|
|
|
|
|
import useUserStore from "@/store/user.js"
|
|
|
|
|
import bindPhone from "@/components/bindPhone.vue"
|
|
|
|
|
import { onBackPress } from "@dcloudio/uni-app"
|
|
|
|
|
import { ref } from "vue"
|
|
|
|
|
import { userLoginApi, userLoginWeixinApi, getMobileByMnpApi } from "@/api/user.js";
|
|
|
|
|
import useUserStore from "@/store/user.js"
|
|
|
|
|
import bindPhone from "@/components/bindPhone.vue"
|
|
|
|
|
import modal from "@/components/modal.vue"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const navToIndex = () => {
|
|
|
|
|
if (!userStore.userInfo.supplier) uni.reLaunch({
|
|
|
|
|
url: '/pages/index/index'
|
|
|
|
|
})
|
|
|
|
|
else uni.navigateTo({
|
|
|
|
|
url: '/pageQuota/quotation/index'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const navToIndex = () => {
|
|
|
|
|
if (!userStore.userInfo.supplier) uni.reLaunch({
|
|
|
|
|
url: '/pages/index/index'
|
|
|
|
|
})
|
|
|
|
|
else if(!userStore.userInfo.supplier.openid) {
|
|
|
|
|
return showOfficial.value = true;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
url: '/pageQuota/quotation/detail'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 微信公众号绑定
|
|
|
|
|
const officialCode = ()=>{
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pages/code/code',
|
|
|
|
|
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) {
|
|
|
|
@ -131,20 +143,20 @@
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const showBind = ref(false); //是否显示绑定手机号弹窗
|
|
|
|
|
const getPhoneNumber = (e) => {
|
|
|
|
|
console.log("===", e);
|
|
|
|
|
if (e.detail?.errMsg == 'getPhoneNumber:ok') {
|
|
|
|
|
getMobileByMnpApi({
|
|
|
|
|
code: e.detail.code
|
|
|
|
|
}).then(res => {
|
|
|
|
|
navToIndex();
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
console.log("用户拒绝授权");
|
|
|
|
|
return uni.$u.toast('您拒绝了授权');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const showOfficial = ref(false);
|
|
|
|
|
const showBind = ref(false); //是否显示绑定手机号弹窗
|
|
|
|
|
const getPhoneNumber = (e) => {
|
|
|
|
|
if (e.detail?.errMsg == 'getPhoneNumber:ok') {
|
|
|
|
|
getMobileByMnpApi({
|
|
|
|
|
code: e.detail.code
|
|
|
|
|
}).then(res => {
|
|
|
|
|
navToIndex();
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
console.log("用户拒绝授权");
|
|
|
|
|
return uni.$u.toast('您拒绝了授权');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const loginForm = ref({
|
|
|
|
|
phone: '15366662222',
|
|
|
|
|