You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jwl-applet/src/pages/me/school.vue

58 lines
1.5 KiB

2 years ago
<template>
<view>
<IndexList :dataList="dataList" nameKey="schoolName" idKey="schoolId" v-model:current="current" @click="click"></IndexList>
2 years ago
</view>
</template>
<script>
import IndexList from '@/components/liu-indexed-list/liu-indexed-list.vue'
import { bindSchool } from '@/jtools/api/login.js'
import useUserStore from '@/jtools/store/user.js'
2 years ago
export default {
components: {
IndexList
},
data() {
return {
current: useUserStore().userInfo.schoolId,
dataList: []
2 years ago
}
},
created() {
this._getSchoolOptions()
},
2 years ago
methods: {
_getSchoolOptions() {
uni.request({
url: 'https://xueche.ahduima.com/duima/applet/school/list'
}).then(resp => {
if(resp.data.code == 200) {
this.dataList = resp.data.data
}
})
},
2 years ago
click() {
// 设置用户驾校
const {schoolId,schoolName,phone } = this.dataList.find(it=>it.schoolId == this.current)
const params = {schoolId, schoolName, schoolPhone: phone}
bindSchool(params).then(resp => {
if(resp.code == '0000') {
useUserStore().userInfo.schoolId = schoolId
useUserStore().userInfo.schoolName = schoolName
useUserStore().userInfo.schoolPhone = phone
uni.showToast({
title: '绑定驾校成功!',
icon: 'none'
})
// 然后返回
uni.navigateBack()
}
})
2 years ago
}
}
}
</script>
<style>
</style>