myHome.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <template>
  2. <view class="content">
  3. <view v-if='!editstatus&&fileList.length>0' class="swiper-wrap">
  4. <u-swiper :list="fileList"
  5. autoplay
  6. imgMode='aspectFill'
  7. height='260'
  8. @change="e => current = e.current" @click="click">
  9. <view slot="indicator" class="indicator">
  10. <view
  11. class="indicator__dot"
  12. v-for="(item, index) in fileList"
  13. :key="index"
  14. :class="[index === current && 'indicator__dot--active']">
  15. </view>
  16. </view>
  17. </u-swiper>
  18. </view>
  19. <!-- <u-skeleton
  20. rows="3"
  21. title
  22. loading
  23. ></u-skeleton> -->
  24. <view class="top" v-else>
  25. </view>
  26. <view class="company-title row flex flex-between line" >
  27. <view class='title' v-if='!editstatus'>{{companyData.companyName}}</view>
  28. <view v-if='!editstatus' class='button flex align-item-center' @click='edit'>
  29. <image src="../../static/imgs/mySet/edit.png" style='width:26rpx;height:26rpx;' mode=""></image>
  30. <view style='margin-left:10rpx;'>编辑</view>
  31. </view>
  32. <view v-else @click='$u.debounce(buttonsubmit, 500)' class='button'>提交</view>
  33. </view>
  34. <view class="content1" :class="editstatus?'content1-edit':''">
  35. <view v-if='editstatus' class="row flex flex-between line" >
  36. <view>公司/机构名称</view>
  37. <u--input v-model="companyData.companyName" placeholder="请输入公司名称" border="none" inputAlign='right'></u--input>
  38. </view>
  39. <view class="intro top-m">
  40. <view v-if='editstatus' class="row">公司/机构简介</view>
  41. <view v-else class="title">基本信息</view>
  42. <u--textarea v-if='editstatus' v-model="companyData.companyIntroduction" count placeholder="请输入公司/机构简介,不超过1000个字"></u--textarea>
  43. <view class='content' v-else>{{companyData.companyIntroduction}}</view>
  44. </view>
  45. <view class="scope top-m">
  46. <view v-if='editstatus' class="row">业务范围</view>
  47. <view v-else class="title">业务范围</view>
  48. <u--textarea v-if='editstatus' v-model="companyData.scopeOfBusiness" count placeholder="输入业务范围,不超过500个字"></u--textarea>
  49. <view class='content' v-else>{{companyData.scopeOfBusiness}}</view>
  50. </view>
  51. <view class='compInformation' v-if='!editstatus'>
  52. <view class="row flex top-m align-item-center">
  53. <view class='image-wrap'>
  54. <image style='width:24rpx;height:31rpx;' src="../../static/imgs/mySet/home/address.png" mode=""></image>
  55. </view>
  56. <view>地址:{{companyData.companyAddress}}</view>
  57. </view>
  58. <view class="row flex top-m align-item-center">
  59. <view class='image-wrap'>
  60. <image style='width:27rpx;height:28rpx;' src="../../static/imgs/mySet/home/phone.png" mode=""></image>
  61. </view>
  62. <view>电话:{{companyData.phone}}</view>
  63. </view>
  64. <view class="row flex top-m align-item-center">
  65. <view class='image-wrap'>
  66. <image style='width:27rpx;height:28rpx;' src="../../static/imgs/mySet/home/portraiture.png" mode=""></image>
  67. </view>
  68. <view>座机:{{companyData.portraiture}}</view>
  69. </view>
  70. <view class="row flex top-m align-item-center">
  71. <view class='image-wrap'>
  72. <image style='width:29rpx;height:25rpx;' src="../../static/imgs/mySet/home/postbox.png" mode=""></image>
  73. </view>
  74. <view>邮箱:{{companyData.postbox}}</view>
  75. </view>
  76. </view>
  77. <view v-if='editstatus' class="row flex flex-between line top-m">
  78. <view>公司地址</view>
  79. <u--input v-model="companyData.companyAddress" placeholder="输入地址" border="none" inputAlign='right'></u--input>
  80. </view>
  81. <view v-if='editstatus' class="row flex flex-between line top-m">
  82. <view>联系电话</view>
  83. <u--input v-model="companyData.phone" placeholder="输入联系电话" border="none" inputAlign='right'></u--input>
  84. </view>
  85. <view v-if='editstatus' class="row flex flex-between line top-m">
  86. <view >传真</view>
  87. <u--input v-model="companyData.portraiture" placeholder="输入传真号" border="none" inputAlign='right'></u--input>
  88. </view>
  89. <view v-if='editstatus' class="row flex flex-between line top-m">
  90. <view>邮箱</view>
  91. <u--input v-if='editstatus' v-model="companyData.postbox" placeholder="输入邮箱" border="none" inputAlign='right'></u--input>
  92. </view>
  93. <view v-if='editstatus'>
  94. <view class="qyfc">企业风采</view>
  95. <!-- <image v-for='item in fileList' :src="item.url" mode=""></image> -->
  96. <u-upload
  97. @afterRead="afterRead"
  98. :fileList="fileList1"
  99. @delete="deletePic"
  100. name="1"
  101. multiple
  102. :maxCount="10"
  103. >
  104. <image style='width:24rpx;height:31rpx;' src="../../static/imgs/mySet/home/address.png" mode=""></image>
  105. </u-upload>
  106. </view>
  107. </view>
  108. <view class="footer">
  109. <button v-if='editstatus' @click='$u.debounce(buttonsubmit, 500)' class='button' type="default">提交</button>
  110. </view>
  111. <u-toast ref="uToast"></u-toast>
  112. </view>
  113. </template>
  114. <script>
  115. import uploadImage from '@/components/ossutil/uploadFile.js';
  116. export default {
  117. data() {
  118. return {
  119. companyData:{
  120. commonId:''
  121. },
  122. userInfo:{},
  123. fileList:[],
  124. fileList1:[],
  125. editstatus:false,
  126. id:'',
  127. current:0,
  128. }
  129. },
  130. onLoad(options) {
  131. this.id=options.id
  132. uni.showLoading({
  133. title: '数据加载中'
  134. })
  135. this.getList()
  136. },
  137. onShow() {
  138. this.userInfo = uni.getStorageSync("userInfo")
  139. this.companyData.commonId=uni.getStorageSync("userInfo").id
  140. console.log(1111111111)
  141. // this.getList()
  142. },
  143. onUnload(){
  144. this.id=''
  145. },
  146. methods: {
  147. getList(){
  148. var data={}
  149. if(this.id){
  150. data={
  151. personalHomeId:this.id,
  152. page:1,
  153. limit:10,
  154. }
  155. }else{
  156. data={
  157. page:1,
  158. limit:10,
  159. commonId:uni.getStorageSync("userInfo").id
  160. }
  161. }
  162. this.$request.baseRequest('admin.unimall.personalHomepageInfo', 'list',data, failres => {
  163. console.log('res+++++', failres.errmsg)
  164. this.$refs.uToast.show({
  165. type: 'error',
  166. message: failres.errmsg,
  167. })
  168. uni.hideLoading()
  169. }).then(res => {
  170. console.log(res)
  171. if(res.data.items.length>0){
  172. this.companyData=res.data.items[0]
  173. if(res.data.items[0].addressUrl){
  174. var arr=res.data.items[0].addressUrl.split(',')
  175. this.fileList1=[]
  176. for(var i=0;i<arr.length;i++){
  177. if(arr[i]){
  178. this.fileList1.push({url:arr[i]})
  179. }
  180. }
  181. this.fileList=arr
  182. }
  183. console.log(this.fileList1)
  184. this.editstatus=false
  185. }else{
  186. this.editstatus=true
  187. }
  188. // if (res.errno == 200) {
  189. uni.hideLoading()
  190. // }
  191. })
  192. },
  193. edit(){
  194. this.editstatus=true
  195. },
  196. change(){
  197. },
  198. click(index){
  199. console.log(index)
  200. uni.previewImage({
  201. current: index, // 当前显示图片的索引值
  202. urls: this.fileList, // 需要预览的图片列表,photoList要求必须是数组
  203. loop:true, // 是否可循环预览
  204. })
  205. },
  206. buttonsubmit(){
  207. uni.showLoading({
  208. title: '数据加载中',
  209. mask:true
  210. })
  211. if(this.companyData.id){
  212. this.$request.baseRequest('admin.unimall.personalHomepageInfo', 'update',{
  213. personalHomepageInfo:JSON.stringify(this.companyData)
  214. }, failres => {
  215. console.log('res+++++', failres.errmsg)
  216. this.$refs.uToast.show({
  217. type: 'error',
  218. message: failres.errmsg,
  219. })
  220. uni.hideLoading()
  221. }).then(res => {
  222. // if (res.errno == 200) {
  223. uni.hideLoading()
  224. this.$refs.uToast.show({
  225. type: 'success',
  226. message: '编辑成功',
  227. })
  228. this.getList()
  229. // }
  230. })
  231. }else{
  232. this.$request.baseRequest('admin.unimall.personalHomepageInfo', 'add',{
  233. personalHomepageInfo:JSON.stringify(this.companyData)
  234. }, failres => {
  235. console.log('res+++++', failres.errmsg)
  236. this.$refs.uToast.show({
  237. type: 'error',
  238. message: failres.errmsg,
  239. })
  240. uni.hideLoading()
  241. }).then(res => {
  242. // if (res.errno == 200) {
  243. uni.hideLoading()
  244. this.$refs.uToast.show({
  245. type: 'success',
  246. message: '提交成功',
  247. })
  248. this.getList()
  249. // }
  250. })
  251. }
  252. },
  253. deletePic(event) {
  254. this[`fileList${event.name}`].splice(event.index, 1)
  255. this.companyData.addressUrl =this[`fileList${event.name}`].toString()
  256. },
  257. // 新增图片
  258. async afterRead(event) {
  259. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  260. let lists = [].concat(event.file)
  261. let fileListLen = this[`fileList${event.name}`].length
  262. lists.map((item) => {
  263. this[`fileList${event.name}`].push({
  264. ...item,
  265. status: 'uploading',
  266. message: '上传中'
  267. })
  268. })
  269. // console.log(event,111111,fileListLen)
  270. for (let i = 0; i < lists.length; i++) {
  271. const result = await this.uploadFilePromise(lists[i].url)
  272. this.companyData.addressUrl = this.companyData.addressUrl?this.companyData.addressUrl+','+result:result
  273. this[`fileList${event.name}`][fileListLen]={}
  274. let item = this[`fileList${event.name}`][fileListLen]
  275. console.log(item)
  276. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  277. status: 'success',
  278. message: '',
  279. url: result
  280. }))
  281. fileListLen++
  282. }
  283. console.log(this[`fileList${event.name}`])
  284. },
  285. uploadFilePromise(url) {
  286. console.log(url)
  287. return new Promise((resolve, reject) => {
  288. uploadImage(url, 'cardImages/',
  289. result => {
  290. console.log(result,22222)
  291. resolve(result)
  292. }
  293. )
  294. // let a = uni.uploadFile({
  295. // url: 'http://192.168.2.21:7001/upload', // 仅为示例,非真实的接口地址
  296. // filePath: url,
  297. // name: 'file',
  298. // formData: {
  299. // user: 'test'
  300. // },
  301. // success: (res) => {
  302. // setTimeout(() => {
  303. // resolve(res.data.data)
  304. // }, 1000)
  305. // }
  306. // });
  307. })
  308. },
  309. }
  310. }
  311. </script>
  312. <style scoped lang="scss">
  313. /deep/.u-border {
  314. border-color: #E6E6E6!important;
  315. }
  316. .content{
  317. }
  318. .indicator {
  319. background:rgba(10, 23, 61, 0.5);
  320. padding: 9rpx 5rpx;
  321. border-radius: 20rpx;
  322. @include flex(row);
  323. justify-content: center;
  324. &__dot {
  325. height: 6px;
  326. width: 6px;
  327. border-radius: 100px;
  328. background-color: rgba(255, 255, 255, 0.5);
  329. margin: 0 5px;
  330. transition: background-color 0.3s;
  331. &--active {
  332. background-color: #ffffff;
  333. }
  334. }
  335. }
  336. .top{
  337. width: 100vw;
  338. height: 135rpx;
  339. background: #112253;
  340. border-radius: 0px 0px 20rpx 20rpx;
  341. }
  342. .content1{
  343. margin: 0rpx 0 120rpx 0;
  344. background-color: #fff;
  345. border-radius: 20rpx 20rpx 0 0;
  346. padding:10rpx 20rpx;
  347. box-sizing: border-box;
  348. .row{
  349. padding-bottom: 24rpx;
  350. }
  351. .line{
  352. border-bottom: 1px solid #E6E6E6;
  353. }
  354. .top-m{
  355. margin-top: 24rpx;
  356. }
  357. .qyfc{
  358. margin: 24rpx 0;
  359. }
  360. }
  361. .content1-edit{
  362. position: relative;
  363. top: -230rpx;
  364. margin: 20rpx 20rpx 120rpx 20rpx;
  365. border-radius: 20rpx;
  366. padding:20rpx;
  367. }
  368. .footer{
  369. position: fixed;
  370. bottom: 80rpx;
  371. width: calc(100% - 40rpx);
  372. padding: 0 20rpx;
  373. z-index: 999;
  374. }
  375. .button{
  376. color: #fff;
  377. background-color: #112253;
  378. border-radius: 20rpx;
  379. padding:10rpx;
  380. font-size:28rpx;
  381. }
  382. .company-title{
  383. margin:30rpx 20rpx;
  384. .button{
  385. padding:10rpx 20rpx;
  386. }
  387. }
  388. .company-title .title{
  389. color:#112253;
  390. font-size:36rpx;
  391. font-weight: bold;
  392. }
  393. .title{
  394. font-size:32rpx;
  395. font-weight: bold;
  396. color: #1A1A1A;
  397. }
  398. .content{
  399. font-size: 28rpx;
  400. font-weight: 500;
  401. color: #666666;
  402. }
  403. .compInformation{
  404. margin:20rpx 0;
  405. background:#F7F7F7;
  406. color:#112253;
  407. font-size: 28rpx;
  408. font-weight: 500;
  409. padding:10rpx 30rpx;
  410. border-radius:20rpx;
  411. }
  412. .image-wrap{
  413. width:50rpx;
  414. position:relative;
  415. top:2rpx;
  416. }
  417. </style>