trust.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002
  1. <template>
  2. <view class="container">
  3. <scroll-view scroll-x class="nav">
  4. <view class="flex text-center">
  5. <view class="cu-item flex-sub" :class="0==TabCur?'text-white':''" @tap="tabSelect" data-id="0">
  6. <text>我要卖粮</text>
  7. </view>
  8. <view class="cu-item flex-sub" :class="1==TabCur?'text-white':''" @tap="tabSelect" data-id="1">
  9. <text>我要买粮</text>
  10. </view>
  11. <view v-if="showTran" class="cu-item flex-sub" :class="2==TabCur?'text-white':''" @tap="tabSelect" data-id="2">
  12. <text>我要找车</text>
  13. </view>
  14. <view v-if="showTran" class="cu-item flex-sub" :class="3==TabCur?'text-white':''" @tap="tabSelect" data-id="3">
  15. <text>我要找货</text>
  16. </view>
  17. </view>
  18. </scroll-view>
  19. <block v-if="TabCur==0">
  20. <view class="cu-form-group">
  21. <view class="title">卖方</view>
  22. <input placeholder="请填写" name="input" @input="sellerInput"></input>
  23. </view>
  24. <view class="cu-form-group">
  25. <view class="title">卖方电话</view>
  26. <input placeholder="请填写" type="mobile" name="input" @input="sellerPhoneInput"></input>
  27. </view>
  28. <view class="cu-form-group">
  29. <view class="title">验证码</view>
  30. <input type="mobile" value="" placeholder="6位验证码" maxlength="6"
  31. data-key="verifyCode" @input="verifyCodeInput" style="width: 60%;"></input>
  32. <button class='cu-btn bg-green shadow':disabled="sendDisabled0" @click="doGetVerify">{{sendText0}}</button>
  33. </view>
  34. <view class="cu-form-group">
  35. <view class="title">货名</view>
  36. <input placeholder="请填写" name="input" @input="goodsNameInput"></input>
  37. </view>
  38. <view class="cu-form-group ">
  39. <view class="title">价格类型</view>
  40. <picker @change="PriceTypeChange" :value="priceTypeIndex" :range="priceType">
  41. <view class="picker">
  42. {{priceTypeIndex>-1?priceType[priceTypeIndex]:'请选择'}}
  43. </view>
  44. </picker>
  45. </view>
  46. <view class="cu-form-group">
  47. <view class="title">协议单价(元/吨)</view>
  48. <input placeholder="请填写" type="mobile" name="input" @input="unitPriceInput"></input>
  49. </view>
  50. <view class="cu-form-group">
  51. <view class="title">产地</view>
  52. <input placeholder="请填写" name="input" @input="originInput"></input>
  53. </view>
  54. <view class="cu-form-group">
  55. <view class="title">库存地</view>
  56. <input placeholder="请填写" name="input" @input="stockInput"></input>
  57. </view>
  58. <view class="cu-form-group">
  59. <view class="title">最小成交量</view>
  60. <input placeholder="请填写" type="mobile" name="input" @input="minSaleInput"></input>
  61. </view>
  62. <view class="cu-form-group">
  63. <view class="title">库存量</view>
  64. <input placeholder="请填写" type="mobile" name="input" @input="exsitCountInput"></input>
  65. </view>
  66. <view class="cu-form-group">
  67. <view class="title">国标等级</view>
  68. <input placeholder="请填写" name="input" @input="levelInput"></input>
  69. </view>
  70. <view class="padding flex flex-direction">
  71. <button class="cu-btn commit margin-tb-sm lg" @click="commit">提交</button>
  72. </view>
  73. </block>
  74. <block v-if="TabCur==1">
  75. <view class="cu-form-group">
  76. <view class="title">买方</view>
  77. <input placeholder="请填写" name="input" @input="buyerInput"></input>
  78. </view>
  79. <view class="cu-form-group">
  80. <view class="title">买方电话</view>
  81. <input placeholder="请填写" type="mobile" name="input" @input="buyerPhoneInput"></input>
  82. </view>
  83. <view class="cu-form-group">
  84. <view class="title">验证码</view>
  85. <input type="mobile" value="" placeholder="6位验证码" maxlength="6"
  86. data-key="verifyCode" @input="verifyCodeInput" style="width: 60%;"></input>
  87. <button class='cu-btn bg-green shadow':disabled="sendDisabled1" @click="doGetVerify">{{sendText1}}</button>
  88. </view>
  89. <view class="cu-form-group">
  90. <view class="title">货名</view>
  91. <input placeholder="请填写" name="input" @input="goodsNameInput"></input>
  92. </view>
  93. <view class="cu-form-group margin-top">
  94. <view class="title">价格类型</view>
  95. <picker @change="PriceTypeChange" :value="priceTypeIndex" :range="priceType">
  96. <view class="picker">
  97. {{priceTypeIndex>-1?priceType[priceTypeIndex]:'请选择'}}
  98. </view>
  99. </picker>
  100. </view>
  101. <view class="cu-form-group">
  102. <view class="title">协议单价(元/吨)</view>
  103. <input placeholder="请填写" type="mobile" name="input" @input="unitPriceInput"></input>
  104. </view>
  105. <view class="cu-form-group">
  106. <view class="title">产地</view>
  107. <input placeholder="请填写" name="input" @input="originInput"></input>
  108. </view>
  109. <view class="cu-form-group">
  110. <view class="title">库存地</view>
  111. <input placeholder="请填写" name="input" @input="stockInput"></input>
  112. </view>
  113. <view class="cu-form-group">
  114. <view class="title">采购量</view>
  115. <input placeholder="请填写" type="mobile" name="input" @input="exsitCountInput"></input>
  116. </view>
  117. <view class="cu-form-group">
  118. <view class="title">国标等级</view>
  119. <input placeholder="请填写" name="input" @input="levelInput"></input>
  120. </view>
  121. <view class="padding flex flex-direction">
  122. <button class="cu-btn commit margin-tb-sm lg" @click="commit">提交</button>
  123. </view>
  124. </block>
  125. <block v-if="TabCur==2">
  126. <view class="cu-form-group">
  127. <view class="title">始发地</view>
  128. <input placeholder="请填写" name="input" @input="startPlaceInput"></input>
  129. </view>
  130. <view class="cu-form-group">
  131. <view class="title">目的地</view>
  132. <input placeholder="请填写" name="input" @input="endPlaceInput"></input>
  133. </view>
  134. <view class="cu-form-group">
  135. <view class="title">货名</view>
  136. <input placeholder="请填写" name="input" @input="goodsNameInput"></input>
  137. </view>
  138. <view class="cu-form-group">
  139. <view class="title">总吨数</view>
  140. <input placeholder="请填写" type="mobile" name="input" @input="totalInput"></input>
  141. </view>
  142. <view class="cu-form-group">
  143. <view class="title">价格(元/吨)</view>
  144. <input placeholder="请填写" type="mobile" name="input" @input="priceInput"></input>
  145. </view>
  146. <view class="cu-form-group">
  147. <view class="title">发货人</view>
  148. <input placeholder="请填写" name="input" @input="senderInput"></input>
  149. </view>
  150. <view class="cu-form-group">
  151. <view class="title">发货人电话</view>
  152. <input placeholder="请填写" name="input" @input="senderPhoneInput"></input>
  153. </view>
  154. <view class="cu-form-group">
  155. <view class="title">验证码</view>
  156. <input type="mobile" value="" placeholder="6位验证码" maxlength="6"
  157. data-key="verifyCode" @input="verifyCodeInput" style="width: 60%;"></input>
  158. <button class='cu-btn bg-green shadow':disabled="sendDisabled2" @click="doGetVerify">{{sendText2}}</button>
  159. </view>
  160. <view class="cu-form-group">
  161. <view class="title">收货人</view>
  162. <input placeholder="请填写" name="input" @input="receiverInput"></input>
  163. </view>
  164. <view class="cu-form-group">
  165. <view class="title">收货人电话</view>
  166. <input placeholder="请填写" name="input" @input="receiverPhoneInput"></input>
  167. </view>
  168. <view class="padding flex flex-direction">
  169. <button class="cu-btn commit margin-tb-sm lg" @click="commit">提交</button>
  170. </view>
  171. </block>
  172. <block v-if="TabCur==3">
  173. <view class="cu-form-group">
  174. <view class="title">始发地</view>
  175. <input placeholder="请填写" name="input" @input="startPlaceInput"></input>
  176. </view>
  177. <view class="cu-form-group">
  178. <view class="title">目的地</view>
  179. <input placeholder="请填写" name="input" @input="endPlaceInput"></input>
  180. </view>
  181. <view class="cu-form-group">
  182. <view class="title">运价(元)</view>
  183. <input placeholder="请填写" name="input" @input="priceInput"></input>
  184. </view>
  185. <view class="cu-form-group">
  186. <view class="title">车牌号</view>
  187. <input placeholder="请填写" name="input" @input="carNoInput"></input>
  188. </view>
  189. <view class="cu-form-group">
  190. <view class="title">承运人</view>
  191. <input placeholder="请填写" type="mobile" name="input" @input="driverInput"></input>
  192. </view>
  193. <view class="cu-form-group">
  194. <view class="title">承运人电话</view>
  195. <input placeholder="请填写" type="mobile" name="input" @input="driverPhoneInput"></input>
  196. </view>
  197. <view class="cu-form-group"> <view class="title">验证码</view> <input type="mobile" value="" placeholder="6位验证码" maxlength="6" data-key="verifyCode" @input="verifyCodeInput" style="width: 60%;"></input> <button class='cu-btn bg-green shadow':disabled="sendDisabled3" @click="doGetVerify">{{sendText3}}</button> </view>
  198. <view class="cu-bar bg-white margin-top">
  199. <view class="action">
  200. 司机身份证(正、反面)上传
  201. </view>
  202. </view>
  203. <view class="cu-form-group">
  204. <view class="grid col-4 grid-square flex-sub">
  205. <view class="bg-img" v-if="personNoImg != ''" @tap="ViewImage" :data-url="personNoImg">
  206. <image :src="personNoImg" mode="aspectFit"></image>
  207. <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="0">
  208. <text class='cuIcon-close'></text>
  209. </view>
  210. </view>
  211. <view class="bg-img" v-if="personNoImg1 != ''" @tap="ViewImage" :data-url="personNoImg1">
  212. <image :src="personNoImg1" mode="aspectFit"></image>
  213. <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="1">
  214. <text class='cuIcon-close'></text>
  215. </view>
  216. </view>
  217. <view class="solids" @tap="ChooseImagePerson" v-if="personNoImg == '' || personNoImg1 == ''">
  218. <text class='cuIcon-cameraadd'></text>
  219. </view>
  220. </view>
  221. </view>
  222. <view class="cu-bar bg-white margin-top">
  223. <view class="action">
  224. 司机驾驶证(主页、副页)上传
  225. </view>
  226. </view>
  227. <view class="cu-form-group">
  228. <view class="grid col-4 grid-square flex-sub">
  229. <view class="bg-img" v-if="driverNoImg != ''" @tap="ViewImage" :data-url="driverNoImg">
  230. <image :src="driverNoImg" mode="aspectFit"></image>
  231. <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="2">
  232. <text class='cuIcon-close'></text>
  233. </view>
  234. </view>
  235. <view class="bg-img" v-if="driverNoImg1 != ''" @tap="ViewImage" :data-url="driverNoImg1">
  236. <image :src="driverNoImg1" mode="aspectFit"></image>
  237. <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="3">
  238. <text class='cuIcon-close'></text>
  239. </view>
  240. </view>
  241. <view class="solids" @tap="ChooseImageDriver" v-if="driverNoImg == '' || driverNoImg1 == ''">
  242. <text class='cuIcon-cameraadd'></text>
  243. </view>
  244. </view>
  245. </view>
  246. <view class="cu-bar bg-white margin-top">
  247. <view class="action">
  248. 行车证(主页、副页)上传
  249. </view>
  250. </view>
  251. <view class="cu-form-group">
  252. <view class="grid col-4 grid-square flex-sub">
  253. <view class="bg-img" v-if="carNoImg != ''" @tap="ViewImage" :data-url="carNoImg">
  254. <image :src="carNoImg" mode="aspectFit"></image>
  255. <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="4">
  256. <text class='cuIcon-close'></text>
  257. </view>
  258. </view>
  259. <view class="bg-img" v-if="carNoImg1 != ''" @tap="ViewImage" :data-url="carNoImg1">
  260. <image :src="carNoImg1" mode="aspectFit"></image>
  261. <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="5">
  262. <text class='cuIcon-close'></text>
  263. </view>
  264. </view>
  265. <view class="solids" @tap="ChooseImageCar" v-if="carNoImg == '' || carNoImg1 == ''">
  266. <text class='cuIcon-cameraadd'></text>
  267. </view>
  268. </view>
  269. </view>
  270. <view class="padding flex flex-direction">
  271. <button class="cu-btn commit margin-tb-sm lg" @click="commit">提交</button>
  272. </view>
  273. </block>
  274. </view>
  275. </template>
  276. <script>
  277. import uploadImage from '@/components/ossutil/uploadFile.js';
  278. import {
  279. mapState
  280. } from 'vuex';
  281. export default {
  282. name: "trust",
  283. data() {
  284. return {
  285. saleInfo:{
  286. seller:'',
  287. sellerPhone:'',
  288. priceType:'',
  289. unitPrice:0,
  290. origin:'',
  291. stock:'',
  292. minSale:0,
  293. exsitCount:0,
  294. goodsName:'',
  295. verifyCode:'',
  296. buyer:'',
  297. buyerPhone:'',
  298. level:''
  299. },
  300. tran: {
  301. total: 0,
  302. price: 0,
  303. startPlace: undefined,
  304. endPlace: undefined,
  305. goodsName: undefined,
  306. sender:'',
  307. senderPhone:'',
  308. status:0,
  309. receiver:'',
  310. receiverPhone:'',
  311. verifyCode:'',
  312. driver:'',
  313. driverPhone:'',
  314. carNo:'',
  315. personNoImg:'',
  316. personNoImg1:'',
  317. driverNoImg:'',
  318. driverNoImg1:'',
  319. carNoImg:'',
  320. carNoImg1:''
  321. },
  322. PageCur: "trust",
  323. TabCur: 0,
  324. priceTypeIndex:-1,
  325. priceType: ['库内价', '到库价', '到港价'],
  326. unitPrice:0,
  327. price:'',
  328. seller:'',
  329. sellerPhone:'',
  330. minSale:'',
  331. exsitCount:0,
  332. origin:'',
  333. stock:'',
  334. goodsName:'',
  335. verifyCode:'',
  336. sendText0:'获取验证码',
  337. sendText1:'获取验证码',
  338. sendText2:'获取验证码',
  339. sendText3:'获取验证码',
  340. sendDisabled0: false,
  341. sendDisabled1: false,
  342. sendDisabled2: false,
  343. sendDisabled3: false,
  344. buyer:'',
  345. buyerPhone:'',
  346. level:'',
  347. sender:'',
  348. senderPhone:'',
  349. receiver:'',
  350. receiverPhone:'',
  351. total:0,
  352. startPlace:'',
  353. endPlace:'',
  354. driver:'',
  355. driverPhone:'',
  356. carNo:'',
  357. personNoImg:'',
  358. personNoImg1:'',
  359. driverNoImg:'',
  360. driverNoImg1:'',
  361. carNoImg:'',
  362. carNoImg1:'',
  363. showTran:true
  364. };
  365. },
  366. computed: {
  367. ...mapState(['hasLogin','userInfo'])
  368. },
  369. onShow() {
  370. this.loadData()
  371. },
  372. methods: {
  373. async loadData(){
  374. if (!this.hasLogin) {
  375. uni.showModal({
  376. title: '登录提示',
  377. content: '您尚未登录,是否立即登录?',
  378. showCancel: true,
  379. confirmText: '登录',
  380. success: (e) => {
  381. if (e.confirm) {
  382. uni.navigateTo({
  383. url: '/pages/public/login'
  384. })
  385. }
  386. },
  387. fail: () => {},
  388. complete: () => {}
  389. })
  390. }
  391. },
  392. driverInput(e) {
  393. this.driver = e.detail.value
  394. },
  395. driverPhoneInput(e) {
  396. this.driverPhone = e.detail.value
  397. },
  398. carNoInput(e) {
  399. this.carNo = e.detail.value
  400. },
  401. senderInput(e){
  402. this.sender = e.detail.value;
  403. },
  404. senderPhoneInput(e){
  405. this.senderPhone = e.detail.value;
  406. },
  407. receiverInput(e){
  408. this.receiver = e.detail.value;
  409. },
  410. receiverPhoneInput(e){
  411. this.receiverPhone = e.detail.value;
  412. },
  413. startPlaceInput(e){
  414. this.startPlace = e.detail.value;
  415. },
  416. endPlaceInput(e){
  417. this.endPlace = e.detail.value;
  418. },
  419. totalInput(e){
  420. this.total = e.detail.value;
  421. },
  422. priceInput(e){
  423. this.price = e.detail.value;
  424. },
  425. tabSelect(e) {
  426. this.TabCur = e.currentTarget.dataset.id;
  427. },
  428. PriceTypeChange(e) {
  429. this.priceTypeIndex = e.detail.value
  430. this.price = this.priceType[this.priceTypeIndex]
  431. },
  432. RegionChange(e) {
  433. this.region = e.detail.value
  434. this.province = this.region[0];
  435. this.area = this.region[0]+this.region[1]+this.region[2];
  436. },
  437. sellerInput(e){
  438. this.seller = e.detail.value
  439. },
  440. sellerPhoneInput(e){
  441. this.sellerPhone = e.detail.value
  442. },
  443. buyerInput(e){
  444. this.buyer = e.detail.value
  445. },
  446. buyerPhoneInput(e){
  447. this.buyerPhone = e.detail.value
  448. },
  449. unitPriceInput(e){
  450. this.unitPrice = e.detail.value
  451. },
  452. minSaleInput(e){
  453. this.minSale = e.detail.value
  454. },
  455. exsitCountInput(e){
  456. this.exsitCount = e.detail.value
  457. },
  458. originInput(e){
  459. this.origin = e.detail.value
  460. },
  461. stockInput(e){
  462. this.stock = e.detail.value
  463. },
  464. goodsNameInput(e){
  465. this.goodsName = e.detail.value
  466. },
  467. verifyCodeInput(e){
  468. this.verifyCode = e.detail.value
  469. },
  470. levelInput(e){
  471. this.level = e.detail.value
  472. },
  473. doGetVerify() {
  474. const that = this
  475. var phone = "";
  476. if(this.TabCur == 0){
  477. phone = that.sellerPhone
  478. }else if(this.TabCur == 1){
  479. phone = that.buyerPhone
  480. }
  481. else if(this.TabCur == 2){
  482. phone = that.senderPhone
  483. }
  484. else if(this.TabCur == 3){
  485. phone = that.driverPhone
  486. }
  487. if (!phone || phone.length != 11) {
  488. uni.showToast({
  489. title:'请输入正确手机号!',
  490. icon:'none'
  491. })
  492. return
  493. }
  494. that.$api.request('user', 'sendVerifyCode', {
  495. phone: phone,
  496. }).then(res => {
  497. if(that.TabCur == 0){
  498. that.sendDisabled0 = true
  499. }else if(that.TabCur == 1){
  500. that.sendDisabled1 = true
  501. }
  502. else if(that.TabCur == 2){
  503. that.sendDisabled2 = true
  504. }
  505. else if(that.TabCur == 3){
  506. that.sendDisabled3 = true
  507. }
  508. let sec = 60
  509. let interval = setInterval(() => {
  510. sec--;
  511. if(that.TabCur == 0){
  512. that.sendText0 = sec + 's后重发'
  513. if (sec <= 0) {
  514. that.sendDisabled0 = false
  515. that.sendText0 = "获取验证码"
  516. clearInterval(interval)
  517. }
  518. }else if(that.TabCur == 1){
  519. that.sendText1 = sec + 's后重发'
  520. if (sec <= 0) {
  521. that.sendDisabled1 = false
  522. that.sendText1 = "获取验证码"
  523. clearInterval(interval)
  524. }
  525. }
  526. else if(that.TabCur == 2){
  527. that.sendText2 = sec + 's后重发'
  528. if (sec <= 0) {
  529. that.sendDisabled2 = false
  530. that.sendText2 = "获取验证码"
  531. clearInterval(interval)
  532. }
  533. }
  534. else if(that.TabCur == 3){
  535. that.sendText3 = sec + 's后重发'
  536. if (sec <= 0) {
  537. that.sendDisabled3 = false
  538. that.sendText3 = "获取验证码"
  539. clearInterval(interval)
  540. }
  541. }
  542. }, 1000)
  543. })
  544. },
  545. ChooseImagePerson() {
  546. uni.chooseImage({
  547. count: 1, //默认9
  548. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  549. sourceType: ['album','camera'], //从相册选择
  550. success: (res) => {
  551. //上传图片
  552. //图片路径可自行修改
  553. uploadImage(res.tempFilePaths[0], 'personNoImg/',
  554. result => {
  555. if (this.personNoImg.length != 0) {
  556. this.personNoImg1 = result
  557. } else {
  558. this.personNoImg = result
  559. }
  560. uni.hideLoading();
  561. }
  562. )
  563. }
  564. });
  565. },
  566. ChooseImageDriver() {
  567. uni.chooseImage({
  568. count: 1, //默认9
  569. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  570. sourceType: ['album','camera'], //从相册选择
  571. success: (res) => {
  572. //上传图片
  573. //图片路径可自行修改
  574. uploadImage(res.tempFilePaths[0], 'driverNoImg/',
  575. result => {
  576. if (this.driverNoImg.length != 0) {
  577. this.driverNoImg1 = result
  578. } else {
  579. this.driverNoImg = result
  580. }
  581. uni.hideLoading();
  582. }
  583. )
  584. }
  585. });
  586. },
  587. ChooseImageCar() {
  588. uni.chooseImage({
  589. count: 1, //默认9
  590. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  591. sourceType: ['album','camera'], //从相册选择
  592. success: (res) => {
  593. //上传图片
  594. //图片路径可自行修改
  595. uploadImage(res.tempFilePaths[0], 'carNoImg/',
  596. result => {
  597. if (this.carNoImg.length != 0) {
  598. this.carNoImg1 = result
  599. } else {
  600. this.carNoImg = result
  601. }
  602. uni.hideLoading();
  603. }
  604. )
  605. }
  606. });
  607. },
  608. ViewImage(e) {
  609. var img = [];
  610. img = e.currentTarget.dataset.url.split(' ')
  611. uni.previewImage({
  612. current:0,
  613. urls: img
  614. });
  615. },
  616. DelImg(e) {
  617. uni.showModal({
  618. title: '提示',
  619. content: '确定要删除该照片吗?',
  620. cancelText: '取消',
  621. confirmText: '确定',
  622. success: res => {
  623. if (res.confirm) {
  624. if(e.currentTarget.dataset.index == 0){
  625. this.personNoImg = "";
  626. }
  627. else if(e.currentTarget.dataset.index == 1){
  628. this.personNoImg1 = "";
  629. }
  630. else if(e.currentTarget.dataset.index == 2){
  631. this.driverNoImg = "";
  632. }
  633. else if(e.currentTarget.dataset.index == 3){
  634. this.driverNoImg1 = "";
  635. }
  636. else if(e.currentTarget.dataset.index == 4){
  637. this.carNoImg = "";
  638. }
  639. else if(e.currentTarget.dataset.index == 5){
  640. this.carNoImg1 = "";
  641. }
  642. }
  643. }
  644. })
  645. },
  646. commit(){
  647. if (!this.hasLogin) {
  648. uni.showModal({
  649. title: '登录提示',
  650. content: '您尚未登录,是否立即登录?',
  651. showCancel: true,
  652. confirmText: '登录',
  653. success: (e) => {
  654. if (e.confirm) {
  655. uni.navigateTo({
  656. url: '/pages/public/login'
  657. })
  658. }
  659. },
  660. fail: () => {},
  661. complete: () => {}
  662. })
  663. }
  664. else{
  665. const that = this
  666. if(this.TabCur == 0){
  667. if(!that.seller){
  668. this.$api.msg('请填写卖方');
  669. return;
  670. }
  671. if(!that.sellerPhone){
  672. this.$api.msg('请填写手机号码');
  673. return;
  674. }
  675. if(!that.exsitCount){
  676. this.$api.msg('请填写库存量');
  677. return;
  678. }
  679. if(!that.minSale){
  680. this.$api.msg('请填写最小成交量');
  681. return;
  682. }
  683. if(!that.goodsName){
  684. this.$api.msg('请填写货名');
  685. return;
  686. }
  687. if(!that.verifyCode){
  688. this.$api.msg('请填写验证码');
  689. return;
  690. }
  691. if (!that.price) {
  692. that.$api.msg('请选择价格类型')
  693. return
  694. }
  695. if(!that.unitPrice){
  696. that.$api.msg('请填写协议价格(元/吨)');
  697. return
  698. }
  699. if(!that.origin){
  700. this.$api.msg('请填写产地');
  701. return;
  702. }
  703. if(!that.stock){
  704. this.$api.msg('请填写库存地');
  705. return;
  706. }
  707. if(!that.level){
  708. this.$api.msg('请填写国标等级');
  709. return;
  710. }
  711. that.saleInfo.seller = that.seller
  712. that.saleInfo.sellerPhone = that.sellerPhone
  713. that.saleInfo.priceType = that.price
  714. that.saleInfo.unitPrice = that.unitPrice
  715. that.saleInfo.minSale = that.minSale
  716. that.saleInfo.exsitCount = that.exsitCount
  717. that.saleInfo.origin = that.origin
  718. that.saleInfo.stock = that.stock
  719. that.saleInfo.verifyCode = that.verifyCode
  720. that.saleInfo.goodsName = that.goodsName
  721. that.saleInfo.buyer = that.buyer
  722. that.saleInfo.buyerPhone = that.buyerPhone
  723. that.saleInfo.level = that.level
  724. }else if(this.TabCur == 1){
  725. if(!that.buyer){
  726. this.$api.msg('请填写买方');
  727. return;
  728. }
  729. if(!that.buyerPhone){
  730. this.$api.msg('请填写手机号码');
  731. return;
  732. }
  733. if(!that.goodsName){
  734. this.$api.msg('请填写货名');
  735. return;
  736. }
  737. if(!that.verifyCode){
  738. this.$api.msg('请填写验证码');
  739. return;
  740. }
  741. if (!that.price) {
  742. that.$api.msg('请选择价格类型')
  743. return
  744. }
  745. if(!that.unitPrice){
  746. that.$api.msg('请填写协议价格(元/吨)');
  747. return
  748. }
  749. if(!that.origin){
  750. this.$api.msg('请填写产地');
  751. return;
  752. }
  753. if(!that.stock){
  754. this.$api.msg('请填写库存地');
  755. return;
  756. }
  757. if(!that.level){
  758. this.$api.msg('请填写国标等级');
  759. return;
  760. }
  761. that.saleInfo.seller = that.seller
  762. that.saleInfo.sellerPhone = that.sellerPhone
  763. that.saleInfo.priceType = that.price
  764. that.saleInfo.unitPrice = that.unitPrice
  765. that.saleInfo.minSale = that.minSale
  766. that.saleInfo.exsitCount = that.exsitCount
  767. that.saleInfo.origin = that.origin
  768. that.saleInfo.stock = that.stock
  769. that.saleInfo.verifyCode = that.verifyCode
  770. that.saleInfo.goodsName = that.goodsName
  771. that.saleInfo.buyer = that.buyer
  772. that.saleInfo.buyerPhone = that.buyerPhone
  773. that.saleInfo.level = that.level
  774. }
  775. else if(this.TabCur == 2){
  776. if(!that.sender){
  777. this.$api.msg('请填写发货方');
  778. return;
  779. }
  780. if(!that.senderPhone){
  781. this.$api.msg('请填写发货方手机号码');
  782. return;
  783. }
  784. if(!that.receiver){
  785. this.$api.msg('请填写收货方');
  786. return;
  787. }
  788. if(!that.receiverPhone){
  789. this.$api.msg('请填写收货方手机号码');
  790. return;
  791. }
  792. if(!that.goodsName){
  793. this.$api.msg('请填写货名');
  794. return;
  795. }
  796. if(!that.verifyCode){
  797. this.$api.msg('请填写验证码');
  798. return;
  799. }
  800. that.tran.sender = that.sender
  801. that.tran.senderPhone = that.senderPhone
  802. that.tran.receiver = that.receiver
  803. that.tran.receiverPhone = that.receiverPhone
  804. that.tran.verifyCode = that.verifyCode
  805. that.tran.goodsName = that.goodsName
  806. that.tran.total = that.total
  807. that.tran.price = that.price
  808. that.tran.startPlace = that.startPlace
  809. that.tran.endPlace = that.endPlace
  810. }
  811. else if(this.TabCur == 3){
  812. if(!that.startPlace){
  813. this.$api.msg('请填写起始地');
  814. return;
  815. }
  816. if(!that.endPlace){
  817. this.$api.msg('请填写目的地');
  818. return;
  819. }
  820. if(!that.driver){
  821. this.$api.msg('请填写承运人');
  822. return;
  823. }
  824. if(!that.driverPhone){
  825. this.$api.msg('请填写承运人手机号码');
  826. return;
  827. }
  828. if(!/(^1[3|4|5|7|8][0-9]{9}$)/.test(that.driverPhone)){
  829. that.$api.msg('请输入正确的承运人手机号码');
  830. return
  831. }
  832. if(!that.carNo){
  833. this.$api.msg('请填写车牌号');
  834. return;
  835. }
  836. if(!that.verifyCode){
  837. this.$api.msg('请填写验证码');
  838. return;
  839. }
  840. if (!that.personNoImg || !that.personNoImg1) {
  841. that.$api.msg('请上传身份证正、反面照片');
  842. return
  843. }
  844. if (!that.driverNoImg || !that.driverNoImg1) {
  845. that.$api.msg('请上传驾驶证主、副页照片');
  846. return
  847. }
  848. if (!that.carNoImg || !that.carNoImg1) {
  849. that.$api.msg('请上传行车证主、副页照片');
  850. return
  851. }
  852. that.tran.driver = that.driver
  853. that.tran.driverPhone = that.driverPhone
  854. that.tran.verifyCode = that.verifyCode
  855. that.tran.price = that.price
  856. that.tran.startPlace = that.startPlace
  857. that.tran.endPlace = that.endPlace
  858. that.tran.carNo = that.carNo
  859. that.tran.personNoImg = that.personNoImg
  860. that.tran.personNoImg1 = that.personNoImg1
  861. that.tran.driverNoImg = that.driverNoImg
  862. that.tran.driverNoImg1 = that.driverNoImg1
  863. that.tran.carNoImg = that.carNoImg
  864. that.tran.carNoImg1 = that.carNoImg1
  865. }
  866. // 获取用户的当前设置,判断是否点击了“总是保持以上,不在询问”
  867. wx.getSetting({
  868. // withSubscriptions: true,//是否获取用户订阅消息的订阅状态,默认false不返回
  869. success(res){
  870. if(res.authSetting['scope.subscribeMessage']){
  871. uni.openSetting({ // 打开设置页
  872. success(res) {
  873. console.log(res.authSetting)
  874. }
  875. });
  876. }else{// 用户没有点击“总是保持以上,不再询问”则每次都会调起订阅消息
  877. uni.requestSubscribeMessage({
  878. tmplIds: ['8cVkckXi_8zfHeScXRHhjN6cgZFYYCWIMPDTiPWagXY'],//
  879. success (res) {
  880. console.log(res)
  881. if(res['8cVkckXi_8zfHeScXRHhjN6cgZFYYCWIMPDTiPWagXY'] == "accept"){// 字段就是tmplIds模板id
  882. uni.showLoading({
  883. title: '正在提交',
  884. mask:true
  885. })
  886. if(that.TabCur == 0){
  887. that.$api.request('sale', 'addSale',that.saleInfo, failres => {
  888. uni.hideLoading()
  889. that.$api.msg(failres.errmsg);
  890. }).then(res => {
  891. uni.hideLoading()
  892. uni.showModal({
  893. title: '提示',
  894. content: "发布提交成功,工作人员会尽快联系该号码:"+that.sellerPhone,
  895. showCancel: false,
  896. confirmText: '确定',
  897. success: () => {
  898. uni.navigateBack()
  899. }
  900. })
  901. // that.$api.prePage().refreshList(data, that.manageType);
  902. })
  903. }
  904. else if(that.TabCur == 1){
  905. that.$api.request('sale', 'addBuy',that.saleInfo, failres => {
  906. uni.hideLoading()
  907. that.$api.msg(failres.errmsg);
  908. }).then(res => {
  909. uni.hideLoading()
  910. uni.showModal({
  911. title: '提示',
  912. showCancel: false,
  913. content: "发布提交成功,工作人员会尽快联系该号码:"+that.buyerPhone,
  914. confirmText: '确定',
  915. success: () => {
  916. uni.navigateBack()
  917. }
  918. })
  919. // that.$api.prePage().refreshList(data, that.manageType);
  920. })
  921. }
  922. else if(that.TabCur == 2){
  923. that.$api.request('tran', 'addTran',that.tran, failres => {
  924. uni.hideLoading()
  925. that.$api.msg(failres.errmsg);
  926. }).then(res => {
  927. uni.hideLoading()
  928. uni.showModal({
  929. title: '提示',
  930. showCancel: false,
  931. content: "发布提交成功,工作人员会尽快联系该号码:"+that.senderPhone,
  932. confirmText: '确定',
  933. success: () => {
  934. uni.navigateBack()
  935. }
  936. })
  937. // that.$api.prePage().refreshList(data, that.manageType);
  938. })
  939. }
  940. else if(that.TabCur == 3){
  941. that.$api.request('tran', 'addCarDriver',that.tran, failres => {
  942. uni.hideLoading()
  943. that.$api.msg(failres.errmsg);
  944. }).then(res => {
  945. uni.hideLoading()
  946. uni.showModal({
  947. title: '提示',
  948. showCancel: false,
  949. content: "发布提交成功,工作人员会尽快联系该号码:"+that.driverPhone,
  950. confirmText: '确定',
  951. success: () => {
  952. uni.navigateBack()
  953. }
  954. })
  955. // that.$api.prePage().refreshList(data, that.manageType);
  956. })
  957. }
  958. }
  959. }
  960. })
  961. }
  962. }
  963. })
  964. }
  965. }
  966. },
  967. }
  968. </script>
  969. <style scoped>
  970. .container{
  971. padding-bottom: 160rpx;
  972. }
  973. .cu-form-group input {
  974. text-align: right;
  975. }
  976. .text-white text{
  977. background: linear-gradient(45deg, #3DC146, #B2D612);
  978. padding:5px 10px;
  979. border-radius: 38rpx;
  980. }
  981. .cu-form-group textarea {
  982. text-align: right;
  983. }
  984. .commit{
  985. background: linear-gradient(45deg, #DF331C, #DA611A);
  986. color:#fff;
  987. }
  988. </style>