382 lines
8.3 KiB
Vue
382 lines
8.3 KiB
Vue
|
|
<template>
|
||
|
|
<view class="content">
|
||
|
|
<view class="conts">
|
||
|
|
<image class="logo" src="/static/image/bghome.png"></image>
|
||
|
|
|
||
|
|
<view class="contop">
|
||
|
|
<view class="tops">
|
||
|
|
<view class="changeyy" @click="showlang = true">
|
||
|
|
<image src="/static/image/change.png" mode=""></image>{{$t('home.langbtn')}}
|
||
|
|
</view>
|
||
|
|
</view>
|
||
|
|
<text class="text">2025 USED CAR</text>
|
||
|
|
<text class="cont">
|
||
|
|
{{$t('home.title')}}
|
||
|
|
</text>
|
||
|
|
</view>
|
||
|
|
</view>
|
||
|
|
<view class="foot">
|
||
|
|
<button class="btn" @click="addCar"> <image class="carimg" src="/static/image/car.png" mode=""></image> {{$t('home.addbtn')}}</button>
|
||
|
|
</view>
|
||
|
|
<view>
|
||
|
|
<u-popup :show="show" :closeOnClickOverlay="false" :round="20" mode="center">
|
||
|
|
<view class="popupcontent">
|
||
|
|
<image class="log1" src="/static/image/log1.png"></image>
|
||
|
|
<view class="title">{{$t('home.loginmsg')}}</view>
|
||
|
|
<!-- <view class="yhxy">
|
||
|
|
{{$t('home.loginmsg1')}}
|
||
|
|
</view> -->
|
||
|
|
<view class="yhxy">
|
||
|
|
<checkbox-group name="" style="width: 28px;display: inline-block;">
|
||
|
|
<label @tap="selfChangde()">
|
||
|
|
<checkbox :checked="selfChecked" activeBackgroundColor="#3F435B" style="transform:scale(0.7);border-radius: 50%"/>
|
||
|
|
</label>
|
||
|
|
</checkbox-group>
|
||
|
|
{{$t('home.argin')}}<text class="xy" @click="gouser">{{$t('home.UserAgreement')}}</text>{{$t('home.and')}}<text class="xy" @click="goprivacy">{{$t('home.Privacy')}}</text>
|
||
|
|
</view>
|
||
|
|
<!-- <view class="yhxy">
|
||
|
|
|
||
|
|
</view> -->
|
||
|
|
</view>
|
||
|
|
<view class="cent">
|
||
|
|
<button class="btn1" @click="show = !show">{{$t('cancel')}}</button>
|
||
|
|
<button v-if="selfChecked" class="btn" open-type="getPhoneNumber" @click="show = !show" @getphonenumber="getPhoneNumber">{{$t('login')}}</button>
|
||
|
|
<button v-else class="btn" @click="loginbtn">{{$t('login')}}</button>
|
||
|
|
</view>
|
||
|
|
</u-popup>
|
||
|
|
</view>
|
||
|
|
<u-picker immediateChange="true" :cancel-text="$t('cancel')" :confirm-text="$t('confirm')" @close="close('showlang')" :show="showlang" :columns="columns"
|
||
|
|
@cancel="cancellang" @confirm="confirmlang" :title="$t('home.langbtn')" keyName="label"></u-picker>
|
||
|
|
</view>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
import { request,showToast } from '@/api/apiT.js'
|
||
|
|
export default {
|
||
|
|
data() {
|
||
|
|
return {
|
||
|
|
title: 'Hello',
|
||
|
|
selfChecked: false,
|
||
|
|
home: this.$t('tabbar.home'),
|
||
|
|
is_login:uni.getStorageSync('is_login'),
|
||
|
|
show: false,
|
||
|
|
showlang: false,
|
||
|
|
columns: [
|
||
|
|
[{
|
||
|
|
label: this.$t('zh'),
|
||
|
|
id: 'zh'
|
||
|
|
}, {
|
||
|
|
label: this.$t('en'),
|
||
|
|
id: 'en'
|
||
|
|
},{
|
||
|
|
label: this.$t('ru'),
|
||
|
|
id: 'ru'
|
||
|
|
}]
|
||
|
|
],
|
||
|
|
}
|
||
|
|
},
|
||
|
|
onLoad() {
|
||
|
|
this.mini_login()
|
||
|
|
},
|
||
|
|
onShow() {
|
||
|
|
uni.setTabBarItem({
|
||
|
|
index: 0,
|
||
|
|
text: this.$t('tabbar.home')
|
||
|
|
})
|
||
|
|
uni.setTabBarItem({
|
||
|
|
index: 1,
|
||
|
|
text: this.$t('tabbar.mine')
|
||
|
|
})
|
||
|
|
},
|
||
|
|
methods: {
|
||
|
|
cancellang() {
|
||
|
|
this.showlang = false
|
||
|
|
},
|
||
|
|
close(value){
|
||
|
|
this[value] = false
|
||
|
|
},
|
||
|
|
//语言切换事件
|
||
|
|
confirmlang(e) {
|
||
|
|
var that = this
|
||
|
|
this.$i18n.locale = e.value[0].id
|
||
|
|
uni.setLocale(e.value[0].id)
|
||
|
|
uni.setStorageSync('i18locale', e.value[0].id);
|
||
|
|
console.log(uni.getLocale())
|
||
|
|
this.columns =[
|
||
|
|
[{
|
||
|
|
label: this.$t('zh'),
|
||
|
|
id: 'zh'
|
||
|
|
}, {
|
||
|
|
label: this.$t('en'),
|
||
|
|
id: 'en'
|
||
|
|
},{
|
||
|
|
label: this.$t('ru'),
|
||
|
|
id: 'ru'
|
||
|
|
}]
|
||
|
|
];
|
||
|
|
uni.setTabBarItem({
|
||
|
|
index: 0,
|
||
|
|
text: this.$t('tabbar.home')
|
||
|
|
})
|
||
|
|
uni.setTabBarItem({
|
||
|
|
index: 1,
|
||
|
|
text: this.$t('tabbar.mine')
|
||
|
|
})
|
||
|
|
this.showlang = false
|
||
|
|
var languages = e.value[0].id
|
||
|
|
if(e.value[0].id=='zh'){
|
||
|
|
languages= 'zh_CN'
|
||
|
|
}
|
||
|
|
request({
|
||
|
|
url:'user/update',
|
||
|
|
method:'POST',
|
||
|
|
data:{
|
||
|
|
language:languages
|
||
|
|
}
|
||
|
|
}).then(res => {
|
||
|
|
uni.showToast({
|
||
|
|
title: res.data.message,
|
||
|
|
icon: 'none'
|
||
|
|
});
|
||
|
|
})
|
||
|
|
},
|
||
|
|
goprivacy(){
|
||
|
|
uni.navigateTo({
|
||
|
|
url: '/pages/login/agreement',// 替换为你要跳转的页面路径
|
||
|
|
});
|
||
|
|
},
|
||
|
|
gouser(){
|
||
|
|
uni.navigateTo({
|
||
|
|
url: '/pages/login/agreementuser',// 替换为你要跳转的页面路径
|
||
|
|
});
|
||
|
|
},
|
||
|
|
addCar(){
|
||
|
|
if(uni.getStorageSync('is_login')){
|
||
|
|
uni.removeStorageSync('draftid')
|
||
|
|
uni.removeStorageSync('carinfo')
|
||
|
|
uni.navigateTo({
|
||
|
|
url: '/pages/carinfo/index'
|
||
|
|
});
|
||
|
|
}else{
|
||
|
|
this.show = true
|
||
|
|
}
|
||
|
|
},
|
||
|
|
selfChangde(e) {
|
||
|
|
this.selfChecked = !this.selfChecked;
|
||
|
|
},
|
||
|
|
loginbtn(){
|
||
|
|
if(!this.selfChecked){
|
||
|
|
uni.showToast({
|
||
|
|
title:this.$t('home.arginimg'),
|
||
|
|
icon: 'none'
|
||
|
|
});
|
||
|
|
return false
|
||
|
|
}
|
||
|
|
},
|
||
|
|
getPhoneNumber(e) {
|
||
|
|
|
||
|
|
console.log(e.detail.code) // 动态令牌
|
||
|
|
let that = this;
|
||
|
|
request({
|
||
|
|
url:'miniapp/phone',
|
||
|
|
method:'POST',
|
||
|
|
data:{
|
||
|
|
phone_code: e.detail.code,
|
||
|
|
}
|
||
|
|
}).then(res => {
|
||
|
|
console.log(res.data.data)
|
||
|
|
if (res.data.code == -1) {
|
||
|
|
uni.showToast({
|
||
|
|
title: res.data.msg,
|
||
|
|
icon: 'none'
|
||
|
|
});
|
||
|
|
|
||
|
|
} else if (res.data.code == 0) {
|
||
|
|
//返回数据接收成功
|
||
|
|
uni.setStorageSync('is_login', true);
|
||
|
|
uni.navigateTo({
|
||
|
|
url: '/pages/carinfo/index'
|
||
|
|
});
|
||
|
|
}
|
||
|
|
})
|
||
|
|
},
|
||
|
|
mini_login() {
|
||
|
|
let that = this;
|
||
|
|
uni.login({
|
||
|
|
provider: 'weixin',
|
||
|
|
success: loginRes => {
|
||
|
|
console.log(loginRes);
|
||
|
|
that.code = loginRes.code;
|
||
|
|
// 2. 将用户登录code传递到后台置换用户SessionKey、OpenId等信息
|
||
|
|
request({
|
||
|
|
url:'miniapp/login',
|
||
|
|
method:'POST',
|
||
|
|
data:{
|
||
|
|
code: loginRes.code
|
||
|
|
}
|
||
|
|
}).then(res => {
|
||
|
|
console.log(res.data);
|
||
|
|
uni.hideLoading()
|
||
|
|
if (res.data.code == 0) {
|
||
|
|
//存取session
|
||
|
|
uni.setStorageSync('openid', res.data.data.openid);
|
||
|
|
uni.setStorageSync('token', res.data.data.token);
|
||
|
|
if(res.data.data.phone&&res.data.data.phone!=''&&res.data.data.phone!=null){
|
||
|
|
uni.setStorageSync('is_login', true);
|
||
|
|
}else{
|
||
|
|
uni.setStorageSync('is_login', false);
|
||
|
|
}
|
||
|
|
console.log(uni.getStorageSync('is_login'))
|
||
|
|
} else {
|
||
|
|
uni.showToast({
|
||
|
|
title: res.data.msg,
|
||
|
|
icon: 'none'
|
||
|
|
})
|
||
|
|
}
|
||
|
|
})
|
||
|
|
},
|
||
|
|
fail: () => {
|
||
|
|
uni.showToast({
|
||
|
|
title: '获取 code 失败',
|
||
|
|
icon: 'none'
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
},
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<style lang="scss">
|
||
|
|
.changeyy {
|
||
|
|
padding: 20rpx 30rpx;
|
||
|
|
border-radius: 50px;
|
||
|
|
background-color: rgba(255, 255, 255, 0.2);
|
||
|
|
margin-bottom: 50rpx;
|
||
|
|
display: inline-block;
|
||
|
|
color: #fff;
|
||
|
|
image {
|
||
|
|
width: 14px;
|
||
|
|
height: 12px;
|
||
|
|
margin-right: 5px;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
.content{
|
||
|
|
/* height: 100vh; */
|
||
|
|
width: 100%;
|
||
|
|
background: #F9F9F9;
|
||
|
|
height: 100%;
|
||
|
|
}
|
||
|
|
.logo{
|
||
|
|
width: 100%;
|
||
|
|
height: 1000rpx;
|
||
|
|
}
|
||
|
|
.conts{
|
||
|
|
width: 100%;
|
||
|
|
position: relative;
|
||
|
|
}
|
||
|
|
.contop{
|
||
|
|
position: absolute;
|
||
|
|
top: 6%;
|
||
|
|
text-align: center;
|
||
|
|
}
|
||
|
|
.tops{
|
||
|
|
text-align: left;
|
||
|
|
padding: 10px;
|
||
|
|
}
|
||
|
|
.text{
|
||
|
|
font-size: 32px;
|
||
|
|
font-weight: bold;
|
||
|
|
background: linear-gradient(120deg, #B9773C 0%, #67450D 100%);
|
||
|
|
-webkit-background-clip: text;
|
||
|
|
color: transparent;
|
||
|
|
background-clip: text;
|
||
|
|
display: inline-block;
|
||
|
|
}
|
||
|
|
.cont{
|
||
|
|
background-image: linear-gradient(#4C392B, #0A0604);
|
||
|
|
padding: 4px 28px;
|
||
|
|
color: #FFEBCC;
|
||
|
|
text-align: center;
|
||
|
|
border-radius: 6px;
|
||
|
|
display: inline-block;
|
||
|
|
margin-top: 12px;
|
||
|
|
font-size: 16px;
|
||
|
|
}
|
||
|
|
.foot{
|
||
|
|
width: 87%;
|
||
|
|
margin: 0px auto;
|
||
|
|
text-align: center;
|
||
|
|
}
|
||
|
|
.btn{
|
||
|
|
background-color: #3F435B;
|
||
|
|
color: white;
|
||
|
|
border-radius: 50px;
|
||
|
|
width: 100%;
|
||
|
|
margin-top: 40px;
|
||
|
|
height: 50px;
|
||
|
|
line-height: 50px;
|
||
|
|
}
|
||
|
|
.carimg{
|
||
|
|
width: 28px;
|
||
|
|
height: 28px;
|
||
|
|
vertical-align: sub;
|
||
|
|
margin-right: 10px;
|
||
|
|
}
|
||
|
|
.gobtn{
|
||
|
|
color: #007aff !important;
|
||
|
|
}
|
||
|
|
.popupcontent{
|
||
|
|
background: url(/static/image/log0.png);
|
||
|
|
background-size: 100% 100%;
|
||
|
|
padding: 26px 15px;
|
||
|
|
text-align: center;
|
||
|
|
background-repeat: no-repeat;
|
||
|
|
.title{
|
||
|
|
color: #333333;
|
||
|
|
font-size: 15px;
|
||
|
|
margin-bottom: 15px;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
.log1{
|
||
|
|
width: 180px;
|
||
|
|
height: 180px;
|
||
|
|
}
|
||
|
|
.yhxy{
|
||
|
|
color: #999999;
|
||
|
|
font-size: 12px;
|
||
|
|
margin-bottom: 5px;
|
||
|
|
.xy{
|
||
|
|
color: #297EFF;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
.qxbtn{
|
||
|
|
width: 99%;
|
||
|
|
}
|
||
|
|
.cent{
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
justify-content: space-around;
|
||
|
|
padding: 0px 10px 20px;
|
||
|
|
.btn1{
|
||
|
|
background-color: #fff;
|
||
|
|
border: 1px solid #3F435B;
|
||
|
|
color: #3F435B;
|
||
|
|
border-radius: 50px;
|
||
|
|
width: 46%;
|
||
|
|
margin: 10px 0px 20px;
|
||
|
|
height: 50px;
|
||
|
|
line-height: 50px;
|
||
|
|
}
|
||
|
|
.btn{
|
||
|
|
background-color: #3F435B;
|
||
|
|
color: white;
|
||
|
|
border-radius: 50px;
|
||
|
|
width: 46%;
|
||
|
|
margin: 10px 0px 20px;
|
||
|
|
height: 50px;
|
||
|
|
line-height: 50px;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</style>
|