parcelArea.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  58. // +----------------------------------------------------------------------
  59. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  60. // +----------------------------------------------------------------------
  61. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  62. // +----------------------------------------------------------------------
  63. // | Author: CRMEB Team <admin@crmeb.com>
  64. // +----------------------------------------------------------------------
  65. // 配送区域
  66. import areas from '../components/areas.vue';
  67. import { navigateTo, serialize, setStorage, navigateBack } from '../../../libs/uniApi.js';
  68. export default {
  69. components: {
  70. areas
  71. },
  72. props: {
  73. parcelData: {
  74. type: Array,
  75. default: () => {
  76. []
  77. }
  78. },
  79. popup: {
  80. type: Object,
  81. default: function() {
  82. return {
  83. showParael: false
  84. };
  85. }
  86. }
  87. },
  88. data() {
  89. return {
  90. parcelArea: this.parcelData,
  91. allReadySelect: [],
  92. selectIndex: ''
  93. }
  94. },
  95. mounted(){
  96. },
  97. methods: {
  98. //初始化数据
  99. initParcelData(){
  100. let arr = [...this.parcelData]
  101. if(arr.length == 0){
  102. arr = [
  103. {
  104. city_id: [],
  105. number: '',
  106. price: '',
  107. city_name: []
  108. }
  109. ]
  110. }
  111. this.parcelArea = arr
  112. },
  113. deleteParcelArea(item, index) {
  114. this.parcelArea.splice(index, 1);
  115. },
  116. close() {
  117. this.$refs.area_popup.close();
  118. },
  119. changeClose(){
  120. this.$emit('changeClose');
  121. },
  122. selectArea(item, index) {
  123. this.allReadySelect = item.city_name;
  124. this.selectIndex = index;
  125. this.$refs.area_popup.open();
  126. },
  127. // 添加指定包邮区域
  128. addParcelAreaItem() {
  129. this.parcelArea.push({
  130. city_id: [],
  131. number: '',
  132. price: '',
  133. city_name: []
  134. })
  135. },
  136. // 确定选择
  137. handleGetSelectArea(item) {
  138. this.allReadySelect = item;
  139. this.parcelArea[this.selectIndex].city_name = item;
  140. this.parcelArea[this.selectIndex].city_id = item.map(val => val.id);
  141. this.$refs.area_popup.close();
  142. },
  143. // 保存
  144. save() {
  145. let that = this;
  146. let value = that.parcelArea;
  147. for(var i=0; i<value.length; i++){
  148. if((value[i].city_id).length == 0) return that.$util.Tips({
  149. title: '请选择地区'
  150. });
  151. if (value[i].number === "") return that.$util.Tips({
  152. title: '请输入最低购买数量'
  153. });
  154. if (value[i].price === "") return that.$util.Tips({
  155. title: '请输入最低购买金额'
  156. });
  157. }
  158. that.$emit('getData',that.parcelArea);
  159. // setStorage('parcelArea', this.parcelArea);
  160. // navigateBack(1);
  161. }
  162. }
  163. }
  164. </script>
  165. <style lang="scss" scoped>
  166. .pouponCount {
  167. position: fixed;
  168. bottom: 0;
  169. width: 100%;
  170. left: 0;
  171. background-color: #f5f5f5;
  172. z-index: 77;
  173. border-radius: 16rpx 16rpx 0 0;
  174. padding-bottom: 20rpx;
  175. transform: translate3d(0, 100%, 0);
  176. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  177. }
  178. .pouponCount.on {
  179. transform: translate3d(0, 0, 0);
  180. }
  181. .pouponCount .title {
  182. font-size: 32rpx;
  183. font-weight: bold;
  184. text-align: center;
  185. padding: 36rpx 0;
  186. position: relative;
  187. }
  188. .pouponCount .icon-guanbi {
  189. position: absolute;
  190. right: 20rpx;
  191. color: #8a8a8a;
  192. font-size: 30rpx;
  193. line-height: 30rpx;
  194. top: 40rpx;
  195. background-color: transparent;
  196. font-weight: normal;
  197. }
  198. scroll-view{
  199. height: 650rpx;
  200. }
  201. .container {
  202. padding-top: 20rpx;
  203. padding-bottom: 197rpx;
  204. }
  205. .add {
  206. margin: auto;
  207. width: 710rpx;
  208. height: 106rpx;
  209. background: #ffffff;
  210. border-radius: 10px;
  211. display: flex;
  212. align-items: center;
  213. justify-content: center;
  214. color: #e93323;
  215. font-size: 30rpx;
  216. .iconfont {
  217. display: inline-block;
  218. margin-right: 10rpx;
  219. }
  220. }
  221. .distribution_area {
  222. margin: 0 auto 30rpx;
  223. width: 710rpx;
  224. padding: 36rpx 30rpx 31rpx 30rpx;
  225. min-height: 355rpx;
  226. box-sizing: border-box;
  227. background: #fff;
  228. border-radius: 10px;
  229. &_title {
  230. display: flex;
  231. justify-content: space-between;
  232. font-size: 30rpx;
  233. margin-bottom: 36rpx;
  234. > view:nth-child(2) {
  235. color: #666666;
  236. }
  237. &_del {
  238. color: #e93323 !important;
  239. font-size: 28rpx !important;
  240. display: flex;
  241. align-items: center;
  242. .iconfont {
  243. font-size: 30rpx;
  244. margin-right: 15rpx;
  245. }
  246. }
  247. }
  248. &_item {
  249. height: 84rpx;
  250. background: #f5f5f5;
  251. display: flex;
  252. justify-content: space-between;
  253. align-items: center;
  254. padding: 0 30rpx;
  255. border-radius: 10rpx;
  256. margin-bottom: 20rpx;
  257. &_value {
  258. text-align: right;
  259. display: flex;
  260. align-items: center;
  261. }
  262. .line1{
  263. max-width: 430rpx;
  264. }
  265. .select_name{
  266. // font-weight: bold;
  267. }
  268. .right {
  269. color: #bbbbbb;
  270. > span:nth-child(1) {
  271. max-width: 300rpx;
  272. overflow: hidden;
  273. white-space: nowrap;
  274. text-overflow: ellipsis;
  275. display: inline-block;
  276. margin-right: 14rpx;
  277. }
  278. }
  279. }
  280. }
  281. .handle {
  282. width: 100%;
  283. height: 126rpx;
  284. background: #ffffff;
  285. display: flex;
  286. align-items: center;
  287. justify-content: center;
  288. position: fixed;
  289. left: 0;
  290. bottom: 0;
  291. &_button {
  292. width: 690rpx;
  293. height: 86rpx;
  294. background: #e93323;
  295. border-radius: 43px;
  296. display: flex;
  297. align-items: center;
  298. justify-content: center;
  299. font-size: 32rpx;
  300. color: #ffffff;
  301. }
  302. }
  303. .inputHolder {
  304. color: #bbbbbb;
  305. font-size: 30rpx;
  306. }
  307. </style>