Browse Source

refactor: 优化代码结构并修复多个问题

- 将 `tourGuide` 页面从子包移至主包
- 添加 `homeList` 组件以复用房源列表展示逻辑
- 修复登录和用户信息获取逻辑
- 调整环境配置和基础 URL
- 优化房源详情和列表展示逻辑
- 修复表单验证和提交逻辑
master
前端-胡立永 2 months ago
parent
commit
23fb411eed
21 changed files with 345 additions and 99 deletions
  1. +1
    -3
      App.vue
  2. +2
    -2
      common/config.js
  3. +65
    -0
      components/home/homeList.vue
  4. +1
    -1
      config.js
  5. +3
    -1
      main.js
  6. +47
    -0
      mixins/configList.js
  7. +14
    -8
      pages.json
  8. +16
    -16
      pages/auth/index.vue
  9. +14
    -11
      pages/home/index.vue
  10. +24
    -22
      pages/login/index.vue
  11. +32
    -6
      pages/tourGuide/tourGuide.vue
  12. +19
    -1
      pages/user/index.vue
  13. +3
    -3
      pages_subpack/broker-account/index.vue
  14. +3
    -3
      pages_subpack/broker-center/index.vue
  15. +6
    -3
      pages_subpack/category/index.vue
  16. +6
    -4
      pages_subpack/detail/index.vue
  17. +7
    -6
      pages_subpack/house/index.vue
  18. +55
    -5
      store/index.js
  19. +0
    -1
      store/modules/data.js
  20. +21
    -3
      store/modules/user.js
  21. +6
    -0
      utils/utils.js

+ 1
- 3
App.vue View File

@ -2,12 +2,10 @@
export default {
onLaunch: function() {
console.log('App Launch')
this.$store.commit('initConfig')
},
onShow: function() {
},
onHide: function() {


+ 2
- 2
common/config.js View File

@ -1,6 +1,6 @@
export default {
baseUrl : 'http://127.0.0.1:8000',
// baseUrl : 'http://127.0.0.1:8000',
// baseUrl: 'https://api.book118.com',
// baseUrl:'https://houserent-admin.hhlm1688.com'
baseUrl:'https://houserent-admin.hhlm1688.com'
// baseUrl:'http://h5.xzaiyp.top'
}

+ 65
- 0
components/home/homeList.vue View File

@ -0,0 +1,65 @@
<template>
<view class="se-pb-200">
<view v-if="list.length>0">
<view @click="onDetail(item)" class="se-my-10 se-mx-20 se-px-20 se-py-20 se-br-20 se-bgc-white se-flex" v-for="(item,index) in list" :key="index">
<view class="se-pos se-w-260 se-h-180">
<image v-if="item.iconImage" class="se-a-80 se-pos-lt" :src="item.iconImage" mode=""></image>
<image class="se-w-260 se-h-180 se-br-10" :src="item.images[0]" mode=""></image>
</view>
<view class="se-pl-10 se-w-p-100">
<view class="se-c-black se-fs-28">
{{item.title}}
</view>
<view class="se-flex se-flex-h-sb se-flex-ai-c se-fs-24 se-mt-10 se-c-66">
<text>{{item.homeType}}</text>
<text>{{item.timeGo}}</text>
</view>
<view class="se-flex se-flex-h-sb se-flex-ai-c se-mt-10">
<template v-if="item.iconTitles.length>0">
<view class="se-flex">
<view class="se-display-ib se-c-white se-bgc-orange se-fs-22 se-br-8 se-px-10 se-py-5 se-mr-10" v-for="(items,indexs) in item.iconTitles" :key="indexs">
{{items}}
</view>
</view>
</template>
<template v-else><view></view></template>
<view class="se-c-66 se-flex se-flex-ai-c">
<uv-icon name="eye"></uv-icon>
<text class="se-ml-5 se-fs-18">{{item.num}}</text>
</view>
</view>
<view class="se-flex se-flex-h-sb se-flex-ai-c se-mt-10">
<text class="se-c-red se-fs-24 se-fw-6 se-toe-1">{{item.price}}/{{item.unit}}</text>
<text class="se-c-66 se-fs-22 se-toe-1">{{item.address}}</text>
</view>
</view>
</view>
</view>
<view v-else>
<uv-empty mode="list" ></uv-empty>
</view>
</view>
</template>
<script>
export default {
name:"homeList",
props : ['list'],
data() {
return {
};
},
methods : {
onDetail(event){
uni.navigateTo({
url:"/pages_subpack/detail/index?id="+event.id
})
},
}
}
</script>
<style>
</style>

+ 1
- 1
config.js View File

@ -5,7 +5,7 @@ import uvUI from '@/uni_modules/uv-ui-tools'
Vue.use(uvUI);
// 当前环境
const type = 'local'
const type = 'prod'
// 环境配置


+ 3
- 1
main.js View File

@ -7,9 +7,11 @@ import Vue from 'vue'
Vue.config.productionTip = false
console.info('config')
import './config.js' import './utils/index.js'
import mixinConfigList from '@/mixins/configList.js'
Vue.mixin(mixinConfigList)
App.mpType = 'app'


+ 47
- 0
mixins/configList.js View File

@ -0,0 +1,47 @@
import { mapState } from 'vuex'
export default {
data() {
return {
// 默认的全局分享内容
Gshare: {
// title: '三只青蛙',
path: '/pages/index/index', // 全局分享的路径,比如 首页
// imageUrl: '/static/image/login/logo.png', // 全局分享的图片(可本地可网络)
}
}
},
computed: {
...mapState(['userInfo']),
},
// 定义全局分享
// 1.发送给朋友
// onShareAppMessage(res) {
// let o = {
// title : this.configList.logo_name,
// ...this.Gshare,
// }
// if(this.userInfo.id){
// if(this.Gshare.path.includes('?')){
// o.path += '&shareId=' + this.userInfo.id
// }else{
// o.path += '?shareId=' + this.userInfo.id
// }
// }
// return o
// },
// //2.分享到朋友圈
// onShareTimeline(res) {
// let o = {
// ...this.Gshare,
// title : this.configList.logo_name,
// }
// if(this.userInfo.id){
// o.path = this.Gshare.path + '?shareId=' + this.userInfo.id
// }
// return o
// },
methods: {
}
}

+ 14
- 8
pages.json View File

@ -56,6 +56,14 @@
"style": {
"navigationBarTitleText": "申请"
}
},
{
"path": "pages/tourGuide/tourGuide",
"style": {
"navigationBarTitleText": "地图导览",
"navigationBarBackgroundColor": "#1EC77A",
"navigationBarTextStyle": "white"
}
}
],
"subPackages": [
@ -170,14 +178,6 @@
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},
{
"path": "tourGuide/tourGuide",
"style": {
"navigationBarTitleText": "地图导览",
"navigationBarBackgroundColor": "#1EC77A",
"navigationBarTextStyle": "white"
}
}
]
}
@ -198,6 +198,12 @@
"selectedIconPath": "static/bar/home_selected.png",
"text": "首页"
},
{
"pagePath": "pages/tourGuide/tourGuide",
"iconPath": "static/bar/find.png",
"selectedIconPath": "static/bar/find_selected.png",
"text": "发现"
},
// {
// "pagePath": "pages/discover/index",
// "iconPath": "static/bar/find.png",


+ 16
- 16
pages/auth/index.vue View File

@ -12,6 +12,11 @@
<image class="se-w-45 se-h-35" src="@/static/image/wechat.png" mode=""></image>
<text class="se-ml-10">微信登录</text>
</button>
<button @getuserinfo="onLogin"
style="margin-top: 30rpx;background-color: rgba(#0f0, 0.4);color: #0f0;"
class="se-mx-80 se-br-40 se-flex-h-c se-h-80 se-lh-80 se-ta-c se-fs-32">
<text class="se-ml-10">取消登录</text>
</button>
<!-- <view class="se-mx-80 se-br-40 se-mt-40 se-flex-h-c se-h-80 se-lh-80 se-ta-c se-fs-32 se-c-66 se-bgc-f5">
<text>手机验证码登录</text>
</view> -->
@ -98,7 +103,7 @@
title: '登录中...'
})
uni.login({
success(res) {
success : res => {
console.info(res.code)
if(res.errMsg != "login:ok"){
return
@ -119,24 +124,19 @@
uni.setStorageSync('token', response.result.token)
uni.setStorageSync('sessionKey', response.result.userInfo.sessionKey)
uni.setStorageSync('userInfo', response.result.userInfo)
// that.commit('setUserInfo',{userInfo:response.result.userInfo,token:response.result.token})
getInfo({}).then(result=>{
// console.info('resultresult',result)
let userInfo =response.result.userInfo
if(!userInfo.nickName
|| !userInfo.phone){
uni.navigateTo({
url:"/pages/login/index"
})
// if(result.result.nickName){
// uni.switchTab({
// url:"/pages/home/index"
// })
// }else{
// }
}).catch(err=>{
})
}else{
uni.switchTab({
url:"/pages/home/index"
})
}
}).catch((error) =>{


+ 14
- 11
pages/home/index.vue View File

@ -34,7 +34,7 @@
<view class="se-bgc-white se-my-20">
<uv-tabs @click="onClickHouseType" :list="houseTypeList" keyName="title" :activeStyle="{color:'#000000'}" :inactiveStyle="{color:'#666666'}" :lineColor="`url(${lineBg}) 100% 100%`"></uv-tabs>
</view>
<view class="se-pb-200">
<!-- <view class="se-pb-200">
<view v-if="list.length>0">
<view @click="onDetail(item)" class="se-my-10 se-mx-20 se-px-20 se-py-20 se-br-20 se-bgc-white se-flex" v-for="(item,index) in list" :key="index">
<view class="se-pos se-w-260 se-h-180">
@ -73,10 +73,12 @@
<view v-else>
<uv-empty mode="list" ></uv-empty>
</view>
</view>
</view> -->
<homeList :list="list" />
<!-- 发布房源 -->
<view class="se-pos-fixed se-pos-rc" style="right: 30rpx;">
<view class="se-pos-fixed se-pos-rc" style="right: 30rpx;top: 70vh;">
<image @click="onNavigator()" class="se-a-150" src="@/static/image/discover.png" mode=""></image>
</view>
@ -90,9 +92,11 @@
import citySelect from "@/components/cityselect/index.vue"
const lineBg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAANCAYAAAC3mX7tAAAAAXNSR0IArs4c6QAAAbxJREFUOE+lk0FrE1EUhc+ZDOhMigjZdNcWdCPJqNCdlkZw4TKL2mVwkKLQ/gAFRcEu/AEKuumDrEopNEsXSlNoV+2iTYIbBdNdNwGpmRmFyVx5oQk6mYSpvt1799z7zTnvDQPlBAJcRGxZOLXotn7Gz8ftZePaROCZP+IaEh36a04LxFS8mMmgcKFcb54H9Kvi5LtdNIZ6BMf0lVMDMD88UJ7abuP1eUDeWuEZyVcJPZ/oKeclgRcJxRMrG17l4udOGthZbF8ATMb1IvKcXiU/y66xnziM2LQf1O+nAfnq+hYgpSStCeMmdcFXzi6AWyMGrlvZcGmUs54T31QQLIzo37Pd+u0eKFD5osDYHvPlJyLyNopYnbgUtrSuc2pOG4aUSC4nxTWYFXHOfni02wPp5anCO4KP0sSUViOQ91m38VjrByDZLprBt/ZHkAkvMO3oP3QiO9ZM7i7v1MK/QHoj6sblQLrV/4ZpCDMluoff++iBo/6Bdua32m/+NUYdlz2dW+k7GQnqF84eyOqY1xjPcw8Rn+iLTwp6yFFcpP8zhLxHsgjBFRrI9WKO0AbxVURqMOVDttw8GHeTvwFKoZ4cmcUYJAAAAABJRU5ErkJggg==";
import QQMapWX from "@/util/qqmap-wx-jssdk.min.js"
import homeList from '@/components/home/homeList.vue'
export default{
components:{
citySelect
citySelect,
homeList,
},
data(){
return{
@ -144,7 +148,6 @@
this.onHousePageList();
this.onHouseType();
// this.onGetConfig()
this.$store.commit('initConfig')
},
onPullDownRefresh() {
@ -210,12 +213,12 @@
let hasMapGuide = that.nav.some(item => item.url === '/pages_subpack/tourGuide/tourGuide')
if(!hasMapGuide) {
//
that.nav.push({
id: 'map_guide',
title: '地图导览',
image: 'https://tennis-oss.xzaiyp.top/2024-12-08/9704d4a0-e8d8-40fc-a2b6-28b928013a60.png',
url: '/pages_subpack/tourGuide/tourGuide'
})
// that.nav.push({
// id: 'map_guide',
// title: '',
// image: 'https://tennis-oss.xzaiyp.top/2024-12-08/9704d4a0-e8d8-40fc-a2b6-28b928013a60.png',
// url: '/pages/tourGuide/tourGuide'
// })
}
}).catch(error=>{


+ 24
- 22
pages/login/index.vue View File

@ -23,14 +23,14 @@
<input type="nickname" placeholder="请输入昵称" v-model="nameUser"
@blur="bindblur" class="se-h-80 se-lh-80 se-w-320 se-fs-24 se-ta-r" placeholder-class="se-fs-24 se-ta-r" />
</view>
<!-- <view class=" se-b-b se-flex se-h-140 se-lh-140 se-flex-h-sb">
<view class=" se-b-b se-flex se-h-140 se-lh-140 se-flex-h-sb">
<text>手机号</text>
<button v-if="phone" class="default-btn se-h-100 se-p-0 se-m-0" open-type="getPhoneNumber" @getphonenumber="onPhonenumber">{{phone}}</button>
<button v-else class="se-w-140 se-h-60 se-lh-60 se-fs-20 se-bgc-green se-c-white se-py-0 se-br-30 se-px-20 se-m-0" open-type="getPhoneNumber" @getphonenumber="onPhonenumber">
获取手机号
</button>
</view> -->
</view>
</view>
<view class="se-mx-40">
<view @click="onUpdateInfo" class="se-br-40 se-flex-h-c se-h-80 se-lh-80 se-ta-c se-fs-32 se-c-white se-bgc-green">
@ -94,30 +94,32 @@
let params={
avatarUrl:that.imagUrl,
nickName:that.nameUser,
// phone:that.phone
phone:that.phone
}
// &&that.phone
if(that.imagUrl&&that.nameUser){
UpdateInfo(params).then((response) => {
if(this.back==1){
uni.navigateBack({
delta:1
})
}else{
uni.switchTab({
url:"/pages/home/index"
})
}
}).catch((error) =>{
})
}else{
return uni.showToast({
icon:"none",
title:"头像和昵称不能为空!"
})
if (that.$utils.verificationAll(params, {
avatarUrl: '请选择头像',
nickName: '请填写昵称',
phone: '请填写手机号',
})) {
return
}
UpdateInfo(params).then((response) => {
if(this.back==1){
uni.navigateBack({
delta:1
})
}else{
uni.switchTab({
url:"/pages/home/index"
})
}
}).catch((error) =>{
})
}
}


pages_subpack/tourGuide/tourGuide.vue → pages/tourGuide/tourGuide.vue View File

@ -65,7 +65,7 @@
</view>
</view>
<uv-empty v-else text="该景区没有哦" textSize="30rpx" iconSize="200rpx" icon="list"></uv-empty>
<uv-empty v-else text="没有哦" textSize="30rpx" iconSize="200rpx" icon="list"></uv-empty>
</view>
@ -74,13 +74,13 @@
<script>
import { housePageList, houseType } from "@/common/api.js"
import { getInfo } from "@/common/api.js"
export default {
data() {
return {
scale: 12, //
show: true,
context: uni.createInnerAudioContext(),
tabs: ['遗产文化', '找美食', '找民宿', '找厕所'],
tabs: [],
spotGuideIndex: 0, //
position: {
latitude: 23.106574,
@ -93,7 +93,7 @@ export default {
pageNo: 1,
pageSize: 10,
houseTypeList: [], //
currentHouseType: 0 //
currentHouseType: 0 ,//
}
},
computed: {
@ -125,22 +125,43 @@ export default {
},
created() {
this.getCurrentLocation()
this.onHousePageList()
this.onHouseType() //
this.onHousePageList() //
this.onHousePageList() //
this.getUserInfo() //
},
onPullDownRefresh() {
if(!uni.getStorageSync('token') || this.userInfo.isPay != 1){
return
}
let that = this
that.pageNo = 1
that.list = []
that.onHousePageList()
},
onReachBottom() {
if(!uni.getStorageSync('token') || this.userInfo.isPay != 1){
return
}
let that = this
that.pageNo = that.pageNo + 1
that.onHousePageList()
},
methods: {
getUserInfo(state){
this.$store.commit('getUserInfo', userInfo => {
if(userInfo.isPay != 1){
uni.showModal({
title: '开通会员可查看租房地图',
success : res => {
if(res.confirm){
this.getUserInfo()
}
}
})
}
})
},
//
getCurrentLocation() {
const that = this;
@ -304,6 +325,11 @@ export default {
},
//
onHousePageList() {
if(!uni.getStorageSync('token') || this.userInfo.isPay != 1){
return
}
let that = this
let params = {
classId: that.classId,

+ 19
- 1
pages/user/index.vue View File

@ -4,8 +4,26 @@
<view class="se-flex">
<image @click="onHead" :src="user.headImage" class="se-br-p-50 se-bgc-f9 se-w-120 se-h-120" mode=""></image>
<view class="se-ml-20 se-flex se-flex-v-sa se-flex-ai-fs">
<view class="se-flex">
<view class="se-flex"
style="align-items: center;">
<text class="se-fw-6 se-fs-30">{{user.nickName?user.nickName:'暂无昵称'}}</text>
<view class=""
v-if="user.isPay == 1"
style="display: flex;background-color: #fff;
color: #0f0;
font-size: 24rpx;
align-items: center;
border-radius: 20rpx;
padding: 4rpx 10rpx;">
<uv-icon
name="level"
size="40rpx"
color="#0f0"
></uv-icon>
会员
</view>
<!-- <view class="se-flex se-flex-ai-c se-ml-20">
<image class="se-a-25 se-mr-10" src="@/static/image/pencil.png" mode=""></image>
<text class="se-fs-22">修改资料</text>


+ 3
- 3
pages_subpack/broker-account/index.vue View File

@ -11,7 +11,7 @@
<text class="se-ml-20 se-fw-5">账号</text>
</view>
<view class="se-flex se-flex-ai-c">
{{detail.account}}
{{ detail.account || '暂无' }}
</view>
</view>
<view class="se-py-30 se-px-20 se-flex se-flex-h-sb se-b-b se-fs-26">
@ -19,7 +19,7 @@
<text class="se-ml-20 se-fw-5">密码</text>
</view>
<view class="se-flex se-flex-ai-c">
{{detail.password}}
{{ detail.password || '暂无' }}
</view>
</view>
<view class="se-py-30 se-px-20 se-flex se-flex-h-sb se-b-b se-fs-26">
@ -27,7 +27,7 @@
<text class="se-ml-20 se-fw-5">邀请码</text>
</view>
<view class="se-flex se-flex-ai-c">
{{detail.invoice}}
{{ detail.invoice || '暂无' }}
</view>
</view>
</view>


+ 3
- 3
pages_subpack/broker-center/index.vue View File

@ -65,18 +65,18 @@
}
},
onLoad(options) {
this.onMyVipPageList()
this.onMyHousePageList()
},
onPullDownRefresh() {
let that = this
that.pageNo = 1
that.list = []
that.onMyVipPageList()
that.onMyHousePageList()
},
onReachBottom() {
let that = this
that.pageNo = that.pageNo + 1
that.onMyVipPageList()
that.onMyHousePageList()
},
methods:{
onMyHousePageList(){


+ 6
- 3
pages_subpack/category/index.vue View File

@ -1,7 +1,7 @@
<template>
<view class="uv-page">
<searchVue @onSearch="onSearch($event)" @onParent="onDropDown($event)" />
<view class="se-pb-200">
<!-- <view class="se-pb-200">
<view v-if="list.length>0">
<view @click="onDetail(item)" class="se-my-10 se-mx-20 se-px-20 se-py-20 se-br-20 se-bgc-white se-flex" v-for="(item,index) in list" :key="index">
<view class="se-pos se-w-260 se-h-180">
@ -40,7 +40,8 @@
<view v-else>
<uv-empty mode="list" ></uv-empty>
</view>
</view>
</view> -->
<homeList :list="list" />
<!-- <view class="se-my-10 se-mx-20 se-px-20 se-py-20 se-br-20 se-bgc-white se-flex" v-for="(item,index) in 20" :key="index">
<view class="se-pos se-w-260 se-h-180">
<image class="se-a-80 se-pos-lt" src="../../static/image/2x.png" mode=""></image>
@ -75,9 +76,11 @@
<script>
import searchVue from './component/search.vue'
import { housePageList } from "@/common/api.js"
import homeList from '@/components/home/homeList.vue'
export default{
components:{
searchVue
searchVue,
homeList,
},
data(){
return{


+ 6
- 4
pages_subpack/detail/index.vue View File

@ -52,16 +52,18 @@
<text class="se-c-black">{{detail.homeJg}}</text>
</view>
</view>
<view class="se-flex se-fs-24">
<view class="se-flex se-fs-24"
v-if="userInfo.isPay == 1">
<view class="se-flex-2 se-py-20">
<text class="se-c-66 se-mr-20">房屋地址</text>
<text class="se-c-black se-fw-6">{{detail.address}}</text>
<text class="se-c-black se-fw-6">{{ detail.address }}</text>
</view>
</view>
<view class="se-flex bgc-active-lg se-py-20 se-br-10">
<view class="se-flex bgc-active-lg se-py-20 se-br-10"
v-if="userInfo.isPay == 1">
<view class="se-w-p-85 se-pl-30">
<view class=" se-c-black se-fw-6 se-fs-24">
具体地址{{address}}
您的位置{{ detail.address }}
</view>
<!-- <view class="se-fs-22 se-py-5">
距离你1.4km 骑行9分钟 步行18分钟


+ 7
- 6
pages_subpack/house/index.vue View File

@ -138,11 +138,11 @@
<uv-form-item label="报建手续" prop="procedures">
<uv-input v-model="form.procedures" type="text" placeholder="请输入报建手续" customStyle="border-radius: 5px;margin-top:5px;background-color: #f5f5f5;padding:5px 10px;"></uv-input>
</uv-form-item>
<uv-form-item label="产权证照片" labelWidth="250" prop="isOwnershipList" labelPosition="top">
<uv-form-item label="房屋照片" labelWidth="250" prop="isOwnershipList" labelPosition="top">
<uv-upload customStyle="margin-top:20rpx;" :fileList="form.ownershipList" @afterRead="afterOwnershipRead" @delete="deleteOwnershipPic" name="1"
multiple :maxCount="10"></uv-upload>
</uv-form-item>
<uv-form-item label="房屋照片" labelWidth="250" prop="isHouseList" labelPosition="top">
<uv-form-item label="产权证照片" labelWidth="250" prop="isHouseList" labelPosition="top">
<uv-upload customStyle="margin-top:20rpx;" :fileList="form.houseList" @afterRead="afterHouseRead" @delete="deleteHousePic" name="1"
multiple :maxCount="10"></uv-upload>
</uv-form-item>
@ -243,8 +243,8 @@
homeJl:"",//
iconTitle:"",//
housesNumber:1,//
revamp:0,//
resettle:0,//
revamp:'0',//
resettle:'0',//
yardProportion:"",//
noise:"",//
net:"",//
@ -276,7 +276,7 @@
{
type: 'string',
required: true,
message: '请输入账号',
message: '请输入标题',
trigger: ['blur', 'change']
}
],
@ -872,7 +872,8 @@
longitude:that.form.longitude
}
console.log(that.form);
console.log(params);
if(this.$utils.verificationAll(params, {
image : '请上传房屋照片',


+ 55
- 5
store/index.js View File

@ -3,14 +3,64 @@ import Vuex from 'vuex'
import data from './modules/data'
import user from './modules/user'
import { getConfig, getInfo } from "@/common/api.js"
Vue.use(Vuex)
const store = new Vuex.Store({
modules: {
data,
user
}
state: {
token:"",
userInfo : {}, //用户信息
},
mutations: {
// 初始化配置
initConfig(state){
getConfig({}).then(response=>{
uni.setStorageSync('configList', response.result)
}).catch(error=>{
})
},
onAuth(state){
},
setUserInfo(state,obj){
state.userInfo = obj.userInfo
state.token = obj.token
},
getUserInfo(state, fn){
if(!uni.getStorageSync('token')){
return
}
getInfo({}).then(result=>{
if(result.result.nickName){
state.userInfo = result.result
fn && fn(result.result)
}else{
uni.navigateTo({
url:"/pages/login/index"
})
}
})
},
logout(state){
uni.showModal({
title: '确认退出登录吗',
success(r) {
if(r.confirm){
state.userInfo = {}
state.token = ""
uni.removeStorageSync('token')
uni.redirectTo({
url: '/pages/index/index'
})
}
}
})
},
},
})
export default store

+ 0
- 1
store/modules/data.js View File

@ -7,7 +7,6 @@ export default {
},
mutations: {
// 初始化配置
initConfig(state){
getConfig({}).then(response=>{


+ 21
- 3
store/modules/user.js View File

@ -1,19 +1,37 @@
import { getInfo } from "@/common/api.js"
export default {
state: {
token:"",
userInfo : {}, //用户信息
},
mutations: {
onAuth(state){
},
setUserInfo(state,obj){
console.info(`setUserInfo`)
state.userInfo = obj.userInfo
state.token = obj.token
},
getUserInfo(state){
if(!uni.getStorageSync('token')){
return
}
getInfo({}).then(result=>{
if(result.result.nickName){
state.userInfo = result.result
}else{
uni.navigateTo({
url:"/pages/login/index"
})
}
})
},
logout(state){
uni.showModal({
title: '确认退出登录吗',


+ 6
- 0
utils/utils.js View File

@ -34,6 +34,12 @@ function generateLightRandomColor() {
return color;
}
/**
* 表单数据验证
* @param {Object} data - 需要验证的表单数据
* @param {Object} msg - 验证失败时的提示信息
* @returns {boolean} 验证结果true表示验证失败false表示验证通过
*/
function verificationAll(data, msg){
if (!msg){


Loading…
Cancel
Save