会员+驾校联调
This commit is contained in:
@@ -1,45 +1,53 @@
|
||||
<template>
|
||||
<view>
|
||||
<IndexList :dataList="dataList" nameKey="schoolName" v-model:current="current" @click="click"></IndexList>
|
||||
<IndexList :dataList="dataList" nameKey="schoolName" idKey="schoolId" v-model:current="current" @click="click"></IndexList>
|
||||
</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'
|
||||
export default {
|
||||
components: {
|
||||
IndexList
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
current: '1',
|
||||
dataList: [{
|
||||
id: '1',
|
||||
schoolName: '爱尚学车驾校长安分校',
|
||||
},{
|
||||
id: '2',
|
||||
schoolName: '八一驾校',
|
||||
},{
|
||||
id: '3',
|
||||
schoolName: '八零驾校',
|
||||
},{
|
||||
id: '4',
|
||||
schoolName: '畅通驾校',
|
||||
},{
|
||||
id: '5',
|
||||
schoolName: '金灵驾校',
|
||||
},{
|
||||
id: '6',
|
||||
schoolName: '通顺驾校',
|
||||
}]
|
||||
current: useUserStore().userInfo.schoolId,
|
||||
dataList: []
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this._getSchoolOptions()
|
||||
},
|
||||
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
|
||||
}
|
||||
})
|
||||
},
|
||||
click() {
|
||||
// 设置用户驾校
|
||||
|
||||
// 然后返回
|
||||
uni.navigateBack()
|
||||
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()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user