myHome.vue 13 KB

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