addRoute.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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. this.routeData.commonId = uni.getStorageSync("userInfo").id
  192. let name = this.driverData.driverCall.slice(0, 1)
  193. this.routeData.driverNickname = name + "师傅"
  194. this.routeData.driverPortrait = this.avatarUrl
  195. if (this.id) {
  196. this.$request.baseRequest('post', '/commonRoute/api/edit', this.routeData).then(res => {
  197. if (res.code == 200) {
  198. this.$refs.uToast.show({
  199. type: 'success',
  200. message: "修改成功!",
  201. complete() {
  202. uni.$u.route("pages/mine/often/oftenRoute")
  203. }
  204. })
  205. }
  206. })
  207. .catch(res => {
  208. uni.$u.toast(res.message);
  209. });
  210. } else {
  211. this.$request.baseRequest('post', '/commonRoute/api/add', this.routeData).then(res => {
  212. if (res.code == 200) {
  213. this.$refs.uToast.show({
  214. type: 'success',
  215. message: "提交成功!",
  216. complete() {
  217. uni.$u.route("pages/mine/often/oftenRoute")
  218. }
  219. })
  220. }
  221. })
  222. .catch(res => {
  223. uni.$u.toast(res.message);
  224. });
  225. }
  226. },
  227. // regionChange1(value) {
  228. // this.sendregion = value
  229. // this.routeData.sendProvince = this.sendregion[0] == '请选择' ? '' : this.sendregion[0]
  230. // this.routeData.sendCity = this.sendregion[1] == '请选择' ? '' : this.sendregion[1]
  231. // this.routeData.sendArea = this.sendregion[2] == '请选择' ? '' : this.sendregion[2]
  232. // },
  233. // regionChange2(value) {
  234. // this.unloaddregion = value
  235. // this.routeData.unloadProvince = this.unloaddregion[0] == '请选择' ? '' : this.unloaddregion[0]
  236. // this.routeData.unloadCity = this.unloaddregion[1] == '请选择' ? '' : this.unloaddregion[1]
  237. // this.routeData.unloadArea = this.unloaddregion[2] == '请选择' ? '' : this.unloaddregion[2]
  238. // },
  239. // selecteRegion1(value) {
  240. // this.selections1 = value;
  241. // this.routeData.sendNum = this.selections1.toString()
  242. // },
  243. // selecteRegion2(value) {
  244. // this.selections2 = value;
  245. // this.routeData.unloadNum = this.selections2.toString()
  246. // },
  247. }
  248. }
  249. </script>
  250. <style lang="scss" scoped>
  251. .center {
  252. // width: 100%;
  253. padding: 30rpx;
  254. background: #F2F4F7;
  255. }
  256. .route_site{
  257. background: #FFFFFF;
  258. padding: 30rpx;
  259. border-radius: 20rpx;
  260. .out_site{
  261. border-bottom: 1px solid #E6E6E6;
  262. padding-bottom: 20rpx;
  263. }
  264. .in_site{
  265. margin-top: 30rpx;
  266. }
  267. .dot{
  268. display: inline-block;
  269. width: 16rpx;
  270. height: 16rpx;
  271. border-radius: 8rpx;
  272. margin: 20rpx 20rpx 0 0 ;
  273. }
  274. .blueDot{
  275. background: #2772FB;
  276. }
  277. .redDot{
  278. background: #FE6300;
  279. }
  280. .site_change{
  281. margin-top: 20rpx;
  282. text-align: center;
  283. line-height: 64rpx;
  284. border: 1px solid #CFCFCF;
  285. width: 158rpx;
  286. height: 64rpx;
  287. border-radius: 32rpx;
  288. margin-left: 30rpx;
  289. }
  290. .site{
  291. color: #2772FB;
  292. margin-top: 20rpx;
  293. margin-left: 30rpx;
  294. height: 64rpx;
  295. }
  296. }
  297. .text_css{
  298. margin-top: 20rpx;
  299. font-size: 26rpx;
  300. margin-left: 20rpx;
  301. }
  302. .form_css {
  303. width: 100%;
  304. display: flex;
  305. margin: 20rpx 0;
  306. height: 60rpx;
  307. border-bottom: 1px solid #eeeeee;
  308. .left-text {
  309. width: 50%;
  310. text-align: left;
  311. }
  312. .right-text {
  313. width: 50%;
  314. justify-content: flex-end;
  315. display: flex;
  316. text-align: right;
  317. }
  318. }
  319. .btn_css {
  320. margin-top: 300rpx;
  321. }
  322. </style>