123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- <template>
- <view class="content">
- <view v-if='!editstatus&&fileList.length>0' class="swiper-wrap">
- <u-swiper :list="fileList" indicator indicatorMode="dot"
- autoplay
- imgMode='aspectFit'
- height='300'
- @change="change" @click="click">
- </u-swiper>
- </view>
- <!-- <u-skeleton
- rows="3"
- title
- loading
- ></u-skeleton> -->
- <view class="top" v-else>
-
- </view>
- <view class="content1" :class="editstatus?'content1-edit':''">
- <view class="company-title row flex flex-between line" >
- <view v-if='editstatus'>公司/机构名称</view>
- <u--input v-if='editstatus' v-model="companyData.companyName" placeholder="请输入公司名称" border="none" inputAlign='right'></u--input>
- <view v-else>{{companyData.companyName}}</view>
- </view>
- <view class="intro top-m">
- <view v-if='editstatus'class="row">公司/机构简介</view>
- <u--textarea v-if='editstatus' v-model="companyData.companyIntroduction" count placeholder="请输入公司/机构简介,不超过1000个字"></u--textarea>
- <view v-else>{{companyData.companyIntroduction}}</view>
- </view>
- <view class="scope top-m">
- <view class="row">业务范围</view>
- <u--textarea v-if='editstatus' v-model="companyData.scopeOfBusiness" count placeholder="输入业务范围,不超过500个字"></u--textarea>
- <view v-else>{{companyData.scopeOfBusiness}}</view>
- </view>
- <view class="row flex flex-between line top-m">
- <view v-if='editstatus'>公司地址</view>
- <u--input v-if='editstatus' v-model="companyData.companyAddress" placeholder="输入地址" border="none" inputAlign='right'></u--input>
- <view v-else>{{companyData.companyAddress}}</view>
- </view>
- <view class="row flex flex-between line top-m">
- <view v-if='editstatus'>联系电话</view>
- <u--input v-if='editstatus' v-model="companyData.phone" placeholder="输入联系电话" border="none" inputAlign='right'></u--input>
- <view v-else>{{companyData.phone}}</view>
- </view>
- <view class="row flex flex-between line top-m">
- <view v-if='editstatus'>传真</view>
- <u--input v-if='editstatus' v-model="companyData.portraiture" placeholder="输入传真号" border="none" inputAlign='right'></u--input>
- <view v-else>{{companyData.portraiture}}</view>
- </view>
- <view class="row flex flex-between line top-m">
- <view v-if='editstatus'>邮箱</view>
- <u--input v-if='editstatus' v-model="companyData.postbox" placeholder="输入邮箱" border="none" inputAlign='right'></u--input>
- <view v-else>{{companyData.postbox}}</view>
- </view>
- <view v-if='editstatus'>
- <view class="qyfc">企业风采</view>
- <!-- <image v-for='item in fileList' :src="item.url" mode=""></image> -->
- <u-upload
- @afterRead="afterRead"
- :fileList="fileList1"
- @delete="deletePic"
- name="1"
- multiple
- :maxCount="10"
- ></u-upload>
- </view>
- </view>
- <view class="footer">
- <button v-if='!editstatus' @click='edit' class='button' >编辑</button>
- <button v-else @click='$u.debounce(buttonsubmit, 500)' class='button' type="default">提交</button>
- </view>
-
- <u-toast ref="uToast"></u-toast>
- </view>
- </template>
- <script>
- import uploadImage from '@/components/ossutil/uploadFile.js';
- export default {
- data() {
- return {
- companyData:{
- commonId:''
- },
- userInfo:{},
- fileList:[],
- fileList1:[],
- editstatus:false,
- }
- },
- onLoad() {
- uni.showLoading({
- title: '数据加载中'
- })
- this.getList()
- },
- onShow() {
- this.userInfo = uni.getStorageSync("userInfo")
- this.companyData.commonId=uni.getStorageSync("userInfo").id
- console.log(1111111111)
-
-
- // this.getList()
-
- },
- methods: {
- getList(){
- this.$request.baseRequest('admin.unimall.personalHomepageInfo', 'list',{
- page:1,
- limit:10,
- commonId:uni.getStorageSync("userInfo").id
- }, failres => {
- console.log('res+++++', failres.errmsg)
- this.$refs.uToast.show({
- type: 'error',
- message: failres.errmsg,
- })
- uni.hideLoading()
- }).then(res => {
- console.log(res)
- if(res.data.items.length>0){
- this.companyData=res.data.items[0]
- if(res.data.items[0].addressUrl){
- var arr=res.data.items[0].addressUrl.split(',')
- this.fileList1=[]
- for(var i=0;i<arr.length;i++){
- if(arr[i]){
- this.fileList1.push({url:arr[i]})
- }
- }
- this.fileList=arr
- }
- console.log(this.fileList1)
- this.editstatus=false
- }else{
- this.editstatus=true
- }
- // if (res.errno == 200) {
- uni.hideLoading()
-
- // }
- })
- },
- edit(){
- this.editstatus=true
- },
- change(){
-
- },
- click(index){
- console.log(index)
- uni.previewImage({
- current: index, // 当前显示图片的索引值
- urls: this.fileList, // 需要预览的图片列表,photoList要求必须是数组
- loop:true, // 是否可循环预览
- })
- },
- buttonsubmit(){
- uni.showLoading({
- title: '数据加载中',
- mask:true
- })
- if(this.companyData.id){
- this.$request.baseRequest('admin.unimall.personalHomepageInfo', 'update',{
- personalHomepageInfo:JSON.stringify(this.companyData)
- }, failres => {
- console.log('res+++++', failres.errmsg)
- this.$refs.uToast.show({
- type: 'error',
- message: failres.errmsg,
- })
- uni.hideLoading()
- }).then(res => {
- // if (res.errno == 200) {
- uni.hideLoading()
- this.$refs.uToast.show({
- type: 'success',
- message: '编辑成功',
- })
- this.getList()
- // }
- })
- }else{
- this.$request.baseRequest('admin.unimall.personalHomepageInfo', 'add',{
- personalHomepageInfo:JSON.stringify(this.companyData)
- }, failres => {
- console.log('res+++++', failres.errmsg)
- this.$refs.uToast.show({
- type: 'error',
- message: failres.errmsg,
- })
- uni.hideLoading()
- }).then(res => {
- // if (res.errno == 200) {
- uni.hideLoading()
- this.$refs.uToast.show({
- type: 'success',
- message: '提交成功',
- })
- this.getList()
-
- // }
- })
- }
-
- },
- deletePic(event) {
- this[`fileList${event.name}`].splice(event.index, 1)
- this.companyData.addressUrl =this[`fileList${event.name}`].toString()
- },
- // 新增图片
- async afterRead(event) {
- // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
- let lists = [].concat(event.file)
- let fileListLen = this[`fileList${event.name}`].length
- lists.map((item) => {
- this[`fileList${event.name}`].push({
- ...item,
- status: 'uploading',
- message: '上传中'
- })
- })
- // console.log(event,111111,fileListLen)
- for (let i = 0; i < lists.length; i++) {
- const result = await this.uploadFilePromise(lists[i].url)
- this.companyData.addressUrl = this.companyData.addressUrl?this.companyData.addressUrl+','+result:result
- this[`fileList${event.name}`][fileListLen]={}
- let item = this[`fileList${event.name}`][fileListLen]
- console.log(item)
- this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
- status: 'success',
- message: '',
- url: result
- }))
- fileListLen++
- }
- console.log(this[`fileList${event.name}`])
- },
- uploadFilePromise(url) {
- console.log(url)
- return new Promise((resolve, reject) => {
- uploadImage(url, 'cardImages/',
- result => {
- console.log(result,22222)
-
- resolve(result)
- }
- )
- // let a = uni.uploadFile({
- // url: 'http://192.168.2.21:7001/upload', // 仅为示例,非真实的接口地址
- // filePath: url,
- // name: 'file',
- // formData: {
- // user: 'test'
- // },
- // success: (res) => {
- // setTimeout(() => {
- // resolve(res.data.data)
- // }, 1000)
- // }
- // });
- })
- },
- }
- }
- </script>
- <style scoped lang="scss">
- /deep/.u-border {
- border-color: #E6E6E6!important;
- }
- .content{
-
- }
- .top{
- width: 100vw;
- height: 135rpx;
- background: #112253;
- border-radius: 0px 0px 20rpx 20rpx;
- }
- .content1{
- margin: 20rpx 0 120rpx 0;
- background-color: #fff;
- border-radius: 20rpx;
- padding: 20rpx;
- box-sizing: border-box;
- .row{
- padding-bottom: 24rpx;
- }
- .line{
- border-bottom: 1px solid #E6E6E6;
- }
- .top-m{
- margin-top: 24rpx;
- }
- .qyfc{
- margin: 24rpx 0;
- }
- }
- .content1-edit{
- position: relative;
- top: -135rpx;
- }
- .footer{
- position: fixed;
- bottom: 80rpx;
- width: calc(100% - 40rpx);
- padding: 0 20rpx;
- }
- .button{
- color: #fff;
- background-color: #112253;
- border-radius: 20rpx;
- }
- </style>
|