addRoute.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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. this.title1 = address.province + address.city
  101. this.routeData.sendArea = ""
  102. }else{
  103. this.title1 = address.province + address.city + address.area;
  104. }
  105. },
  106. confirmChangeTwo(address) {
  107. this.routeData.unloadProvince = address.province ? address.province : ''
  108. this.routeData.unloadCity = address.city ? address.city : ''
  109. this.routeData.unloadArea = address.area ? address.area : ''
  110. if(address.city == '全省'){
  111. this.title2 = address.province
  112. this.routeData.unloadCity = ""
  113. this.routeData.unloadArea = ""
  114. }else if(address.area == '全市'){
  115. this.title2 = address.province + address.city
  116. this.routeData.unloadArea = ""
  117. }else{
  118. if(address.province == '全国'){
  119. this.title2 = address.province
  120. }else{
  121. this.title2 = address.province + address.city + address.area;
  122. }
  123. }
  124. },
  125. // conceal1(param) {
  126. // const {
  127. // chooseprovince,
  128. // choosecity,
  129. // choosearea
  130. // } = param
  131. // // 获取到传过来的 省 市 区 县数据
  132. // this.routeData.sendProvince = chooseprovince
  133. // this.routeData.sendCity = choosecity == '全部' ? "" : choosecity
  134. // this.routeData.sendArea = choosearea == '全部' ? "" : choosearea
  135. // this.title1 = chooseprovince + choosecity + choosearea
  136. // if (chooseprovince == '全国') {
  137. // this.succeed(1)
  138. // }
  139. // if (choosecity == '全部') {
  140. // this.succeed(1)
  141. // } else if (choosearea != '') {
  142. // this.succeed(1)
  143. // }
  144. // },
  145. // conceal2(param) {
  146. // const {
  147. // chooseprovince,
  148. // choosecity,
  149. // choosearea
  150. // } = param
  151. // // 获取到传过来的 省 市 区 县数据
  152. // this.routeData.unloadProvince = chooseprovince
  153. // this.routeData.unloadCity = choosecity == '全部' ? "" : choosecity
  154. // this.routeData.unloadArea = choosearea == '全部' ? "" : choosearea
  155. // this.title2 = chooseprovince + choosecity + choosearea
  156. // if (chooseprovince == '全国') {
  157. // this.succeed(2)
  158. // }
  159. // if (choosecity == '全部') {
  160. // this.succeed(2)
  161. // } else if (choosearea != '') {
  162. // this.succeed(2)
  163. // }
  164. // },
  165. //筛选框关闭
  166. // succeed(num) {
  167. // // this.$refs.uDropdown.close();
  168. // if (num == 1) {
  169. // this.show1 = false
  170. // } else if (num == 2) {
  171. // this.show2 = false
  172. // }
  173. // },
  174. getList() {
  175. this.$request.baseRequest('get', '/commonRoute/get', {
  176. id: this.id
  177. }).then(res => {
  178. if (res.code == 200) {
  179. this.routeData = res.data
  180. this.title1 = this.routeData.sendProvince + this.routeData.sendCity + this.routeData
  181. .sendArea
  182. this.title2 = this.routeData.unloadProvince + this.routeData.unloadCity + this.routeData
  183. .unloadArea
  184. }
  185. })
  186. .catch(res => {
  187. uni.$u.toast(res.message);
  188. });
  189. },
  190. submit() {
  191. if(!this.title1){
  192. this.$refs.uToast.show({
  193. type: 'error',
  194. message: "请选择发货城市",
  195. })
  196. return
  197. }
  198. if(!this.title2){
  199. this.$refs.uToast.show({
  200. type: 'error',
  201. message: "请选择卸货城市",
  202. })
  203. return
  204. }
  205. this.routeData.commonId = uni.getStorageSync("userInfo").id
  206. let name = this.driverData.driverCall.slice(0, 1)
  207. this.routeData.driverNickname = name + "师傅"
  208. this.routeData.driverPortrait = this.avatarUrl
  209. if (this.id) {
  210. this.$request.baseRequest('post', '/commonRoute/api/edit', this.routeData).then(res => {
  211. if (res.code == 200) {
  212. this.$refs.uToast.show({
  213. type: 'success',
  214. message: "修改成功!",
  215. complete() {
  216. uni.$u.route("pages/mine/often/oftenRoute")
  217. }
  218. })
  219. }
  220. })
  221. .catch(res => {
  222. uni.$u.toast(res.message);
  223. });
  224. } else {
  225. this.$request.baseRequest('post', '/commonRoute/api/add', this.routeData).then(res => {
  226. if (res.code == 200) {
  227. this.$refs.uToast.show({
  228. type: 'success',
  229. message: "提交成功!",
  230. complete() {
  231. uni.$u.route("pages/mine/often/oftenRoute")
  232. }
  233. })
  234. }
  235. })
  236. .catch(res => {
  237. uni.$u.toast(res.message);
  238. });
  239. }
  240. },
  241. // regionChange1(value) {
  242. // this.sendregion = value
  243. // this.routeData.sendProvince = this.sendregion[0] == '请选择' ? '' : this.sendregion[0]
  244. // this.routeData.sendCity = this.sendregion[1] == '请选择' ? '' : this.sendregion[1]
  245. // this.routeData.sendArea = this.sendregion[2] == '请选择' ? '' : this.sendregion[2]
  246. // },
  247. // regionChange2(value) {
  248. // this.unloaddregion = value
  249. // this.routeData.unloadProvince = this.unloaddregion[0] == '请选择' ? '' : this.unloaddregion[0]
  250. // this.routeData.unloadCity = this.unloaddregion[1] == '请选择' ? '' : this.unloaddregion[1]
  251. // this.routeData.unloadArea = this.unloaddregion[2] == '请选择' ? '' : this.unloaddregion[2]
  252. // },
  253. // selecteRegion1(value) {
  254. // this.selections1 = value;
  255. // this.routeData.sendNum = this.selections1.toString()
  256. // },
  257. // selecteRegion2(value) {
  258. // this.selections2 = value;
  259. // this.routeData.unloadNum = this.selections2.toString()
  260. // },
  261. }
  262. }
  263. </script>
  264. <style lang="scss" scoped>
  265. .center {
  266. // width: 100%;
  267. padding: 30rpx;
  268. background: #F2F4F7;
  269. }
  270. .route_site{
  271. background: #FFFFFF;
  272. padding: 30rpx;
  273. border-radius: 20rpx;
  274. .out_site{
  275. border-bottom: 1px solid #E6E6E6;
  276. padding-bottom: 20rpx;
  277. }
  278. .in_site{
  279. margin-top: 30rpx;
  280. }
  281. .dot{
  282. display: inline-block;
  283. width: 16rpx;
  284. height: 16rpx;
  285. border-radius: 8rpx;
  286. margin: 20rpx 20rpx 0 0 ;
  287. }
  288. .blueDot{
  289. background: #2772FB;
  290. }
  291. .redDot{
  292. background: #FE6300;
  293. }
  294. .site_change{
  295. margin-top: 20rpx;
  296. text-align: center;
  297. line-height: 64rpx;
  298. border: 1px solid #CFCFCF;
  299. width: 158rpx;
  300. height: 64rpx;
  301. border-radius: 32rpx;
  302. margin-left: 30rpx;
  303. }
  304. .site{
  305. color: #2772FB;
  306. margin-top: 20rpx;
  307. margin-left: 30rpx;
  308. height: 64rpx;
  309. }
  310. }
  311. .text_css{
  312. margin-top: 20rpx;
  313. font-size: 26rpx;
  314. margin-left: 20rpx;
  315. }
  316. .form_css {
  317. width: 100%;
  318. display: flex;
  319. margin: 20rpx 0;
  320. height: 60rpx;
  321. border-bottom: 1px solid #eeeeee;
  322. .left-text {
  323. width: 50%;
  324. text-align: left;
  325. }
  326. .right-text {
  327. width: 50%;
  328. justify-content: flex-end;
  329. display: flex;
  330. text-align: right;
  331. }
  332. }
  333. .btn_css {
  334. margin-top: 300rpx;
  335. }
  336. </style>