selectCity.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901
  1. <template>
  2. <view>
  3. <u-navbar :title="title" @leftClick='back' :placeholder='true'>
  4. </u-navbar>
  5. <view class="row1">
  6. <view class="start-place" :class="type==0?'active1':''" @click="changeCity(0)">选择发货地</view>
  7. <view class="end-place" :class="type==1?'active1':''" @click="changeCity(1)">选择收货地</view>
  8. </view>
  9. <view class="container">
  10. <view class="row2">
  11. <view class="content1" v-if="type==0">
  12. <view class="history-city-title">历史发货地</view>
  13. <view class="city-list">
  14. <view class="city" v-for="(item,index) in historyFcityList" :key='index' @click="historyClick(0,item)">
  15. {{item.selected}}
  16. </view>
  17. </view>
  18. </view>
  19. <view class="content2" v-if="type==1">
  20. <view class="history-city-title">历史收货地</view>
  21. <view class="city-list">
  22. <view class="city" v-for="(item,index) in historyScityList" :key='index' @click="historyClick(1,item)">
  23. {{item.selected}}
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="page">
  30. <view class="title flex flex-space-between">
  31. <view class="flex nav-bag-left">
  32. <!-- 省 -->
  33. <view class="flex" :class="(type==0?fstatus:sstatus)==0?'select-active':''" @click="titleClick(0)">
  34. <view class="tt point">{{type==0?fchooseprovince:schooseprovince}}</view>
  35. <view v-if="type==0?fchooseprovince:schooseprovince" style="margin: 0 10rpx;">></view>
  36. </view>
  37. <!-- 市 -->
  38. <view class="flex"
  39. v-if="(type==0?fchooseprovince:schooseprovince)!='选择'&&(type==0?fchooseprovince:schooseprovince)!='全国'"
  40. :class="(type==0?fstatus:sstatus)==1?'select-active':''" @click="titleClick(1)">
  41. <view class="tt point nav-point">{{type==0?fchoosecity:schoosecity}}</view>
  42. <view v-if="type==0?fchoosecity:schoosecity" style="margin: 0 10rpx;">></view>
  43. </view>
  44. <!-- 区 -->
  45. <view class="tt area"
  46. v-if="(type==0?fchooseprovince:schooseprovince)!='选择'&&(type==0?fchoosecity:schoosecity)!='请选择市'&&(type==0?fchoosecity:schoosecity)!='全部'"
  47. :class="(type==0?fstatus:sstatus)==2?'select-active':''" @click="titleClick(2)">
  48. {{type==0?fchoosearea:schoosearea}}
  49. </view>
  50. </view>
  51. <view class="back-level" v-if="(type==0?fstatus:sstatus)!=0" @click="backLevel">返回上一级</view>
  52. </view>
  53. <view class="link">
  54. <!-- 省 -->
  55. <view class="container" v-if="(type==0?fstatus:sstatus)==0">
  56. <view class="content-item" :class="index ==(type==0?isfprovince:issprovince) ?'active':''"
  57. @click="selectProvince(item, index,(type==0?fstatus:sstatus))"
  58. v-for="(item,index) in (type==0?fprovincelist:sprovincelist)" :key="index">
  59. {{item.label}}
  60. </view>
  61. </view>
  62. <!-- 市 -->
  63. <view class="container" v-if="(type==0?fstatus:sstatus)==1">
  64. <view class="content-item" :class="index == (type==0?isfcity:isscity)?'active':''"
  65. @click="selectCity(item, index,type==0?fstatus:sstatus)"
  66. v-for="(item,index) in (type==0?fcitylist:scitylist)" :key="index">
  67. {{item.label}}
  68. </view>
  69. </view>
  70. <!-- index ==(type==0?isfarea:issarea) -->
  71. <!-- 区 -->
  72. <view class="container" v-if="(type==0?fstatus:sstatus)==2">
  73. <view class="content-item" :class="item.checked?'active':''"
  74. @click="selectaArea(item, index,(type==0?fstatus:sstatus))"
  75. v-for="(item,index) in (type==0?farealist:sarealist)" :key="index">
  76. {{item.label}}
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. <u-button class="btn" @click="confirmBtn">确定</u-button>
  82. <u-toast ref="uToast"></u-toast>
  83. </view>
  84. </template>
  85. <script>
  86. import {
  87. address
  88. } from '@/components/data/data.js'
  89. export default {
  90. data() {
  91. return {
  92. fstatus: 0,
  93. sstatus: 0,
  94. isfprovince: null,
  95. isfcity: null,
  96. isfarea: null,
  97. issprovince: null,
  98. isscity: null,
  99. issarea: null,
  100. fprovincelist: [],
  101. sprovincelist: [],
  102. fcitylist: [],
  103. scitylist: [],
  104. farealist: [],
  105. sarealist: [],
  106. fchooseprovince: '选择',
  107. fchoosecity: '请选择市',
  108. fchoosearea: '请选择区',
  109. schooseprovince: '选择',
  110. schoosecity: '请选择市',
  111. schoosearea: '请选择区',
  112. heightCot: 0,
  113. historyFcityList: [],
  114. historyScityList: [],
  115. title: '',
  116. type: 0,
  117. count: 0,
  118. ftitle: '',
  119. ftitleList:[],
  120. stitleList:[],
  121. stitle: '',
  122. selectList: [],
  123. }
  124. },
  125. created() {
  126. this.fprovincelist = address
  127. this.sprovincelist = address
  128. console.log('---------------------------------')
  129. console.log(this.type)
  130. },
  131. onLoad(options) {
  132. console.log(options)
  133. this.type = options.type
  134. this.title = JSON.parse(options.startPlace).selected + '→' + JSON.parse(options.endPlace).selected
  135. //获取缓存收发地
  136. if (uni.getStorageSync('fPlaceList')) {
  137. this.historyFcityList = uni.getStorageSync('fPlaceList');
  138. } else {
  139. this.historyFcityList = []
  140. }
  141. if (uni.getStorageSync('sPlaceList')) {
  142. this.historyScityList = uni.getStorageSync('sPlaceList');
  143. } else {
  144. this.historyScityList = []
  145. }
  146. //赋值地区
  147. },
  148. mounted() {
  149. if (uni.getStorageSync('fPlaceObj')) {
  150. this.fchooseprovince=uni.getStorageSync('fPlaceObj').fchooseprovince
  151. this.fchoosecity=uni.getStorageSync('fPlaceObj').fchoosecity
  152. this.fchoosearea=uni.getStorageSync('fPlaceObj').fchoosearea
  153. for (var i = 0; i < this.fprovincelist.length; i++) {
  154. if(this.fprovincelist[i].label==this.fchooseprovince){
  155. this.fprovincelist[i].checked=true
  156. this.fcitylist = this.fprovincelist[i].child
  157. for (var q = 0; q < this.fcitylist.length; q++) {
  158. if(this.fcitylist[q].label==this.fchoosecity){
  159. this.fcitylist[q].checked=true
  160. this.farealist = this.fcitylist[i].child
  161. for (var area = 0; area < this.farealist.length; area++) {
  162. if(this.farealist[area].label==this.fchoosearea){
  163. this.farealist[area].checked=true
  164. }
  165. }
  166. }
  167. }
  168. }
  169. }
  170. this.fstatus=2
  171. }
  172. if (uni.getStorageSync('sPlaceObj')) {
  173. // sprovincelist
  174. // console.log(this.sprovincelist)
  175. this.schooseprovince=uni.getStorageSync('sPlaceObj').schooseprovince
  176. this.schoosecity=uni.getStorageSync('sPlaceObj').schoosecity
  177. this.schoosearea=uni.getStorageSync('sPlaceObj').schoosearea
  178. if(this.schooseprovince=='全国'){
  179. this.sstatus=0
  180. this.$set(this.sprovincelist[0],'checked',true)
  181. this.issprovince=0
  182. }else{
  183. for (var i = 0; i < this.sprovincelist.length; i++) {
  184. if(this.sprovincelist[i].label==this.schooseprovince){
  185. this.sprovincelist[i].checked=true
  186. this.scitylist = this.sprovincelist[i].child
  187. for (var q = 0; q < this.scitylist.length; q++) {
  188. if(this.scitylist[q].label==this.schoosecity){
  189. this.scitylist[q].checked=true
  190. this.sarealist = this.scitylist[i].child
  191. for (var area = 0; area < this.sarealist.length; area++) {
  192. if(this.sarealist[area].label==this.schoosearea){
  193. this.sarealist[area].checked=true
  194. }
  195. }
  196. }
  197. }
  198. }
  199. }
  200. this.sstatus=2
  201. }
  202. }
  203. },
  204. methods: {
  205. historyClick(type,val){
  206. console.log(type)
  207. if(type==0){
  208. this.historyFcityList.unshift(val)
  209. let _newList = this.makeHistoryList(val)
  210. uni.setStorageSync('fPlaceList', _newList);
  211. uni.setStorageSync('fPlaceObj', val);
  212. }else{
  213. this.historyScityList.unshift(val)
  214. let _newList = this.makeHistoryList(val)
  215. uni.setStorageSync('sPlaceList', _newList);
  216. uni.setStorageSync('sPlaceObj',val )
  217. }
  218. uni.switchTab({
  219. url: '/pages/goodSource/index'
  220. });
  221. },
  222. // 历史收发地去重
  223. makeHistoryList(val) {
  224. if (this.type == 0) {
  225. let _obj = {}
  226. // for (let i = 0; i < this.historyScityList.length; i++) {
  227. // // let _data = this.historyScityList[i]
  228. // }
  229. if (val.selected == '全国' || val.fchoosecity == '全部') {
  230. this.historyFcityList = this.historyFcityList.reduce((cur, item) => {
  231. _obj[item.selected] ? "" : _obj[item.selected] = true && cur.push(item);
  232. return cur;
  233. }, [])
  234. } else {
  235. this.historyFcityList = this.historyFcityList.reduce((cur, item) => {
  236. if (item.fchoosecity == val.fchoosecity) {
  237. _obj[item.selected] ? "" : _obj[item.selected] = true && cur.push(item);
  238. return cur;
  239. } else {
  240. _obj[item.selected] ? "" : _obj[item.selected] = true && cur.push(item);
  241. return cur;
  242. }
  243. }, [])
  244. }
  245. return this.historyFcityList
  246. } else {
  247. let _obj = {}
  248. // for (let i = 0; i < this.historyScityList.length; i++) {
  249. // // let _data = this.historyScityList[i]
  250. // }
  251. if (val.selected == '全国' || val.schoosecity == '全部') {
  252. this.historyScityList = this.historyScityList.reduce((cur, item) => {
  253. _obj[item.selected] ? "" : _obj[item.selected] = true && cur.push(item);
  254. return cur;
  255. }, [])
  256. } else {
  257. this.historyScityList = this.historyScityList.reduce((cur, item) => {
  258. if (item.schoosecity == val.schoosecity) {
  259. _obj[item.selected] ? "" : _obj[item.selected] = true && cur.push(item);
  260. return cur;
  261. } else {
  262. _obj[item.selected] ? "" : _obj[item.selected] = true && cur.push(item);
  263. return cur;
  264. }
  265. }, [])
  266. }
  267. return this.historyScityList
  268. }
  269. },
  270. confirmBtn() {
  271. //设置地区 0发货地 1收货地
  272. if (this.fchooseprovince == '选择' ||(this.fchoosearea == '请选择区'&&this.fchoosecity!='全部')|| (this.fchoosecity == '请选择市' && this.fchooseprovince != '全国')) {
  273. this.$refs.uToast.show({
  274. type: 'error',
  275. message: "请选择发货地区域!",
  276. })
  277. return
  278. }
  279. //收货地
  280. if (this.schooseprovince == '选择' ||(this.schoosearea == '请选择区'&&this.schoosecity!='全部'&& this.schooseprovince != '全国')|| (this.schoosecity == '请选择市' && this.schooseprovince != '全国')) {
  281. this.$refs.uToast.show({
  282. type: 'error',
  283. message: "请选择收货地区域!",
  284. })
  285. return
  286. }
  287. // }
  288. // console.log("省", this.fchooseprovince)
  289. // console.log("市", this.fchoosecity)
  290. // console.log("区", this.fchoosearea)
  291. let _obj = {
  292. fchooseprovince: this.fchooseprovince,
  293. fchoosecity: this.fchoosecity,
  294. fchoosearea: this.fchoosearea,
  295. selected: ''
  296. }
  297. //选中全国
  298. if (this.fchoosecity == '请选择市' && this.fchooseprovince == '全国') {
  299. _obj.selected = this.fchooseprovince
  300. this.historyFcityList.unshift(_obj)
  301. let _newList = this.makeHistoryList(_obj)
  302. uni.setStorageSync('fPlaceList', _newList);
  303. }
  304. //选择省
  305. if (this.fchoosearea == '请选择区' && this.fchoosecity == '全部') {
  306. _obj.selected = this.fchooseprovince
  307. this.historyFcityList.unshift(_obj)
  308. let _newList = this.makeHistoryList(_obj)
  309. uni.setStorageSync('fPlaceList', _newList);
  310. }
  311. //选择市
  312. if (this.fchoosearea == '全部') {
  313. if(this.fchoosecity=='市辖区'){
  314. _obj.selected = this.fchooseprovince
  315. }else{
  316. _obj.selected = this.fchoosecity
  317. }
  318. this.historyFcityList.unshift(_obj)
  319. let _newList = this.makeHistoryList(_obj)
  320. uni.setStorageSync('fPlaceList', _newList);
  321. }
  322. uni.setStorageSync('fPlaceObj', _obj);
  323. //选择区
  324. if (this.fchoosearea != '请选择区' && this.fchoosearea != '全部') {
  325. console.log(this.fchooseprovince,this.fchoosecity,this.fchoosearea)
  326. // let _list = this.fchoosearea.split(',')
  327. // let _newList
  328. // //设置历史收发地并去重,区重名判断是否是同一个市在去重
  329. // for (let i = 0; i < _list.length; i++) {
  330. // let _deepObj = uni.$u.deepClone(_obj)
  331. // _deepObj.selected = _list[i]
  332. // this.historyFcityList.unshift(_deepObj)
  333. // _newList = this.makeHistoryList(_deepObj)
  334. // }
  335. // console.log(_newList)
  336. uni.setStorageSync('fPlaceList', this.historyFcityList);
  337. uni.setStorageSync('fPlaceObj', {
  338. fchooseprovince: this.fchooseprovince,
  339. fchoosecity: this.fchoosecity,
  340. fchoosearea: this.fchoosearea,
  341. selected: this.fchoosearea
  342. });
  343. }
  344. console.log(this.historyFcityList)
  345. // uni.switchTab({
  346. // url: '/pages/goodSource/index'
  347. // });
  348. // } else {
  349. let _obj1 = {
  350. schooseprovince: this.schooseprovince,
  351. schoosecity: this.schoosecity,
  352. schoosearea: this.schoosearea,
  353. selected: ''
  354. }
  355. //选中全国
  356. if (this.schoosecity == '请选择市' && this.schooseprovince == '全国') {
  357. _obj1.selected = this.schooseprovince
  358. this.historyScityList.unshift(_obj1)
  359. let _newList = this.makeHistoryList(_obj1)
  360. uni.setStorageSync('sPlaceList', _newList);
  361. }
  362. //选择省
  363. if (this.schoosearea == '请选择区' && this.schoosecity == '全部') {
  364. _obj1.selected = this.schooseprovince
  365. this.historyScityList.unshift(_obj1)
  366. let _newList = this.makeHistoryList(_obj1)
  367. uni.setStorageSync('sPlaceList', _newList);
  368. }
  369. //选择市
  370. if (this.schoosearea == '全部') {
  371. if(this.schoosecity=='市辖区'){
  372. _obj1.selected = this.schooseprovince
  373. }else{
  374. _obj1.selected = this.schoosecity
  375. }
  376. this.historyScityList.unshift(_obj1)
  377. let _newList = this.makeHistoryList(_obj1)
  378. uni.setStorageSync('sPlaceList', _newList);
  379. }
  380. uni.setStorageSync('sPlaceObj', _obj1);
  381. //选择区
  382. if (this.schoosearea != '请选择区' && this.schoosearea != '全部') {
  383. let _list = this.schoosearea.split(',')
  384. let _newList
  385. for (let i = 0; i < _list.length; i++) {
  386. let _deepObj = uni.$u.deepClone(_obj1)
  387. _deepObj.selected = _list[i]
  388. this.historyScityList.unshift(_deepObj)
  389. _newList = this.makeHistoryList(_deepObj)
  390. }
  391. // console.log(_newList)
  392. uni.setStorageSync('sPlaceList', this.historyScityList);
  393. uni.setStorageSync('sPlaceObj', {
  394. schooseprovince: this.schooseprovince,
  395. schoosecity: this.schoosecity,
  396. schoosearea: this.schoosearea,
  397. selected: this.schoosearea
  398. });
  399. }
  400. console.log(this.historyScityList)
  401. this.schooseprovince='选择'
  402. this.schoosecity='请选择市'
  403. this.schoosearea='请选择区'
  404. this.fchooseprovince='选择'
  405. this.fchoosecity='请选择市'
  406. this.fchoosearea='请选择区'
  407. uni.switchTab({
  408. url: '/pages/goodSource/index'
  409. });
  410. },
  411. //返回上一级
  412. backLevel() {
  413. // this.count=0;
  414. if (this.type == 0) {
  415. this.fstatus--
  416. } else {
  417. this.sstatus--
  418. }
  419. if ((this.type == 0 ? this.fstatus : this.sstatus) == 1) {
  420. if (this.type == 0) {
  421. this.fchoosecity = '请选择市'
  422. this.fchoosearea = ''
  423. this.ftitle = ''
  424. this.isfcity = null
  425. this.ftitleList=[]
  426. } else {
  427. this.schoosecity = '请选择市'
  428. this.schoosearea = ''
  429. this.stitle = ''
  430. this.isscity = null
  431. this.stitleList=[]
  432. }
  433. } else if ((this.type == 0 ? this.fstatus : this.sstatus) == 0) {
  434. if (this.type == 0) {
  435. this.fchooseprovince = '选择'
  436. this.isfprovince = null
  437. } else {
  438. this.schooseprovince = '选择'
  439. this.issprovince = null
  440. }
  441. }
  442. },
  443. // 点击面包屑导航
  444. titleClick(status) {
  445. this.ftitle = ''
  446. this.stitle = ''
  447. this.count = 0
  448. if (this.type == 0) {
  449. this.fstatus = status
  450. this.isfprovince = null
  451. this.isfcity = null
  452. this.isfarea = null
  453. if (this.fchoosecity == '全部') return;
  454. } else {
  455. this.sstatus = status
  456. this.issprovince = null
  457. this.isscity = null
  458. this.issarea = null
  459. if (this.fchoosecity == '全部') return;
  460. }
  461. if (status == 0) {
  462. if (this.type == 0) {
  463. this.fchooseprovince = '选择'
  464. this.fchoosecity = '请选择市'
  465. this.fchoosearea = '请选择区'
  466. this.ftitleList=[]
  467. } else {
  468. this.schooseprovince = '选择'
  469. this.schoosecity = '请选择市'
  470. this.schoosearea = '请选择区'
  471. this.stitleList=[]
  472. }
  473. } else if (status == 1) {
  474. if (this.type == 0) {
  475. this.fchoosecity = '请选择市'
  476. this.fchoosearea = '请选择区'
  477. this.ftitleList=[]
  478. } else {
  479. this.schoosecity = '请选择市'
  480. this.schoosearea = '请选择区'
  481. this.stitleList=[]
  482. }
  483. }
  484. },
  485. // 选择省
  486. selectProvince(item, i, statusIndex) {
  487. console.log(this.type)
  488. this.count = 0;
  489. if (this.type == 0) {
  490. if (i == 0) {
  491. this.$refs.uToast.show({
  492. type: 'error',
  493. message: "发货地不可选择全国!",
  494. })
  495. return
  496. }
  497. this.fchoosecity = '请选择市'
  498. this.fchoosearea = '请选择区'
  499. this.isfprovince = i
  500. this.fchooseprovince = item.label
  501. if (item.child) {
  502. this.fcitylist = item.child
  503. }
  504. if (this.fchoosecity != '全部') {
  505. this.fstatus = statusIndex + 1
  506. }
  507. } else {
  508. this.issprovince = i
  509. this.schooseprovince = item.label
  510. if (item.label == '全国') {
  511. item.checked = !item.checked
  512. if (!item.checked) {
  513. this.issprovince = null
  514. }
  515. return
  516. } else {
  517. this.schoosecity = '请选择市'
  518. this.schoosearea = '请选择区'
  519. if (item.child) {
  520. this.scitylist = item.child
  521. }
  522. if (this.schoosecity != '全部') {
  523. this.sstatus = statusIndex + 1
  524. }
  525. }
  526. }
  527. },
  528. // 选择市
  529. selectCity(item, i, statusIndex) {
  530. if(item.label=='全部'){
  531. this.$refs.uToast.show({
  532. type: 'error',
  533. message: "不能选择全部,请重新选择!"
  534. })
  535. return
  536. }
  537. this.count = 0;
  538. if (this.type == 0) {
  539. this.isfcity = i
  540. } else {
  541. this.isscity = i
  542. }
  543. if (item.child) {
  544. for (let i = 0; i < item.child.length; i++) {
  545. item.child[i].checked = false
  546. }
  547. if (this.type == 0) {
  548. this.farealist = item.child
  549. } else {
  550. this.sarealist = item.child
  551. }
  552. }
  553. if (this.type == 0) {
  554. this.fchoosecity = item.label
  555. } else {
  556. this.schoosecity = item.label
  557. }
  558. if ((this.type == 0 ? this.fchoosecity : this.schoosecity) != '全部') {
  559. if (this.type == 0) {
  560. this.fstatus = statusIndex + 1
  561. } else {
  562. this.sstatus = statusIndex + 1
  563. }
  564. }
  565. },
  566. //选择区
  567. selectaArea(item, i) {
  568. if (item.label == '全部') {
  569. if (this.type == 0) {
  570. for (let i = 0; i < this.farealist.length; i++) {
  571. if (i == 0) {
  572. this.farealist[i].checked = true
  573. } else {
  574. this.farealist[i].checked = false
  575. }
  576. }
  577. this.ftitleList=[]
  578. this.fchoosearea = '全部'
  579. this.$forceUpdate()
  580. return
  581. } else {
  582. for (let i = 0; i < this.sarealist.length; i++) {
  583. if (i == 0) {
  584. this.sarealist[i].checked = true
  585. } else {
  586. this.sarealist[i].checked = false
  587. }
  588. }
  589. this.stitleList=[]
  590. this.schoosearea = '全部'
  591. this.$forceUpdate()
  592. return
  593. }
  594. }
  595. if (this.type == 0) {
  596. this.farealist[0].checked = false
  597. if (this.ftitleList.length < 3) {
  598. item.checked = !item.checked
  599. if (item.checked ) {
  600. if(this.ftitleList.indexOf(item.label)==-1){
  601. this.ftitleList.push(item.label)
  602. }
  603. } else if (!item.checked) {
  604. for (var i = 0; i < this.ftitleList.length; i++) {
  605. console.log(this.ftitleList[i])
  606. if(this.ftitleList[i]==item.label){
  607. this.ftitleList.splice(i,1)
  608. }
  609. }
  610. }
  611. } else {
  612. if (item.checked) {
  613. item.checked = !item.checked
  614. for (var i = 0; i < this.ftitleList.length; i++) {
  615. if(this.ftitleList[i]==item.label){
  616. this.ftitleList.splice(i,1)
  617. }
  618. }
  619. } else {
  620. this.$refs.uToast.show({
  621. type: 'error',
  622. message: "最多选择3个地区",
  623. })
  624. }
  625. }
  626. this.ftitle=this.ftitleList.toString()
  627. this.fchoosearea=this.ftitleList.toString()
  628. }else{
  629. this.sarealist[0].checked = false
  630. if (this.stitleList.length < 3) {
  631. item.checked = !item.checked
  632. if (item.checked ) {
  633. if(this.stitleList.indexOf(item.label)==-1){
  634. this.stitleList.push(item.label)
  635. }
  636. } else if (!item.checked) {
  637. for (var i = 0; i < this.stitleList.length; i++) {
  638. console.log(this.stitleList[i])
  639. if(this.stitleList[i]==item.label){
  640. this.stitleList.splice(i,1)
  641. }
  642. }
  643. }
  644. } else {
  645. if (item.checked) {
  646. item.checked = !item.checked
  647. for (var i = 0; i < this.stitleList.length; i++) {
  648. if(this.stitleList[i]==item.label){
  649. this.stitleList.splice(i,1)
  650. }
  651. }
  652. } else {
  653. this.$refs.uToast.show({
  654. type: 'error',
  655. message: "最多选择3个地区",
  656. })
  657. }
  658. }
  659. this.stitle=this.stitleList.toString()
  660. this.schoosearea=this.stitleList.toString()
  661. }
  662. console.log(this.ftitleList)
  663. this.$forceUpdate()
  664. //设置面包屑 0发货地 1收货地
  665. // if (this.type == 0) {
  666. // this.farealist[0].checked = false
  667. // // if(this.ftitleList.indexOf(item.label)==-1){
  668. // // this.ftitleList.push(item.label)
  669. // // }
  670. // if (item.checked && !this.fchoosearea.includes(item.label)) {
  671. // if (this.ftitle) {
  672. // this.ftitle += ',' + item.label
  673. // } else {
  674. // this.ftitle += item.label
  675. // }
  676. // this.fchoosearea = this.ftitle
  677. // console.log(this.fchoosearea)
  678. // } else {
  679. // if (this.ftitle.includes(',' + item.label)) {
  680. // this.ftitle = this.ftitle.replace(',' + item.label, '')
  681. // this.fchoosearea = this.fchoosearea.replace(',' + item.label, '')
  682. // } else {
  683. // let _val = this.ftitle.split(',')
  684. // let _len = _val.length;
  685. // if (_len == 1) {
  686. // this.ftitle = this.ftitle.replace(item.label, '')
  687. // this.fchoosearea = '请选择区'
  688. // } else if (_len > 1) {
  689. // this.ftitle = this.ftitle.replace(item.label + ',', '')
  690. // this.fchoosearea = this.fchoosearea.replace(item.label + ',', '')
  691. // }
  692. // }
  693. // }
  694. // } else {
  695. // if (item.checked && !this.schoosearea.includes(item.label)) {
  696. // if (this.stitle) {
  697. // this.stitle += ',' + item.label
  698. // } else {
  699. // this.stitle += item.label
  700. // }
  701. // this.schoosearea = this.stitle
  702. // } else {
  703. // if (this.stitle.includes(',' + item.label)) {
  704. // this.stitle = this.stitle.replace(',' + item.label, '')
  705. // this.schoosearea = this.schoosearea.replace(',' + item.label, '')
  706. // } else {
  707. // let _val = this.stitle.split(',')
  708. // let _len = _val.length;
  709. // if (_len == 1) {
  710. // this.stitle = this.stitle.replace(item.label, '')
  711. // this.schoosearea = '请选择区'
  712. // } else if (_len > 1) {
  713. // this.stitle = this.stitle.replace(item.label + ',', '')
  714. // this.schoosearea = this.schoosearea.replace(item.label + ',', '')
  715. // }
  716. // }
  717. // }
  718. // }
  719. },
  720. changeCity(type) {
  721. if (type == 0) {
  722. this.type = 0
  723. } else {
  724. this.type = 1
  725. }
  726. },
  727. back() {
  728. uni.navigateBack({
  729. })
  730. },
  731. }
  732. }
  733. </script>
  734. <style lang="scss" scoped>
  735. .row1 {
  736. display: flex;
  737. justify-content: space-evenly;
  738. margin-top: 10rpx;
  739. border-bottom: 1px solid #E6E6E6;
  740. }
  741. .start-place,
  742. .end-place {
  743. font-size: 28rpx;
  744. color: #B1B5C0;
  745. padding-bottom: 20rpx;
  746. }
  747. .active1 {
  748. position: relative;
  749. color: black;
  750. font-size: 32rpx;
  751. font-weight: 700;
  752. display: flex;
  753. justify-content: center;
  754. }
  755. .active1:after {
  756. content: '';
  757. position: absolute;
  758. bottom: 0rpx;
  759. width: 50%;
  760. left: 25%;
  761. padding: 0 20rpx;
  762. box-sizing: border-box;
  763. height: 6rpx;
  764. background: #2772FB;
  765. border-radius: 3px;
  766. }
  767. .history-city-title {
  768. font-size: 28rpx;
  769. font-weight: 700;
  770. color: #363636;
  771. margin-bottom: 20rpx;
  772. }
  773. .container {
  774. padding: 0 20rpx;
  775. }
  776. .content1 {
  777. margin: 20rpx 0;
  778. }
  779. .city-list {
  780. max-height: 118rpx;
  781. overflow: hidden;
  782. }
  783. .city {
  784. display: inline-block;
  785. font-size: 26rpx;
  786. text-align: center;
  787. padding: 8rpx 16rpx;
  788. margin: 0 20rpx 20rpx 0;
  789. height: 33rpx;
  790. line-height: 33rpx;
  791. border-radius: 4rpx;
  792. background: #F7F8FA;
  793. }
  794. .content2 {
  795. margin: 20rpx 0;
  796. }
  797. .container {
  798. // width: 100%;
  799. width: calc(100% - 40rpx);
  800. display: inline-flex;
  801. flex-flow: row wrap;
  802. align-content: flex-start;
  803. }
  804. .select-active,
  805. .back-level {
  806. color: #2772FB;
  807. font-size: 28rpx;
  808. }
  809. .content-item {
  810. background: #F7F8FA;
  811. margin: 10rpx;
  812. font-size: 30rpx;
  813. color: #333333;
  814. text-align: center;
  815. padding: 10rpx 0;
  816. border-radius: 10rx;
  817. overflow: hidden;
  818. text-overflow: ellipsis;
  819. white-space: nowrap;
  820. padding: 6rpx 8rpx;
  821. box-sizing: border-box;
  822. flex: 0 0 calc(25% - 20rpx);
  823. }
  824. .title {
  825. margin: 0 20rpx;
  826. }
  827. .active {
  828. background: #E5F0FE;
  829. border-radius: 10rpx;
  830. // border: 1px solid #2772FB;
  831. color: #2772FB;
  832. box-sizing: border-box;
  833. }
  834. .area {
  835. width: 55%;
  836. text-overflow: ellipsis;
  837. white-space: nowrap;
  838. overflow: hidden;
  839. }
  840. .nav-bag-left {
  841. width: 70%;
  842. font-size: 30rpx;
  843. }
  844. .btn {
  845. background: #2772FB;
  846. color: white;
  847. width: 80%;
  848. position: absolute;
  849. bottom: 30rpx;
  850. margin-left: 10%;
  851. border-radius: 50rpx;
  852. }
  853. </style>