123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- <template>
- <view class="content">
- <view class="box">
- <view class="title">需求说明</view>
- <u--textarea v-model="purchase.description" placeholder="请详细描述你的采购需求" border="none"></u--textarea>
- <view class="title">上传营业执照或者身份证件照</view>
- <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple :maxCount="1" width="200rpx" height="200rpx"></u-upload>
- </view>
- <view class="box" style="margin-bottom: 186rpx;">
- <view class="title">上传图片以及资质证件照片</view>
- <u-upload :fileList="fileList2" @afterRead="afterRead" @delete="deletePic" name="2" multiple :maxCount="9" width="200rpx" height="200rpx"></u-upload>
- </view>
- <view class="bottom">
- <view class="bottom_btn" @click="open">立即发布</view>
- </view>
- </view>
- </template>
- <script>
- import $api from '@/static/js/api.js'
- var that = ''
- export default {
- data() {
- return {
- purchase: {
- },
- fileList1: [],
- fileList2: []
- }
- },
- onLoad() {
- that = this
- },
- methods: {
- // 删除图片
- deletePic(event) {
- this[`fileList${event.name}`].splice(event.index, 1)
- },
- // 新增图片
- async afterRead(event) {
- uni.showLoading({
- title: '上传中',
- mask: true
- })
- let lists = [].concat(event.file)
- let fileListLen = this[`fileList${event.name}`].length
- lists.map((item) => {
- this[`fileList${event.name}`].push({
- ...item,
- status: 'uploading',
- message: '上传中'
- })
- })
- for (let i = 0; i < lists.length; i++) {
- const result = await this.uploadFilePromise(lists[i].url)
- let item = this[`fileList${event.name}`][fileListLen]
- this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
- status: 'success',
- message: '',
- url: result.url
- }))
- fileListLen++
- if(lists.length - 1 == i) {
- uni.hideLoading()
- }
- }
- },
- uploadFilePromise(url) {
- return new Promise((resolve, reject) => {
- let a = uni.uploadFile({
- url: $api.config.baseUrl + '/data/api.auth.Center/upload',
- filePath: url,
- name: 'file',
- header: {
- 'content-type': 'application/x-www-form-urlencoded',
- 'api-token': uni.getStorageSync('token').token?uni.getStorageSync('token').token:'',
- 'api-name': 'wxapp'
- },
- formData: {
- user: 'test'
- },
- success: (res) => {
- setTimeout(() => {
- var data = JSON.parse(res.data)
- resolve(data.data)
- }, 1000)
- }
- });
- })
- },
- // 立即发布
- open() {
- var imgs = ''
- if(that.fileList2.length == 1) {
- imgs = that.fileList2[0].url
- } else if (that.fileList2.length > 1) {
- for(var i=0;i<that.fileList2.length;i++) {
- if(i == that.fileList2.length - 1) {
- imgs += that.fileList2[i].url
- } else {
- imgs += that.fileList2[i].url + ','
- }
- }
- }
- $api.req({
- url: '/data/api.auth.Center/subpurchaseacceptance',
- method: 'POST',
- data: {
- description : that.purchase.description,
- business_img: that.fileList1[0].url,
- imgs: imgs,
- province: uni.getStorageSync('location').province,
- city: uni.getStorageSync('location').city,
- area: uni.getStorageSync('location').district,
- id: that.purchase.id?that.purchase.id:''
- }
- }, function(res) {
- if(res.code == 1) {
- $api.info(res.info)
- $api.jump(-1)
- }
- })
- },
- },
- }
- </script>
- <style lang="scss" scoped>
- .content::v-deep {
- background: #F5F5F5;
- .box {
- width: 690rpx;
- margin: 20rpx 30rpx 0;
- background: #FFFFFF;
- border-radius: 20rpx;
- box-sizing: border-box;
- padding: 12rpx 20rpx;
- .title {
- font-size: 28rpx;
- font-weight: 400;
- color: #222222;
- margin: 20rpx 0;
- }
- .u-textarea {
- background: #F5F5F5;
- }
- }
- .bottom {
- width: 100%;
- z-index: 9;
- position: fixed;
- bottom: 0;
- height: 166rpx;
- background: #FFFFFF;
- box-sizing: border-box;
- padding: 8rpx 40rpx 74rpx;
- .bottom_btn {
- width: 100%;
- height: 84rpx;
- background: #506DFF;
- border-radius: 42rpx;
- font-size: 36rpx;
- font-weight: 500;
- color: #FFFFFF;
- text-align: center;
- line-height: 84rpx;
- }
-
- }
- }
- </style>
|