offer2.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <view class="content">
  3. <view v-if="pageData.list">
  4. <view class="box">
  5. <view class="title">报价记录</view>
  6. <!-- <view class="offer_detail hflex acenter">
  7. <view class="offer_money" v-if="pageData.list.length == 0">未填写报价</view>
  8. </view> -->
  9. <block v-for="(item,index) in pageData.list" :key="index">
  10. <view class="offer_detail hflex acenter">
  11. <view class="offer_left">第{{index + 1}}次报价</view>
  12. <view class="offer_money" v-if="item.price != 0">{{item.price}}</view>
  13. </view>
  14. </block>
  15. <view class="text_style1" style="padding: 20rpx 0;" v-if="status == 3">图片及资质证明图片</view>
  16. <view class="hflex acenter" v-if="status == 3">
  17. <block v-for="(item,index) in pageData.imgs" :key="index">
  18. <image :src="item" class="imgs"></image>
  19. </block>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="box" v-if="status != 3">
  24. <view class="title">订单报价</view>
  25. <view class="input hflex acenter">
  26. <view>¥</view>
  27. <u-input v-model="money" border="none" placeholder="请填写你的报价"></u-input>
  28. </view>
  29. <view class="text_style1">上传图片及资质证明图片</view>
  30. <view class="upload">
  31. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" :maxCount="3" name="1" multiple :previewFullImage="true" width="200rpx" height="200rpx">
  32. </u-upload>
  33. </view>
  34. </view>
  35. <view v-if="status != 3">
  36. <view class="btn" @click="create">{{pageData.list.length > 0 ? '重新报价' : '立即报价'}}</view>
  37. <view class="text">友情提醒</view>
  38. <view class="text text2">请认真核算报价,报价后不可修改和删除,报价时间约需x天内报价,逾期影响信用等级。</view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import $api from '@/static/js/api.js'
  44. var that = ''
  45. export default {
  46. data() {
  47. return {
  48. id: '',
  49. pageData: {},
  50. tab: '',
  51. fileList1: [],
  52. money: '',
  53. index: '',
  54. status: '',
  55. }
  56. },
  57. onLoad(options) {
  58. that = this
  59. that.id = options.id
  60. that.status = options.status
  61. that.getData()
  62. },
  63. methods: {
  64. getData() {
  65. $api.req({
  66. url: '/data/api.auth.ShipEngineMaintenance/offerinfo',
  67. method: 'POST',
  68. data: {
  69. id: that.id
  70. }
  71. }, function(res) {
  72. if(res.code == 1) {
  73. that.pageData = res.data
  74. /* if(that.pageData.list) {
  75. that.money = that.pageData.list[that.pageData.list.length - 1].price
  76. } */
  77. for(var i=0;i<res.data.imgs.length;i++) {
  78. var img = {
  79. url: res.data.imgs[i]
  80. }
  81. that.fileList1.push(img)
  82. }
  83. }
  84. })
  85. },
  86. // 删除图片
  87. deletePic(event) {
  88. // that.userInfo.imgList.splice(event.index, 1)
  89. console.log(event)
  90. this[`fileList${event.name}`].splice(event.index, 1)
  91. },
  92. // 新增图片
  93. async afterRead(event) {
  94. uni.showLoading({
  95. title: '上传中',
  96. mask: true
  97. })
  98. let lists = [].concat(event.file)
  99. let fileListLen = this[`fileList${event.name}`].length
  100. lists.map((item) => {
  101. this[`fileList${event.name}`].push({
  102. ...item,
  103. status: 'uploading',
  104. message: '上传中'
  105. })
  106. })
  107. for (let i = 0; i < lists.length; i++) {
  108. const result = await this.uploadFilePromise(lists[i].url)
  109. let item = this[`fileList${event.name}`][fileListLen]
  110. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  111. status: 'success',
  112. message: '',
  113. url: result.url
  114. }))
  115. fileListLen++
  116. if(lists.length - 1 == i) {
  117. uni.hideLoading()
  118. }
  119. }
  120. },
  121. uploadFilePromise(url) {
  122. return new Promise((resolve, reject) => {
  123. let a = uni.uploadFile({
  124. url: $api.config.baseUrl + '/data/api.auth.Center/upload',
  125. filePath: url,
  126. name: 'file',
  127. header: {
  128. 'content-type': 'application/x-www-form-urlencoded',
  129. 'api-token': uni.getStorageSync('token').token?uni.getStorageSync('token').token:'',
  130. 'api-name': 'wxapp'
  131. },
  132. formData: {
  133. user: 'test'
  134. },
  135. success: (res) => {
  136. setTimeout(() => {
  137. var data = JSON.parse(res.data)
  138. resolve(data.data)
  139. }, 1000)
  140. }
  141. });
  142. })
  143. },
  144. create() {
  145. var url = ""
  146. var images = ''
  147. console.log(that.money);
  148. if(!that.money) {
  149. $api.info('请填写报价')
  150. return
  151. }
  152. for(var i=0;i<that.fileList1.length;i++) {
  153. if(i == that.fileList1.length -1) {
  154. images += that.fileList1[i].url
  155. } else {
  156. images += that.fileList1[i].url + ','
  157. }
  158. }
  159. $api.req({
  160. url: '/data/api.auth.ShipEngineMaintenance/repairoffer',
  161. method: 'POST',
  162. data: {
  163. id: that.id,
  164. price: that.money,
  165. imgs: images,
  166. }
  167. }, function(res) {
  168. if(res.code == 1) {
  169. that.getData()
  170. that.name = "",
  171. that.money = ""
  172. that.fileList1 = []
  173. }
  174. })
  175. }
  176. },
  177. }
  178. </script>
  179. <style lang="scss" scoped>
  180. .content::v-deep {
  181. background: #F4F4F4;
  182. padding: 0 30rpx;
  183. .box {
  184. width: 100%;
  185. background: #FFFFFF;
  186. border-radius: 24rpx;
  187. box-sizing: border-box;
  188. padding: 24rpx 20rpx;
  189. margin-top: 20rpx;
  190. .title {
  191. font-size: 28rpx;
  192. font-weight: 500;
  193. color: #222222;
  194. }
  195. .offer_detail {
  196. width: 100%;
  197. height: 68rpx;
  198. background: #F4F4F4;
  199. border-radius: 16rpx;
  200. box-sizing: border-box;
  201. padding: 20rpx;
  202. margin: 10rpx 0;
  203. .offer_left {
  204. font-size: 22rpx;
  205. font-weight: 400;
  206. color: #777777;
  207. margin-right: 40rpx;
  208. }
  209. .offer_money {
  210. font-size: 28rpx;
  211. font-weight: 400;
  212. color: #FF3636;
  213. }
  214. }
  215. .input {
  216. width: 100%;
  217. height: 88rpx;
  218. background: #F4F4F4;
  219. border-radius: 16rpx;
  220. font-size: 32rpx;
  221. font-weight: 500;
  222. color: #222222;
  223. box-sizing: border-box;
  224. padding: 0 20rpx;
  225. line-height: 88rpx;
  226. margin: 20rpx 0;
  227. }
  228. .input_bg {
  229. background: #F4F4F4;
  230. border-radius: 8px;
  231. box-sizing: border-box;
  232. padding: 16rpx 20rpx;
  233. margin: 20rpx 0;
  234. .price {
  235. font-size: 32rpx;
  236. font-weight: 500;
  237. color: #222222;
  238. padding-right: 20rpx;
  239. }
  240. .u-textarea {
  241. background-color: #F4F4F4 !important;
  242. }
  243. .red {
  244. font-size: 28rpx;
  245. font-weight: bold;
  246. color: #FF3636;
  247. }
  248. }
  249. .text_style1 {
  250. font-size: 28rpx;
  251. font-weight: 500;
  252. color: #444444;
  253. }
  254. .imgs {
  255. width: 200rpx;
  256. height: 200rpx;
  257. border-radius: 16rpx;
  258. margin: 0 20rpx 20rpx 0;
  259. }
  260. .upload {
  261. margin-top: 20rpx;
  262. }
  263. }
  264. .btn {
  265. margin: 56rpx 0 22rpx;
  266. width: 100%;
  267. height: 88rpx;
  268. background: #506DFF;
  269. border-radius: 44rpx;
  270. font-size: 36rpx;
  271. font-weight: 500;
  272. text-align: center;
  273. line-height: 88rpx;
  274. color: #FFFFFF;
  275. }
  276. .text {
  277. font-size: 24rpx;
  278. font-weight: 400;
  279. color: #222222;
  280. }
  281. .text2 {
  282. color: #999999;
  283. }
  284. }
  285. </style>