contract_detail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. <template>
  2. <view class="container">
  3. <!-- <block v-if="TabCur==2"> -->
  4. <view class="cu-form-group">
  5. <view class="title">派车编号</view>
  6. <input name="input" v-model="goods.tranCarNo"></input>
  7. </view>
  8. <view class="cu-form-group">
  9. <view class="title">车牌号</view>
  10. <input placeholder="请输入车牌号" name="input" v-model="goods.carNo"></input>
  11. </view>
  12. <view class="cu-form-group">
  13. <view class="title">司机手机号</view>
  14. <input placeholder="请输入司机身份认证的手机号" name="input" v-model="goods.driverPhone"></input>
  15. </view>
  16. <view class="cu-form-group">
  17. <view class="title">毛重(吨)</view>
  18. <input placeholder="请输入毛重" type="mobile" name="input" @input="grossWeightchange" v-model="goods.grossWeight"></input>
  19. </view>
  20. <view class="cu-form-group">
  21. <view class="title">皮重(吨)</view>
  22. <input placeholder="请输入皮重" type="mobile" name="input" @input="tarechange" v-model="goods.tare"></input>
  23. </view>
  24. <view class="cu-form-group">
  25. <view class="title">净重(吨)</view>
  26. <input placeholder="自动计算" type="mobile" name="input" v-model="goods.netWeight"></input>
  27. </view>
  28. <view class="cu-bar bg-white margin-top">
  29. <view class="action">
  30. 上传磅单照片
  31. </view>
  32. </view>
  33. <view class="cu-form-group">
  34. <view class="grid col-4 grid-square flex-sub">
  35. <view class="bg-img" v-if="personNoImg != ''" @tap="ViewImage" :data-url="personNoImg">
  36. <image :src="personNoImg" mode="aspectFit"></image>
  37. <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="0">
  38. <text class='cuIcon-close'></text>
  39. </view>
  40. </view>
  41. <view class="bg-img" v-if="personNoImg1 != ''" @tap="ViewImage" :data-url="personNoImg1">
  42. <image :src="personNoImg1" mode="aspectFit"></image>
  43. <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="1">
  44. <text class='cuIcon-close'></text>
  45. </view>
  46. </view>
  47. <view class="solids" @tap="ChooseImagePerson" v-if="personNoImg == '' || personNoImg1 == ''">
  48. <text class='cuIcon-cameraadd'></text>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="padding flex flex-direction">
  53. <button class="cu-btn commit margin-tb-sm lg" @click="getList">提交</button>
  54. </view>
  55. <!-- </block> -->
  56. </view>
  57. </template>
  58. <script>
  59. import uploadImage from '@/components/ossutil/uploadFile.js';
  60. import {
  61. mapState
  62. } from 'vuex';
  63. export default {
  64. name: "trust",
  65. data() {
  66. return {
  67. goods: {
  68. tranCarNo:'',
  69. carNo:'',
  70. grossWeight:'',
  71. tare:'',
  72. netWeight:'',
  73. personNoImg:'',
  74. personNoImg1:'',
  75. contractNo:'',
  76. goodsName:'',
  77. },
  78. carNo:'',
  79. PageCur: "trust",
  80. TabCur: 0,
  81. priceTypeIndex:-1,
  82. priceType: ['库内价', '到库价', '到港价'],
  83. unitPrice:0,
  84. price:'',
  85. seller:'',
  86. sellerPhone:'',
  87. minSale:'',
  88. exsitCount:0,
  89. origin:'',
  90. stock:'',
  91. goodsName:'',
  92. verifyCode:'',
  93. sendText0:'获取验证码',
  94. sendText1:'获取验证码',
  95. sendText2:'获取验证码',
  96. sendText3:'获取验证码',
  97. sendDisabled0: false,
  98. sendDisabled1: false,
  99. sendDisabled2: false,
  100. sendDisabled3: false,
  101. buyer:'',
  102. buyerPhone:'',
  103. level:'',
  104. sender:'',
  105. senderPhone:'',
  106. receiver:'',
  107. receiverPhone:'',
  108. total:0,
  109. startPlace:'',
  110. endPlace:'',
  111. driver:'',
  112. driverPhone:'',
  113. carNo:'',
  114. personNoImg:'',
  115. personNoImg1:'',
  116. driverNoImg:'',
  117. driverNoImg1:'',
  118. carNoImg:'',
  119. carNoImg1:'',
  120. showTran:true
  121. };
  122. },
  123. computed: {
  124. ...mapState(['hasLogin','userInfo'])
  125. },
  126. onShow() {
  127. },
  128. onLoad(option) {
  129. this.goods.netWeight =option.netWeight
  130. },
  131. methods: {
  132. commit1(item){
  133. uni.navigateTo({
  134. url: `/pageB/contract/look?id=${item.id}&netWeight=${item.netWeight}&carNo=${item.carNo}&sendDateStart=${item.sendDateStart}`
  135. })
  136. },
  137. grossWeightchange(e) {
  138. if (this.goods.grossWeight && this.goods.tare) {
  139. this.goods.netWeight = Number(
  140. this.goods.grossWeight - this.goods.tare
  141. )
  142. }
  143. },
  144. tarechange(e) {
  145. if (this.goods.grossWeight && this.goods.tare) {
  146. this.goods.netWeight = Number(
  147. this.goods.grossWeight - this.goods.tare
  148. )
  149. }
  150. },
  151. getList(){
  152. console.log(this.goods,"duixiang")
  153. this.$api.doRequest('post','/tranCarInfo/api/addTranTask',this.goods).then(res => {
  154. console.log("调用接口")
  155. that.sendDisabled = true
  156. let sec = 60
  157. let interval = setInterval(() => {
  158. sec--;
  159. that.sendText = sec + 's后重发'
  160. if (sec <= 0) {
  161. that.sendDisabled = false
  162. that.sendText = "获取验证码"
  163. clearInterval(interval)
  164. }
  165. }, 1000)
  166. })
  167. .catch(res => {
  168. uni.showToast({
  169. title: res.errmsg,
  170. icon:'none',
  171. duration: 2000
  172. })
  173. });
  174. },
  175. ChooseImagePerson() {
  176. uni.chooseImage({
  177. count: 1, //默认9
  178. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  179. sourceType: ['album','camera'], //从相册选择
  180. success: (res) => {
  181. //上传图片
  182. //图片路径可自行修改
  183. uploadImage(res.tempFilePaths[0], 'personNoImg/',
  184. result => {
  185. if (this.personNoImg.length != 0) {
  186. this.personNoImg1 = result
  187. } else {
  188. this.personNoImg = result
  189. }
  190. uni.hideLoading();
  191. }
  192. )
  193. }
  194. });
  195. },
  196. ChooseImageDriver() {
  197. uni.chooseImage({
  198. count: 1, //默认9
  199. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  200. sourceType: ['album','camera'], //从相册选择
  201. success: (res) => {
  202. //上传图片
  203. //图片路径可自行修改
  204. uploadImage(res.tempFilePaths[0], 'driverNoImg/',
  205. result => {
  206. if (this.driverNoImg.length != 0) {
  207. this.driverNoImg1 = result
  208. } else {
  209. this.driverNoImg = result
  210. }
  211. uni.hideLoading();
  212. }
  213. )
  214. }
  215. });
  216. },
  217. ChooseImageCar() {
  218. uni.chooseImage({
  219. count: 1, //默认9
  220. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  221. sourceType: ['album','camera'], //从相册选择
  222. success: (res) => {
  223. //上传图片
  224. //图片路径可自行修改
  225. uploadImage(res.tempFilePaths[0], 'carNoImg/',
  226. result => {
  227. if (this.carNoImg.length != 0) {
  228. this.carNoImg1 = result
  229. } else {
  230. this.carNoImg = result
  231. }
  232. uni.hideLoading();
  233. }
  234. )
  235. }
  236. });
  237. },
  238. ViewImage(e) {
  239. var img = [];
  240. img = e.currentTarget.dataset.url.split(' ')
  241. uni.previewImage({
  242. current:0,
  243. urls: img
  244. });
  245. },
  246. DelImg(e) {
  247. uni.showModal({
  248. title: '提示',
  249. content: '确定要删除该照片吗?',
  250. cancelText: '取消',
  251. confirmText: '确定',
  252. success: res => {
  253. if (res.confirm) {
  254. if(e.currentTarget.dataset.index == 0){
  255. this.personNoImg = "";
  256. }
  257. else if(e.currentTarget.dataset.index == 1){
  258. this.personNoImg1 = "";
  259. }
  260. else if(e.currentTarget.dataset.index == 2){
  261. this.driverNoImg = "";
  262. }
  263. else if(e.currentTarget.dataset.index == 3){
  264. this.driverNoImg1 = "";
  265. }
  266. else if(e.currentTarget.dataset.index == 4){
  267. this.carNoImg = "";
  268. }
  269. else if(e.currentTarget.dataset.index == 5){
  270. this.carNoImg1 = "";
  271. }
  272. }
  273. }
  274. })
  275. },
  276. commit(){
  277. if (!this.hasLogin) {
  278. uni.showModal({
  279. title: '登录提示',
  280. content: '您尚未登录,是否立即登录?',
  281. showCancel: true,
  282. confirmText: '登录',
  283. success: (e) => {
  284. if (e.confirm) {
  285. uni.navigateTo({
  286. url: '/pages/public/login'
  287. })
  288. }
  289. },
  290. fail: () => {},
  291. complete: () => {}
  292. })
  293. }
  294. else{
  295. const that = this
  296. if(this.TabCur == 0){
  297. if(!that.seller){
  298. this.$api.msg('请填写车牌号');
  299. return;
  300. }
  301. if(!that.sellerPhone){
  302. this.$api.msg('请填写司机手机号码');
  303. return;
  304. }
  305. if(!that.exsitCount){
  306. this.$api.msg('请填写毛重');
  307. return;
  308. }
  309. if(!that.minSale){
  310. this.$api.msg('请填写皮重');
  311. return;
  312. }
  313. that.saleInfo.seller = that.seller
  314. that.saleInfo.sellerPhone = that.sellerPhone
  315. that.saleInfo.priceType = that.price
  316. that.saleInfo.unitPrice = that.unitPrice
  317. that.saleInfo.minSale = that.minSale
  318. that.saleInfo.exsitCount = that.exsitCount
  319. that.saleInfo.origin = that.origin
  320. that.saleInfo.stock = that.stock
  321. that.saleInfo.verifyCode = that.verifyCode
  322. that.saleInfo.goodsName = that.goodsName
  323. that.saleInfo.buyer = that.buyer
  324. that.saleInfo.buyerPhone = that.buyerPhone
  325. that.saleInfo.level = that.level
  326. }else if(this.TabCur == 1){
  327. if(!that.buyer){
  328. this.$api.msg('请填写买方');
  329. return;
  330. }
  331. if(!that.buyerPhone){
  332. this.$api.msg('请填写手机号码');
  333. return;
  334. }
  335. if(!that.goodsName){
  336. this.$api.msg('请填写货名');
  337. return;
  338. }
  339. if(!that.verifyCode){
  340. this.$api.msg('请填写验证码');
  341. return;
  342. }
  343. if (!that.price) {
  344. that.$api.msg('请选择价格类型')
  345. return
  346. }
  347. if(!that.unitPrice){
  348. that.$api.msg('请填写协议价格(元/吨)');
  349. return
  350. }
  351. if(!that.origin){
  352. this.$api.msg('请填写产地');
  353. return;
  354. }
  355. if(!that.stock){
  356. this.$api.msg('请填写库存地');
  357. return;
  358. }
  359. if(!that.level){
  360. this.$api.msg('请填写国标等级');
  361. return;
  362. }
  363. that.saleInfo.seller = that.seller
  364. that.saleInfo.sellerPhone = that.sellerPhone
  365. that.saleInfo.priceType = that.price
  366. that.saleInfo.unitPrice = that.unitPrice
  367. that.saleInfo.minSale = that.minSale
  368. that.saleInfo.exsitCount = that.exsitCount
  369. that.saleInfo.origin = that.origin
  370. that.saleInfo.stock = that.stock
  371. that.saleInfo.verifyCode = that.verifyCode
  372. that.saleInfo.goodsName = that.goodsName
  373. that.saleInfo.buyer = that.buyer
  374. that.saleInfo.buyerPhone = that.buyerPhone
  375. that.saleInfo.level = that.level
  376. }
  377. else if(this.TabCur == 2){
  378. if(!that.sender){
  379. this.$api.msg('请填写发货方');
  380. return;
  381. }
  382. if(!that.senderPhone){
  383. this.$api.msg('请填写发货方手机号码');
  384. return;
  385. }
  386. if(!that.receiver){
  387. this.$api.msg('请填写收货方');
  388. return;
  389. }
  390. if(!that.receiverPhone){
  391. this.$api.msg('请填写收货方手机号码');
  392. return;
  393. }
  394. if(!that.goodsName){
  395. this.$api.msg('请填写货名');
  396. return;
  397. }
  398. if(!that.verifyCode){
  399. this.$api.msg('请填写验证码');
  400. return;
  401. }
  402. that.tran.sender = that.sender
  403. that.tran.senderPhone = that.senderPhone
  404. that.tran.receiver = that.receiver
  405. that.tran.receiverPhone = that.receiverPhone
  406. that.tran.verifyCode = that.verifyCode
  407. that.tran.goodsName = that.goodsName
  408. that.tran.total = that.total
  409. that.tran.price = that.price
  410. that.tran.startPlace = that.startPlace
  411. that.tran.endPlace = that.endPlace
  412. }
  413. else if(this.TabCur == 3){
  414. if(!that.startPlace){
  415. this.$api.msg('请填写起始地');
  416. return;
  417. }
  418. if(!that.endPlace){
  419. this.$api.msg('请填写目的地');
  420. return;
  421. }
  422. if(!that.driver){
  423. this.$api.msg('请填写承运人');
  424. return;
  425. }
  426. if(!that.driverPhone){
  427. this.$api.msg('请填写承运人手机号码');
  428. return;
  429. }
  430. if(!/(^1[3|4|5|7|8][0-9]{9}$)/.test(that.driverPhone)){
  431. that.$api.msg('请输入正确的承运人手机号码');
  432. return
  433. }
  434. if(!that.carNo){
  435. this.$api.msg('请填写车牌号');
  436. return;
  437. }
  438. if(!that.verifyCode){
  439. this.$api.msg('请填写验证码');
  440. return;
  441. }
  442. if (!that.personNoImg || !that.personNoImg1) {
  443. that.$api.msg('请上传磅单');
  444. return
  445. }
  446. if (!that.driverNoImg || !that.driverNoImg1) {
  447. that.$api.msg('请上传驾驶证主、副页照片');
  448. return
  449. }
  450. if (!that.carNoImg || !that.carNoImg1) {
  451. that.$api.msg('请上传行车证主、副页照片');
  452. return
  453. }
  454. that.tran.driver = that.driver
  455. that.tran.driverPhone = that.driverPhone
  456. that.tran.verifyCode = that.verifyCode
  457. that.tran.price = that.price
  458. that.tran.startPlace = that.startPlace
  459. that.tran.endPlace = that.endPlace
  460. that.tran.carNo = that.carNo
  461. that.tran.personNoImg = that.personNoImg
  462. that.tran.personNoImg1 = that.personNoImg1
  463. that.tran.driverNoImg = that.driverNoImg
  464. that.tran.driverNoImg1 = that.driverNoImg1
  465. that.tran.carNoImg = that.carNoImg
  466. that.tran.carNoImg1 = that.carNoImg1
  467. }
  468. // 获取用户的当前设置,判断是否点击了“总是保持以上,不在询问”
  469. wx.getSetting({
  470. // withSubscriptions: true,//是否获取用户订阅消息的订阅状态,默认false不返回
  471. success(res){
  472. if(res.authSetting['scope.subscribeMessage']){
  473. uni.openSetting({ // 打开设置页
  474. success(res) {
  475. console.log(res.authSetting)
  476. }
  477. });
  478. }else{// 用户没有点击“总是保持以上,不再询问”则每次都会调起订阅消息
  479. uni.requestSubscribeMessage({
  480. tmplIds: ['8cVkckXi_8zfHeScXRHhjN6cgZFYYCWIMPDTiPWagXY'],//
  481. success (res) {
  482. console.log(res)
  483. if(res['8cVkckXi_8zfHeScXRHhjN6cgZFYYCWIMPDTiPWagXY'] == "accept"){// 字段就是tmplIds模板id
  484. uni.showLoading({
  485. title: '正在提交',
  486. mask:true
  487. })
  488. if(that.TabCur == 0){
  489. that.$api.request('sale', 'addSale',that.saleInfo, failres => {
  490. uni.hideLoading()
  491. that.$api.msg(failres.errmsg);
  492. }).then(res => {
  493. uni.hideLoading()
  494. uni.showModal({
  495. title: '提示',
  496. content: "发布提交成功,工作人员会尽快联系该号码:"+that.sellerPhone,
  497. showCancel: false,
  498. confirmText: '确定',
  499. success: () => {
  500. uni.navigateBack()
  501. }
  502. })
  503. // that.$api.prePage().refreshList(data, that.manageType);
  504. })
  505. }
  506. else if(that.TabCur == 1){
  507. that.$api.request('sale', 'addBuy',that.saleInfo, failres => {
  508. uni.hideLoading()
  509. that.$api.msg(failres.errmsg);
  510. }).then(res => {
  511. uni.hideLoading()
  512. uni.showModal({
  513. title: '提示',
  514. showCancel: false,
  515. content: "发布提交成功,工作人员会尽快联系该号码:"+that.buyerPhone,
  516. confirmText: '确定',
  517. success: () => {
  518. uni.navigateBack()
  519. }
  520. })
  521. // that.$api.prePage().refreshList(data, that.manageType);
  522. })
  523. }
  524. else if(that.TabCur == 2){
  525. that.$api.request('tran', 'addTran',that.tran, failres => {
  526. uni.hideLoading()
  527. that.$api.msg(failres.errmsg);
  528. }).then(res => {
  529. uni.hideLoading()
  530. uni.showModal({
  531. title: '提示',
  532. showCancel: false,
  533. content: "发布提交成功,工作人员会尽快联系该号码:"+that.senderPhone,
  534. confirmText: '确定',
  535. success: () => {
  536. uni.navigateBack()
  537. }
  538. })
  539. // that.$api.prePage().refreshList(data, that.manageType);
  540. })
  541. }
  542. else if(that.TabCur == 3){
  543. that.$api.request('tran', 'addCarDriver',that.tran, failres => {
  544. uni.hideLoading()
  545. that.$api.msg(failres.errmsg);
  546. }).then(res => {
  547. uni.hideLoading()
  548. uni.showModal({
  549. title: '提示',
  550. showCancel: false,
  551. content: "发布提交成功,工作人员会尽快联系该号码:"+that.driverPhone,
  552. confirmText: '确定',
  553. success: () => {
  554. uni.navigateBack()
  555. }
  556. })
  557. // that.$api.prePage().refreshList(data, that.manageType);
  558. })
  559. }
  560. }
  561. }
  562. })
  563. }
  564. }
  565. })
  566. }
  567. }
  568. },
  569. }
  570. </script>
  571. <style scoped>
  572. .container{
  573. padding-bottom: 160rpx;
  574. }
  575. .cu-form-group input {
  576. text-align: right;
  577. }
  578. .text-white text{
  579. background: linear-gradient(45deg, #3DC146, #B2D612);
  580. padding:5px 10px;
  581. border-radius: 38rpx;
  582. }
  583. .cu-form-group textarea {
  584. text-align: right;
  585. }
  586. .commit{
  587. background: linear-gradient(45deg, #DF331C, #DA611A);
  588. color:#fff;
  589. }
  590. </style>