123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- <template>
- <view class="center">
- <view class="flex row form_css">
- <view class="left-text">发货城市</view>
- <view class="right-text">
- <view @click="selectAddress(1)">{{title1 ? title1 : "请选择地址"}}</view>
- <itmister-address-picker ref="addressElone" @confirmChange="confirmChangeOne"></itmister-address-picker>
- </view>
- </view>
- <view class="flex row form_css">
- <view class="left-text">到货城市</view>
- <view class="right-text">
- <view @click="selectAddress(2)">{{title2 ? title2 : "请选择地址"}}</view>
- <!-- <Linkage @conceal="conceal2" class="flex" v-if="show2" ref="uDropdown"></Linkage> -->
- <itmister-address-picker ref="addressEltwo" @confirmChange="confirmChangeTwo"></itmister-address-picker>
- </view>
- </view>
- <view class="text_css">注:常用路线用于展示给其他司机和货主查看。</view>
- <view class="btn_css">
- <u-button type="primary" @click="submit">提交</u-button>
- </view>
- <u-toast ref="uToast"></u-toast>
- </view>
- </template>
- <script>
- // import regionPicker from "@/components/region/region-picker";
- // import Linkage from '@/components/gaojianghua-linkage/linkage.vue'
- import itmisterAddressPicker from '@/components/itmister-address-picker/itmister-address-picker.nvue'
- export default {
- components: {
- // regionPicker,
- // Linkage,
- itmisterAddressPicker
- },
- data() {
- return {
- id: "",
- routeData: {},
- // selections1: [],
- // selections2: [],
- driverData: {},
- avatarUrl: "",
- // sendregion: [],
- // unloaddregion: [],
- title1: "",
- title2: "",
- }
- },
- onShow() {},
- onLoad(options) {
- this.driverData = uni.getStorageSync('firstAuthentication')
- this.avatarUrl = uni.getStorageSync("userInfo").avatarUrl
- this.id = options.id
- if (this.id) { //修改
- uni.setNavigationBarTitle({
- title: '编辑路线'
- })
- this.getList()
- }
- },
- methods: {
- selectAddress(num) {
- if(num == 1){
- this.$refs.addressElone.show();
- }else{
- this.$refs.addressEltwo.show();
- }
- },
- // 确认选中
- confirmChangeOne(address) {
- this.routeData.sendProvince = address.province ? address.province : ''
- this.routeData.sendCity = address.city ? address.city : ''
- this.routeData.sendArea = address.area ? address.area : ''
- if(address.city == '全省'){
- this.title1 = address.province
- this.routeData.sendCity = ""
- this.routeData.sendArea = ""
- }else if(address.area == '全市'){
- this.title1 = address.province + address.city
- this.routeData.sendArea = ""
- }else{
- this.title1 = address.province + address.city + address.area;
- }
-
- },
- confirmChangeTwo(address) {
- this.routeData.unloadProvince = address.province ? address.province : ''
- this.routeData.unloadCity = address.city ? address.city : ''
- this.routeData.unloadArea = address.area ? address.area : ''
- if(address.city == '全省'){
- this.title2 = address.province
- this.routeData.unloadCity = ""
- this.routeData.unloadArea = ""
- }else if(address.area == '全市'){
- this.title2 = address.province + address.city
- this.routeData.unloadArea = ""
- }else{
- this.title2 = address.province + address.city + address.area;
- }
-
- },
- // conceal1(param) {
- // const {
- // chooseprovince,
- // choosecity,
- // choosearea
- // } = param
- // // 获取到传过来的 省 市 区 县数据
- // this.routeData.sendProvince = chooseprovince
- // this.routeData.sendCity = choosecity == '全部' ? "" : choosecity
- // this.routeData.sendArea = choosearea == '全部' ? "" : choosearea
- // this.title1 = chooseprovince + choosecity + choosearea
- // if (chooseprovince == '全国') {
- // this.succeed(1)
- // }
- // if (choosecity == '全部') {
- // this.succeed(1)
- // } else if (choosearea != '') {
- // this.succeed(1)
- // }
- // },
- // conceal2(param) {
- // const {
- // chooseprovince,
- // choosecity,
- // choosearea
- // } = param
- // // 获取到传过来的 省 市 区 县数据
- // this.routeData.unloadProvince = chooseprovince
- // this.routeData.unloadCity = choosecity == '全部' ? "" : choosecity
- // this.routeData.unloadArea = choosearea == '全部' ? "" : choosearea
- // this.title2 = chooseprovince + choosecity + choosearea
- // if (chooseprovince == '全国') {
- // this.succeed(2)
- // }
- // if (choosecity == '全部') {
- // this.succeed(2)
- // } else if (choosearea != '') {
- // this.succeed(2)
- // }
- // },
- //筛选框关闭
- // succeed(num) {
- // // this.$refs.uDropdown.close();
- // if (num == 1) {
- // this.show1 = false
- // } else if (num == 2) {
- // this.show2 = false
- // }
- // },
- getList() {
- this.$request.baseRequest('get', '/commonRoute/get', {
- id: this.id
- }).then(res => {
- if (res.code == 200) {
- this.routeData = res.data
- this.title1 = this.routeData.sendProvince + this.routeData.sendCity + this.routeData
- .sendArea
- this.title2 = this.routeData.unloadProvince + this.routeData.unloadCity + this.routeData
- .unloadArea
- }
- })
- .catch(res => {
- uni.$u.toast(res.message);
- });
- },
- submit() {
- this.routeData.commonId = uni.getStorageSync("userInfo").id
- let name = this.driverData.driverCall.slice(0, 1)
- this.routeData.driverNickname = name + "师傅"
- this.routeData.driverPortrait = this.avatarUrl
- if (this.id) {
- this.$request.baseRequest('post', '/commonRoute/api/edit', this.routeData).then(res => {
- if (res.code == 200) {
- this.$refs.uToast.show({
- type: 'success',
- message: "修改成功!",
- complete() {
- uni.$u.route("pages/mine/often/oftenRoute")
- }
- })
- }
- })
- .catch(res => {
- uni.$u.toast(res.message);
- });
- } else {
- this.$request.baseRequest('post', '/commonRoute/api/add', this.routeData).then(res => {
- if (res.code == 200) {
- this.$refs.uToast.show({
- type: 'success',
- message: "提交成功!",
- complete() {
- uni.$u.route("pages/mine/often/oftenRoute")
- }
- })
- }
- })
- .catch(res => {
- uni.$u.toast(res.message);
- });
- }
- },
- // regionChange1(value) {
- // this.sendregion = value
- // this.routeData.sendProvince = this.sendregion[0] == '请选择' ? '' : this.sendregion[0]
- // this.routeData.sendCity = this.sendregion[1] == '请选择' ? '' : this.sendregion[1]
- // this.routeData.sendArea = this.sendregion[2] == '请选择' ? '' : this.sendregion[2]
- // },
- // regionChange2(value) {
- // this.unloaddregion = value
- // this.routeData.unloadProvince = this.unloaddregion[0] == '请选择' ? '' : this.unloaddregion[0]
- // this.routeData.unloadCity = this.unloaddregion[1] == '请选择' ? '' : this.unloaddregion[1]
- // this.routeData.unloadArea = this.unloaddregion[2] == '请选择' ? '' : this.unloaddregion[2]
- // },
- // selecteRegion1(value) {
- // this.selections1 = value;
- // this.routeData.sendNum = this.selections1.toString()
- // },
- // selecteRegion2(value) {
- // this.selections2 = value;
- // this.routeData.unloadNum = this.selections2.toString()
- // },
- }
- }
- </script>
- <style lang="scss" scoped>
- .center {
- // width: 100%;
- padding: 30rpx;
- }
- .form_css {
- width: 100%;
- display: flex;
- margin: 20rpx 0;
- height: 60rpx;
- border-bottom: 1px solid #eeeeee;
- .left-text {
- width: 50%;
- text-align: left;
- }
- .right-text {
- width: 50%;
- justify-content: flex-end;
- display: flex;
- text-align: right;
- }
- }
- .btn_css {
- margin-top: 300rpx;
- }
- </style>
|