waixie.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <view class="content">
  3. <view class="title">订单信息</view>
  4. <view class="box">
  5. <view class="box_item hflex acenter">
  6. <view class="left">联系人</view>
  7. <u-input v-model="name" border="none" placeholder="请输入联系人姓名"></u-input>
  8. </view>
  9. <view class="box_item hflex acenter">
  10. <view class="left">联系电话</view>
  11. <u-input v-model="phone" border="none" placeholder="请输入手机号"></u-input>
  12. </view>
  13. </view>
  14. <view class="hflex acenter jbetween" style="padding-right: 30rpx;">
  15. <view class="title">商品信息</view>
  16. <view class="hflex acenter " @click="addGood">
  17. <image src="/static/images/common/add_icon2.png" style="width: 36rpx;height: 36rpx;"></image>
  18. <view class="add_text">添加</view>
  19. </view>
  20. </view>
  21. <block v-for="(item,index) in items">
  22. <view class="box">
  23. <view class="box_item hflex acenter">
  24. <view class="left">商品{{index + 1}}</view>
  25. <u-input v-model="item.name" border="none" placeholder="请输入标题"></u-input>
  26. </view>
  27. <view class="box_item hflex acenter">
  28. <view class="left">规格</view>
  29. <u-input v-model="item.spec" border="none" placeholder="如颜色/尺寸等"></u-input>
  30. </view>
  31. <view class="box_item hflex acenter">
  32. <view class="left">数量</view>
  33. <u-input v-model="item.number" border="none" placeholder="请输入数量"></u-input>
  34. </view>
  35. <view class="box_item hflex acenter jbetween">
  36. <view class="left">附件</view>
  37. <view class="center hflex">
  38. <block v-for="(item2,index2) in item.enclosure" :key="index2">
  39. <view>{{item2.filename}}</view>
  40. </block>
  41. </view>
  42. <view class="right" @click="upload(index)">上传附件</view>
  43. </view>
  44. <view class="hflex acenter jend">
  45. <view class="dte_btn hflex acenter jcenter" @click="delGood(index)">删除</view>
  46. </view>
  47. </view>
  48. </block>
  49. <view class="box">
  50. <view class="box_item1">
  51. <view class="left">生产技术标准</view>
  52. <u-textarea v-model="standard_tech" placeholder="请填写生产技术的标准"></u-textarea>
  53. </view>
  54. <view class="box_item1">
  55. <view class="left">生产验收标准</view>
  56. <u-textarea v-model="standard_check" placeholder="请填写生产验收的标准"></u-textarea>
  57. </view>
  58. <view class="box_item hflex acenter">
  59. <view class="left">交货地址</view>
  60. <u-input v-model="post_address" border="none" placeholder="请填写交货地址"></u-input>
  61. </view>
  62. <view class="box_item hflex acenter" @click="showTime">
  63. <view class="left">交货时间</view>
  64. <u-input v-model="post_time" border="none" disabled disabledColor="#fff" placeholder="请选择交货时间" suffixIcon="arrow-right"></u-input>
  65. </view>
  66. <u-datetime-picker :show="show_time" :formatter="formatter" :minDate="Number(new Date())" mode="datetime" @close="close" @confirm="selectTime"></u-datetime-picker>
  67. </view>
  68. <view class="box">
  69. <view class="box_title">图片/视频</view>
  70. <u-upload :fileList="fileList1" :accept='accept' @afterRead="afterRead" @delete="deletePic" name="1" multiple :maxCount="9" width="200rpx" height="200rpx"></u-upload>
  71. </view>
  72. <view class="btn hflex acenter jcenter" @click="release">立即发布</view>
  73. </view>
  74. </template>
  75. <script>
  76. import $api from '@/static/js/api.js'
  77. var that = ''
  78. export default {
  79. data() {
  80. return {
  81. name: '',
  82. phone: '',
  83. items: [
  84. {
  85. name: '',
  86. spec: '',
  87. number: '',
  88. enclosure: [
  89. {
  90. filename: '',
  91. fileurl: '',
  92. }
  93. ]
  94. }
  95. ],
  96. good: {
  97. name: '',
  98. spec: '',
  99. number: '',
  100. enclosure: [
  101. {
  102. filename: '',
  103. fileurl: '',
  104. }
  105. ]
  106. },
  107. show: false,
  108. accept: ['image','video'],
  109. fileList1: [],
  110. post_address: '',
  111. post_time: '',
  112. show_time: false,
  113. standard_tech: '',
  114. standard_check: '',
  115. id: '',
  116. }
  117. },
  118. onLoad(options) {
  119. that = this
  120. if(options.id) {
  121. that.id = options.id
  122. that.getData()
  123. }
  124. },
  125. methods: {
  126. getData() {
  127. $api.req({
  128. url: '/data/api.business.Purchase/show',
  129. data: {
  130. tab: 3,
  131. id: that.id
  132. }
  133. }, function(res) {
  134. if(res.code == 1) {
  135. that.name = res.data.real_name
  136. that.phone = res.data.mobile
  137. that.items = res.data.items
  138. that.fileList1 = res.data.file
  139. that.post_address = res.data.post_address
  140. that.post_time = res.data.post_time
  141. that.standard_tech = res.data.standard_tech
  142. that.standard_check = res.data.standard_check
  143. }
  144. })
  145. },
  146. showTime() {
  147. that.show_time = true
  148. },
  149. close() {
  150. that.show_time = false
  151. },
  152. selectTime(e) {
  153. that.post_time = $api.formatDate(e)
  154. that.close()
  155. },
  156. upload(index) {
  157. uni.chooseFile({
  158. count: 9, //默认100
  159. type:'all',
  160. success: function (res) {
  161. const tempFilePaths = res.tempFilePaths;
  162. uni.uploadFile({
  163. url: $api.config.baseUrl + '/data/api.auth.Center/upload', //仅为示例,非真实的接口地址
  164. filePath: tempFilePaths[0],
  165. name: 'file',
  166. header: {
  167. 'token': uni.getStorageSync('token')?uni.getStorageSync('token'):'',
  168. 'api-name': 'iosapp'
  169. },
  170. formData: {
  171. 'user': 'test'
  172. },
  173. success: (uploadFileRes) => {
  174. var data = JSON.parse(uploadFileRes.data)
  175. var enclosure = {
  176. filename: res.tempFiles[0].name,
  177. fileurl: data.data.url
  178. }
  179. if(that.items[index].enclosure[0].filename == '') {
  180. that.items[index].enclosure.splice(0,1,enclosure)
  181. } else {
  182. that.items[index].enclosure.push(enclosure)
  183. }
  184. console.log('items',that.items);
  185. }
  186. });
  187. },
  188. fail: function(res) {
  189. console.log('fail',res);
  190. }
  191. });
  192. },
  193. // 删除图片
  194. deletePic(event) {
  195. this[`fileList${event.name}`].splice(event.index, 1)
  196. },
  197. // 新增图片
  198. async afterRead(event) {
  199. let lists = [].concat(event.file)
  200. let fileListLen = this[`fileList${event.name}`].length
  201. lists.map((item) => {
  202. this[`fileList${event.name}`].push({
  203. ...item,
  204. // status: 'uploading',
  205. // message: '上传中'
  206. })
  207. })
  208. for (let i = 0; i < lists.length; i++) {
  209. const result = await this.uploadFilePromise(lists[i].url)
  210. let item = this[`fileList${event.name}`][fileListLen]
  211. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  212. // status: 'success',
  213. type: result.type,
  214. url: result.url
  215. }))
  216. fileListLen++
  217. }
  218. console.log(that.fileList1);
  219. },
  220. uploadFilePromise(url) {
  221. return new Promise((resolve, reject) => {
  222. let a = uni.uploadFile({
  223. url: $api.config.baseUrl + '/data/api.auth.Center/upload', // 仅为示例,非真实的接口地址
  224. filePath: url,
  225. name: 'file',
  226. header: {
  227. 'token': uni.getStorageSync('token')?uni.getStorageSync('token'):'',
  228. 'api-name': 'iosapp'
  229. },
  230. formData: {
  231. user: 'test'
  232. },
  233. success: (res) => {
  234. setTimeout(() => {
  235. var data = JSON.parse(res.data)
  236. console.log('data:',data);
  237. var type = data.data.key.split('.')
  238. if(type[1] == 'mp4') {
  239. that.$set(data.data,'type','video')
  240. } else {
  241. that.$set(data.data,'type','image')
  242. }
  243. resolve(data.data)
  244. }, 1000)
  245. }
  246. });
  247. })
  248. },
  249. addGood() {
  250. that.items.push(that.good)
  251. },
  252. delGood(index) {
  253. that.items.splice(index,1)
  254. },
  255. release() {
  256. console.log(that.fileList1);
  257. var images = []
  258. var image = {}
  259. for(var i=0;i<that.fileList1.length;i++) {
  260. image = {
  261. type: that.fileList1[i].type,
  262. src: that.fileList1[i].url,
  263. url: that.fileList1[i].url
  264. }
  265. images.push(image)
  266. }
  267. $api.req({
  268. url: '/data/api.business.Purchase/coordination_order',
  269. method: 'POST',
  270. data: {
  271. id: that.id,
  272. real_name: that.name,
  273. mobile: that.phone,
  274. standard_tech: that.standard_tech,
  275. standard_check: that.standard_check,
  276. post_time: that.post_time,
  277. post_address: that.post_address,
  278. file: JSON.stringify(images),
  279. item: JSON.stringify(that.items)
  280. }
  281. }, function(res) {
  282. if(res.code == 1) {
  283. $api.info(res.info)
  284. }
  285. })
  286. }
  287. },
  288. }
  289. </script>
  290. <style lang="scss" scoped>
  291. .content::v-deep {
  292. background: #F5F5F5;
  293. .title {
  294. font-size: 30rpx;
  295. font-weight: 500;
  296. color: #222222;
  297. line-height: 42rpx;
  298. padding: 24rpx 0 14rpx 30rpx;
  299. }
  300. .add_text {
  301. font-size: 28rpx;
  302. font-weight: 500;
  303. color: #222222;
  304. line-height: 40rpx;
  305. padding-left: 2rpx;
  306. }
  307. .box {
  308. width: 100%;
  309. box-sizing: border-box;
  310. padding: 0 30rpx;
  311. background: #fff;
  312. margin-bottom: 20rpx;
  313. .box_title {
  314. font-size: 28rpx;
  315. font-weight: 500;
  316. color: #222222;
  317. line-height: 40rpx;
  318. padding: 24rpx 0 20rpx;
  319. }
  320. .box_item {
  321. padding: 28rpx 0;
  322. border-bottom: 1rpx solid #F5F5F5;
  323. .left {
  324. width: 156rpx;
  325. font-size: 30rpx;
  326. font-weight: 400;
  327. color: #222222;
  328. line-height: 42rpx;
  329. }
  330. .center {
  331. width: calc(100% - 276rpx);
  332. }
  333. .right {
  334. font-size: 30rpx;
  335. font-weight: 400;
  336. color: #5471FF;
  337. line-height: 42rpx;
  338. }
  339. }
  340. .box_item1 {
  341. padding: 28rpx 0;
  342. .left {
  343. // width: 156rpx;
  344. font-size: 30rpx;
  345. font-weight: 400;
  346. color: #222222;
  347. line-height: 42rpx;
  348. }
  349. .u-textarea {
  350. margin: 28rpx 0 0;
  351. border: none;
  352. background: #F5F5F5;
  353. border-radius: 16rpx;
  354. }
  355. }
  356. .dte_btn {
  357. width: 132rpx;
  358. height: 52rpx;
  359. margin: 30rpx 0;
  360. border-radius: 26rpx;
  361. border: 1rpx solid #D3D3D3;
  362. font-size: 26rpx;
  363. font-weight: 400;
  364. color: #222222;
  365. line-height: 36rpx;
  366. }
  367. }
  368. .btn {
  369. margin: 28rpx auto;
  370. width: 690rpx;
  371. height: 84rpx;
  372. background: #5471FF;
  373. border-radius: 46rpx;
  374. font-size: 36rpx;
  375. font-weight: 500;
  376. color: #FFFFFF;
  377. }
  378. .popu_title {
  379. font-size: 36rpx;
  380. font-weight: 500;
  381. color: #222222;
  382. line-height: 50rpx;
  383. }
  384. }
  385. </style>