省市的接口对接
身份认证的完成
This commit is contained in:
parent
d07da60e60
commit
8349ab4440
30
pages.json
30
pages.json
@ -353,8 +353,8 @@
|
|||||||
"meta": {
|
"meta": {
|
||||||
"auth": true,
|
"auth": true,
|
||||||
"sync": true,
|
"sync": true,
|
||||||
"title": "用户信息",
|
"title": "我的信息",
|
||||||
"group": "用户中心"
|
"group": "个人中心"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -366,7 +366,7 @@
|
|||||||
"auth": true,
|
"auth": true,
|
||||||
"sync": true,
|
"sync": true,
|
||||||
"title": "我的发布",
|
"title": "我的发布",
|
||||||
"group": "用户中心"
|
"group": "个人中心"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -378,7 +378,7 @@
|
|||||||
"auth": true,
|
"auth": true,
|
||||||
"sync": true,
|
"sync": true,
|
||||||
"title": "我的收藏",
|
"title": "我的收藏",
|
||||||
"group": "用户中心"
|
"group": "个人中心"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -390,7 +390,7 @@
|
|||||||
"auth": true,
|
"auth": true,
|
||||||
"sync": true,
|
"sync": true,
|
||||||
"title": "我的足迹",
|
"title": "我的足迹",
|
||||||
"group": "用户中心"
|
"group": "个人中心"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -402,7 +402,7 @@
|
|||||||
"auth": true,
|
"auth": true,
|
||||||
"sync": true,
|
"sync": true,
|
||||||
"title": "地址管理",
|
"title": "地址管理",
|
||||||
"group": "用户中心"
|
"group": "个人中心"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -424,7 +424,7 @@
|
|||||||
"auth": true,
|
"auth": true,
|
||||||
"sync": true,
|
"sync": true,
|
||||||
"title": "发票管理",
|
"title": "发票管理",
|
||||||
"group": "用户中心"
|
"group": "个人中心"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -446,7 +446,7 @@
|
|||||||
"auth": true,
|
"auth": true,
|
||||||
"sync": true,
|
"sync": true,
|
||||||
"title": "用户余额",
|
"title": "用户余额",
|
||||||
"group": "用户中心"
|
"group": "个人中心"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -470,7 +470,19 @@
|
|||||||
"auth": true,
|
"auth": true,
|
||||||
"sync": true,
|
"sync": true,
|
||||||
"title": "我的积分",
|
"title": "我的积分",
|
||||||
"group": "用户中心"
|
"group": "个人中心"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "authentication",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "身份认证"
|
||||||
|
},
|
||||||
|
"meta": {
|
||||||
|
"auth": true,
|
||||||
|
"sync": true,
|
||||||
|
"title": "身份认证",
|
||||||
|
"group": "个人中心"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -199,8 +199,22 @@
|
|||||||
</view>
|
</view>
|
||||||
</su-popup>
|
</su-popup>
|
||||||
|
|
||||||
<!-- 身份证是否认证
|
<!-- 身份证是否认证 -->
|
||||||
<su-popup @touchmove.native.stop.prevent :closeable="false" :show="cardShow" :round="10" mode="center"
|
<su-popup :show="cardShow == true" type="center" round="10" :isMaskClick="false">
|
||||||
|
<view class="popupContacted">
|
||||||
|
<view class="contactedBox">
|
||||||
|
<image style="width: 198rpx;height: 122rpx;position: relative;left: 12rpx;" src="https://jiangxiaoxian.0rui.cn/couponSuccess.png"></image>
|
||||||
|
<view style="font-size: 36rpx;line-height: 50rpx;font-weight: 900;color: #3d3d3d;text-align: center;">身份认证</view>
|
||||||
|
<view style="font-size: 30rpx;line-height: 44rpx;font-weight: 400;color: #3d3d3d;text-align: center;">认证后即可发布信息</view>
|
||||||
|
</view>
|
||||||
|
<view class="contactBtn">
|
||||||
|
<view class="tactBtnBox" style="color: #999999;" @click="cardShow = false">取消</view>
|
||||||
|
<view class="tactBtnBox2" style="color: #323232;" @click="toPage('')">去认证</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</su-popup>
|
||||||
|
|
||||||
|
<!-- <su-popup @touchmove.native.stop.prevent :closeable="false" :show="cardShow" :round="10" mode="center"
|
||||||
@close="cardShow = false" :safeAreaInsetBottom="false" :custom-style="{
|
@close="cardShow = false" :safeAreaInsetBottom="false" :custom-style="{
|
||||||
width: '600rpx',
|
width: '600rpx',
|
||||||
padding: '24rpx 24rpx 20rpx 24rpx',
|
padding: '24rpx 24rpx 20rpx 24rpx',
|
||||||
@ -279,7 +293,8 @@
|
|||||||
} from '@dcloudio/uni-app';
|
} from '@dcloudio/uni-app';
|
||||||
import {
|
import {
|
||||||
ref,
|
ref,
|
||||||
reactive
|
reactive,
|
||||||
|
computed
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
import {
|
import {
|
||||||
@ -291,7 +306,8 @@
|
|||||||
import {
|
import {
|
||||||
baseUrl
|
baseUrl
|
||||||
} from '@/sheep/config';
|
} from '@/sheep/config';
|
||||||
|
|
||||||
|
const isLogin = computed(() => sheep.$store('user').isLogin);
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
showRegion: false,
|
showRegion: false,
|
||||||
model: {
|
model: {
|
||||||
@ -342,7 +358,6 @@
|
|||||||
cateName: '',
|
cateName: '',
|
||||||
imageList: [],
|
imageList: [],
|
||||||
})
|
})
|
||||||
|
|
||||||
const onRegionConfirm = (e) => {
|
const onRegionConfirm = (e) => {
|
||||||
console.log('onRegionConfirm', e);
|
console.log('onRegionConfirm', e);
|
||||||
state.model = {
|
state.model = {
|
||||||
@ -369,6 +384,39 @@
|
|||||||
getTagList();
|
getTagList();
|
||||||
getTypeList();
|
getTypeList();
|
||||||
})
|
})
|
||||||
|
function getAuthentied() {
|
||||||
|
sheep.$api.rent.isAuthentied().then((res) => {
|
||||||
|
if(res.code == 1) {
|
||||||
|
if(res.data !=1) {
|
||||||
|
cardShow.value = true;
|
||||||
|
}else {
|
||||||
|
cardShow.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const toPage = () => {
|
||||||
|
if (isLogin.value == true) {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: e
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
|
||||||
|
uni.showToast({
|
||||||
|
title: '请先登录',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
|
uni.switchTab({
|
||||||
|
url: '/pages/index/user'
|
||||||
|
})
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function getTagList() {
|
async function getTagList() {
|
||||||
const res = await sheep.$api.rent.tagsList({});
|
const res = await sheep.$api.rent.tagsList({});
|
||||||
if (res.code == 1) {
|
if (res.code == 1) {
|
||||||
@ -577,6 +625,23 @@
|
|||||||
const res = await sheep.$api.rent.addRent(form.value)
|
const res = await sheep.$api.rent.addRent(form.value)
|
||||||
if(res.code == 1){
|
if(res.code == 1){
|
||||||
console.log('发布成功');
|
console.log('发布成功');
|
||||||
|
agreeAdd.value = false;
|
||||||
|
form.value = {
|
||||||
|
title: '',
|
||||||
|
area: '',
|
||||||
|
tags: '',
|
||||||
|
contacts: '',
|
||||||
|
contact_number: '',
|
||||||
|
content: '',
|
||||||
|
address_detail: '',
|
||||||
|
type: '',
|
||||||
|
images: '',
|
||||||
|
province: '',
|
||||||
|
city: '',
|
||||||
|
cate_ids: '',
|
||||||
|
cateName: '',
|
||||||
|
imageList: [],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -159,10 +159,16 @@
|
|||||||
region
|
region
|
||||||
} from '@/sheep/validate/form';
|
} from '@/sheep/validate/form';
|
||||||
|
|
||||||
// 隐藏原生tabBar
|
|
||||||
uni.hideTabBar({
|
function getAreaCity() {
|
||||||
fail: () => {},
|
// if (_.isEmpty(uni.getStorageSync('areaCity'))) {
|
||||||
});
|
sheep.$api.rent.getCity().then((res) => {
|
||||||
|
if (res.code === 1) {
|
||||||
|
uni.setStorageSync('areaCity', res.data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// }
|
||||||
|
};
|
||||||
|
|
||||||
const template = computed(() => sheep.$store('app').template?.home);
|
const template = computed(() => sheep.$store('app').template?.home);
|
||||||
const isLogin = computed(() => sheep.$store('user').isLogin);
|
const isLogin = computed(() => sheep.$store('user').isLogin);
|
||||||
@ -194,6 +200,8 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const proCity = ref('')
|
const proCity = ref('')
|
||||||
|
|
||||||
@ -204,8 +212,14 @@
|
|||||||
...state.model,
|
...state.model,
|
||||||
...e,
|
...e,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if(state.model.province_name == state.model.city_name) {
|
||||||
|
proCity.value = state.model.province_name
|
||||||
|
}else {
|
||||||
|
proCity.value = state.model.province_name + " " + state.model.city_name
|
||||||
|
}
|
||||||
|
|
||||||
proCity.value = state.model.province_name + " " + state.model.city_name
|
// proCity.value = state.model.province_name + " " + state.model.city_name
|
||||||
|
|
||||||
console.log('onRegionConfirm33', state.model, proCity.value);
|
console.log('onRegionConfirm33', state.model, proCity.value);
|
||||||
listQuery.value.province = state.model.province_id
|
listQuery.value.province = state.model.province_id
|
||||||
@ -236,6 +250,7 @@
|
|||||||
|
|
||||||
|
|
||||||
onLoad((options) => {
|
onLoad((options) => {
|
||||||
|
getAreaCity();
|
||||||
getList();
|
getList();
|
||||||
getBanner();
|
getBanner();
|
||||||
// #ifdef MP
|
// #ifdef MP
|
||||||
@ -350,6 +365,11 @@
|
|||||||
// }
|
// }
|
||||||
console.log('getList', rentList.value);
|
console.log('getList', rentList.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 隐藏原生tabBar
|
||||||
|
uni.hideTabBar({
|
||||||
|
fail: () => {},
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<view class="headAvatar-info justify-start">
|
<view class="headAvatar-info justify-start">
|
||||||
<view class="info-name fs-36 weight8 flexD" v-if="isLogin == true">
|
<view class="info-name fs-36 weight8 flexD" v-if="isLogin == true">
|
||||||
<view style="font-weight: 800;" @click="toLogin">{{ userInfo.nickname}} </view>
|
<view style="font-weight: 800;" @click="toLogin">{{ userInfo.nickname}} </view>
|
||||||
<view class="UnAuthenBox weight8 fs-20" v-if="authenInfo.status == -1 ">未认证</view>
|
<view class="UnAuthenBox weight8 fs-20" v-if="authenInfo.status == -1 " @click="toPage('/pages/user/authentication')">未认证</view>
|
||||||
<view class="authenticationBox weight8 fs-20" v-if="authenInfo.status == 1 ">已认证</view>
|
<view class="authenticationBox weight8 fs-20" v-if="authenInfo.status == 1 ">已认证</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="info-name fs-36 weight8 flexD" v-else>
|
<view class="info-name fs-36 weight8 flexD" v-else>
|
||||||
|
168
pages/user/authentication.vue
Normal file
168
pages/user/authentication.vue
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
<template>
|
||||||
|
<s-layout title="认证信息" :bgStyle="{ color: '#ffffff' }">
|
||||||
|
<view class="container">
|
||||||
|
<view class="contifionType">
|
||||||
|
<su-tabs :list="tabMaps" @change="onChange" :scrollable="false" :current="currentTab"></su-tabs>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view style="padding: 0 30rpx;width: 100%;">
|
||||||
|
<view v-if="currentTab == 0">
|
||||||
|
<image v-if="form.workimage != '' && form.status == 1" style="width: 690rpx;height: 350rpx;" :src="baseUrl + form.workimage" @click="afterRead"></image>
|
||||||
|
<image v-else style="width: 690rpx;height: 350rpx;"
|
||||||
|
src="https://jiangxiaoxian.0rui.cn/manager.png" @click="afterRead"></image>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-if="currentTab == 1">
|
||||||
|
<image v-if="form.gateimage != '' && form.status == 2" style="width: 690rpx;height: 350rpx;"
|
||||||
|
:src="baseUrl + form.gateimage" @click="afterRead"></image>
|
||||||
|
<image v-else style="width: 690rpx;height: 350rpx;" @click="afterRead"
|
||||||
|
src="https://jiangxiaoxian.0rui.cn/Merchant.png">
|
||||||
|
</image>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
|
||||||
|
<view class="footer-box">
|
||||||
|
<view class="submitAuth" @click="submit()">提交认证</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</s-layout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import sheep from '@/sheep';
|
||||||
|
import {
|
||||||
|
onLoad,
|
||||||
|
onShow,
|
||||||
|
onReachBottom
|
||||||
|
} from '@dcloudio/uni-app';
|
||||||
|
import {
|
||||||
|
ref,
|
||||||
|
reactive
|
||||||
|
} from 'vue';
|
||||||
|
import _ from 'lodash';
|
||||||
|
import {
|
||||||
|
baseUrl
|
||||||
|
} from '@/sheep/config';
|
||||||
|
|
||||||
|
const tabMaps = [{
|
||||||
|
name: '餐厅经理',
|
||||||
|
value: '1',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '档口商户',
|
||||||
|
value: '2',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const currentTab = ref(0)
|
||||||
|
//切换tabs
|
||||||
|
function onChange(e) {
|
||||||
|
console.log('onChange', e);
|
||||||
|
currentTab.value = e.index
|
||||||
|
console.log('切换tabs', currentTab.value);
|
||||||
|
if (currentTab.value == 0) {
|
||||||
|
form.value.status = 1
|
||||||
|
form.value.workimage = '';
|
||||||
|
form.value.gateimage = '';
|
||||||
|
} else {
|
||||||
|
form.value.status = 2
|
||||||
|
form.value.gateimage = '';
|
||||||
|
form.value.workimage = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const form = ref({
|
||||||
|
workimage: '',
|
||||||
|
gateimage: '',
|
||||||
|
status: 0,
|
||||||
|
})
|
||||||
|
|
||||||
|
async function uploadAvatar(tempUrl) {
|
||||||
|
if (!tempUrl) return;
|
||||||
|
let {
|
||||||
|
url
|
||||||
|
} = await sheep.$api.app.upload(tempUrl, 'ugc');
|
||||||
|
console.log('url', url);
|
||||||
|
if (currentTab.value == 0) {
|
||||||
|
form.value.status = 1
|
||||||
|
form.value.workimage = url;
|
||||||
|
} else {
|
||||||
|
form.value.status = 2
|
||||||
|
form.value.gateimage = url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function afterRead() {
|
||||||
|
console.log('afterRead触发了吗?');
|
||||||
|
uni.chooseImage({
|
||||||
|
success: async (chooseImageRes) => {
|
||||||
|
const tempUrl = chooseImageRes.tempFilePaths[0];
|
||||||
|
uploadAvatar(tempUrl);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function submit() {
|
||||||
|
const data = {
|
||||||
|
status: form.value.status,
|
||||||
|
workimage: form.value.workimage,
|
||||||
|
gateimage: form.value.gateimage,
|
||||||
|
}
|
||||||
|
sheep.$api.user.authPhoto(data).then((res) => {
|
||||||
|
if(res.code == 1) {
|
||||||
|
console.log('提交认证成功');
|
||||||
|
uni.showToast({
|
||||||
|
title:'提交认证成功',
|
||||||
|
icon: 'success',
|
||||||
|
})
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.navigateBack()
|
||||||
|
},1000)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.container {
|
||||||
|
background: #ffffff;
|
||||||
|
width: 100%;
|
||||||
|
// display: grid;
|
||||||
|
// justify-content: center;
|
||||||
|
|
||||||
|
|
||||||
|
.contifionType {
|
||||||
|
margin-bottom: 30rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.footer-box {
|
||||||
|
width: 100%;
|
||||||
|
height: 90rpx;
|
||||||
|
padding: 30rpx;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 10rpx;
|
||||||
|
left: 0;
|
||||||
|
|
||||||
|
.submitAuth {
|
||||||
|
background: linear-gradient(to right, #FFBD25, #FCCA58);
|
||||||
|
width: 690rpx;
|
||||||
|
height: 90rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: #333333;
|
||||||
|
font-size: 32rpx;
|
||||||
|
font-weight: 45rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
border-radius: 148rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
</style>
|
@ -1,25 +1,26 @@
|
|||||||
import request from '@/sheep/request';
|
import request from '@/sheep/request';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
//省市区列表
|
//省市区列表
|
||||||
area: () =>
|
area: () =>
|
||||||
request({
|
request({
|
||||||
url: 'data.area',
|
url: 'data.area',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
}),
|
}),
|
||||||
//常见问题
|
|
||||||
faq: () =>
|
//常见问题
|
||||||
request({
|
faq: () =>
|
||||||
url: 'data.faq',
|
request({
|
||||||
method: 'GET',
|
url: 'data.faq',
|
||||||
}),
|
method: 'GET',
|
||||||
//富文本
|
}),
|
||||||
richtext: (id) =>
|
//富文本
|
||||||
request({
|
richtext: (id) =>
|
||||||
url: 'data.richtext',
|
request({
|
||||||
method: 'GET',
|
url: 'data.richtext',
|
||||||
params: {
|
method: 'GET',
|
||||||
id: id,
|
params: {
|
||||||
},
|
id: id,
|
||||||
}),
|
},
|
||||||
};
|
}),
|
||||||
|
};
|
@ -43,13 +43,32 @@ export default {
|
|||||||
url: 'meal.information/type_list',
|
url: 'meal.information/type_list',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
params,
|
params,
|
||||||
|
|
||||||
}),
|
}),
|
||||||
//提交发布
|
//提交发布
|
||||||
addRent: (data)=>
|
addRent: (data) =>
|
||||||
request({
|
request({
|
||||||
url: 'meal.information/add',
|
url: 'meal.information/add',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data,
|
data,
|
||||||
|
}),
|
||||||
|
//省市
|
||||||
|
getCity: () =>
|
||||||
|
request({
|
||||||
|
url: 'index/city',
|
||||||
|
method: 'GET',
|
||||||
|
}),
|
||||||
|
//发布须知
|
||||||
|
fabuAgree: (params) =>
|
||||||
|
request({
|
||||||
|
url: 'meal.information/agreement',
|
||||||
|
method: 'GET',
|
||||||
|
params,
|
||||||
|
}),
|
||||||
|
//发布身份认证查询
|
||||||
|
isAuthentied: () =>
|
||||||
|
request({
|
||||||
|
url: 'meal.auth/info',
|
||||||
|
method: 'GET',
|
||||||
})
|
})
|
||||||
};
|
};
|
@ -352,6 +352,14 @@ export default {
|
|||||||
auth: true,
|
auth: true,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
//提交认证信息
|
||||||
|
authPhoto: (data) =>
|
||||||
|
request({
|
||||||
|
url: 'meal.auth/save',
|
||||||
|
method: 'POST',
|
||||||
|
data,
|
||||||
|
}),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<su-toolbar :cancelColor="cancelColor" :confirmColor="confirmColor" :cancelText="cancelText"
|
<su-toolbar :cancelColor="cancelColor" :confirmColor="confirmColor" :cancelText="cancelText"
|
||||||
:confirmText="confirmText" title="选择区域" @cancel="onCancel" @confirm="onConfirm('confirm')"></su-toolbar>
|
:confirmText="confirmText" title="选择区域" @cancel="onCancel" @confirm="onConfirm('confirm')"></su-toolbar>
|
||||||
<view class="ui-picker-body">
|
<view class="ui-picker-body">
|
||||||
<picker-view :value="state.currentIndex" @change="change" class="ui-picker-view" @pickstart="pickstart"
|
<picker-view :value="state.currentCityIndex" @change="change" class="ui-picker-view" @pickstart="pickstart"
|
||||||
@pickend="pickend">
|
@pickend="pickend">
|
||||||
<picker-view-column>
|
<picker-view-column>
|
||||||
<view class="ui-column-item" v-for="province in provinceList" :key="province.id">
|
<view class="ui-column-item" v-for="province in provinceList" :key="province.id">
|
||||||
@ -45,6 +45,7 @@
|
|||||||
computed,
|
computed,
|
||||||
reactive
|
reactive
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
|
import sheep from '@/sheep';
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
show: {
|
show: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@ -71,12 +72,24 @@
|
|||||||
default: '确认',
|
default: '确认',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getAreaCity = () => {
|
||||||
|
// if (_.isEmpty(uni.getStorageSync('areaCity'))) {}
|
||||||
|
sheep.$api.rent.getCity().then((res) => {
|
||||||
|
if (res.code === 1) {
|
||||||
|
uni.setStorageSync('areaCity', res.data);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
// const areaData = uni.getStorageSync('areaData')
|
// const areaData = uni.getStorageSync('areaData')
|
||||||
const proFirst = [{
|
const proFirst = [{
|
||||||
children: [{
|
child: [{
|
||||||
id: '',
|
id: '',
|
||||||
level: "city",
|
level: "city",
|
||||||
name: "全部",
|
name: "全国",
|
||||||
pid: 0
|
pid: 0
|
||||||
}], // 确保有默认的子项
|
}], // 确保有默认的子项
|
||||||
id: '',
|
id: '',
|
||||||
@ -84,8 +97,8 @@
|
|||||||
name: "全国",
|
name: "全国",
|
||||||
pid: 0
|
pid: 0
|
||||||
}]
|
}]
|
||||||
const areaData = proFirst.concat(uni.getStorageSync('areaData'))
|
const areaData = proFirst.concat(uni.getStorageSync('areaCity'))
|
||||||
|
console.log('province',provinceList,uni.getStorageSync('areaCity'));
|
||||||
|
|
||||||
const getSizeByNameLength = (name) => {
|
const getSizeByNameLength = (name) => {
|
||||||
// if (!name) return ''; // 添加这行防御性代码
|
// if (!name) return ''; // 添加这行防御性代码
|
||||||
@ -99,21 +112,20 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
currentIndex: [0, 0, 0],
|
currentCityIndex: [0, 0],
|
||||||
moving: false, // 列是否还在滑动中,微信小程序如果在滑动中就点确定,结果可能不准确
|
moving: false, // 列是否还在滑动中,微信小程序如果在滑动中就点确定,结果可能不准确
|
||||||
});
|
});
|
||||||
const emits = defineEmits(['confirm', 'cancel', 'change']);
|
const emits = defineEmits(['confirm', 'cancel', 'change']);
|
||||||
|
|
||||||
// const provinceList = areaData;
|
const provinceList = areaData;
|
||||||
const provinceList = proFirst.concat(uni.getStorageSync('areaData'))
|
// const provinceList = proFirst.concat(uni.getStorageSync('areaData'))
|
||||||
console.log('province',provinceList.value);
|
|
||||||
|
|
||||||
const cityList = computed(() => {
|
const cityList = computed(() => {
|
||||||
return areaData[state.currentIndex[0]].children;
|
return areaData[state.currentCityIndex[0]].child;
|
||||||
});
|
|
||||||
const districtList = computed(() => {
|
|
||||||
return cityList.value[state.currentIndex[1]]?.children;
|
|
||||||
});
|
});
|
||||||
|
// const districtList = computed(() => {
|
||||||
|
// return cityList.value[state.currentCityIndex[1]]?.child;
|
||||||
|
// });
|
||||||
// 标识滑动开始,只有微信小程序才有这样的事件
|
// 标识滑动开始,只有微信小程序才有这样的事件
|
||||||
const pickstart = () => {
|
const pickstart = () => {
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
@ -136,21 +148,21 @@
|
|||||||
// 用户更改picker的列选项
|
// 用户更改picker的列选项
|
||||||
const change = (e) => {
|
const change = (e) => {
|
||||||
if (
|
if (
|
||||||
state.currentIndex[0] === e.detail.value[0] &&
|
state.currentCityIndex[0] === e.detail.value[0] &&
|
||||||
state.currentIndex[1] === e.detail.value[1]
|
state.currentCityIndex[1] === e.detail.value[1]
|
||||||
) {
|
) {
|
||||||
// 不更改省市区列表
|
// 不更改省市区列表
|
||||||
state.currentIndex[2] = e.detail.value[2];
|
state.currentCityIndex[2] = e.detail.value[2];
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// 更改省市区列表
|
// 更改省市区列表
|
||||||
if (state.currentIndex[0] !== e.detail.value[0]) {
|
if (state.currentCityIndex[0] !== e.detail.value[0]) {
|
||||||
e.detail.value[1] = 0;
|
e.detail.value[1] = 0;
|
||||||
}
|
}
|
||||||
e.detail.value[2] = 0;
|
e.detail.value[2] = 0;
|
||||||
state.currentIndex = e.detail.value;
|
state.currentCityIndex = e.detail.value;
|
||||||
}
|
}
|
||||||
emits('change', state.currentIndex);
|
emits('change', state.currentCityIndex);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 用户点击确定按钮
|
// 用户点击确定按钮
|
||||||
@ -158,8 +170,13 @@
|
|||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
if (state.moving) return;
|
if (state.moving) return;
|
||||||
// #endif
|
// #endif
|
||||||
let index = state.currentIndex;
|
let index = state.currentCityIndex;
|
||||||
let province = provinceList[index[0]];
|
let province = provinceList[index[0]];
|
||||||
|
// if(province == '全国') {
|
||||||
|
// let city = cityList.value[index[1]];
|
||||||
|
// }else {
|
||||||
|
|
||||||
|
// }
|
||||||
let city = cityList.value[index[1]];
|
let city = cityList.value[index[1]];
|
||||||
// let district = districtList.value[index[2]];
|
// let district = districtList.value[index[2]];
|
||||||
let result = {
|
let result = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user