myHome.vue 13 KB

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