123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- <template>
- <view>
- <view class="pouponCount" :class="popup.showParael==true?'on':''">
- <view class='title'>指定包邮区域<text class='iconfont icon-guanbi' @tap='changeClose'></text></view>
- <view class="container">
- <scroll-view scroll-y="true">
- <view class="distribution_area" v-for="(item, index) in parcelArea" :key="index">
- <view class="distribution_area_title">
- <view>新增包邮区域</view>
- <view class="distribution_area_title_del" @click="deleteParcelArea(item, index)" v-if="index">
- <text class="iconfont icon-shanchu2"></text>
- <text>删除</text>
- </view>
- </view>
- <view class="distribution_area_item" @click="selectArea(item, index)">
- <view class="distribution_area_item_label">选择地区</view>
- <view class="distribution_area_item_value right">
- <text class="line1" v-if="item.city_name">
- <text class="select_name" v-if="Array.isArray(item.city_name)">{{item.city_name.length ? item.city_name.map(val => val.name).join(',') : '选择区域'}}</text>
- <text class="select_name" v-else>{{item.city_name}}</text>
- </text>
- <text v-else>选择区域</text>
- <text class="iconfont"></text>
- </view>
- </view>
- <view class="distribution_area_item">
- <view class="distribution_area_item_label">最低限购数</view>
- <view class="distribution_area_item_value">
- <input type="number" v-model="item.number" placeholder="请填写运费金额" @input="item.number = Number(item.number)" placeholder-class="inputHolder" />
- </view>
- </view>
- <view class="distribution_area_item">
- <view class="distribution_area_item_label">最低购买金额</view>
- <view class="distribution_area_item_value">
- <input type="number" v-model="item.price" @input="item.price = Number(item.price)" placeholder="请填写续件金额" placeholder-class="inputHolder" />
- </view>
- </view>
- </view>
- <view class="add" @click="addParcelAreaItem">
- <text class="iconfont"></text>
- <text>添加指定包邮区域</text>
- </view>
- </scroll-view>
- <uni-popup ref="area_popup" type="bottom">
- <areas @handleGetSelectArea="handleGetSelectArea" :allReadySelect="allReadySelect" @close="close"></areas>
- </uni-popup>
- <view class="handle">
- <view class="handle_button" @click="save">保存</view>
- </view>
- </view>
- </view>
- <view class='mask' catchtouchmove="true" :hidden='popup.showParael==false' @tap="changeClose"></view>
- </view>
-
- </template>
- <script>
- import areas from '../components/areas.vue';
- import { navigateTo, serialize, setStorage, navigateBack } from '../../../libs/uniApi.js';
- export default {
- components: {
- areas
- },
- props: {
- parcelData: {
- type: Array,
- default: () => {
- []
- }
- },
- popup: {
- type: Object,
- default: function() {
- return {
- showParael: false
- };
- }
- }
- },
- data() {
- return {
- parcelArea: this.parcelData,
- allReadySelect: [],
- selectIndex: ''
- }
- },
- mounted(){
-
- },
- methods: {
-
- initParcelData(){
- let arr = [...this.parcelData]
- if(arr.length == 0){
- arr = [
- {
- city_id: [],
- number: '',
- price: '',
- city_name: []
- }
- ]
- }
- this.parcelArea = arr
- },
- deleteParcelArea(item, index) {
- this.parcelArea.splice(index, 1);
- },
- close() {
- this.$refs.area_popup.close();
- },
- changeClose(){
- this.$emit('changeClose');
- },
- selectArea(item, index) {
- this.allReadySelect = item.city_name;
- this.selectIndex = index;
- this.$refs.area_popup.open();
- },
-
- addParcelAreaItem() {
- this.parcelArea.push({
- city_id: [],
- number: '',
- price: '',
- city_name: []
- })
- },
-
- handleGetSelectArea(item) {
- this.allReadySelect = item;
- this.parcelArea[this.selectIndex].city_name = item;
- this.parcelArea[this.selectIndex].city_id = item.map(val => val.id);
- this.$refs.area_popup.close();
- },
-
- save() {
- let that = this;
- let value = that.parcelArea;
- for(var i=0; i<value.length; i++){
- if((value[i].city_id).length == 0) return that.$util.Tips({
- title: '请选择地区'
- });
- if (value[i].number === "") return that.$util.Tips({
- title: '请输入最低购买数量'
- });
- if (value[i].price === "") return that.$util.Tips({
- title: '请输入最低购买金额'
- });
- }
- that.$emit('getData',that.parcelArea);
-
-
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .pouponCount {
- position: fixed;
- bottom: 0;
- width: 100%;
- left: 0;
- background-color: #f5f5f5;
- z-index: 77;
- border-radius: 16rpx 16rpx 0 0;
- padding-bottom: 20rpx;
- transform: translate3d(0, 100%, 0);
- transition: all .3s cubic-bezier(.25, .5, .5, .9);
- }
- .pouponCount.on {
- transform: translate3d(0, 0, 0);
- }
- .pouponCount .title {
- font-size: 32rpx;
- font-weight: bold;
- text-align: center;
- padding: 36rpx 0;
- position: relative;
- }
- .pouponCount .icon-guanbi {
- position: absolute;
- right: 20rpx;
- color: #8a8a8a;
- font-size: 30rpx;
- line-height: 30rpx;
- top: 40rpx;
- background-color: transparent;
- font-weight: normal;
- }
- scroll-view{
- height: 650rpx;
- }
- .container {
- padding-top: 20rpx;
- padding-bottom: 197rpx;
- }
- .add {
- margin: auto;
- width: 710rpx;
- height: 106rpx;
- background: #ffffff;
- border-radius: 10px;
- display: flex;
- align-items: center;
- justify-content: center;
- color: #e93323;
- font-size: 30rpx;
- .iconfont {
- display: inline-block;
- margin-right: 10rpx;
- }
- }
- .distribution_area {
- margin: 0 auto 30rpx;
- width: 710rpx;
- padding: 36rpx 30rpx 31rpx 30rpx;
- min-height: 355rpx;
- box-sizing: border-box;
- background: #fff;
- border-radius: 10px;
- &_title {
- display: flex;
- justify-content: space-between;
- font-size: 30rpx;
- margin-bottom: 36rpx;
- > view:nth-child(2) {
- color: #666666;
- }
- &_del {
- color: #e93323 !important;
- font-size: 28rpx !important;
- display: flex;
- align-items: center;
- .iconfont {
- font-size: 30rpx;
- margin-right: 15rpx;
- }
- }
- }
- &_item {
- height: 84rpx;
- background: #f5f5f5;
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 0 30rpx;
- border-radius: 10rpx;
- margin-bottom: 20rpx;
- &_value {
- text-align: right;
- display: flex;
- align-items: center;
- }
- .line1{
- max-width: 430rpx;
- }
- .select_name{
- // font-weight: bold;
- }
- .right {
- color: #bbbbbb;
- > span:nth-child(1) {
- max-width: 300rpx;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- display: inline-block;
- margin-right: 14rpx;
- }
- }
- }
- }
- .handle {
- width: 100%;
- height: 126rpx;
- background: #ffffff;
- display: flex;
- align-items: center;
- justify-content: center;
- position: fixed;
- left: 0;
- bottom: 0;
- &_button {
- width: 690rpx;
- height: 86rpx;
- background: #e93323;
- border-radius: 43px;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 32rpx;
- color: #ffffff;
- }
- }
- .inputHolder {
- color: #bbbbbb;
- font-size: 30rpx;
- }
- </style>
|