trust.vue 31 KB

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