addRoute.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <template>
  2. <view class="center">
  3. <view class="route_site">
  4. <view class="out_site">
  5. <span class="blueDot dot"></span>
  6. 请选择发货城市
  7. <view class="site_change" @click="selectAddress(1)" v-if="!title1">
  8. 选择
  9. </view>
  10. <view class="site" @click="selectAddress(1)" v-else>{{title1 ? title1 : ""}}</view>
  11. <itmister-address-picker ref="addressElone" @confirmChange="confirmChangeOne"></itmister-address-picker>
  12. </view>
  13. <view class="in_site">
  14. <span class="redDot dot"></span>
  15. 请选择卸货城市
  16. <view class="site_change" @click="selectAddress(2)" v-if="!title2">
  17. 选择
  18. </view>
  19. <view class="site" @click="selectAddress(2)" v-else>{{title2 ? title2 : ""}}</view>
  20. <itmister-address-picker-other ref="addressEltwo" @confirmChange="confirmChangeTwo"></itmister-address-picker-other>
  21. </view>
  22. </view>
  23. <!-- <view class="flex row form_css">
  24. <view class="left-text">发货城市</view>
  25. <view class="right-text">
  26. <view @click="selectAddress(1)">{{title1 ? title1 : "请选择地址"}}</view>
  27. <itmister-address-picker ref="addressElone" @confirmChange="confirmChangeOne"></itmister-address-picker>
  28. </view>
  29. </view>
  30. <view class="flex row form_css">
  31. <view class="left-text">到货城市</view>
  32. <view class="right-text">
  33. <view @click="selectAddress(2)">{{title2 ? title2 : "请选择地址"}}</view>
  34. <itmister-address-picker-other ref="addressEltwo" @confirmChange="confirmChangeTwo"></itmister-address-picker-other>
  35. </view>
  36. </view> -->
  37. <view class="text_css">注:常用路线用于展示给其他司机和货主查看。</view>
  38. <view class="btn_css">
  39. <u-button type="primary" @click="submit">提交</u-button>
  40. </view>
  41. <u-toast ref="uToast"></u-toast>
  42. </view>
  43. </template>
  44. <script>
  45. // import regionPicker from "@/components/region/region-picker";
  46. // import Linkage from '@/components/gaojianghua-linkage/linkage.vue'
  47. import itmisterAddressPicker from '@/components/itmister-address-picker/itmister-address-picker.nvue'
  48. import itmisterAddressPickerOther from '@/components/itmister-address-picker/itmister-address-picker-other.nvue'
  49. export default {
  50. components: {
  51. // regionPicker,
  52. // Linkage,
  53. itmisterAddressPicker,
  54. itmisterAddressPickerOther
  55. },
  56. data() {
  57. return {
  58. id: "",
  59. routeData: {},
  60. // selections1: [],
  61. // selections2: [],
  62. driverData: {},
  63. avatarUrl: "",
  64. // sendregion: [],
  65. // unloaddregion: [],
  66. title1: "",
  67. title2: "",
  68. }
  69. },
  70. onShow() {},
  71. onLoad(options) {
  72. this.driverData = uni.getStorageSync('firstAuthentication')
  73. this.avatarUrl = uni.getStorageSync("userInfo").avatarUrl
  74. this.id = options.id
  75. if (this.id) { //修改
  76. uni.setNavigationBarTitle({
  77. title: '编辑路线'
  78. })
  79. this.getList()
  80. }
  81. },
  82. methods: {
  83. selectAddress(num) {
  84. if(num == 1){
  85. this.$refs.addressElone.show();
  86. }else{
  87. this.$refs.addressEltwo.show();
  88. }
  89. },
  90. // 确认选中
  91. confirmChangeOne(address) {
  92. this.routeData.sendProvince = address.province ? address.province : ''
  93. this.routeData.sendCity = address.city ? address.city : ''
  94. this.routeData.sendArea = address.area ? address.area : ''
  95. if(address.city == '全省'){
  96. this.title1 = address.province
  97. this.routeData.sendCity = ""
  98. this.routeData.sendArea = ""
  99. }else if(address.area == '全市'){
  100. if(address.province=='北京'||address.province=='天津'||address.province=='上海'||address.province=='重庆'||address.province=='台湾'){
  101. this.title1 = address.province
  102. this.routeData.sendCity = ''
  103. }else{
  104. this.title1 = address.province + address.city
  105. }
  106. // this.title1 = address.province + address.city
  107. this.routeData.sendArea = ""
  108. }else{
  109. if(address.province=='北京'||address.province=='天津'||address.province=='上海'||address.province=='重庆'||address.province=='台湾'){
  110. this.title1 = address.province+ address.area;
  111. this.routeData.sendCity = ''
  112. }else{
  113. this.title1 = address.province + address.city + address.area;
  114. }
  115. }
  116. },
  117. confirmChangeTwo(address) {
  118. this.routeData.unloadProvince = address.province ? address.province : ''
  119. this.routeData.unloadCity = address.city ? address.city : ''
  120. this.routeData.unloadArea = address.area ? address.area : ''
  121. if(address.city == '全省'){
  122. this.title2 = address.province
  123. this.routeData.unloadCity = ""
  124. this.routeData.unloadArea = ""
  125. }else if(address.area == '全市'){
  126. if(address.province=='北京'||address.province=='天津'||address.province=='上海'||address.province=='重庆'||address.province=='台湾'){
  127. this.title2 = address.province
  128. this.routeData.unloadCity =''
  129. }else{
  130. this.title2 = address.province + address.city
  131. }
  132. this.routeData.unloadArea = ""
  133. }else{
  134. if(address.province == '全国'){
  135. this.title2 = address.province
  136. }else{
  137. if(address.province=='北京'||address.province=='天津'||address.province=='上海'||address.province=='重庆'||address.province=='台湾'){
  138. this.title2 = address.province+ address.area;
  139. this.routeData.unloadCity = ""
  140. }else{
  141. this.title2 = address.province + address.city + address.area;
  142. }
  143. }
  144. }
  145. },
  146. // conceal1(param) {
  147. // const {
  148. // chooseprovince,
  149. // choosecity,
  150. // choosearea
  151. // } = param
  152. // // 获取到传过来的 省 市 区 县数据
  153. // this.routeData.sendProvince = chooseprovince
  154. // this.routeData.sendCity = choosecity == '全部' ? "" : choosecity
  155. // this.routeData.sendArea = choosearea == '全部' ? "" : choosearea
  156. // this.title1 = chooseprovince + choosecity + choosearea
  157. // if (chooseprovince == '全国') {
  158. // this.succeed(1)
  159. // }
  160. // if (choosecity == '全部') {
  161. // this.succeed(1)
  162. // } else if (choosearea != '') {
  163. // this.succeed(1)
  164. // }
  165. // },
  166. // conceal2(param) {
  167. // const {
  168. // chooseprovince,
  169. // choosecity,
  170. // choosearea
  171. // } = param
  172. // // 获取到传过来的 省 市 区 县数据
  173. // this.routeData.unloadProvince = chooseprovince
  174. // this.routeData.unloadCity = choosecity == '全部' ? "" : choosecity
  175. // this.routeData.unloadArea = choosearea == '全部' ? "" : choosearea
  176. // this.title2 = chooseprovince + choosecity + choosearea
  177. // if (chooseprovince == '全国') {
  178. // this.succeed(2)
  179. // }
  180. // if (choosecity == '全部') {
  181. // this.succeed(2)
  182. // } else if (choosearea != '') {
  183. // this.succeed(2)
  184. // }
  185. // },
  186. //筛选框关闭
  187. // succeed(num) {
  188. // // this.$refs.uDropdown.close();
  189. // if (num == 1) {
  190. // this.show1 = false
  191. // } else if (num == 2) {
  192. // this.show2 = false
  193. // }
  194. // },
  195. getList() {
  196. this.$request.baseRequest('get', '/commonRoute/get', {
  197. id: this.id
  198. }).then(res => {
  199. if (res.code == 200) {
  200. this.routeData = res.data
  201. if(this.routeData.sendProvince=='北京'&&this.routeData.sendArea==''
  202. ||this.routeData.sendProvince=='天津'&&this.routeData.sendArea==''
  203. ||this.routeData.sendProvince=='上海'&&this.routeData.sendArea==''
  204. ||this.routeData.sendProvince=='重庆'&&this.routeData.sendArea==''
  205. ||this.routeData.sendProvince=='台湾'&&this.routeData.sendArea==''){
  206. this.title1 = this.routeData.sendProvince
  207. }else{
  208. this.title1 = this.routeData.sendProvince + this.routeData.sendCity + this.routeData
  209. .sendArea
  210. }
  211. if(this.routeData.unloadProvince=='北京'&&this.routeData.unloadArea==''
  212. ||this.routeData.unloadProvince=='天津'&&this.routeData.unloadArea==''
  213. ||this.routeData.unloadProvince=='上海'&&this.routeData.unloadArea==''
  214. ||this.routeData.unloadProvince=='重庆'&&this.routeData.unloadArea==''
  215. ||this.routeData.unloadProvince=='台湾'&&this.routeData.unloadArea==''){
  216. this.title2 = this.routeData.unloadProvince
  217. }else{
  218. this.title2 = this.routeData.unloadProvince + this.routeData.unloadCity + this.routeData
  219. .unloadArea
  220. }
  221. }
  222. })
  223. .catch(res => {
  224. uni.$u.toast(res.message);
  225. });
  226. },
  227. submit() {
  228. if(!this.title1){
  229. this.$refs.uToast.show({
  230. type: 'error',
  231. message: "请选择发货城市",
  232. })
  233. return
  234. }
  235. if(!this.title2){
  236. this.$refs.uToast.show({
  237. type: 'error',
  238. message: "请选择卸货城市",
  239. })
  240. return
  241. }
  242. this.routeData.commonId = uni.getStorageSync("userInfo").id
  243. let name = this.driverData.driverCall.slice(0, 1)
  244. this.routeData.driverNickname = name + "师傅"
  245. this.routeData.driverPortrait = this.avatarUrl
  246. if (this.id) {
  247. this.$request.baseRequest('post', '/commonRoute/api/edit', this.routeData).then(res => {
  248. if (res.code == 200) {
  249. this.$refs.uToast.show({
  250. type: 'success',
  251. message: "修改成功!",
  252. complete() {
  253. uni.$u.route("pages/mine/often/oftenRoute")
  254. }
  255. })
  256. }
  257. })
  258. .catch(res => {
  259. uni.$u.toast(res.message);
  260. });
  261. } else {
  262. this.$request.baseRequest('post', '/commonRoute/api/add', this.routeData).then(res => {
  263. if (res.code == 200) {
  264. this.$refs.uToast.show({
  265. type: 'success',
  266. message: "提交成功!",
  267. complete() {
  268. uni.navigateBack({
  269. delta: 1
  270. });
  271. // uni.$u.route("pages/mine/often/oftenRoute")
  272. }
  273. })
  274. }
  275. })
  276. .catch(res => {
  277. uni.$u.toast(res.message);
  278. });
  279. }
  280. },
  281. // regionChange1(value) {
  282. // this.sendregion = value
  283. // this.routeData.sendProvince = this.sendregion[0] == '请选择' ? '' : this.sendregion[0]
  284. // this.routeData.sendCity = this.sendregion[1] == '请选择' ? '' : this.sendregion[1]
  285. // this.routeData.sendArea = this.sendregion[2] == '请选择' ? '' : this.sendregion[2]
  286. // },
  287. // regionChange2(value) {
  288. // this.unloaddregion = value
  289. // this.routeData.unloadProvince = this.unloaddregion[0] == '请选择' ? '' : this.unloaddregion[0]
  290. // this.routeData.unloadCity = this.unloaddregion[1] == '请选择' ? '' : this.unloaddregion[1]
  291. // this.routeData.unloadArea = this.unloaddregion[2] == '请选择' ? '' : this.unloaddregion[2]
  292. // },
  293. // selecteRegion1(value) {
  294. // this.selections1 = value;
  295. // this.routeData.sendNum = this.selections1.toString()
  296. // },
  297. // selecteRegion2(value) {
  298. // this.selections2 = value;
  299. // this.routeData.unloadNum = this.selections2.toString()
  300. // },
  301. }
  302. }
  303. </script>
  304. <style lang="scss" scoped>
  305. .center {
  306. // width: 100%;
  307. padding: 30rpx;
  308. background: #F2F4F7;
  309. height:100vh;
  310. }
  311. .route_site{
  312. background: #FFFFFF;
  313. padding: 30rpx;
  314. border-radius: 20rpx;
  315. .out_site{
  316. border-bottom: 1px solid #E6E6E6;
  317. padding-bottom: 20rpx;
  318. }
  319. .in_site{
  320. margin-top: 30rpx;
  321. }
  322. .dot{
  323. display: inline-block;
  324. width: 16rpx;
  325. height: 16rpx;
  326. border-radius: 8rpx;
  327. margin: 20rpx 20rpx 0 0 ;
  328. }
  329. .blueDot{
  330. background: #2772FB;
  331. }
  332. .redDot{
  333. background: #FE6300;
  334. }
  335. .site_change{
  336. margin-top: 20rpx;
  337. text-align: center;
  338. line-height: 64rpx;
  339. border: 1px solid #CFCFCF;
  340. width: 158rpx;
  341. height: 64rpx;
  342. border-radius: 32rpx;
  343. margin-left: 30rpx;
  344. }
  345. .site{
  346. color: #2772FB;
  347. margin-top: 20rpx;
  348. margin-left: 30rpx;
  349. height: 64rpx;
  350. }
  351. }
  352. .text_css{
  353. margin-top: 20rpx;
  354. font-size: 26rpx;
  355. margin-left: 20rpx;
  356. }
  357. .form_css {
  358. width: 100%;
  359. display: flex;
  360. margin: 20rpx 0;
  361. height: 60rpx;
  362. border-bottom: 1px solid #eeeeee;
  363. .left-text {
  364. width: 50%;
  365. text-align: left;
  366. }
  367. .right-text {
  368. width: 50%;
  369. justify-content: flex-end;
  370. display: flex;
  371. text-align: right;
  372. }
  373. }
  374. .btn_css {
  375. margin-top: 300rpx;
  376. }
  377. </style>