distributionArea.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <template>
  2. <view>
  3. <view class="pouponCount" :class="popup.show==true?'on':''">
  4. <view class='title'>配送区域及运费<text class='iconfont icon-guanbi' @tap='changeClose'></text></view>
  5. <view class="container">
  6. <view class="area_container">
  7. <scroll-view scroll-y="true">
  8. <view v-if="shippingAddressData.length">
  9. <view class="distribution_area" v-for="(item, index) in shippingAddressData" :key="index">
  10. <view class="distribution_area_title">
  11. <view>{{ item.title }}</view>
  12. <view class="distribution_area_title_del blackColor" v-if="item.label">
  13. <span>{{ item.label }}</span>
  14. </view>
  15. <view class="distribution_area_title_del" v-else @click="deleteAreaAndFreight(item, index)">
  16. <text class="iconfont icon-shanchu2"></text>
  17. <span>删除</span>
  18. </view>
  19. </view>
  20. <view class="distribution_area_item" @click="selectArea(item, index)" v-if="index">
  21. <view class="distribution_area_item_label">配送区域</view>
  22. <view class="distribution_area_item_value right">
  23. <text class="line1" v-if="item.city_name">
  24. <text class="select_name" v-if="Array.isArray(item.city_name)">{{item.city_name.length ? item.city_name.map(val => val.name).join(',') : '选择区域'}}</text>
  25. <text class="select_name" v-else>{{item.city_name}}</text>
  26. </text>
  27. <text v-else>选择区域</text>
  28. <text class="iconfont">&#xe617;</text>
  29. </view>
  30. </view>
  31. <view class="distribution_area_item">
  32. <view class="distribution_area_item_label">首件</view>
  33. <view class="distribution_area_item_value">
  34. <input type="number" v-model="item.first" @input="item.first = Number(item.first)" placeholder="请填写首件数量" placeholder-class="inputHolder" />
  35. </view>
  36. </view>
  37. <view class="distribution_area_item">
  38. <view class="distribution_area_item_label">运费</view>
  39. <view class="distribution_area_item_value">
  40. <input type="number" v-model="item.first_price" @input="item.first_price = Number(item.first_price)" placeholder="请填写运费金额" placeholder-class="inputHolder" />
  41. </view>
  42. </view>
  43. <view class="distribution_area_item">
  44. <view class="distribution_area_item_label">续件</view>
  45. <view class="distribution_area_item_value">
  46. <input type="number" :min="0.1" v-model="item.continue" @input="item.continue = Number(item.continue)" placeholder="请填写续件数量" placeholder-class="inputHolder" />
  47. </view>
  48. </view>
  49. <view class="distribution_area_item">
  50. <view class="distribution_area_item_label">续费</view>
  51. <view class="distribution_area_item_value">
  52. <input type="number" v-model="item.continue_price" @input="item.continue_price = Number(item.continue_price)" placeholder="请填写续费金额" placeholder-class="inputHolder" />
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="add" @click="addAreaAndFreight">
  58. <span class="iconfont">&#xe70e;</span>
  59. <span>添加配送区域及运费</span>
  60. </view>
  61. </scroll-view>
  62. </view>
  63. <view class="handle"><view class="handle_button" @click="save">保存</view></view>
  64. <uni-popup ref="area_popup" type="bottom"><areas @handleGetSelectArea="handleGetSelectArea" :allReadySelect="allReadySelect" @close="close"></areas></uni-popup>
  65. </view>
  66. </view>
  67. <view class='mask' catchtouchmove="true" :hidden='popup.show==false' @tap="changeClose"></view>
  68. </view>
  69. </template>
  70. <script>
  71. // +----------------------------------------------------------------------
  72. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  73. // +----------------------------------------------------------------------
  74. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  75. // +----------------------------------------------------------------------
  76. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  77. // +----------------------------------------------------------------------
  78. // | Author: CRMEB Team <admin@crmeb.com>
  79. // +----------------------------------------------------------------------
  80. // 配送区域
  81. import areas from '../components/areas.vue';
  82. export default {
  83. components: {
  84. areas
  85. },
  86. props: {
  87. freightData: {
  88. type: Array,
  89. default: () => {
  90. []
  91. }
  92. },
  93. popup: {
  94. type: Object,
  95. default: function() {
  96. return {
  97. show: false
  98. };
  99. }
  100. }
  101. },
  102. data() {
  103. return {
  104. // shippingAddressData: [
  105. // {
  106. // title: '配送区域',
  107. // label: '默认全国',
  108. // city_id: [],
  109. // first: '', //首件条件
  110. // first_price: '', //首件运费
  111. // continue: '', // 续件数量
  112. // continue_price: '' // 续件金额
  113. // }
  114. // ],
  115. shippingAddressData: this.freightData,
  116. selectIndex: '',
  117. allReadySelect: []
  118. };
  119. },
  120. watch: {
  121. },
  122. mounted() {
  123. },
  124. methods: {
  125. //初始化数据
  126. initListData(){
  127. console.log(this.freightData)
  128. let arr = [...this.freightData]
  129. if(arr.length == 0){
  130. arr = [
  131. {
  132. title: '配送区域',
  133. label: '默认全国',
  134. city_id: [],
  135. first: '', //首件条件
  136. first_price: '', //首件运费
  137. continue: '', // 续件数量
  138. continue_price: '' // 续件金额
  139. }
  140. ]
  141. }else{
  142. arr.forEach((value,i)=>{
  143. value['title'] = '配送区域'
  144. if(i == 0)value['label'] = '默认全国'
  145. })
  146. }
  147. this.shippingAddressData = arr
  148. },
  149. // 点击 添加配送区域及运费
  150. addAreaAndFreight() {
  151. this.shippingAddressData.push({
  152. title: '配送区域',
  153. city_id: [],
  154. city_name: '',
  155. selectData: [],
  156. first: '', //首件条件
  157. first_price: '', //首件运费
  158. continue: '', // 续件数量
  159. continue_price: '' // 续件金额
  160. });
  161. },
  162. // 删除配送区域和运费
  163. deleteAreaAndFreight(item, index) {
  164. this.shippingAddressData.splice(index, 1);
  165. },
  166. selectArea(item, index) {
  167. this.selectIndex = index;
  168. if(!item.selectData){
  169. item.name = this.shippingAddressData[this.selectIndex]['city_name'].map(val => val.name).join('/')
  170. this.allReadySelect = [item];
  171. }else{
  172. this.allReadySelect = item.selectData;
  173. }
  174. this.$refs.area_popup.open();
  175. },
  176. // 获取所限地址
  177. handleGetSelectArea(item) {
  178. this.shippingAddressData[this.selectIndex].selectData = item;
  179. this.shippingAddressData[this.selectIndex].city_name = item.map(val => val.name).join(',');
  180. this.shippingAddressData[this.selectIndex].city_id = item.map(val => val.id);
  181. this.$refs.area_popup.close();
  182. },
  183. // 关闭选择弹窗
  184. close() {
  185. this.$refs.area_popup.close();
  186. },
  187. changeClose(){
  188. this.$emit('changeClose')
  189. },
  190. // 点击保存
  191. save() {
  192. let that = this;
  193. let value = that.shippingAddressData
  194. for(var i=0; i<value.length; i++){
  195. if (value[i].first === "") return that.$util.Tips({
  196. title: '请填写首件数量'
  197. });
  198. if (value[i].first < 1) return that.$util.Tips({
  199. title: '首件数量不能小于1'
  200. });
  201. if (value[i].first_price === "") return that.$util.Tips({
  202. title: '请填写首件金额'
  203. });
  204. if (value[i].continue === "") return that.$util.Tips({
  205. title: '请填写续件数量'
  206. });
  207. if (value[i].continue_price === "") return that.$util.Tips({
  208. title: '请填写续费金额'
  209. });
  210. if(i != 0 && (value[i].city_id).length == 0) return that.$util.Tips({
  211. title: '请填写配送区域'
  212. });
  213. }
  214. that.$emit('getData',that.shippingAddressData);
  215. }
  216. }
  217. };
  218. </script>
  219. <style lang="scss" scoped>
  220. .pouponCount {
  221. position: fixed;
  222. bottom: 0;
  223. width: 100%;
  224. left: 0;
  225. background-color: #f5f5f5;
  226. z-index: 77;
  227. border-radius: 16rpx 16rpx 0 0;
  228. padding-bottom: 120rpx;
  229. transform: translate3d(0, 100%, 0);
  230. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  231. }
  232. .pouponCount.on {
  233. transform: translate3d(0, 0, 0);
  234. }
  235. .pouponCount .title {
  236. font-size: 32rpx;
  237. font-weight: bold;
  238. text-align: center;
  239. padding: 36rpx 0;
  240. position: relative;
  241. }
  242. .pouponCount .icon-guanbi {
  243. position: absolute;
  244. right: 20rpx;
  245. color: #8a8a8a;
  246. font-size: 30rpx;
  247. top: 40rpx;
  248. line-height: 30rpx;
  249. top: 20rpx;
  250. font-weight: normal;
  251. background-color: transparent;
  252. }
  253. scroll-view{
  254. height: 70vh;
  255. }
  256. .area_container{
  257. padding: 20rpx;
  258. background-color: #f7f7f7;
  259. }
  260. .add {
  261. margin: auto;
  262. width: 710rpx;
  263. height: 106rpx;
  264. background: #ffffff;
  265. border-radius: 10px;
  266. display: flex;
  267. align-items: center;
  268. justify-content: center;
  269. color: #e93323;
  270. font-size: 30rpx;
  271. .iconfont {
  272. display: inline-block;
  273. margin-right: 10rpx;
  274. }
  275. }
  276. .distribution_area {
  277. margin: 0 auto 30rpx;
  278. width: 710rpx;
  279. padding: 36rpx 30rpx 31rpx 30rpx;
  280. box-sizing: border-box;
  281. background: #fff;
  282. border-radius: 10px;
  283. &:first-child{
  284. margin-top: 0;
  285. }
  286. &_title {
  287. display: flex;
  288. justify-content: space-between;
  289. font-size: 30rpx;
  290. margin-bottom: 36rpx;
  291. > view:nth-child(2) {
  292. color: #666666;
  293. }
  294. &_del {
  295. color: #e93323 !important;
  296. font-size: 28rpx !important;
  297. display: flex;
  298. align-items: center;
  299. .iconfont {
  300. font-size: 30rpx;
  301. margin-right: 15rpx;
  302. }
  303. }
  304. .blackColor {
  305. color: #666666 !important;
  306. }
  307. }
  308. &_item {
  309. height: 84rpx;
  310. background: #f5f5f5;
  311. display: flex;
  312. justify-content: space-between;
  313. align-items: center;
  314. padding: 0 30rpx;
  315. border-radius: 10rpx;
  316. margin-bottom: 20rpx;
  317. &_value {
  318. text-align: right;
  319. display: flex;
  320. align-items: center;
  321. }
  322. .select_name{
  323. // font-weight: bold;
  324. }
  325. .line1{
  326. max-width: 430rpx;
  327. }
  328. .right {
  329. color: #bbbbbb;
  330. > span:nth-child(1) {
  331. display: inline-block;
  332. margin-right: 14rpx;
  333. max-width: 350rpx;
  334. overflow: hidden;
  335. white-space: nowrap;
  336. text-overflow: ellipsis;
  337. }
  338. }
  339. }
  340. }
  341. .handle {
  342. width: 100%;
  343. height: 126rpx;
  344. display: flex;
  345. align-items: center;
  346. justify-content: center;
  347. position: fixed;
  348. left: 0;
  349. bottom: 0;
  350. }
  351. .handle_button {
  352. background: #e93323;
  353. border-radius: 43rpx;
  354. display: flex;
  355. align-items: center;
  356. justify-content: center;
  357. font-size: 32rpx;
  358. color: #ffffff;
  359. width: 690rpx;
  360. padding: 21rpx 0;
  361. box-sizing: border-box;
  362. }
  363. .inputHolder {
  364. color: #bbbbbb;
  365. font-size: 30rpx;
  366. }
  367. </style>