publish.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <view>
  3. <view class="plr-36 flex">
  4. <view class="u-flex-1">
  5. <view class="flex ptb-40">
  6. <view class="center flex-column">
  7. <view style="width: 28rpx;height: 28rpx;background: #6340FF;border-radius: 50%;"></view>
  8. <view class="mt-10">
  9. 起点
  10. </view>
  11. </view>
  12. <view class="input ml-30 u-flex-1 ptb-12 plr-20" style="border: 1rpx solid #ddd;" @click="goSearch(1)">
  13. <input type="text" v-model="start.city+'--'+start.name" placeholder="请选择起点" :disabled="true" v-if="start.address" />
  14. <text class="gray-2 size-28" v-else>请选择起点</text>
  15. </view>
  16. </view>
  17. <view class="flex pb-40">
  18. <view class="center flex-column">
  19. <view style="width: 28rpx;height: 28rpx;background: #EA0000;border-radius: 50%;"></view>
  20. <view class="mt-10">
  21. 终点
  22. </view>
  23. </view>
  24. <view class="input ml-30 u-flex-1 ptb-12 plr-20" style="border: 1rpx solid #ddd;" @click="goSearch(2)">
  25. <input type="text" v-model="end.city+'--'+end.name" placeholder="请选择终点" :disabled="true" v-if="end.address" />
  26. <text class="gray-2 size-28" v-else>请选择终点</text>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="img plr-20" @click="change">
  31. <image src="../../static/pub-switching.png" mode=""></image>
  32. </view>
  33. </view>
  34. <u-field class=" textarea" type="textarea" :clearable="false" v-model="line" label-width="140" label="路线" placeholder="请输入路线">
  35. <view slot="icon" class="icon flex1 mr-20">
  36. <image src="../../static/pub-icon-1.png" mode=""></image>
  37. </view>
  38. </u-field>
  39. <u-field class="" v-model="time" label-width="140" label="时间" :disabled="true" placeholder="请选择出发时间" @click="showTime=true">
  40. <view slot="icon" class="icon flex mr-20">
  41. <image src="../../static/pub-icon-2.png" mode=""></image>
  42. </view>
  43. </u-field>
  44. <u-field class="" v-model="model" label-width="140" label="车型" placeholder="例: 大众朗逸">
  45. <view slot="icon" class="icon flex mr-20">
  46. <image src="../../static/pub-icon-3.png" mode=""></image>
  47. </view>
  48. </u-field>
  49. <u-field class="" v-model="seat" label-width="140" label="余座" :disabled="true" placeholder="请选择余座" @click="show=true">
  50. <view slot="icon" class="icon flex mr-20">
  51. <image src="../../static/pub-icon-4.png" mode=""></image>
  52. </view>
  53. </u-field>
  54. <u-field class="" v-model="price" label-width="140" label="A费" placeholder="例: 30元/座">
  55. <view slot="icon" class="icon flex mr-20">
  56. <image src="../../static/pub-icon-5.png" mode=""></image>
  57. </view>
  58. </u-field>
  59. <u-field class="" v-model="mark" label-width="140" label="备注" placeholder="请填写备注">
  60. <view slot="icon" class="icon flex mr-20">
  61. <image src="../../static/pub-icon-6.png" mode=""></image>
  62. </view>
  63. </u-field>
  64. <view class="plr-36 flex1 flex-middle mt-40 mb-40">
  65. <view class="radio center">
  66. <view class="radio-circle">
  67. </view>
  68. </view>
  69. <view class="size-26 ml-10">
  70. 我已阅读并同意<text class="blue" @click="goDetail">《合乘协议》</text>
  71. </view>
  72. </view>
  73. <u-button class="mt-30" :disabled="!line || !time || !model || !seat || !price || !mark" type="primary" @click="submit">发布出行信息</u-button>
  74. <!-- 选择时间 -->
  75. <u-popup v-model="showTime" mode="bottom" height="400" @close="$emit('close')">
  76. <longDate type="day" :openStatus="true" :getDayNum="7" :chooesMaxDay="7" @select="onSelectTime">
  77. </longDate>
  78. </u-popup>
  79. <!-- 选择座位 -->
  80. <u-select v-model="show" :list="list" @confirm="confirm"></u-select>
  81. <!-- 弹出提示 -->
  82. <u-modal v-model="showModal" :content="content" :show-title="false" :show-cancel-button="true" :confirm-text="confirmText" @confirm="goOwner"></u-modal>
  83. </view>
  84. </template>
  85. <script>
  86. import {
  87. mapState
  88. } from 'vuex'
  89. import longDate from '../../components/long-date/long-date.vue'
  90. export default {
  91. data() {
  92. return {
  93. line: '',
  94. time: '',
  95. model: '',
  96. seat: '',
  97. price: '',
  98. mark: '顺路上下,预订后电话确认一下',
  99. showTime: false,
  100. show:false,
  101. list:[{
  102. value:1,
  103. label:'1座'
  104. },
  105. {
  106. value:2,
  107. label:'2座'
  108. },
  109. {
  110. value:3,
  111. label:'3座'
  112. },
  113. {
  114. value:4,
  115. label:'4座'
  116. },
  117. {
  118. value:5,
  119. label:'5座'
  120. },
  121. {
  122. value:6,
  123. label:'6座'
  124. },
  125. {
  126. value:7,
  127. label:'7座'
  128. }],
  129. showModal: false,
  130. content:'',
  131. confirmText:''
  132. };
  133. },
  134. components:{
  135. longDate
  136. },
  137. computed: {
  138. ...mapState(['start', 'end','userInfo']),
  139. },
  140. onShow() {
  141. if(this.userInfo.card_verified == 2){
  142. this.showModal = true
  143. this.confirmText = '确认'
  144. this.content = '您的车主认证正在审核中,请耐心等待审核通过之后才能发布订单'
  145. }else if(this.userInfo.card_verified != 1){
  146. this.showModal = true
  147. this.confirmText = '去认证'
  148. this.content = '请先进行车主认证之后,才能发布订单'
  149. }
  150. this.model = this.userInfo.card_type
  151. this.getLine()
  152. },
  153. methods: {
  154. //合乘协议
  155. goDetail(){
  156. uni.navigateTo({
  157. url:'/pages/my/help/details?id=16'
  158. })
  159. },
  160. // 切换起点和终点
  161. change(){
  162. let start = this.start
  163. let end = this.end
  164. this.$store.commit('getStart', end)
  165. this.$store.commit('getEnd', start)
  166. this.getLine()
  167. },
  168. // 获取路线
  169. getLine(){
  170. if(this.start.address && this.end.address ){
  171. this.line = this.start.name + '出发,X 站上车,X站下车,目的地:' + this.end.name
  172. }
  173. },
  174. goSearch(i) {
  175. uni.navigateTo({
  176. url: '/pages/shunfeng/search?type=' + i
  177. })
  178. },
  179. // 确定时间
  180. onSelectTime(res) {
  181. console.log(res);
  182. if (res.tip) {
  183. uni.showToast({
  184. title: res.tip,
  185. icon: 'none'
  186. })
  187. } else {
  188. this.time = res.time
  189. this.showTime = false
  190. }
  191. },
  192. // 选择余座
  193. confirm(e){
  194. console.log(e);
  195. this.seat = e[0].value
  196. },
  197. // 去车主认证
  198. goOwner(){
  199. if(this.userInfo.card_verified !=2 && this.userInfo.card_verified !=1){
  200. uni.navigateTo({
  201. url:'/pages/my/owner/index'
  202. })
  203. }
  204. },
  205. submit() {
  206. let arr = []
  207. arr.push(this.time.split(' ')[0].split('-')[0],this.time.split(' ')[0].split('-')[1]-1,this.time.split(' ')[0].split('-')[2])
  208. let t = new Date(...(arr),...(this.time.split(' ')[1].split(':')),"00");
  209. let time = parseInt(t.getTime()/1000)
  210. this.$http('/addons/ddrive/sforder/ddriver_create',{
  211. start_address: this.start.district + this.start.address + this.start.name,
  212. start_name:this.start.name,
  213. end_address: this.end.district + this.end.address + this.end.name,
  214. end_name:this.end.name,
  215. order_type: 2,
  216. route: this.line,
  217. start_time: time,
  218. car_type: this.model,
  219. more_seats: this.seat,
  220. car_price: this.price,
  221. remark: this.mark,
  222. start_city: this.start.city,
  223. end_city: this.end.city,
  224. people_num:'',
  225. start_latitude: this.start.latitude,
  226. start_longitude:this.start.longitude,
  227. end_latitude:this.end.latitude,
  228. end_longitude:this.end.longitude
  229. },"POST").then(data=>{
  230. uni.showToast({
  231. title:'发布成功'
  232. })
  233. setTimeout(()=>{
  234. uni.redirectTo({
  235. url:'/pages/shunfeng/pub-list'
  236. })
  237. },1500)
  238. })
  239. }
  240. }
  241. }
  242. </script>
  243. <style lang="scss" scoped>
  244. /deep/.u-primary-hover {
  245. background-color: $blue !important;
  246. }
  247. /deep/.u-btn--primary--disabled {
  248. background-color: $bg-1 !important;
  249. }
  250. /deep/.u-field {
  251. margin: 0 34rpx !important;
  252. padding: 26rpx 0 !important;
  253. }
  254. /deep/.u-field .u-label-text {
  255. font-weight: 400 !important;
  256. }
  257. .textarea{
  258. /deep/.fild-body {
  259. margin-top: 10rpx;
  260. }
  261. }
  262. .input {
  263. input {
  264. font-size: 28rpx;
  265. }
  266. }
  267. .img {
  268. image {
  269. width: 34rpx;
  270. height: 34rpx;
  271. }
  272. }
  273. .icon {
  274. image {
  275. width: 50rpx;
  276. height: 50rpx;
  277. }
  278. }
  279. .radio {
  280. width: 30rpx;
  281. height: 30rpx;
  282. border-radius: 50%;
  283. border: 1rpx solid #999;
  284. .radio-circle {
  285. width: 22rpx;
  286. height: 22rpx;
  287. background: $blue;
  288. border-radius: 50%;
  289. }
  290. }
  291. </style>