123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- <template>
- <view class="login-wrap">
- <view v-if="showEnvTips" style="text-align: center;color: #999999;padding-top: 40px;">{{ envTips }}</view>
- <image :src="`/static/${theme}/logo.png`" class="logo"></image>
- <form class="login-form" @submit="formSubmit">
- <view class="form-item">
- <u-icon size="40" color="#999" name="account-fill"></u-icon>
- <input v-model="form.username" class="item-inp" name="username" type="number" maxlength="11" placeholder="请输入用户名" />
- </view>
- <view class="form-item">
- <u-icon size="40" color="#999" name="lock-fill"></u-icon>
- <input v-model="form.password" class="item-inp" name="password" password type="text" maxlength="12" placeholder="请输入密码" />
- </view>
- <view class="flex-box" style="margin-top: 60upx;">
- <view class="remember-pass">
- <checkbox-group @change="rememberChange">
- <label>
- <checkbox value="true" :checked="isRemember" class="login-form-checkbox" />
- <text>记住密码</text>
- </label>
- </checkbox-group>
- </view>
- <view class="forget-pass" @click="forgetPass">忘记密码</view>
- </view>
- <view class="form-btn-con">
- <button class="form-btn" :style="{background: $config('buttonColors')}" form-type="submit">登录</button>
-
- </view>
- </form>
- <view class="authUserYs">
- <checkbox-group @change="authuserChange">
- <label>
- <checkbox value="true" :checked="isAuthuserYs" class="login-form-checkbox" />
- 登录代表同意<text @click="toYsPage()">用户协议及隐私保护政策</text>
- </label>
- </checkbox-group>
- </view>
- </view>
- </template>
- <script>
- import market from "@/js_sdk/dc-market/market.js"
- import { checkVersionToLoadUpdate, setStorageForAppVersion } from '@/libs/tools'
- import { isvalidPhone } from '@/libs/tools.js';
- import { login } from '@/api/user.js';
- import { getSysVersion } from '@/api/data.js'
- export default {
- data() {
- return {
- form: {
- username: this.$store.state.vuex_user.account,
- password: this.$store.state.vuex_user.password
- },
- isRemember: true,
- isAuthuserYs: false,
- envTips: '',
- showEnvTips: '',
- theme: ''
- };
- },
- mounted() {
- this.theme = this.$config('themePath')
- this.isRemember = this.$store.state.vuex_isRemember;
- this.isAuthuserYs = this.$store.state.vuex_isUsrAuthYs;
- this.envTips = getApp().globalData.envTips;
- this.showEnvTips = process.env.NODE_ENV == 'development'
- },
- onShow() {
-
- uni.getSystemInfo({
- success:(res) => {
-
- if(res.platform=="android"){
-
- plus.runtime.getProperty(plus.runtime.appid,(wgtinfo)=>{
- getApp().globalData.version = wgtinfo
- this.AndroidCheckUpdate()
- })
- }
- }
- })
-
- },
- methods: {
-
- AndroidCheckUpdate(){
- let _this = this
- getSysVersion().then(ret => {
- if(ret.status == 200){
- this.$store.state.vuex_versionInfo = ret.data
- let currTimeStamp = new Date(ret.data.publicDate).getTime();
-
- uni.getStorage({
- key: 'tip_version_update_time',
- success: function (res) {
- let lastTimeStamp = res.data;
-
- let tipTimeLength = 60*60*1000*3;
-
- if(ret.data.forceUpgrade == 1){
- tipTimeLength = 0
-
- checkVersionToLoadUpdate(ret.data,0,market);
- }else{
- if((lastTimeStamp+tipTimeLength) <= currTimeStamp){
-
- setStorageForAppVersion(currTimeStamp);
-
- checkVersionToLoadUpdate(ret.data,0,market);
- }
- }
- },
- fail:function(res){
- setStorageForAppVersion(currTimeStamp);
- }
- });
- }
- })
- },
-
- fiterAuthCode(data) {
- data.permCodes = data.permCodes.filter(item => item.indexOf('_mobile') > 0);
- console.log(data.permCodes)
- return data;
- },
-
- formSubmit() {
- const _this = this;
-
- if (_this.form.username == '') {
- uni.showToast({ icon: 'none', title: '请输入用户名' });
- return;
- }
- if (!isvalidPhone(_this.form.username)) {
- uni.showToast({ icon: 'none', title: '请输入正确的手机号码' });
- return;
- }
- if (_this.form.password == '') {
- uni.showToast({ icon: 'none', title: '请输入密码' });
- return;
- }
- if (_this.form.password.length < 6 || _this.form.password.length > 12) {
- uni.showToast({ icon: 'none', title: '请输入6-12位密码' });
- return;
- }
- if (!_this.isAuthuserYs) {
- uni.showToast({ icon: 'none', title: '请同意并阅读用户隐私政策' });
- return;
- }
- uni.showLoading({
- title: '正在登录...'
- });
-
- login(_this.form).then(ret => {
- uni.hideLoading();
- let res = ret.data ? ret.data : ret;
- if (res.status == 200) {
- _this.$u.vuex('vuex_token', res.access_token);
- _this.$u.vuex('vuex_userData', _this.fiterAuthCode(res.auth_user));
- getApp().globalData.token = res.access_token;
-
- if (_this.isRemember) {
-
- _this.$u.vuex('vuex_user.account', _this.form.username);
- _this.$u.vuex('vuex_user.password', _this.form.password);
- } else {
-
- _this.$u.vuex('vuex_user.account', '');
- _this.$u.vuex('vuex_user.password', '');
- _this.form.username = '';
- _this.form.password = '';
- }
- uni.setStorageSync('loginTimeOut', 'NO');
- _this.toMain();
- } else {
- uni.showToast({ icon: 'none', title: res.message });
- }
- });
- },
- toMain() {
-
- uni.switchTab({
- url:'/pages/index/index'
- })
- },
-
- applyTrial() {
- uni.navigateTo({
- url: '/pages/login/apply-trial'
- });
- },
-
- forgetPass() {
- uni.navigateTo({
- url: '/pages/login/forget-pass?username=' + this.form.username
- });
- },
-
- rememberChange(e) {
- this.isRemember = e.detail.value.length > 0;
- },
-
- authuserChange(e) {
- this.isAuthuserYs = e.detail.value.length > 0;
- this.$u.vuex('vuex_isUsrAuthYs', this.isAuthuserYs);
- },
- toYsPage() {
- uni.navigateTo({
- url: '/pages/login/userAuthYs'
- });
- }
- }
- };
- </script>
- <style scoped lang="scss">
- @import './login.scss';
- </style>
|