myHome.vue 13 KB

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