Files
jwl-applet/src/pages/me/school.vue

58 lines
1.5 KiB
Vue
Raw Normal View History

2023-08-17 01:17:33 +08:00
<template>
<view>
2023-08-19 17:42:47 +08:00
<IndexList :dataList="dataList" nameKey="schoolName" idKey="schoolId" v-model:current="current" @click="click"></IndexList>
2023-08-17 01:17:33 +08:00
</view>
</template>
<script>
import IndexList from '@/components/liu-indexed-list/liu-indexed-list.vue'
2023-08-19 17:42:47 +08:00
import { bindSchool } from '@/jtools/api/login.js'
import useUserStore from '@/jtools/store/user.js'
2023-08-17 01:17:33 +08:00
export default {
components: {
IndexList
},
data() {
return {
2023-08-19 17:42:47 +08:00
current: useUserStore().userInfo.schoolId,
dataList: []
2023-08-17 01:17:33 +08:00
}
},
2023-08-19 17:42:47 +08:00
created() {
this._getSchoolOptions()
},
2023-08-17 01:17:33 +08:00
methods: {
2023-08-19 17:42:47 +08:00
_getSchoolOptions() {
uni.request({
url: 'https://xueche.ahduima.com/duima/applet/school/list'
}).then(resp => {
if(resp.data.code == 200) {
this.dataList = resp.data.data
}
})
},
2023-08-17 01:17:33 +08:00
click() {
// 设置用户驾校
2023-08-19 17:42:47 +08:00
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()
}
})
2023-08-17 01:17:33 +08:00
}
}
}
</script>
<style>
</style>