parcelArea.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <view>
  3. <view class="pouponCount" :class="popup.showParael==true?'on':''">
  4. <view class='title'>指定包邮区域<text class='iconfont icon-guanbi' @tap='changeClose'></text></view>
  5. <view class="container">
  6. <scroll-view scroll-y="true">
  7. <view class="distribution_area" v-for="(item, index) in parcelArea" :key="index">
  8. <view class="distribution_area_title">
  9. <view>新增包邮区域</view>
  10. <view class="distribution_area_title_del" @click="deleteParcelArea(item, index)" v-if="index">
  11. <text class="iconfont icon-shanchu2"></text>
  12. <text>删除</text>
  13. </view>
  14. </view>
  15. <view class="distribution_area_item" @click="selectArea(item, index)">
  16. <view class="distribution_area_item_label">选择地区</view>
  17. <view class="distribution_area_item_value right">
  18. <text class="line1" v-if="item.city_name">
  19. <text class="select_name" v-if="Array.isArray(item.city_name)">{{item.city_name.length ? item.city_name.map(val => val.name).join(',') : '选择区域'}}</text>
  20. <text class="select_name" v-else>{{item.city_name}}</text>
  21. </text>
  22. <text v-else>选择区域</text>
  23. <text class="iconfont">&#xe617;</text>
  24. </view>
  25. </view>
  26. <view class="distribution_area_item">
  27. <view class="distribution_area_item_label">最低限购数</view>
  28. <view class="distribution_area_item_value">
  29. <input type="number" v-model="item.number" placeholder="请填写运费金额" @input="item.number = Number(item.number)" placeholder-class="inputHolder" />
  30. </view>
  31. </view>
  32. <view class="distribution_area_item">
  33. <view class="distribution_area_item_label">最低购买金额</view>
  34. <view class="distribution_area_item_value">
  35. <input type="number" v-model="item.price" @input="item.price = Number(item.price)" placeholder="请填写续件金额" placeholder-class="inputHolder" />
  36. </view>
  37. </view>
  38. </view>
  39. <view class="add" @click="addParcelAreaItem">
  40. <text class="iconfont">&#xe70e;</text>
  41. <text>添加指定包邮区域</text>
  42. </view>
  43. </scroll-view>
  44. <uni-popup ref="area_popup" type="bottom">
  45. <areas @handleGetSelectArea="handleGetSelectArea" :allReadySelect="allReadySelect" @close="close"></areas>
  46. </uni-popup>
  47. <view class="handle">
  48. <view class="handle_button" @click="save">保存</view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class='mask' catchtouchmove="true" :hidden='popup.showParael==false' @tap="changeClose"></view>
  53. </view>
  54. </template>
  55. <script>
  56. // 配送区域
  57. import areas from '../components/areas.vue';
  58. import { navigateTo, serialize, setStorage, navigateBack } from '../../../libs/uniApi.js';
  59. export default {
  60. components: {
  61. areas
  62. },
  63. props: {
  64. parcelData: {
  65. type: Array,
  66. default: () => {
  67. []
  68. }
  69. },
  70. popup: {
  71. type: Object,
  72. default: function() {
  73. return {
  74. showParael: false
  75. };
  76. }
  77. }
  78. },
  79. data() {
  80. return {
  81. parcelArea: this.parcelData,
  82. allReadySelect: [],
  83. selectIndex: ''
  84. }
  85. },
  86. mounted(){
  87. },
  88. methods: {
  89. //初始化数据
  90. initParcelData(){
  91. let arr = [...this.parcelData]
  92. if(arr.length == 0){
  93. arr = [
  94. {
  95. city_id: [],
  96. number: '',
  97. price: '',
  98. city_name: []
  99. }
  100. ]
  101. }
  102. this.parcelArea = arr
  103. },
  104. deleteParcelArea(item, index) {
  105. this.parcelArea.splice(index, 1);
  106. },
  107. close() {
  108. this.$refs.area_popup.close();
  109. },
  110. changeClose(){
  111. this.$emit('changeClose');
  112. },
  113. selectArea(item, index) {
  114. this.allReadySelect = item.city_name;
  115. this.selectIndex = index;
  116. this.$refs.area_popup.open();
  117. },
  118. // 添加指定包邮区域
  119. addParcelAreaItem() {
  120. this.parcelArea.push({
  121. city_id: [],
  122. number: '',
  123. price: '',
  124. city_name: []
  125. })
  126. },
  127. // 确定选择
  128. handleGetSelectArea(item) {
  129. this.allReadySelect = item;
  130. this.parcelArea[this.selectIndex].city_name = item;
  131. this.parcelArea[this.selectIndex].city_id = item.map(val => val.id);
  132. this.$refs.area_popup.close();
  133. },
  134. // 保存
  135. save() {
  136. let that = this;
  137. let value = that.parcelArea;
  138. for(var i=0; i<value.length; i++){
  139. if((value[i].city_id).length == 0) return that.$util.Tips({
  140. title: '请选择地区'
  141. });
  142. if (value[i].number === "") return that.$util.Tips({
  143. title: '请输入最低购买数量'
  144. });
  145. if (value[i].price === "") return that.$util.Tips({
  146. title: '请输入最低购买金额'
  147. });
  148. }
  149. that.$emit('getData',that.parcelArea);
  150. // setStorage('parcelArea', this.parcelArea);
  151. // navigateBack(1);
  152. }
  153. }
  154. }
  155. </script>
  156. <style lang="scss" scoped>
  157. .pouponCount {
  158. position: fixed;
  159. bottom: 0;
  160. width: 100%;
  161. left: 0;
  162. background-color: #f5f5f5;
  163. z-index: 77;
  164. border-radius: 16rpx 16rpx 0 0;
  165. padding-bottom: 20rpx;
  166. transform: translate3d(0, 100%, 0);
  167. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  168. }
  169. .pouponCount.on {
  170. transform: translate3d(0, 0, 0);
  171. }
  172. .pouponCount .title {
  173. font-size: 32rpx;
  174. font-weight: bold;
  175. text-align: center;
  176. padding: 36rpx 0;
  177. position: relative;
  178. }
  179. .pouponCount .icon-guanbi {
  180. position: absolute;
  181. right: 20rpx;
  182. color: #8a8a8a;
  183. font-size: 30rpx;
  184. line-height: 30rpx;
  185. top: 40rpx;
  186. background-color: transparent;
  187. font-weight: normal;
  188. }
  189. scroll-view{
  190. height: 650rpx;
  191. }
  192. .container {
  193. padding-top: 20rpx;
  194. padding-bottom: 197rpx;
  195. }
  196. .add {
  197. margin: auto;
  198. width: 710rpx;
  199. height: 106rpx;
  200. background: #ffffff;
  201. border-radius: 10px;
  202. display: flex;
  203. align-items: center;
  204. justify-content: center;
  205. color: #e93323;
  206. font-size: 30rpx;
  207. .iconfont {
  208. display: inline-block;
  209. margin-right: 10rpx;
  210. }
  211. }
  212. .distribution_area {
  213. margin: 0 auto 30rpx;
  214. width: 710rpx;
  215. padding: 36rpx 30rpx 31rpx 30rpx;
  216. min-height: 355rpx;
  217. box-sizing: border-box;
  218. background: #fff;
  219. border-radius: 10px;
  220. &_title {
  221. display: flex;
  222. justify-content: space-between;
  223. font-size: 30rpx;
  224. margin-bottom: 36rpx;
  225. > view:nth-child(2) {
  226. color: #666666;
  227. }
  228. &_del {
  229. color: #e93323 !important;
  230. font-size: 28rpx !important;
  231. display: flex;
  232. align-items: center;
  233. .iconfont {
  234. font-size: 30rpx;
  235. margin-right: 15rpx;
  236. }
  237. }
  238. }
  239. &_item {
  240. height: 84rpx;
  241. background: #f5f5f5;
  242. display: flex;
  243. justify-content: space-between;
  244. align-items: center;
  245. padding: 0 30rpx;
  246. border-radius: 10rpx;
  247. margin-bottom: 20rpx;
  248. &_value {
  249. text-align: right;
  250. display: flex;
  251. align-items: center;
  252. }
  253. .line1{
  254. max-width: 430rpx;
  255. }
  256. .select_name{
  257. // font-weight: bold;
  258. }
  259. .right {
  260. color: #bbbbbb;
  261. > span:nth-child(1) {
  262. max-width: 300rpx;
  263. overflow: hidden;
  264. white-space: nowrap;
  265. text-overflow: ellipsis;
  266. display: inline-block;
  267. margin-right: 14rpx;
  268. }
  269. }
  270. }
  271. }
  272. .handle {
  273. width: 100%;
  274. height: 126rpx;
  275. background: #ffffff;
  276. display: flex;
  277. align-items: center;
  278. justify-content: center;
  279. position: fixed;
  280. left: 0;
  281. bottom: 0;
  282. &_button {
  283. width: 690rpx;
  284. height: 86rpx;
  285. background: #e93323;
  286. border-radius: 43px;
  287. display: flex;
  288. align-items: center;
  289. justify-content: center;
  290. font-size: 32rpx;
  291. color: #ffffff;
  292. }
  293. }
  294. .inputHolder {
  295. color: #bbbbbb;
  296. font-size: 30rpx;
  297. }
  298. </style>