offer.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <template>
  2. <view class="content">
  3. <view v-if="pageData.user_order && pageData.statue != 3">
  4. <view class="box">
  5. <view class="title">报价记录</view>
  6. <block v-for="(item,index) in pageData.user_order.amounts" :key="index">
  7. <view class="offer_detail hflex acenter" v-if="item.user_id == userId">
  8. <view class="offer_left">第{{index + 1}}次报价</view>
  9. <view class="offer_money">{{item.amount?item.amount:'暂无报价'}}</view>
  10. </view>
  11. </block>
  12. </view>
  13. </view>
  14. <view v-else-if="!pageData.user_order && pageData.item[index].statue != 3">
  15. <view class="box">
  16. <view class="title">报价记录</view>
  17. <block v-for="(item,index1) in pageData.items[index].user_order.amounts" :key="index1">
  18. <view class="offer_detail hflex acenter" v-if="item.user_id == userId">
  19. <view class="offer_left">第{{index1 + 1}}次报价</view>
  20. <view class="offer_money">{{item.amount?item.amount:'暂无报价'}}</view>
  21. </view>
  22. </block>
  23. </view>
  24. </view>
  25. <view class="box" v-if="pageData.tab == 1 && pageData.items[index].status !=3">
  26. <view class="title">订单报价</view>
  27. <view class="input hflex acenter">
  28. <view>¥</view>
  29. <u-input v-model="money" border="none" placeholder="请填写你的报价"></u-input>
  30. </view>
  31. <view class="input_bg hflex acenter" v-if="tab == 3 || tab == 4">
  32. <view class="price">报价说明</view>
  33. <u-input v-model="description" placeholder="例如:税前/税后" border="none"></u-input>
  34. </view>
  35. <view class="input_bg hflex acenter" v-if="tab == 1 || tab == 2">
  36. <view class="price">货期</view>
  37. <u-input v-model="lead_time" placeholder="例如: 1个月" border="none"></u-input>
  38. </view>
  39. <view class="input_bg" v-if="tab == 2 || tab == 1">
  40. <view class="price">产品介绍以及报价说明</view>
  41. <u--textarea v-model="description" placeholder="例如:税前/税后" border="none"></u--textarea>
  42. </view>
  43. <view class="hflex acenter jbetween" v-if="tab == 1">
  44. <view class="price">是否现货</view>
  45. <u-switch v-model="is_stock" activeColor="#506dff" @change="change"></u-switch>
  46. </view>
  47. <view class="text_style1">上传图片及资质证明图片</view>
  48. <view class="upload">
  49. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" :maxCount="3" name="1" multiple :previewFullImage="true" width="200rpx" height="200rpx">
  50. </u-upload>
  51. </view>
  52. </view>
  53. <view class="box" v-if="pageData.status != 3 && pageData.tab !=1">
  54. <view class="title">订单报价</view>
  55. <view class="input hflex acenter">
  56. <view>¥</view>
  57. <u-input v-model="money" border="none" placeholder="请填写你的报价"></u-input>
  58. </view>
  59. <view class="input_bg hflex acenter" v-if="tab == 3 || tab == 4">
  60. <view class="price">报价说明</view>
  61. <u-input v-model="description" placeholder="例如:税前/税后" border="none"></u-input>
  62. </view>
  63. <view class="input_bg hflex acenter" v-if="tab == 1 || tab == 2">
  64. <view class="price">货期</view>
  65. <u-input v-model="lead_time" placeholder="例如: 1个月" border="none"></u-input>
  66. </view>
  67. <view class="input_bg" v-if="tab == 2 || tab == 1">
  68. <view class="price">产品介绍以及报价说明</view>
  69. <u--textarea v-model="description" placeholder="例如:税前/税后" border="none"></u--textarea>
  70. </view>
  71. <view class="hflex acenter jbetween" v-if="tab == 1">
  72. <view class="price">是否现货</view>
  73. <u-switch v-model="is_stock" activeColor="#506dff" @change="change"></u-switch>
  74. </view>
  75. <view class="text_style1">上传图片及资质证明图片</view>
  76. <view class="upload">
  77. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" :maxCount="3" name="1" multiple :previewFullImage="true" width="200rpx" height="200rpx">
  78. </u-upload>
  79. </view>
  80. </view>
  81. <view v-if="pageData.user_order">
  82. <view class="box" v-if="pageData.status == 3">
  83. <view class="title">报价信息</view>
  84. <view class="hflex acenter cell" >
  85. <view class="left">价格</view>
  86. <view class="right" style="font-size: 32rpx;color: #222222;">{{money?money:'暂无报价'}}</view>
  87. </view>
  88. <view class="hflex acenter cell" v-if="lead_time">
  89. <view class="left">货期</view>
  90. <view class="right">{{lead_time}}</view>
  91. </view>
  92. <view class="hflex acenter cell">
  93. <view class="left">说明</view>
  94. <view class="right">{{description}}</view>
  95. </view>
  96. <view class="hflex acenter cell" v-if="is_stock">
  97. <view class="left">是否现货</view>
  98. <view class="right">{{is_stock==0?'否':'是'}}</view>
  99. </view>
  100. <!-- <block v-if="pageData.status == 3 && pageData.file">
  101. <view class="text_style1 cell">图片及资质证明图片</view>
  102. <view class="hflex acenter fwrap">
  103. <block v-for="(item,index1) in pageData.user_order.file" :key="index1">
  104. <image :src="item" mode="aspectFill" class="imgs"></image>
  105. </block>
  106. </view>
  107. </block> -->
  108. <block v-if="pageData.status == 3 && pageData.user_order.images">
  109. <view class="text_style1 cell">图片及资质证明图片</view>
  110. <view class="hflex acenter fwrap">
  111. <block v-for="(item,index1) in pageData.user_order.images" :key="index1">
  112. <image :src="item" mode="aspectFill" class="imgs"></image>
  113. </block>
  114. </view>
  115. </block>
  116. </view>
  117. </view>
  118. <view class="" v-if="pageData.items[index].user_order">
  119. <view class="box" v-if="pageData.items[index].status == 3">
  120. <view class="title">报价信息</view>
  121. <view class="hflex acenter cell" >
  122. <view class="left">价格</view>
  123. <view class="right" style="font-size: 32rpx;color: #222222;">{{money?money:'暂无报价'}}</view>
  124. </view>
  125. <view class="hflex acenter cell" v-if="lead_time">
  126. <view class="left">货期</view>
  127. <view class="right">{{lead_time}}</view>
  128. </view>
  129. <view class="hflex acenter cell">
  130. <view class="left">说明</view>
  131. <view class="right">{{description}}</view>
  132. </view>
  133. <view class="hflex acenter cell" v-if="is_stock">
  134. <view class="left">是否现货</view>
  135. <view class="right">{{is_stock==0?'否':'是'}}</view>
  136. </view>
  137. <block v-if="pageData.items[index].status == 3 && pageData.images">
  138. <view class="text_style1 cell">图片及资质证明图片</view>
  139. <view class="hflex acenter fwrap">
  140. <block v-for="(item,index1) in pageData.items[index].user_order.images" :key="index1">
  141. <image :src="item" mode="aspectFill" class="imgs"></image>
  142. </block>
  143. </view>
  144. </block>
  145. </view>
  146. </view>
  147. <view v-if="pageData.tab == 1 && pageData.items[index].status !=3">
  148. <view class="btn" @click="create" v-if="pageData.items[index].user_order">{{pageData.items[index].user_order.amounts.length > 0 ? '重新报价' : '立即报价'}}</view>
  149. <view class="btn" @click="create" v-else>立即报价</view>
  150. <view class="text">友情提醒</view>
  151. <view class="text text2">请认真核算报价,报价后不可修改和删除,报价时间约需x天内报价,逾期影响信用等级。</view>
  152. </view>
  153. <view v-if="pageData.status != 3 && pageData.tab != 1">
  154. <view class="btn" @click="create" v-if="pageData.user_order">{{pageData.user_order.amounts.length > 0 ? '重新报价' : '立即报价'}}</view>
  155. <view class="btn" @click="create" v-else>立即报价</view>
  156. <view class="text">友情提醒</view>
  157. <view class="text text2">请认真核算报价,报价后不可修改和删除,报价时间约需x天内报价,逾期影响信用等级。</view>
  158. </view>
  159. </view>
  160. </template>
  161. <script>
  162. import $api from '@/static/js/api.js'
  163. var that = ''
  164. export default {
  165. data() {
  166. return {
  167. id: '',
  168. pageData: {},
  169. tab: '',
  170. fileList1: [],
  171. money: '',
  172. index: '',
  173. is_stock: '',
  174. description: '',
  175. lead_time: '',
  176. userId: '',
  177. }
  178. },
  179. onLoad(options) {
  180. that = this
  181. that.userId = uni.getStorageSync('id')
  182. that.id = options.id
  183. that.tab = options.tab
  184. if(options.index) {
  185. that.index = options.index
  186. }
  187. that.getData()
  188. },
  189. methods: {
  190. getData() {
  191. var url = ""
  192. switch(that.tab) {
  193. case '1':
  194. url = '/data/api.auth.Purchase/show';
  195. break;
  196. case '2':
  197. url = '/data/api.auth.Purchase/production_show';
  198. break;
  199. case '3':
  200. url = '/data/api.auth.Purchase/coor_show';
  201. break;
  202. case '4':
  203. url = '/data/api.auth.Purchase/ocean_show';
  204. break;
  205. }
  206. $api.req({
  207. url: url,
  208. data: {
  209. id: that.id
  210. }
  211. }, function(res) {
  212. if(res.code == 1) {
  213. that.pageData = res.data
  214. if(that.tab == '1') {
  215. that.money = that.pageData.items[that.index].user_order.amount
  216. that.lead_time = that.pageData.items[that.index].user_order.date
  217. that.description = that.pageData.items[that.index].user_order.desc
  218. that.is_stock = that.pageData.items[that.index].user_order.is_have == 1 ? true : false
  219. for(var i=0;i<that.pageData.items[that.index].user_order.images.length;i++) {
  220. var img = {
  221. url: that.pageData.items[that.index].user_order.images[i]
  222. }
  223. that.fileList1.push(img)
  224. }
  225. // that.fileList1 = that.pageData.items[that.index].user_order.images
  226. } else {
  227. that.money = that.pageData.user_order.amount
  228. that.lead_time = that.pageData.user_order.date
  229. that.description = that.pageData.user_order.desc
  230. that.is_stock = that.pageData.user_order.is_have == 1 ? true : false
  231. for(var i=0;i<that.pageData.user_order.images.length;i++) {
  232. var img = {
  233. url: that.pageData.user_order.images[i]
  234. }
  235. that.fileList1.push(img)
  236. }
  237. }
  238. }
  239. })
  240. },
  241. // 是否现货
  242. change(e) {
  243. console.log(e);
  244. that.is_stock = e
  245. },
  246. // 删除图片
  247. deletePic(event) {
  248. // that.userInfo.imgList.splice(event.index, 1)
  249. console.log(event)
  250. this[`fileList${event.name}`].splice(event.index, 1)
  251. },
  252. // 新增图片
  253. async afterRead(event) {
  254. uni.showLoading({
  255. title: '上传中',
  256. mask: true
  257. })
  258. let lists = [].concat(event.file)
  259. let fileListLen = this[`fileList${event.name}`].length
  260. lists.map((item) => {
  261. this[`fileList${event.name}`].push({
  262. ...item,
  263. status: 'uploading',
  264. message: '上传中'
  265. })
  266. })
  267. for (let i = 0; i < lists.length; i++) {
  268. const result = await this.uploadFilePromise(lists[i].url)
  269. let item = this[`fileList${event.name}`][fileListLen]
  270. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  271. status: 'success',
  272. message: '',
  273. url: result.url
  274. }))
  275. fileListLen++
  276. if(lists.length - 1 == i) {
  277. uni.hideLoading()
  278. }
  279. }
  280. },
  281. uploadFilePromise(url) {
  282. return new Promise((resolve, reject) => {
  283. let a = uni.uploadFile({
  284. url: $api.config.baseUrl + '/data/api.auth.Center/upload',
  285. filePath: url,
  286. name: 'file',
  287. header: {
  288. 'content-type': 'application/x-www-form-urlencoded',
  289. 'api-token': uni.getStorageSync('token').token?uni.getStorageSync('token').token:'',
  290. 'api-name': 'wxapp'
  291. },
  292. formData: {
  293. user: 'test'
  294. },
  295. success: (res) => {
  296. setTimeout(() => {
  297. var data = JSON.parse(res.data)
  298. resolve(data.data)
  299. }, 1000)
  300. }
  301. });
  302. })
  303. },
  304. create() {
  305. var url = ""
  306. var images = []
  307. for(var i=0;i<that.fileList1.length;i++) {
  308. images.push(that.fileList1[i].url)
  309. }
  310. if(that.description == "") {
  311. $api.info('请填写报价说明')
  312. return
  313. }
  314. if(images.length == 0) {
  315. $api.info('请上传图片资质')
  316. return
  317. }
  318. var data = {}
  319. switch(that.pageData.tab) {
  320. case 1:
  321. url = '/data/api.auth.Purchase/purchase_create';
  322. data = {
  323. id: that.pageData.items[that.index].id,
  324. amount: that.money,
  325. date: that.lead_time,
  326. desc: that.description,
  327. is_have: that.is_stock?1:0,
  328. images: images,
  329. is_edit: 1
  330. };
  331. break;
  332. case 2:
  333. url = '/data/api.auth.Purchase/production_create';
  334. data = {
  335. id: that.pageData.id,
  336. amount: that.money,
  337. date: that.lead_time,
  338. desc: that.description,
  339. images: images,
  340. is_edit: 1
  341. };
  342. break;
  343. case 3:
  344. url = '/data/api.auth.Purchase/coor_create';
  345. data = {
  346. id: that.pageData.id,
  347. amount: that.money,
  348. desc: that.description,
  349. images: images,
  350. is_edit: 1
  351. };
  352. break;
  353. case 4:
  354. url = '/data/api.auth.Purchase/ocean_create';
  355. data = {
  356. id: that.pageData.id,
  357. amount: that.money,
  358. desc: that.description,
  359. images: images,
  360. is_edit: 1
  361. };
  362. break;
  363. }
  364. $api.req({
  365. url: url,
  366. method: 'POST',
  367. data: data
  368. }, function(res) {
  369. if(res.code == 1) {
  370. /* that.getData()
  371. that.name = "",
  372. that.money = ""
  373. that.fileList1 = [] */
  374. $api.jump(-1)
  375. }
  376. })
  377. }
  378. },
  379. }
  380. </script>
  381. <style lang="scss" scoped>
  382. .content::v-deep {
  383. background: #F4F4F4;
  384. padding: 0 30rpx;
  385. .box {
  386. width: 100%;
  387. background: #FFFFFF;
  388. border-radius: 24rpx;
  389. box-sizing: border-box;
  390. padding: 24rpx 20rpx;
  391. margin-top: 20rpx;
  392. .title {
  393. font-size: 28rpx;
  394. font-weight: 500;
  395. color: #222222;
  396. }
  397. .cell {
  398. padding: 18rpx 0;
  399. }
  400. .left {
  401. font-size: 26rpx;
  402. font-weight: 400;
  403. color: #222222;
  404. line-height: 36rpx;
  405. padding-right: 20rpx;
  406. }
  407. .right {
  408. font-size: 26rpx;
  409. font-weight: 400;
  410. color: #222222;
  411. line-height: 36rpx;
  412. }
  413. .offer_detail {
  414. width: 100%;
  415. height: 68rpx;
  416. background: #F4F4F4;
  417. border-radius: 16rpx;
  418. box-sizing: border-box;
  419. padding: 20rpx;
  420. margin: 10rpx 0;
  421. .offer_left {
  422. font-size: 22rpx;
  423. font-weight: 400;
  424. color: #777777;
  425. margin-right: 40rpx;
  426. }
  427. .offer_money {
  428. font-size: 28rpx;
  429. font-weight: 400;
  430. color: #FF3636;
  431. }
  432. }
  433. .input {
  434. width: 100%;
  435. height: 88rpx;
  436. background: #F4F4F4;
  437. border-radius: 16rpx;
  438. font-size: 32rpx;
  439. font-weight: 500;
  440. color: #222222;
  441. box-sizing: border-box;
  442. padding: 0 20rpx;
  443. line-height: 88rpx;
  444. margin: 20rpx 0;
  445. }
  446. .input_bg {
  447. background: #F4F4F4;
  448. border-radius: 8px;
  449. box-sizing: border-box;
  450. padding: 16rpx 20rpx;
  451. margin: 20rpx 0;
  452. .price {
  453. font-size: 32rpx;
  454. font-weight: 500;
  455. color: #222222;
  456. padding-right: 20rpx;
  457. }
  458. .u-textarea {
  459. background-color: #F4F4F4 !important;
  460. }
  461. .red {
  462. font-size: 28rpx;
  463. font-weight: bold;
  464. color: #FF3636;
  465. }
  466. }
  467. .text_style1 {
  468. font-size: 28rpx;
  469. font-weight: 500;
  470. color: #444444;
  471. }
  472. .imgs {
  473. width: 200rpx;
  474. height: 200rpx;
  475. border-radius: 16rpx;
  476. margin: 0 15rpx 20rpx 0;
  477. }
  478. .upload {
  479. margin-top: 20rpx;
  480. }
  481. }
  482. .btn {
  483. margin: 56rpx 0 22rpx;
  484. width: 100%;
  485. height: 88rpx;
  486. background: #506DFF;
  487. border-radius: 44rpx;
  488. font-size: 36rpx;
  489. font-weight: 500;
  490. text-align: center;
  491. line-height: 88rpx;
  492. color: #FFFFFF;
  493. }
  494. .text {
  495. font-size: 24rpx;
  496. font-weight: 400;
  497. color: #222222;
  498. }
  499. .text2 {
  500. color: #999999;
  501. }
  502. }
  503. </style>