123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- <template>
- <view class="container" :style="{paddingTop:CustomBar+'px'}">
- <tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading ="true" :loadingType="7"></tui-skeleton>
- <template v-else>
- <view class="tui-page-title">登录</view>
- <view class="tui-form">
- <view class="tui-view-input">
- <tui-list-cell :hover="false" :lineLeft="false" backgroundColor="transparent">
- <view class="tui-cell-input">
- <tui-icon name="mobile" color="#6d7a87" :size="20"></tui-icon>
- <input
- :adjust-position="false"
- v-model="param.mobile"
- placeholder="请输入账号/手机号"
- placeholder-class="tui-phcolor"
- type="number"
- maxlength="11"
- />
- <view class="" v-show="param.mobile" @click.stop="clearInput(1)">
- <tui-icon name="close-fill" :size="16" color="#bfbfbf" ></tui-icon>
- </view>
- </view>
- </tui-list-cell>
- <tui-list-cell :hover="false" :lineLeft="false" backgroundColor="transparent">
- <view class="tui-cell-input">
- <tui-icon name="pwd" color="#6d7a87" :size="20"></tui-icon>
- <input
- v-if="!isShowEye"
- :adjust-position="false"
- v-model="param.password"
- placeholder="请输入密码"
- placeholder-class="tui-phcolor"
- type="text"
- maxlength="36"
- />
- <input
- v-if="isShowEye"
- :adjust-position="false"
- v-model="param.password"
- placeholder="请输入密码"
- placeholder-class="tui-phcolor"
- type="password"
- maxlength="36"
- />
- <view class="" v-show="param.password" style="margin: 0 20rpx 0 0;" @click.stop="changInputType">
- <tui-icon :name="isShowEye ? 'unseen' : 'eye'" :size="22" color="#bfbfbf"></tui-icon>
- </view>
- <view class="" v-show="param.password" @click.stop="clearInput(2)">
- <tui-icon name="close-fill" :size="16" color="#bfbfbf" ></tui-icon>
- </view>
- </view>
- </tui-list-cell>
- </view>
- <view class="tui-btn-box">
- <tui-button type="primary" :disabledGray="true" :disabled="disabled" :shadow="true" shape="circle" @click="hanldeClick">登录</tui-button>
- </view>
- </view>
- </template>
- </view>
- </template>
- <script>
- import { mapMutations } from 'vuex'
- import authorize from '@/common/config/authorize.js'
- export default {
- computed: {
- disabled: function() {
- let bool = true
- if (this.param.mobile && this.param.password) {
- bool = false
- }
- return bool
- }
- },
- data() {
- return {
- CustomBar:this.CustomBar,// 顶部导航栏高度
- param:{
- code:null,
- encryptedData:null,
- iv:null ,
- mobile: '',
- password: '',
- },
- popupShow: false,
- passwordType:'password',
- skeletonShow:true,
- isShowEye:true
- }
- },
- onLoad(options) {
-
- },
- methods: {
- ...mapMutations(['login', 'logout']),
- async getWxAuthorize(){// 初始化授权登录
- const WxCode = await authorize.getCode('weixin')
- const Wx = await authorize.getUserInfo('weixin')
- this.UserService.UserLoginAuthApplets({
- code:WxCode,
- encryptedData:Wx.encryptedData,
- iv:Wx.iv ,
- })
- .then(response =>{
- let data = response.data
- this.login(response.data)
- this.$store.commit('updateStatus',response.data)
- setTimeout(()=>{
- this.navigateLink(response.data.userType)
- },500)
- }).catch(error =>{
- this.logout()
- this.skeletonShow = false
- this.$store.commit('updateStatus',error.data)
- })
- },
- async UserLoginReceiptPassword(){// 账号密码登录
- const WxCode = await authorize.getCode('weixin')
- const Wx = await authorize.getUserInfo('weixin')
- this.param.code = WxCode
- this.param.iv = Wx.iv
- this.param.encryptedData = Wx.encryptedData
- this.UserService.UserLoginReceiptPassword(this.param).then(response =>{
- this.login(response.data)
- this.$store.commit('updateStatus',response.data)
- this.navigateLink(response.data.userType)
- }).catch(err =>{
- this.$util.msg(err.msg,2000)
- })
- },
- hanldeClick(){//点击登录
- this.UserLoginReceiptPassword()
- },
- navigateLink(userType){// 根据用户权限跳转对应页面
- /**
- * 用户类型 1协销人员,2客服,3财务,4超级管理员
- * 1. 协销人员跳转到收款列表页面
- * 2. 客服跳转到收款列表页面
- * 3. 财务人员跳转到款项识别页面
- * 4. 超级管理员跳转到款项识别页面
- * */
- switch(userType){
- case 1:
- this.$api.navigateTo('/pages/collection/list')
- break
- case 2:
- this.$api.navigateTo('/pages/collection/list')
- break
- case 3:
- this.$api.navigateTo('/pages/collection/sms')
- break
- case 4:
- this.$api.navigateTo('/pages/collection/sms')
- break
-
- }
- },
- changInputType(){// 控制显示密码
- this.isShowEye = !this.isShowEye
- },
- clearInput(type) {// 清除输入框信息
- if (type == 1) {
- this.param.mobile = ''
- } else {
- this.param.password = ''
- }
- }
- },
- onShow() {
- this.getWxAuthorize()
- }
- }
- </script>
- <style lang="scss">
- .container {
- .tui-status-bar {
- width: 100%;
- height: var(--status-bar-height);
- }
- .tui-header {
- width: 100%;
- padding: 40rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- box-sizing: border-box;
- }
- .tui-page-title {
- width: 100%;
- font-size: 48rpx;
- font-weight: bold;
- color: $uni-text-color;
- line-height: 42rpx;
- padding: 40rpx;
- box-sizing: border-box;
- }
- .tui-form {
- padding-top: 50rpx;
- .tui-view-input {
- width: 100%;
- box-sizing: border-box;
- padding: 0 40rpx;
- .tui-cell-input {
- width: 100%;
- display: flex;
- align-items: center;
- padding-top: 48rpx;
- padding-bottom: $uni-spacing-col-base;
- input {
- flex: 1;
- padding-left: $uni-spacing-row-base;
- }
- .tui-icon-close {
- margin-left: auto;
- }
- }
- }
- .tui-cell-text {
- width: 100%;
- padding: $uni-spacing-col-lg $uni-spacing-row-lg;
- box-sizing: border-box;
- font-size: $uni-font-size-sm;
- color: $uni-text-color-grey;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .tui-color-primary {
- color: $uni-color-primary;
- }
- }
- .tui-btn-box {
- width: 100%;
- padding: 0 $uni-spacing-row-lg;
- box-sizing: border-box;
- margin-top: 80rpx;
- }
- }
- .tui-login-way {
- width: 100%;
- font-size: 26rpx;
- color: $uni-color-primary;
- display: flex;
- justify-content: center;
- position: fixed;
- left: 0;
- bottom: 80rpx;
- view {
- padding: 12rpx 0;
- }
- }
- .tui-auth-login {
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- padding-bottom: 80rpx;
- padding-top: 20rpx;
- .tui-icon-platform {
- width: 90rpx;
- height: 90rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- position: relative;
- margin-left: 40rpx;
- &::after {
- content: '';
- position: absolute;
- width: 200%;
- height: 200%;
- transform-origin: 0 0;
- transform: scale(0.5, 0.5) translateZ(0);
- box-sizing: border-box;
- left: 0;
- top: 0;
- border-radius: 180rpx;
- border: 1rpx solid $uni-text-color-placeholder;
- }
- }
- .tui-login-logo {
- width: 60rpx;
- height: 60rpx;
- }
- }
- }
- </style>
|