addRoute.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <view class="center">
  3. <view class="flex row form_css">
  4. <view class="left-text">发货城市</view>
  5. <view class="right-text">
  6. <view @click="selectAddress(1)">{{title1 ? title1 : "请选择地址"}}</view>
  7. <itmister-address-picker ref="addressElone" @confirmChange="confirmChangeOne"></itmister-address-picker>
  8. </view>
  9. </view>
  10. <view class="flex row form_css">
  11. <view class="left-text">到货城市</view>
  12. <view class="right-text">
  13. <view @click="selectAddress(2)">{{title2 ? title2 : "请选择地址"}}</view>
  14. <!-- <Linkage @conceal="conceal2" class="flex" v-if="show2" ref="uDropdown"></Linkage> -->
  15. <itmister-address-picker ref="addressEltwo" @confirmChange="confirmChangeTwo"></itmister-address-picker>
  16. </view>
  17. </view>
  18. <view class="text_css">注:常用路线用于展示给其他司机和货主查看。</view>
  19. <view class="btn_css">
  20. <u-button type="primary" @click="submit">提交</u-button>
  21. </view>
  22. <u-toast ref="uToast"></u-toast>
  23. </view>
  24. </template>
  25. <script>
  26. // import regionPicker from "@/components/region/region-picker";
  27. // import Linkage from '@/components/gaojianghua-linkage/linkage.vue'
  28. import itmisterAddressPicker from '@/components/itmister-address-picker/itmister-address-picker.nvue'
  29. export default {
  30. components: {
  31. // regionPicker,
  32. // Linkage,
  33. itmisterAddressPicker
  34. },
  35. data() {
  36. return {
  37. id: "",
  38. routeData: {},
  39. // selections1: [],
  40. // selections2: [],
  41. driverData: {},
  42. avatarUrl: "",
  43. // sendregion: [],
  44. // unloaddregion: [],
  45. title1: "",
  46. title2: "",
  47. }
  48. },
  49. onShow() {},
  50. onLoad(options) {
  51. this.driverData = uni.getStorageSync('firstAuthentication')
  52. this.avatarUrl = uni.getStorageSync("userInfo").avatarUrl
  53. this.id = options.id
  54. if (this.id) { //修改
  55. uni.setNavigationBarTitle({
  56. title: '编辑路线'
  57. })
  58. this.getList()
  59. }
  60. },
  61. methods: {
  62. selectAddress(num) {
  63. if(num == 1){
  64. this.$refs.addressElone.show();
  65. }else{
  66. this.$refs.addressEltwo.show();
  67. }
  68. },
  69. // 确认选中
  70. confirmChangeOne(address) {
  71. this.routeData.sendProvince = address.province ? address.province : ''
  72. this.routeData.sendCity = address.city ? address.city : ''
  73. this.routeData.sendArea = address.area ? address.area : ''
  74. if(address.city == '全省'){
  75. this.title1 = address.province
  76. this.routeData.sendCity = ""
  77. this.routeData.sendArea = ""
  78. }else if(address.area == '全市'){
  79. this.title1 = address.province + address.city
  80. this.routeData.sendArea = ""
  81. }else{
  82. this.title1 = address.province + address.city + address.area;
  83. }
  84. },
  85. confirmChangeTwo(address) {
  86. this.routeData.unloadProvince = address.province ? address.province : ''
  87. this.routeData.unloadCity = address.city ? address.city : ''
  88. this.routeData.unloadArea = address.area ? address.area : ''
  89. if(address.city == '全省'){
  90. this.title2 = address.province
  91. this.routeData.unloadCity = ""
  92. this.routeData.unloadArea = ""
  93. }else if(address.area == '全市'){
  94. this.title2 = address.province + address.city
  95. this.routeData.unloadArea = ""
  96. }else{
  97. this.title2 = address.province + address.city + address.area;
  98. }
  99. },
  100. // conceal1(param) {
  101. // const {
  102. // chooseprovince,
  103. // choosecity,
  104. // choosearea
  105. // } = param
  106. // // 获取到传过来的 省 市 区 县数据
  107. // this.routeData.sendProvince = chooseprovince
  108. // this.routeData.sendCity = choosecity == '全部' ? "" : choosecity
  109. // this.routeData.sendArea = choosearea == '全部' ? "" : choosearea
  110. // this.title1 = chooseprovince + choosecity + choosearea
  111. // if (chooseprovince == '全国') {
  112. // this.succeed(1)
  113. // }
  114. // if (choosecity == '全部') {
  115. // this.succeed(1)
  116. // } else if (choosearea != '') {
  117. // this.succeed(1)
  118. // }
  119. // },
  120. // conceal2(param) {
  121. // const {
  122. // chooseprovince,
  123. // choosecity,
  124. // choosearea
  125. // } = param
  126. // // 获取到传过来的 省 市 区 县数据
  127. // this.routeData.unloadProvince = chooseprovince
  128. // this.routeData.unloadCity = choosecity == '全部' ? "" : choosecity
  129. // this.routeData.unloadArea = choosearea == '全部' ? "" : choosearea
  130. // this.title2 = chooseprovince + choosecity + choosearea
  131. // if (chooseprovince == '全国') {
  132. // this.succeed(2)
  133. // }
  134. // if (choosecity == '全部') {
  135. // this.succeed(2)
  136. // } else if (choosearea != '') {
  137. // this.succeed(2)
  138. // }
  139. // },
  140. //筛选框关闭
  141. // succeed(num) {
  142. // // this.$refs.uDropdown.close();
  143. // if (num == 1) {
  144. // this.show1 = false
  145. // } else if (num == 2) {
  146. // this.show2 = false
  147. // }
  148. // },
  149. getList() {
  150. this.$request.baseRequest('get', '/commonRoute/get', {
  151. id: this.id
  152. }).then(res => {
  153. if (res.code == 200) {
  154. this.routeData = res.data
  155. this.title1 = this.routeData.sendProvince + this.routeData.sendCity + this.routeData
  156. .sendArea
  157. this.title2 = this.routeData.unloadProvince + this.routeData.unloadCity + this.routeData
  158. .unloadArea
  159. }
  160. })
  161. .catch(res => {
  162. uni.$u.toast(res.message);
  163. });
  164. },
  165. submit() {
  166. this.routeData.commonId = uni.getStorageSync("userInfo").id
  167. let name = this.driverData.driverCall.slice(0, 1)
  168. this.routeData.driverNickname = name + "师傅"
  169. this.routeData.driverPortrait = this.avatarUrl
  170. if (this.id) {
  171. this.$request.baseRequest('post', '/commonRoute/api/edit', this.routeData).then(res => {
  172. if (res.code == 200) {
  173. this.$refs.uToast.show({
  174. type: 'success',
  175. message: "修改成功!",
  176. complete() {
  177. uni.$u.route("pages/mine/often/oftenRoute")
  178. }
  179. })
  180. }
  181. })
  182. .catch(res => {
  183. uni.$u.toast(res.message);
  184. });
  185. } else {
  186. this.$request.baseRequest('post', '/commonRoute/api/add', this.routeData).then(res => {
  187. if (res.code == 200) {
  188. this.$refs.uToast.show({
  189. type: 'success',
  190. message: "提交成功!",
  191. complete() {
  192. uni.$u.route("pages/mine/often/oftenRoute")
  193. }
  194. })
  195. }
  196. })
  197. .catch(res => {
  198. uni.$u.toast(res.message);
  199. });
  200. }
  201. },
  202. // regionChange1(value) {
  203. // this.sendregion = value
  204. // this.routeData.sendProvince = this.sendregion[0] == '请选择' ? '' : this.sendregion[0]
  205. // this.routeData.sendCity = this.sendregion[1] == '请选择' ? '' : this.sendregion[1]
  206. // this.routeData.sendArea = this.sendregion[2] == '请选择' ? '' : this.sendregion[2]
  207. // },
  208. // regionChange2(value) {
  209. // this.unloaddregion = value
  210. // this.routeData.unloadProvince = this.unloaddregion[0] == '请选择' ? '' : this.unloaddregion[0]
  211. // this.routeData.unloadCity = this.unloaddregion[1] == '请选择' ? '' : this.unloaddregion[1]
  212. // this.routeData.unloadArea = this.unloaddregion[2] == '请选择' ? '' : this.unloaddregion[2]
  213. // },
  214. // selecteRegion1(value) {
  215. // this.selections1 = value;
  216. // this.routeData.sendNum = this.selections1.toString()
  217. // },
  218. // selecteRegion2(value) {
  219. // this.selections2 = value;
  220. // this.routeData.unloadNum = this.selections2.toString()
  221. // },
  222. }
  223. }
  224. </script>
  225. <style lang="scss" scoped>
  226. .center {
  227. // width: 100%;
  228. padding: 30rpx;
  229. }
  230. .form_css {
  231. width: 100%;
  232. display: flex;
  233. margin: 20rpx 0;
  234. height: 60rpx;
  235. border-bottom: 1px solid #eeeeee;
  236. .left-text {
  237. width: 50%;
  238. text-align: left;
  239. }
  240. .right-text {
  241. width: 50%;
  242. justify-content: flex-end;
  243. display: flex;
  244. text-align: right;
  245. }
  246. }
  247. .btn_css {
  248. margin-top: 300rpx;
  249. }
  250. </style>