myHome.vue 13 KB

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