addRoute.vue 6.2 KB

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