myHome.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  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. companyIntroduction:'',
  125. scopeOfBusiness:''
  126. },
  127. userInfo:{},
  128. fileList:[],
  129. fileList1:[],
  130. editstatus:false,
  131. id:'',
  132. current:0,
  133. loading:true,
  134. }
  135. },
  136. onLoad(options) {
  137. this.id=options.id
  138. uni.showLoading({
  139. title: '数据加载中'
  140. })
  141. this.getList()
  142. },
  143. onShow() {
  144. this.userInfo = uni.getStorageSync("userInfo")
  145. this.companyData.commonId=uni.getStorageSync("userInfo").id
  146. console.log(1111111111)
  147. // this.getList()
  148. },
  149. onUnload(){
  150. this.id=''
  151. },
  152. methods: {
  153. getList(){
  154. var that=this
  155. var data={}
  156. var type=''
  157. if(this.id){
  158. data={
  159. id:this.id,
  160. }
  161. type='get'
  162. }else{
  163. data={
  164. page:1,
  165. limit:10,
  166. commonId:uni.getStorageSync("userInfo").id
  167. }
  168. type='list'
  169. }
  170. this.$request.baseRequest('admin.unimall.personalHomepageInfo', type,data, failres => {
  171. console.log('res+++++', failres.errmsg)
  172. uni.hideLoading()
  173. uni.showToast({
  174. icon:"none",
  175. title: failres.errmsg,
  176. duration: 3000
  177. });
  178. }).then(res => {
  179. console.log(res)
  180. if(type=='list'){
  181. if(res.data.items.length>0){
  182. this.companyData=res.data.items[0]
  183. if(res.data.items[0].addressUrl){
  184. var arr=res.data.items[0].addressUrl.split(',')
  185. this.fileList1=[]
  186. for(var i=0;i<arr.length;i++){
  187. if(arr[i]){
  188. this.fileList1.push({url:arr[i]})
  189. }
  190. }
  191. this.fileList=arr
  192. }
  193. console.log(this.fileList1)
  194. this.editstatus=false
  195. }else{
  196. this.editstatus=true
  197. }
  198. }else{
  199. if(res.data){
  200. this.companyData=res.data
  201. if(res.data.addressUrl){
  202. var arr=res.data.addressUrl.split(',')
  203. this.fileList1=[]
  204. for(var i=0;i<arr.length;i++){
  205. if(arr[i]){
  206. this.fileList1.push({url:arr[i]})
  207. }
  208. }
  209. this.fileList=arr
  210. }
  211. console.log(this.fileList1)
  212. this.editstatus=false
  213. }else{
  214. this.editstatus=true
  215. }
  216. }
  217. setTimeout(()=>{
  218. that.loading=false
  219. },1000)
  220. // if (res.errno == 200) {
  221. uni.hideLoading()
  222. // }
  223. })
  224. },
  225. edit(){
  226. this.editstatus=true
  227. },
  228. change(){
  229. },
  230. click(index){
  231. console.log(index)
  232. uni.previewImage({
  233. current: index, // 当前显示图片的索引值
  234. urls: this.fileList, // 需要预览的图片列表,photoList要求必须是数组
  235. loop:true, // 是否可循环预览
  236. })
  237. },
  238. buttonsubmit(){
  239. uni.showLoading({
  240. title: '数据加载中',
  241. mask:true
  242. })
  243. if(this.companyData.id){
  244. this.$request.baseRequest('admin.unimall.personalHomepageInfo', 'update',{
  245. personalHomepageInfo:JSON.stringify(this.companyData)
  246. }, failres => {
  247. console.log('res+++++', failres.errmsg)
  248. uni.showToast({
  249. icon:"none",
  250. title: failres.errmsg,
  251. duration: 3000
  252. });
  253. }).then(res => {
  254. // if (res.errno == 200) {
  255. uni.hideLoading()
  256. uni.showToast({
  257. icon:"success",
  258. title: '编辑成功!',
  259. duration: 2000
  260. });
  261. this.getList()
  262. // }
  263. })
  264. }else{
  265. this.$request.baseRequest('admin.unimall.personalHomepageInfo', 'add',{
  266. personalHomepageInfo:JSON.stringify(this.companyData)
  267. }, failres => {
  268. console.log('res+++++', failres.errmsg)
  269. uni.hideLoading()
  270. uni.showToast({
  271. icon:"none",
  272. title: failres.errmsg,
  273. duration: 3000
  274. });
  275. }).then(res => {
  276. uni.hideLoading()
  277. uni.showToast({
  278. icon:"success",
  279. title: '提交成功!',
  280. duration: 2000
  281. });
  282. this.getList()
  283. })
  284. }
  285. },
  286. deletePic(event) {
  287. this[`fileList${event.name}`].splice(event.index, 1)
  288. this.companyData.addressUrl =this[`fileList${event.name}`].toString()
  289. },
  290. // 新增图片
  291. async afterRead(event) {
  292. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  293. let lists = [].concat(event.file)
  294. let fileListLen = this[`fileList${event.name}`].length
  295. lists.map((item) => {
  296. this[`fileList${event.name}`].push({
  297. ...item,
  298. status: 'uploading',
  299. message: '上传中'
  300. })
  301. })
  302. // console.log(event,111111,fileListLen)
  303. for (let i = 0; i < lists.length; i++) {
  304. const result = await this.uploadFilePromise(lists[i].url)
  305. this.companyData.addressUrl = this.companyData.addressUrl?this.companyData.addressUrl+','+result:result
  306. this[`fileList${event.name}`][fileListLen]={}
  307. let item = this[`fileList${event.name}`][fileListLen]
  308. console.log(item)
  309. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  310. status: 'success',
  311. message: '',
  312. url: result
  313. }))
  314. fileListLen++
  315. }
  316. console.log(this[`fileList${event.name}`])
  317. },
  318. uploadFilePromise(url) {
  319. console.log(url)
  320. return new Promise((resolve, reject) => {
  321. uploadImage(url, 'cardImages/',
  322. result => {
  323. console.log(result,22222)
  324. resolve(result)
  325. }
  326. )
  327. })
  328. },
  329. }
  330. }
  331. </script>
  332. <style scoped lang="scss">
  333. /deep/.u-border {
  334. border-color: #E6E6E6!important;
  335. }
  336. .content{
  337. }
  338. .indicator {
  339. background:rgba(10, 23, 61, 0.5);
  340. padding: 9rpx 5rpx;
  341. border-radius: 20rpx;
  342. @include flex(row);
  343. justify-content: center;
  344. &__dot {
  345. height: 6px;
  346. width: 6px;
  347. border-radius: 100px;
  348. background-color: rgba(255, 255, 255, 0.5);
  349. margin: 0 5px;
  350. transition: background-color 0.3s;
  351. &--active {
  352. background-color: #ffffff;
  353. }
  354. }
  355. }
  356. .top{
  357. width: 100vw;
  358. height: 135rpx;
  359. background: #112253;
  360. border-radius: 0px 0px 20rpx 20rpx;
  361. }
  362. .content1{
  363. margin: 0rpx 0 120rpx 0;
  364. background-color: #fff;
  365. border-radius: 20rpx 20rpx 0 0;
  366. padding:10rpx 20rpx;
  367. box-sizing: border-box;
  368. .row:last-child{
  369. padding-bottom: 20rpx;
  370. }
  371. .line{
  372. border-bottom: 1px solid #E6E6E6;
  373. }
  374. .top-m{
  375. margin-top: 20rpx;
  376. }
  377. .qyfc{
  378. margin: 24rpx 0;
  379. }
  380. }
  381. .content1-edit{
  382. position: relative;
  383. top: -230rpx;
  384. margin: 20rpx 20rpx 120rpx 20rpx;
  385. border-radius: 20rpx;
  386. padding:20rpx;
  387. }
  388. .footer{
  389. position: fixed;
  390. bottom: 0rpx;
  391. width: calc(100% - 40rpx);
  392. padding: 40rpx 20rpx;
  393. z-index: 999;
  394. background:#fff;
  395. }
  396. .button{
  397. color: #fff;
  398. background-color: #112253;
  399. border-radius: 20rpx;
  400. padding:10rpx;
  401. font-size:28rpx;
  402. }
  403. .company-title{
  404. margin:30rpx 20rpx;
  405. .button{
  406. padding:10rpx 20rpx;
  407. width:96rpx;
  408. }
  409. }
  410. .company-title .title{
  411. color:#112253;
  412. font-size:36rpx;
  413. font-weight: bold;
  414. }
  415. .title{
  416. font-size:32rpx;
  417. font-weight: bold;
  418. color: #1A1A1A;
  419. margin:20rpx 0;
  420. }
  421. .content{
  422. font-size: 28rpx;
  423. font-weight: 500;
  424. color: #666666;
  425. }
  426. .compInformation{
  427. margin:20rpx 0;
  428. background:#F7F7F7;
  429. color:#112253;
  430. font-size: 28rpx;
  431. font-weight: 500;
  432. padding:10rpx 30rpx;
  433. border-radius:20rpx;
  434. }
  435. .image-wrap{
  436. width:50rpx;
  437. position:relative;
  438. top:2rpx;
  439. }
  440. .input-title{
  441. margin-right:10rpx;
  442. }
  443. </style>