myHome.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  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. this.$refs.uToast.show({
  173. type: 'error',
  174. message: failres.errmsg,
  175. })
  176. uni.hideLoading()
  177. }).then(res => {
  178. console.log(res)
  179. if(type=='list'){
  180. if(res.data.items.length>0){
  181. this.companyData=res.data.items[0]
  182. if(res.data.items[0].addressUrl){
  183. var arr=res.data.items[0].addressUrl.split(',')
  184. this.fileList1=[]
  185. for(var i=0;i<arr.length;i++){
  186. if(arr[i]){
  187. this.fileList1.push({url:arr[i]})
  188. }
  189. }
  190. this.fileList=arr
  191. }
  192. console.log(this.fileList1)
  193. this.editstatus=false
  194. }else{
  195. this.editstatus=true
  196. }
  197. }else{
  198. if(res.data){
  199. this.companyData=res.data
  200. if(res.data.addressUrl){
  201. var arr=res.data.addressUrl.split(',')
  202. this.fileList1=[]
  203. for(var i=0;i<arr.length;i++){
  204. if(arr[i]){
  205. this.fileList1.push({url:arr[i]})
  206. }
  207. }
  208. this.fileList=arr
  209. }
  210. console.log(this.fileList1)
  211. this.editstatus=false
  212. }else{
  213. this.editstatus=true
  214. }
  215. }
  216. setTimeout(()=>{
  217. that.loading=false
  218. },1000)
  219. // if (res.errno == 200) {
  220. uni.hideLoading()
  221. // }
  222. })
  223. },
  224. edit(){
  225. this.editstatus=true
  226. },
  227. change(){
  228. },
  229. click(index){
  230. console.log(index)
  231. uni.previewImage({
  232. current: index, // 当前显示图片的索引值
  233. urls: this.fileList, // 需要预览的图片列表,photoList要求必须是数组
  234. loop:true, // 是否可循环预览
  235. })
  236. },
  237. buttonsubmit(){
  238. uni.showLoading({
  239. title: '数据加载中',
  240. mask:true
  241. })
  242. if(this.companyData.id){
  243. this.$request.baseRequest('admin.unimall.personalHomepageInfo', 'update',{
  244. personalHomepageInfo:JSON.stringify(this.companyData)
  245. }, failres => {
  246. console.log('res+++++', failres.errmsg)
  247. this.$refs.uToast.show({
  248. type: 'error',
  249. message: failres.errmsg,
  250. })
  251. uni.hideLoading()
  252. }).then(res => {
  253. // if (res.errno == 200) {
  254. uni.hideLoading()
  255. this.$refs.uToast.show({
  256. type: 'success',
  257. message: '编辑成功',
  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. this.$refs.uToast.show({
  268. type: 'error',
  269. message: failres.errmsg,
  270. })
  271. uni.hideLoading()
  272. }).then(res => {
  273. // if (res.errno == 200) {
  274. uni.hideLoading()
  275. this.$refs.uToast.show({
  276. type: 'success',
  277. message: '提交成功',
  278. })
  279. this.getList()
  280. // }
  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. // let a = uni.uploadFile({
  326. // url: 'http://192.168.2.21:7001/upload', // 仅为示例,非真实的接口地址
  327. // filePath: url,
  328. // name: 'file',
  329. // formData: {
  330. // user: 'test'
  331. // },
  332. // success: (res) => {
  333. // setTimeout(() => {
  334. // resolve(res.data.data)
  335. // }, 1000)
  336. // }
  337. // });
  338. })
  339. },
  340. }
  341. }
  342. </script>
  343. <style scoped lang="scss">
  344. /deep/.u-border {
  345. border-color: #E6E6E6!important;
  346. }
  347. .content{
  348. }
  349. .indicator {
  350. background:rgba(10, 23, 61, 0.5);
  351. padding: 9rpx 5rpx;
  352. border-radius: 20rpx;
  353. @include flex(row);
  354. justify-content: center;
  355. &__dot {
  356. height: 6px;
  357. width: 6px;
  358. border-radius: 100px;
  359. background-color: rgba(255, 255, 255, 0.5);
  360. margin: 0 5px;
  361. transition: background-color 0.3s;
  362. &--active {
  363. background-color: #ffffff;
  364. }
  365. }
  366. }
  367. .top{
  368. width: 100vw;
  369. height: 135rpx;
  370. background: #112253;
  371. border-radius: 0px 0px 20rpx 20rpx;
  372. }
  373. .content1{
  374. margin: 0rpx 0 120rpx 0;
  375. background-color: #fff;
  376. border-radius: 20rpx 20rpx 0 0;
  377. padding:10rpx 20rpx;
  378. box-sizing: border-box;
  379. .row:last-child{
  380. padding-bottom: 20rpx;
  381. }
  382. .line{
  383. border-bottom: 1px solid #E6E6E6;
  384. }
  385. .top-m{
  386. margin-top: 20rpx;
  387. }
  388. .qyfc{
  389. margin: 24rpx 0;
  390. }
  391. }
  392. .content1-edit{
  393. position: relative;
  394. top: -230rpx;
  395. margin: 20rpx 20rpx 120rpx 20rpx;
  396. border-radius: 20rpx;
  397. padding:20rpx;
  398. }
  399. .footer{
  400. position: fixed;
  401. bottom: 0rpx;
  402. width: calc(100% - 40rpx);
  403. padding: 40rpx 20rpx;
  404. z-index: 999;
  405. background:#fff;
  406. }
  407. .button{
  408. color: #fff;
  409. background-color: #112253;
  410. border-radius: 20rpx;
  411. padding:10rpx;
  412. font-size:28rpx;
  413. }
  414. .company-title{
  415. margin:30rpx 20rpx;
  416. .button{
  417. padding:10rpx 20rpx;
  418. width:96rpx;
  419. }
  420. }
  421. .company-title .title{
  422. color:#112253;
  423. font-size:36rpx;
  424. font-weight: bold;
  425. }
  426. .title{
  427. font-size:32rpx;
  428. font-weight: bold;
  429. color: #1A1A1A;
  430. margin:20rpx 0;
  431. }
  432. .content{
  433. font-size: 28rpx;
  434. font-weight: 500;
  435. color: #666666;
  436. }
  437. .compInformation{
  438. margin:20rpx 0;
  439. background:#F7F7F7;
  440. color:#112253;
  441. font-size: 28rpx;
  442. font-weight: 500;
  443. padding:10rpx 30rpx;
  444. border-radius:20rpx;
  445. }
  446. .image-wrap{
  447. width:50rpx;
  448. position:relative;
  449. top:2rpx;
  450. }
  451. .input-title{
  452. margin-right:10rpx;
  453. }
  454. </style>