myHome.vue 12 KB

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