123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- <template>
- <view class="login">
- <view class="navLeft" @click="goBack">
- <image src="../static/img/nav_icon_back.png" mode="aspectFit" class="backImg" @click="goback"></image>
- </view>
- <image src="/static/img/logo.png" mode="" class="logoImg"></image>
- <view class="title">供应商登录</view>
-
- <view class="loginLine">
- <view class="lineTitle">账号</view>
- <view>
- <input v-model="form.phone" class="lineInput" placeholder="请输入账号" type="text">
- </view>
- </view>
- <view class="loginLine" style="margin-top: 30rpx;">
- <view class="lineTitle">密码</view>
- <view style="position: relative;">
- <input v-model="form.password" class="lineInput" placeholder="请输入密码" type="text" :password="!password.visible">
- <image src="/static/img/yanjing.png" v-if="password.visible" @click="switchPasswordVisible" mode="" class="yanjing"></image>
- <image src="/static/img/invisible.png" v-if="!password.visible" @click="switchPasswordVisible" mode="" class="yanjing2"></image>
- </view>
- </view>
-
- <view class="loginBtn" @click="login">登录</view>
-
-
-
-
- <view class="user-selector" style="display: none;">
- <!-- <view class="selected-area" @click="switchSelectorVisible">
- <view class="selected-content" v-if="userSelector.selectedUser">
- <image :src="userSelector.selectedUser.avatar"></image>
- <text>{{ userSelector.selectedUser.name }}</text>
- </view>
- <view class="selected-content" v-else>
- <text>请选择用户</text>
- </view>
- <image class="selected-icon rotate" src="/static/images/up.png"></image>
- </view> -->
- <view v-if="userSelector.visible" class="dialog-area">
- <view class="dialog-list">
- <view class="dialog-list-item" v-for="(user, index) in userSelector.users" :key="index" @click="selectUser(user)">
- <image class="dialog-list-item-avatar" :src="user.avatar"></image>
- <text>{{ user.name }}</text>
- </view>
- </view>
- </view>
- </view>
- <!-- <view class="password-box">
- <input v-model="form.phone" class="password-input" placeholder="请输入账号" type="text">
-
- </view>
- <view class="password-box">
- <input v-model="form.password" class="password-input" placeholder="请输入密码" :password="!password.visible" type="text">
- <image class="password-image" @click="switchPasswordVisible" src="/static/images/visible.png"></image>
- </view>
- <view v-show="errorVisible" class="alert-box">
- <image src="/static/images/login-alert-icon.png"></image>
- <span>请输入正确的用户名和密码</span>
- </view>
- <button class="login-btn" @click="login">登录</button>
- <view class="version">{{ versionName }}</view> -->
- </view>
- </template>
- <script>
- import restApi from '../lib/restapi';
- const {versionName} = require('../manifest.json');
- export default {
- name: 'Login',
- data() {
- return {
- versionName: versionName,
- userSelector: {
- users: [],
- visible: false,
- selectedUser: null
- },
- username: '',
- password: {
- visible: false,
- value: '123'
- },
- form:{
- password:'',
- phone:'',
- },
- errorVisible: false
- }
- },
- onLoad() {
- var token= uni.getStorageSync("accessToken")
- if(token){
- uni.switchTab({url: './conversations'});
- }
- //this.userSelector.users = restApi.findUsers();
- },
- methods: {
- goBack(){
- //app交互
- var standalone = window.navigator.standalone
- var userAgent = window.navigator.userAgent.toLowerCase()
- var safari = /safari/.test(userAgent)
- var ios = /iphone|ipod|ipad|mac/.test(userAgent)
- var android = /android/.test(userAgent)
- if (ios) {
- if ( true) {//!standalone&& !safari
- window.webkit.messageHandlers.goMyNav.postMessage(null)
- }
- } else if (android) {
- window.android.postMessage()
- }
- },
- switchSelectorVisible() {
- this.userSelector.visible = !this.userSelector.visible;
- },
- selectUser(user) {
- this.userSelector.visible = false;
- this.userSelector.selectedUser = user;
- this.username = user.name;
- },
- switchPasswordVisible() {
- this.password.visible = !this.password.visible;
- },
- login() {
- var that=this;
- var obj={
- name:'',
- id:'',
- email:'',
- avatar:'',
- password:'',
- phone:'',
- }
- this.$http('imSys/imLoginTmp', {
- userCode:this.form.phone,
- userPwd:this.form.password,
-
- },'POST').then(res => {
- console.log(res)
- uni.setStorageSync('loginInfo', res.data);
- obj.name=res.data.supplierName
- obj.id=res.data.userId
- obj.password=this.form.password
- obj.phone=this.form.phone
- uni.setStorageSync('currentUser', obj);
- uni.setStorageSync('token', res.data.imAccessToken.accessToken);
- uni.setStorageSync('accessToken', res.data.imAccessToken.accessToken);
- uni.switchTab({url: './conversations'});
- })
- /* if (this.username.trim() !== '' && this.password.value.trim() !== '') {
- let user = restApi.findUser(this.username, this.password.value);
- if (user) {
- uni.setStorageSync('currentUser', user);
- uni.switchTab({url: './conversations'});
- return
- }
- } */
- // this.errorVisible = true;
- }
- }
- }
- </script>
- <style scoped>
- .loginLine{
- padding: 10rpx 66rpx;
- }
- .lineInput{
- font-size: 34rpx;
- padding: 20rpx 0;
- border-bottom: 1px solid #DDDDDD;
- }
- .lineTitle{
- font-weight: 400;
- font-size: 24rpx;
- color: #333333;
- }
- .loginBtn{
- width: 620rpx;
- height: 87rpx;
- background: #3F90F7;
- border-radius: 10rpx;
- text-align: center;
- line-height: 87rpx;
- font-weight: 400;
- font-size: 32rpx;
- color: #FFFFFF;
- margin-top: 40rpx;
- margin-left: 64rpx;
- }
- .yanjing{
- position: absolute;
- right: 0;
- top: 30rpx;
- width: 34rpx;
- height: 18rpx;
- }
- .yanjing2{
- position: absolute;
- right: 0;
- top: 30rpx;
- width: 34rpx;
- height: 34rpx;
- }
- .login {
- width: 100%;
- height: 100%;
- /* display: flex;
- flex-direction: column;
- align-items: center; */
- background: linear-gradient( 180deg, #E4F0FF 0%, #FFFFFF 100%);
- }
- .title {
- padding-top: 190rpx;
- font-weight: 500;
- font-size: 48rpx;
- color: #101E29;
- padding-left: 60rpx;
- padding-bottom: 80rpx;
- }
- .alert-box {
- width: 640rpx;
- height: 60rpx;
- margin-bottom: 60rpx;
- padding: 0rpx 20rpx;
- font-size: 34rpx;
- line-height: 48rpx;
- display: flex;
- align-content: center;
- overflow: hidden;
- color: #EE593C;
- align-items: center;
- }
- .alert-box image {
- width: 30rpx;
- height: 30rpx;
- margin-right: 20rpx;
- }
- .login-btn {
- width: 680rpx;
- height: 100rpx;
- line-height: 100rpx;
- font-size: 36rpx;
- text-align: center;
- color: #ffffff;
- background: #d02129;
- outline: none;
- border: 0;
- }
- .password-box {
- position: relative;
- }
- .password-input {
- width: 620rpx;
- padding: 28rpx;
- border: 1px solid #cccccc;
- margin-bottom: 40rpx;
- font-size: 34rpx;
- }
- .password-image {
- width: 50rpx;
- height: 50rpx;
- position: absolute;
- top: 28rpx;
- right: 28rpx;
- }
- .user-selector {
- width: 700rpx;
- margin-bottom: 40rpx;
- }
- .selected-area {
- display: flex;
- flex-direction: row;
- align-items: center;
- width: 620rpx;
- height: 100rpx;
- border: 1px solid #cccccc;
- margin: 0 auto;
- padding: 0 28rpx;
- }
- .selected-content {
- display: flex;
- align-items: center;
- flex-grow: 1;
- }
- .selected-content image {
- width: 80rpx;
- height: 80rpx;
- margin-right: 30rpx;
- border-radius: 50%;
- }
- .selected-icon {
- width: 40rpx;
- height: 40rpx;
- margin-right: 10rpx;
- }
- .selected-icon.rotate {
- transform-origin: center;
- transform: rotate(180deg);
- }
- .dialog-area {
- position: absolute;
- width: 100%;
- background: #E5E5E5;
- }
- .dialog-list {
- position: absolute;
- left: 10rpx;
- top: 8rpx;
- width: 674rpx;
- border: 1px solid #cccccc;
- background: #ffffff;
- box-shadow: 8rpx 8rpx 10rpx #e1e1e1;
- padding: 30rpx 0;
- z-index: 99;
- }
- .dialog-list-item {
- width: 100%;
- margin: 25rpx 0;
- padding-left: 40rpx;
- display: flex;
- align-items: center;
- }
- .dialog-list-item-avatar {
- width: 80rpx;
- height: 80rpx;
- margin-right: 30rpx;
- border-radius: 50%;
- }
- .version {
- color: #ffffff;
- font-size: 40rpx;
- margin-top: 60rpx;
- }
- view {
- user-select: text;
- }
- .logoImg{
- width: 390rpx;
- position: fixed;
- top: 0;
- right: 0;
- }
- .backImg{
- width: 44rpx;
- height: 44rpx;
-
- }
- .navLeft{
- position: fixed;
- top: 40rpx;
- left: 40rpx;
- }
- </style>
|