selectCity.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902
  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[q].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[q].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.removeStorageSync('longitudeAndLatitude')
  408. uni.switchTab({
  409. url: '/pages/goodSource/index'
  410. });
  411. },
  412. //返回上一级
  413. backLevel() {
  414. // this.count=0;
  415. if (this.type == 0) {
  416. this.fstatus--
  417. } else {
  418. this.sstatus--
  419. }
  420. if ((this.type == 0 ? this.fstatus : this.sstatus) == 1) {
  421. if (this.type == 0) {
  422. this.fchoosecity = '请选择市'
  423. this.fchoosearea = ''
  424. this.ftitle = ''
  425. this.isfcity = null
  426. this.ftitleList=[]
  427. } else {
  428. this.schoosecity = '请选择市'
  429. this.schoosearea = ''
  430. this.stitle = ''
  431. this.isscity = null
  432. this.stitleList=[]
  433. }
  434. } else if ((this.type == 0 ? this.fstatus : this.sstatus) == 0) {
  435. if (this.type == 0) {
  436. this.fchooseprovince = '选择'
  437. this.isfprovince = null
  438. } else {
  439. this.schooseprovince = '选择'
  440. this.issprovince = null
  441. }
  442. }
  443. },
  444. // 点击面包屑导航
  445. titleClick(status) {
  446. this.ftitle = ''
  447. this.stitle = ''
  448. this.count = 0
  449. if (this.type == 0) {
  450. this.fstatus = status
  451. this.isfprovince = null
  452. this.isfcity = null
  453. this.isfarea = null
  454. if (this.fchoosecity == '全部') return;
  455. } else {
  456. this.sstatus = status
  457. this.issprovince = null
  458. this.isscity = null
  459. this.issarea = null
  460. if (this.fchoosecity == '全部') return;
  461. }
  462. if (status == 0) {
  463. if (this.type == 0) {
  464. this.fchooseprovince = '选择'
  465. this.fchoosecity = '请选择市'
  466. this.fchoosearea = '请选择区'
  467. this.ftitleList=[]
  468. } else {
  469. this.schooseprovince = '选择'
  470. this.schoosecity = '请选择市'
  471. this.schoosearea = '请选择区'
  472. this.stitleList=[]
  473. }
  474. } else if (status == 1) {
  475. if (this.type == 0) {
  476. this.fchoosecity = '请选择市'
  477. this.fchoosearea = '请选择区'
  478. this.ftitleList=[]
  479. } else {
  480. this.schoosecity = '请选择市'
  481. this.schoosearea = '请选择区'
  482. this.stitleList=[]
  483. }
  484. }
  485. },
  486. // 选择省
  487. selectProvince(item, i, statusIndex) {
  488. console.log(this.type)
  489. this.count = 0;
  490. if (this.type == 0) {
  491. if (i == 0) {
  492. this.$refs.uToast.show({
  493. type: 'error',
  494. message: "发货地不可选择全国!",
  495. })
  496. return
  497. }
  498. this.fchoosecity = '请选择市'
  499. this.fchoosearea = '请选择区'
  500. this.isfprovince = i
  501. this.fchooseprovince = item.label
  502. if (item.child) {
  503. this.fcitylist = item.child
  504. }
  505. if (this.fchoosecity != '全部') {
  506. this.fstatus = statusIndex + 1
  507. }
  508. } else {
  509. this.issprovince = i
  510. this.schooseprovince = item.label
  511. if (item.label == '全国') {
  512. item.checked = !item.checked
  513. if (!item.checked) {
  514. this.issprovince = null
  515. }
  516. return
  517. } else {
  518. this.schoosecity = '请选择市'
  519. this.schoosearea = '请选择区'
  520. if (item.child) {
  521. this.scitylist = item.child
  522. }
  523. if (this.schoosecity != '全部') {
  524. this.sstatus = statusIndex + 1
  525. }
  526. }
  527. }
  528. },
  529. // 选择市
  530. selectCity(item, i, statusIndex) {
  531. if(item.label=='全部'){
  532. this.$refs.uToast.show({
  533. type: 'error',
  534. message: "不能选择全部,请重新选择!"
  535. })
  536. return
  537. }
  538. this.count = 0;
  539. if (this.type == 0) {
  540. this.isfcity = i
  541. } else {
  542. this.isscity = i
  543. }
  544. if (item.child) {
  545. for (let i = 0; i < item.child.length; i++) {
  546. item.child[i].checked = false
  547. }
  548. if (this.type == 0) {
  549. this.farealist = item.child
  550. } else {
  551. this.sarealist = item.child
  552. }
  553. }
  554. if (this.type == 0) {
  555. this.fchoosecity = item.label
  556. } else {
  557. this.schoosecity = item.label
  558. }
  559. if ((this.type == 0 ? this.fchoosecity : this.schoosecity) != '全部') {
  560. if (this.type == 0) {
  561. this.fstatus = statusIndex + 1
  562. } else {
  563. this.sstatus = statusIndex + 1
  564. }
  565. }
  566. },
  567. //选择区
  568. selectaArea(item, i) {
  569. if (item.label == '全部') {
  570. if (this.type == 0) {
  571. for (let i = 0; i < this.farealist.length; i++) {
  572. if (i == 0) {
  573. this.farealist[i].checked = true
  574. } else {
  575. this.farealist[i].checked = false
  576. }
  577. }
  578. this.ftitleList=[]
  579. this.fchoosearea = '全部'
  580. this.$forceUpdate()
  581. return
  582. } else {
  583. for (let i = 0; i < this.sarealist.length; i++) {
  584. if (i == 0) {
  585. this.sarealist[i].checked = true
  586. } else {
  587. this.sarealist[i].checked = false
  588. }
  589. }
  590. this.stitleList=[]
  591. this.schoosearea = '全部'
  592. this.$forceUpdate()
  593. return
  594. }
  595. }
  596. if (this.type == 0) {
  597. this.farealist[0].checked = false
  598. if (this.ftitleList.length < 3) {
  599. item.checked = !item.checked
  600. if (item.checked ) {
  601. if(this.ftitleList.indexOf(item.label)==-1){
  602. this.ftitleList.push(item.label)
  603. }
  604. } else if (!item.checked) {
  605. for (var i = 0; i < this.ftitleList.length; i++) {
  606. console.log(this.ftitleList[i])
  607. if(this.ftitleList[i]==item.label){
  608. this.ftitleList.splice(i,1)
  609. }
  610. }
  611. }
  612. } else {
  613. if (item.checked) {
  614. item.checked = !item.checked
  615. for (var i = 0; i < this.ftitleList.length; i++) {
  616. if(this.ftitleList[i]==item.label){
  617. this.ftitleList.splice(i,1)
  618. }
  619. }
  620. } else {
  621. this.$refs.uToast.show({
  622. type: 'error',
  623. message: "最多选择3个地区",
  624. })
  625. }
  626. }
  627. this.ftitle=this.ftitleList.toString()
  628. this.fchoosearea=this.ftitleList.toString()
  629. }else{
  630. this.sarealist[0].checked = false
  631. if (this.stitleList.length < 3) {
  632. item.checked = !item.checked
  633. if (item.checked ) {
  634. if(this.stitleList.indexOf(item.label)==-1){
  635. this.stitleList.push(item.label)
  636. }
  637. } else if (!item.checked) {
  638. for (var i = 0; i < this.stitleList.length; i++) {
  639. console.log(this.stitleList[i])
  640. if(this.stitleList[i]==item.label){
  641. this.stitleList.splice(i,1)
  642. }
  643. }
  644. }
  645. } else {
  646. if (item.checked) {
  647. item.checked = !item.checked
  648. for (var i = 0; i < this.stitleList.length; i++) {
  649. if(this.stitleList[i]==item.label){
  650. this.stitleList.splice(i,1)
  651. }
  652. }
  653. } else {
  654. this.$refs.uToast.show({
  655. type: 'error',
  656. message: "最多选择3个地区",
  657. })
  658. }
  659. }
  660. this.stitle=this.stitleList.toString()
  661. this.schoosearea=this.stitleList.toString()
  662. }
  663. console.log(this.ftitleList)
  664. this.$forceUpdate()
  665. //设置面包屑 0发货地 1收货地
  666. // if (this.type == 0) {
  667. // this.farealist[0].checked = false
  668. // // if(this.ftitleList.indexOf(item.label)==-1){
  669. // // this.ftitleList.push(item.label)
  670. // // }
  671. // if (item.checked && !this.fchoosearea.includes(item.label)) {
  672. // if (this.ftitle) {
  673. // this.ftitle += ',' + item.label
  674. // } else {
  675. // this.ftitle += item.label
  676. // }
  677. // this.fchoosearea = this.ftitle
  678. // console.log(this.fchoosearea)
  679. // } else {
  680. // if (this.ftitle.includes(',' + item.label)) {
  681. // this.ftitle = this.ftitle.replace(',' + item.label, '')
  682. // this.fchoosearea = this.fchoosearea.replace(',' + item.label, '')
  683. // } else {
  684. // let _val = this.ftitle.split(',')
  685. // let _len = _val.length;
  686. // if (_len == 1) {
  687. // this.ftitle = this.ftitle.replace(item.label, '')
  688. // this.fchoosearea = '请选择区'
  689. // } else if (_len > 1) {
  690. // this.ftitle = this.ftitle.replace(item.label + ',', '')
  691. // this.fchoosearea = this.fchoosearea.replace(item.label + ',', '')
  692. // }
  693. // }
  694. // }
  695. // } else {
  696. // if (item.checked && !this.schoosearea.includes(item.label)) {
  697. // if (this.stitle) {
  698. // this.stitle += ',' + item.label
  699. // } else {
  700. // this.stitle += item.label
  701. // }
  702. // this.schoosearea = this.stitle
  703. // } else {
  704. // if (this.stitle.includes(',' + item.label)) {
  705. // this.stitle = this.stitle.replace(',' + item.label, '')
  706. // this.schoosearea = this.schoosearea.replace(',' + item.label, '')
  707. // } else {
  708. // let _val = this.stitle.split(',')
  709. // let _len = _val.length;
  710. // if (_len == 1) {
  711. // this.stitle = this.stitle.replace(item.label, '')
  712. // this.schoosearea = '请选择区'
  713. // } else if (_len > 1) {
  714. // this.stitle = this.stitle.replace(item.label + ',', '')
  715. // this.schoosearea = this.schoosearea.replace(item.label + ',', '')
  716. // }
  717. // }
  718. // }
  719. // }
  720. },
  721. changeCity(type) {
  722. if (type == 0) {
  723. this.type = 0
  724. } else {
  725. this.type = 1
  726. }
  727. },
  728. back() {
  729. uni.navigateBack({
  730. })
  731. },
  732. }
  733. }
  734. </script>
  735. <style lang="scss" scoped>
  736. .row1 {
  737. display: flex;
  738. justify-content: space-evenly;
  739. margin-top: 10rpx;
  740. border-bottom: 1px solid #E6E6E6;
  741. }
  742. .start-place,
  743. .end-place {
  744. font-size: 28rpx;
  745. color: #B1B5C0;
  746. padding-bottom: 20rpx;
  747. }
  748. .active1 {
  749. position: relative;
  750. color: black;
  751. font-size: 32rpx;
  752. font-weight: 700;
  753. display: flex;
  754. justify-content: center;
  755. }
  756. .active1:after {
  757. content: '';
  758. position: absolute;
  759. bottom: 0rpx;
  760. width: 50%;
  761. left: 25%;
  762. padding: 0 20rpx;
  763. box-sizing: border-box;
  764. height: 6rpx;
  765. background: #2772FB;
  766. border-radius: 3px;
  767. }
  768. .history-city-title {
  769. font-size: 28rpx;
  770. font-weight: 700;
  771. color: #363636;
  772. margin-bottom: 20rpx;
  773. }
  774. .container {
  775. padding: 0 20rpx;
  776. }
  777. .content1 {
  778. margin: 20rpx 0;
  779. }
  780. .city-list {
  781. max-height: 118rpx;
  782. overflow: hidden;
  783. }
  784. .city {
  785. display: inline-block;
  786. font-size: 26rpx;
  787. text-align: center;
  788. padding: 8rpx 16rpx;
  789. margin: 0 20rpx 20rpx 0;
  790. height: 33rpx;
  791. line-height: 33rpx;
  792. border-radius: 4rpx;
  793. background: #F7F8FA;
  794. }
  795. .content2 {
  796. margin: 20rpx 0;
  797. }
  798. .container {
  799. // width: 100%;
  800. width: calc(100% - 40rpx);
  801. display: inline-flex;
  802. flex-flow: row wrap;
  803. align-content: flex-start;
  804. }
  805. .select-active,
  806. .back-level {
  807. color: #2772FB;
  808. font-size: 28rpx;
  809. }
  810. .content-item {
  811. background: #F7F8FA;
  812. margin: 10rpx;
  813. font-size: 30rpx;
  814. color: #333333;
  815. text-align: center;
  816. padding: 10rpx 0;
  817. border-radius: 10rx;
  818. overflow: hidden;
  819. text-overflow: ellipsis;
  820. white-space: nowrap;
  821. padding: 6rpx 8rpx;
  822. box-sizing: border-box;
  823. flex: 0 0 calc(25% - 20rpx);
  824. }
  825. .title {
  826. margin: 0 20rpx;
  827. }
  828. .active {
  829. background: #E5F0FE;
  830. border-radius: 10rpx;
  831. // border: 1px solid #2772FB;
  832. color: #2772FB;
  833. box-sizing: border-box;
  834. }
  835. .area {
  836. width: 55%;
  837. text-overflow: ellipsis;
  838. white-space: nowrap;
  839. overflow: hidden;
  840. }
  841. .nav-bag-left {
  842. width: 70%;
  843. font-size: 30rpx;
  844. }
  845. .btn {
  846. background: #2772FB;
  847. color: white;
  848. width: 80%;
  849. position: absolute;
  850. bottom: 30rpx;
  851. margin-left: 10%;
  852. border-radius: 50rpx;
  853. }
  854. </style>