123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434 |
- <template>
- <view class="content">
- <view class="content1">
- <u-search placeholder="可按地址、联系人和电话查找" v-model="searchKeyWord" :showAction='false' @search="getList()">
- </u-search>
- </view>
- <view class="content2-wrap">
- <view class="content2" v-for="(item,index) in dataList" @click="configAddress(item)">
- <view class="row flex row1">
- <view class="name">
- {{item.contacts}}
- </view>
- <view class="phone">
- {{item.contactPhone1}}
- </view>
- </view>
- <view class="row flex row2">
- {{item.province}}{{item.city}}{{item.area}}{{item.detailedAddress}}
- </view>
- <view class="row flex row3">
- <u-radio-group placement="row" class="select-type" v-model="item.radiovalue">
- <u-radio :customStyle="radioCustomStyle" v-for="item1 in radiolist1" :label="item1.name"
- :name="item1.name" @change="radioChange($event,item)" labelSize='12px' :iconSize='10'>
- </u-radio>
- </u-radio-group>
- <view class="flex">
- <view class="mr20 icon-img" @click.stop="toTop(item)">
- <!-- <u-icon name="arrow-upward" color="#999999" size="18"></u-icon> -->
- <image class="jt-icon" src="@/static/images/release/zhiding.png" mode='widthFix'>
- </image>
- 置顶
- </view>
- <view class="mr20 icon-img" @click.stop="edit(item)">
- <!-- <u-icon name="edit-pen-fill" color="#999999" size="18"></u-icon> -->
- <image class="jt-icon" src="@/static/images/release/bianji.png" mode='widthFix'>
- </image>
- 编辑
- </view>
- <view class="mr20 icon-img" @click.stop="del(item)">
- <!-- <u-icon name="trash-fill" color="#999999" size="18"></u-icon> -->
- <image class="jt-icon" src="@/static/images/release/shanchu.png" mode='widthFix'>
- </image>
- 删除
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="bottom-btn">
- <view class="btn-left" @click="selectAddress(0)">选择临时地址</view>
- <view class="btn-right" @click="selectAddress(1)">新增常用地址</view>
- </view>
- <u-modal :show="isShowAlert" :title="alertTitle" :content='alertContent' :closeOnClickOverlay='true'
- :showCancelButton='showCancelButton' confirmColor='#2772FB' @confirm="$u.throttle(confirmClick, 1000)"
- @close="cancelClick" @cancel="cancelClick"></u-modal>
- <u-toast ref="uToast"></u-toast>
- </view>
- </template>
- <script>
- let that;
- import {
- mapState
- } from 'vuex';
- export default {
- data() {
- return {
- temporaryAddress: {
- latitude: '',
- longitude: '',
- detailedAddress: '',
- province: '',
- city: '',
- area: '',
- commonId: '',
- },
- radioCustomStyle: {
- margin: '0 20rpx 0 0',
- },
- type: '',
- radiovalue: '',
- dataList: [],
- searchKeyWord: '',
- radiolist1: [
- {
- name: '默认装货',
- disabled: false
- },
- {
- name: '默认卸货',
- disabled: false
- },
- ],
- delId: "",
- isShowAlert: false,
- alertTitle: "",
- alertContent: "",
- showCancelButton: false
- }
- },
- computed: {
- ...mapState(['hasLogin', 'userInfo'])
- },
- onLoad(options) {
- console.log(options)
- this.type = options.type
- that = this
- },
- onShow() {
- this.getList()
- },
- methods: {
- confirmClick() {
- this.isShowAlert = false
- this.$request.baseRequest('post', '/cargoOwnerAddressInfo/api/deleteCargoOwnerAddress', {
- id: this.delId,
- }).then(res => {
- if (res.code == 200) {
- this.$refs.uToast.show({
- type: 'success',
- message: "删除成功",
- complete() {
- that.getList()
- }
- })
- }
- })
- .catch(res => {
- uni.showToast({
- title: res.message,
- icon: 'none',
- duration: 2000
- })
- });
- },
- cancelClick() {
- this.isShowAlert = false
- },
- configAddress(val) {
- if (this.type == 0) {
- uni.setStorageSync('storage_faddress', val);
- } else {
- uni.setStorageSync('storage_saddress', val);
- }
- // uni.$u.route('/pages/release/release');
- uni.navigateBack({
- delta: 1
- })
- },
- getList() {
- uni.showLoading({
- mask: true,
- title: '加载中...'
- })
- this.$request.baseRequest('get', '/cargoOwnerAddressInfo/selectCargoOwnerAddress', {
- commonId: this.userInfo.id,
- searchKeyWord: this.searchKeyWord,
- pageSize: 100,
- currentPage: 1
- }).then(res => {
- uni.hideLoading()
- if (res.code == 200) {
- if (res.data.records.length) {
- for (var i = 0; i < res.data.records.length; i++) {
- res.data.records[i].contactPhone1 = res.data.records[i].contactPhone.replace(
- /(\d{3})(\d{4})(\d{4})/, "$1****$3")
- }
- }
- this.dataList = res.data.records
- this.$forceUpdate()
- for (let i = 0; i < this.dataList.length; i++) {
- if (this.dataList[i].defaultShipment == 1) {
- this.dataList[i].radiovalue = '默认装货'
- }
- if (this.dataList[i].defaultReceipt == 1) {
- this.dataList[i].radiovalue = '默认卸货'
- }
- }
- }
- })
- .catch(res => {
- uni.hideLoading()
- uni.showToast({
- title: res.message,
- icon: 'none',
- duration: 2000
- })
- });
- },
- radioChange(n, val) {
- for (var i = 0; i < this.dataList.length; i++) {
- if (this.dataList[i].defaultShipment == 1 && n == '默认装货') {
- this.dataList[i].radiovalue = ''
- }
- if (this.dataList[i].defaultReceipt == 1 && n == '默认卸货') {
- this.dataList[i].radiovalue = ''
- }
- }
- this.$set(val, 'radioChange', n)
- let _flag;
- if (n == '默认卸货') {
- _flag = 2
- } else {
- _flag = 1
- }
- this.$request.baseRequest('post', '/cargoOwnerAddressInfo/api/setDefault', {
- commonId: this.userInfo.id,
- id: val.id,
- defaultFlag: _flag
- }).then(res => {
- if (res.code == 200) {
- this.$refs.uToast.show({
- type: 'success',
- message: "设置成功",
- complete() {
- that.getList()
- }
- })
- }
- })
- .catch(res => {
- uni.showToast({
- title: res.message,
- icon: 'none',
- duration: 2000
- })
- });
- },
- toTop(val) {
- this.$request.baseRequest('post', '/cargoOwnerAddressInfo/api/setDefault', {
- commonId: this.userInfo.id,
- id: val.id,
- }).then(res => {
- if (res.code == 200) {
- this.$refs.uToast.show({
- type: 'success',
- message: "置顶成功",
- complete() {
- that.getList()
- }
- })
- }
- })
- .catch(res => {
- uni.showToast({
- title: res.message,
- icon: 'none',
- duration: 2000
- })
- });
- },
- edit(val) {
- uni.$u.route('/pages/release/editAddress', val);
- },
- del(val) {
- this.delId = val.id
- this.isShowAlert = true
- this.alertTitle = "确定将要删除该常用地址?"
- },
- selectAddress(type) {
- // 0临时地址 1 新增地址
- if (type == 0) {
- var that = this
- uni.chooseLocation({
- success: function(res) {
- // var locationObj = that.$helper.formatLocation(res);
- // console.log(locationObj)
- console.log(res);
- console.log('位置名称:' + res.name);
- console.log('详细地址:' + res.address);
- console.log('纬度:' + res.latitude);
- console.log('经度:' + res.longitude);
- let _address = that.$helper.formatLocation(res.address)
- console.log('----------------------------')
- console.log(_address, that.type)
- var data = {}
- data.latitude = res.latitude
- data.longitude = res.longitude
- data.detailedAddress = _address.Village ? _address.Village : res.name
- data.province = _address.Province
- data.city = _address.City
- data.area = _address.Country
- data.commonId = that.userInfo.id
-
- console.log("城市",_address.City)
- uni.request({
- url: 'https://restapi.amap.com/v3/config/district?key=d29a9d10160efaca0dd616bbec936d7f&subdistrict=1&keywords=' +
- _address.City,
- success: (res) => {
- for (let i = 0; i < res.data.districts[0].districts.length; i++) {
- if (res.data.districts[0].districts[i].name == _address.Country) {
- data.adCode = res.data.districts[0].districts[i].adcode
- console.log("行政区划代码" + data.adCode)
- // that.$forceUpdate()
- if (that.type == 0) {
- uni.setStorageSync('storage_faddress', data)
- } else {
- uni.setStorageSync('storage_saddress', data)
- }
- uni.navigateBack({
- delta: 1
- })
- break
- }
- }
- }
- });
- },
- fail(err) {
- console.log(err)
- },
- complete(res1) {
- console.log(res1)
- }
- });
- // uni.getLocation({
- // type: 'gcj02',
- // geocode: true,
- // isHighAccuracy: true,
- // success: function(res) {
- // console.log('当前位置的经度:' + res.longitude);
- // console.log('当前位置的纬度:' + res.latitude);
- // }
- // })
- } else {
- uni.$u.route('/pages/release/addAddress', {
- type: type,
- });
- }
- },
- }
- }
- </script>
- <style scoped lang="scss">
- .content1 {
- background: white;
- padding: 20rpx;
- }
- .content {
- height: 100vh;
- overflow: scroll;
- }
- .content2-wrap {
- margin-bottom: 200rpx;
- }
- .jt-icon {
- position: relative;
- top: 4rpx;
- width: 24rpx;
- margin: 0 10rpx;
- }
- .content2 {
- border-radius: 20rpx;
- background: white;
- margin: 20rpx;
- padding: 20rpx;
- .row {
- margin-top: 20rpx;
- }
- .row1 {
- font-weight: 700;
- color: #333333;
- .name {
- margin-right: 20rpx;
- }
- }
- .row2 {
- color: #7D7D7D;
- }
- .row3 {
- font-size: 24rpx;
- }
- }
- .bottom-btn {
- position: fixed;
- bottom: 0rpx;
- padding: 50rpx 0;
- width: 100%;
- background-color: #fff;
- display: flex;
- justify-content: space-around;
- .btn-left {
- text-align: center;
- width: 30%;
- font-size: 32rpx;
- font-weight: 500;
- color: #2772FB;
- background-color: #EEF4FF;
- padding: 20rpx 40rpx;
- border-radius: 40rpx;
- }
- .btn-right {
- text-align: center;
- width: 30%;
- font-size: 32rpx;
- font-weight: 500;
- color: white;
- background-color: #2772FB;
- padding: 20rpx 40rpx;
- border-radius: 50rpx;
- }
- }
- .icon-img {
- display: flex;
- align-items: center;
- color: #999999;
- }
- </style>
|