| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
- <home-base :show="false"><view class="div container">
- <view class="div common-header-wrap">
- <view :style="'height:'+navHeight+'px'"></view>
- <view class="common-header-holder"></view>
- <view class="common-header-fixed">
- <title-header />
- <uni-nav-bar title="商家登录" class="common-header">
- </uni-nav-bar>
- </view>
- </view>
- <view class="div main-content">
- <view class="div top-wrapper">
- <view class="div">
- <flex-line class="input-wrapper" :show-border="true">
- <input class="field-input" v-model="sellername" placeholder="商家账户" />
- </flex-line>
- </view>
- <view class="div">
- <flex-line class="input-wrapper" :show-border="true">
- <input class="field-input" type="password" v-model="password" placeholder="请输入密码" maxlength="20" />
- </flex-line>
- </view>
- </view>
- <view class="div common-btn ds-button-large mt-10 mb-10" @click="signin">登录</view>
- </view>
- </view></home-base>
- </template>
- <script>
- import {getFontSize} from '@/util/common'
- import TitleHeader from '../../TitleHeader'
- import HomeBase from '../HomeBase'
- import { sellerlogin } from '../../../api/sellerLogin'
- import { mapState, mapMutations, mapActions } from 'vuex'
- import flexLine from '../../flexLine'
- export default {
- name: 'login',
- mounted(){
- // #ifdef MP-WEIXIN
- this.navHeight = uni.getMenuButtonBoundingClientRect().height
- // #endif
- },
- data(){
- return {
- navHeight: 0,
- sellername: '',
- password: ''
- }
- },
- components:{TitleHeader,HomeBase,flexLine,},
- onLoad: function (option) {
- uni.hideLoading()
- if (option.clear) {
- this.sellerLogout()
- }
- this.fetchConfig({}).then(
- response => {
- },
- error => {
- uni.showToast({icon:'none',title: error.message})
- }
- )
- },
- computed:{
- fontSize(){
- return getFontSize()
- },
- ...mapState({
- config: state => state.config.config
- }),
- },
- methods:{
- goBack(){uni.navigateBack({delta:1})},
- ...mapActions({
- fetchConfig: 'fetchConfig'
- }),
- ...mapMutations({
- saveAuthInfo: 'sellerLogin',
- sellerLogout: 'sellerLogout'
- }),
- signin () {
- let sellername = this.sellername
- let password = this.password
- if (sellername.length === 0) {
- uni.showToast({icon:'none',title: '请输入用户名/邮箱/手机号'})
- return
- }
- // TODO: 用户名(为手机号或邮箱)校验
- if (password.length === 0) {
- uni.showToast({icon:'none',title: '请输入密码'})
- return
- }
- if (password.length < 6) {
- uni.showToast({icon:'none',title: '至少输入6位密码'})
- return
- }
- uni.showLoading({ title: '加载中' })
- sellerlogin(sellername, password).then(
- response => {
- uni.hideLoading()
- this.saveAuthInfo({ token: response.result.token, info: response.result.info })
- this.goSellerIndex()
- },
- error => {
- uni.hideLoading()
- uni.showToast({icon:'none',title: error.message})
- }
- )
- },
- goSellerIndex () {
- uni.reLaunch({url:'/pages/seller/index/Index'})
- }
- }
- }
- </script>
- <style scoped lang='scss'>
- .common-header{
- .btn{background: #000;color: #fff;box-shadow: 0px 2px 4px #d2d2d2;}
- }
- .container {
- flex: 1;
- display: flex;
- flex-direction: column;
- justify-content: flex-start;
- align-items: stretch;
- .main-content{background: #fff;padding:0 $pageSpace}
- .top-wrapper {
- .input-wrapper {
- display: flex;
- align-content: center;
- align-items: center;
- padding-left: 0.5rem;
- background-color: #fff;
- height: 2.2rem;
- .img {
- width: 1.2rem;
- height: 1.2rem;
- margin: 0;
- padding: 0;
- }
- input {
- flex: 1;
- font-size:$subFontSize;
- }
- .bottom-input {
- border-bottom-width: 0;
- }
- }
- }
- }
- </style>
|