storeinfo.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. <template>
  2. <div>
  3. <div class="com-mobile-header">
  4. <a @click="goLastPage"><i class="iconfont icon-fanhui"></i></a>
  5. <p>店铺信息
  6. <span @click="updateInfo()" v-show="storeState === 'look'"><i class="iconfont icon-edit"></i>编辑</span>
  7. </p>
  8. </div>
  9. <!-- 店铺管理 -->
  10. <template v-if="storeInfo.storeName" >
  11. <div class="user-content mobile-fix-content">
  12. <div ref="userContent" class="user-center-content">
  13. <div class="scroll">
  14. <div class="si-wrap">
  15. <ul class="infoul" :class="{'no-edit': !isAdmin}">
  16. <li class="clearfix" :class="{border: storeState !== 'look'}">
  17. <div class="name pull-left" :class="{update: storeState !== 'look'}">店铺LOGO:</div>
  18. <div class="file_logo pull-left">
  19. <div class="file_img">
  20. <img :src="imageUploadUrl ? imageUploadUrl : storeInfo.logoUrl ? storeInfo.logoUrl : '/images/logo/default.png'">
  21. </div>
  22. <div class="file_input" v-if="storeState !== 'look'">
  23. <input type="file"
  24. class="file-input"
  25. name="name"
  26. accept="image/jpeg,image/jpg,image/gif,image/bmp,image/png"
  27. @change="uploadImg"/>
  28. <span>仅支持JPG、PNG、GIF格式,大小不超过500kb,建议使用220*220的图片</span>
  29. </div>
  30. </div>
  31. </li>
  32. <li class="clearfix" :class="{border: storeState !== 'look'}">
  33. <div class="name pull-left" :class="{update: storeState !== 'look'}">店铺名称:</div>
  34. <div class="text pull-left" v-if="storeState === 'look'">
  35. {{storeInfo.storeName || '暂无信息'}}
  36. </div>
  37. <div class="text pull-left" v-else>
  38. <input v-model="storeInfo.storeName" type="text"/>
  39. </div>
  40. </li>
  41. <li class="clearfix" :class="{border: storeState !== 'look'}">
  42. <div class="name pull-left" :class="{update: storeState !== 'look'}">主营产品:</div>
  43. <div class="text pull-left clearfix" v-if="storeState === 'look'">
  44. {{Islook ? dealWithText(storeInfo.description) : dealWithText()}}
  45. <a class="pull-right" @click="dealWithText2('open')" v-show="Islook">
  46. 全部<img src="/images/store/default/openblack.png"/>
  47. </a>
  48. <a class="pull-right upload" @click="dealWithText2('hide')" v-show="!hidelook">
  49. 收起<img src="/images/store/default/openblack.png"/>
  50. </a>
  51. </div>
  52. <div class="text pull-left" v-else>
  53. <textarea v-model="storeInfo.description" maxlength="500" ref="descTextarea"></textarea>
  54. </div>
  55. </li>
  56. <li class="clearfix" :class="{border: storeState !== 'look'}">
  57. <div class="name pull-left" :class="{update: storeState !== 'look'}">应用领域:</div>
  58. <div class="text pull-left clearfix" v-if="storeState === 'look'">
  59. {{storeInfo.storeApplication || '暂无信息'}}
  60. </div>
  61. <div class="text pull-left" v-else>
  62. <textarea v-model="storeInfo.storeApplication" maxlength="100" ref="applicationTextarea"></textarea>
  63. </div>
  64. </li>
  65. <li class="clearfix" :class="{border: storeState !== 'look'}">
  66. <div class="name pull-left" :class="{update: storeState !== 'look'}">企业介绍:</div>
  67. <div class="text pull-left clearfix" v-if="storeState === 'look'">
  68. {{IsEnlook ? dealWithEnText(storeInfo.enterprise.description) : dealWithEnText()}}
  69. <a class="pull-right" @click="dealWithEnText2('open')" v-show="IsEnlook">
  70. 全部<img src="/images/store/default/openblack.png"/>
  71. </a>
  72. <a class="pull-right upload" @click="dealWithEnText2('hide')" v-show="!hideEnlook">
  73. 收起<img src="/images/store/default/openblack.png"/>
  74. </a>
  75. </div>
  76. <div class="text pull-left" v-else>
  77. <textarea v-model="storeInfo.enterprise.description" maxlength="500" ref="enTextarea"></textarea>
  78. </div>
  79. </li>
  80. <!-- <li class="clearfix" :class="{border: storeState !== 'look'}">
  81. <div class="name pull-left" :class="{update: storeState !== 'look'}">店铺地址:</div>
  82. <div class="text pull-left" v-if="storeState === 'look'">
  83. {{storeInfo.enterprise.address || '暂无信息'}}
  84. </div>
  85. <div class="text pull-left" v-else>
  86. <textarea v-model="storeInfo.enterprise.address" maxlength="50" ref="addTextarea"></textarea>
  87. &lt;!&ndash;<input v-model="storeInfo.enterprise.address" type="text" maxlength="50"/>&ndash;&gt;
  88. </div>
  89. </li>-->
  90. <li class="clearfix" :class="{border: storeState !== 'look'}">
  91. <div class="name pull-left" :class="{update: storeState !== 'look'}">电话:</div>
  92. <div class="text pull-left" v-if="storeState === 'look'">
  93. {{storeInfo.enterprise.enTel || '暂无信息'}}
  94. </div>
  95. <div class="text pull-left" v-else>
  96. <input v-model="storeInfo.enterprise.enTel" type="text" maxlength="20"/>
  97. </div>
  98. </li>
  99. <li class="clearfix" :class="{border: storeState !== 'look'}">
  100. <div class="name pull-left" :class="{update: storeState !== 'look'}">传真:</div>
  101. <div class="text pull-left" v-if="storeState === 'look'">
  102. {{storeInfo.enterprise.enFax || '暂无信息'}}
  103. </div>
  104. <div class="text pull-left" v-else>
  105. <input v-model="storeInfo.enterprise.enFax" type="text" maxlength="20"/>
  106. </div>
  107. </li>
  108. <li class="clearfix" :class="{border: storeState !== 'look'}">
  109. <div class="name pull-left" :class="{update: storeState !== 'look'}">手机:</div>
  110. <div class="text pull-left" v-if="storeState === 'look'">
  111. {{storeInfo.enterprise.enPhone || '暂无信息'}}
  112. </div>
  113. <div class="text pull-left" v-else>
  114. <input v-model="storeInfo.enterprise.enPhone" type="text" maxlength="11"/>
  115. </div>
  116. </li>
  117. <li class="clearfix" :class="{border: storeState !== 'look'}">
  118. <div class="name pull-left" :class="{update: storeState !== 'look'}">微信:</div>
  119. <div class="text pull-left" v-if="storeState === 'look'">
  120. {{storeInfo.enterprise.enWeixin || '暂无信息'}}
  121. </div>
  122. <div class="text pull-left" v-else>
  123. <input v-model="storeInfo.enterprise.enWeixin" type="text" maxlength="20"/>
  124. </div>
  125. </li>
  126. <li class="clearfix" :class="{border: storeState !== 'look'}">
  127. <div class="name pull-left" :class="{update: storeState !== 'look'}">QQ:</div>
  128. <div class="text pull-left" v-if="storeState === 'look'">
  129. {{storeInfo.enterprise.enQQ || '暂无信息'}}
  130. </div>
  131. <div class="text pull-left" v-else>
  132. <input v-model="storeInfo.enterprise.enQQ" type="text" maxlength="11"/>
  133. </div>
  134. </li>
  135. </ul>
  136. </div>
  137. <div class="control clearfix" v-if="storeState !== 'look'">
  138. <div class="cancel" @click="storeInfosave('cancel')" >取消</div>
  139. <div class="save" @click="storeInfosave()">保存</div>
  140. </div>
  141. </div>
  142. </div>
  143. </div>
  144. </template>
  145. <template v-else>
  146. <div class="none-state">
  147. <img src="/images/mobile/@2x/empty-collect.png">
  148. <p v-text="getRemindText"></p>
  149. <nuxt-link to="/">返回首页</nuxt-link>
  150. </div>
  151. </template>
  152. <!-- /end 店铺管理 -->
  153. <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
  154. <div v-if="storeI && false"></div>
  155. </div>
  156. </template>
  157. <script>
  158. import BScroll from 'better-scroll'
  159. import { RemindBox } from '~components/mobile/common'
  160. export default {
  161. layout: 'mobileNoHeader',
  162. middleware: 'authenticated',
  163. fetch ({ store }) {
  164. return Promise.all([
  165. store.dispatch('loadStoreStatus', { op: 'check' })
  166. ])
  167. },
  168. data() {
  169. return {
  170. imageUploadUrl: '',
  171. storeState: 'look',
  172. storeInfo: {},
  173. splitText: '', // 省略号文本
  174. normalText: '', // 原来文本
  175. Islook: true,
  176. hidelook: true,
  177. normalEnText: '', // 原来文本
  178. IsEnlook: true,
  179. hideEnlook: true,
  180. timeoutCount: 0,
  181. collectResult: ''
  182. }
  183. },
  184. watch: {
  185. 'storeInfo.description': {
  186. handler: function (val) {
  187. this.setTextareaHeight()
  188. }
  189. },
  190. // 'storeInfo.storeApplication': {
  191. // handler: function (val) {
  192. // this.setApplicationTextareaHeight()
  193. // }
  194. // },
  195. 'storeInfo.enterprise.description': {
  196. handler: function (val) {
  197. this.setEnTextareaHeight()
  198. }
  199. }
  200. // 'storeInfo.enterprise.address': {
  201. // handler: function (val) {
  202. // this.setAddarea()
  203. // }
  204. // }
  205. },
  206. methods: {
  207. uploadImg (e) {
  208. let file = e.target.files[0]
  209. if (file && file.size >= 500 * 1025) {
  210. this.collectResult = '选择图片过大,请重新选择!'
  211. this.timeoutCount++
  212. return
  213. }
  214. if (file) {
  215. let param = new FormData()
  216. param.append('image', file, file.name)
  217. let config = {
  218. headers: {'Content-Type': 'multipart/form-data'}
  219. }
  220. this.$http.post('/api/images', param, config)
  221. .then(response => {
  222. if (response.data) {
  223. this.imageUploadUrl = response.data[0].path
  224. }
  225. })
  226. }
  227. },
  228. setRemindText (str) {
  229. this.collectResult = str
  230. this.timeoutCount++
  231. },
  232. updateInfo() {
  233. this.authorityInterceptor('/store-service/stores/*', () => {
  234. this.storeState = 'update'
  235. this.Islook = true
  236. this.hidelook = true
  237. this.IsEnlook = true
  238. this.hideEnlook = true
  239. this.setTextareaHeight()
  240. this.setApplicationTextareaHeight()
  241. this.setEnTextareaHeight()
  242. // this.setAddarea()
  243. })
  244. },
  245. dealWithText2(tp) {
  246. if (tp === 'open') {
  247. this.Islook = false
  248. this.hidelook = false
  249. } else {
  250. this.Islook = true
  251. this.hidelook = true
  252. }
  253. },
  254. dealWithEnText2(tp) {
  255. if (tp === 'open') {
  256. this.IsEnlook = false
  257. this.hideEnlook = false
  258. } else {
  259. this.IsEnlook = true
  260. this.hideEnlook = true
  261. }
  262. },
  263. dealWithText(_T) {
  264. if (_T !== undefined) {
  265. // 文本处理
  266. this.normalText = _T
  267. if (_T.length < 140) {
  268. this.Islook = false
  269. return _T
  270. } else {
  271. this.Islook = true
  272. return _T.substr(0, 140) + '...'
  273. }
  274. } else {
  275. this.Islook = false
  276. return this.normalText && this.normalText.length ? this.normalText : '暂无信息'
  277. }
  278. },
  279. dealWithEnText(_T) {
  280. if (_T !== undefined) {
  281. // 文本处理
  282. this.normalEnText = _T
  283. if (_T.length < 140) {
  284. this.IsEnlook = false
  285. return _T
  286. } else {
  287. this.IsEnlook = true
  288. return _T.substr(0, 140) + '...'
  289. }
  290. } else {
  291. this.IsEnlook = false
  292. return this.normalEnText && this.normalEnText.length ? this.normalEnText : '暂无信息'
  293. }
  294. },
  295. storeInfosave(_tp) {
  296. this.BScroll.refresh()
  297. if (_tp === 'cancel') {
  298. let str = JSON.stringify(this.$store.state.option.storeStatus.data)
  299. this.storeInfo = JSON.parse(str)
  300. this.storeState = 'look'
  301. return false
  302. }
  303. if (!this.storeInfo) {
  304. this.collectResult = '店铺信息不能为空'
  305. this.timeoutCount++
  306. return false
  307. }
  308. // if (!this.storeInfo.description || this.storeInfo.description === '') {
  309. // this.collectResult = '店铺简介信息不能为空'
  310. // this.timeoutCount++
  311. // return false
  312. // }
  313. if (!this.storeInfo.enterprise) {
  314. this.collectResult = '企业信息不能为空'
  315. this.timeoutCount++
  316. return false
  317. }
  318. // if (!this.storeInfo.enterprise.description || this.storeInfo.enterprise.description === '') {
  319. // this.collectResult = '企业介绍不能为空'
  320. // this.timeoutCount++
  321. // return false
  322. // }
  323. if (!this.storeInfo.enterprise.enTel || this.storeInfo.enterprise.enTel === '' || !/^[\d-]{8,20}$/.test(this.storeInfo.enterprise.enTel)) {
  324. this.collectResult = '请输入正确的电话号码'
  325. this.timeoutCount++
  326. return false
  327. }
  328. if (this.storeInfo.enterprise.enFax && this.storeInfo.enterprise.enFax !== '' && !/^[\d-]{8,20}$/.test(this.storeInfo.enterprise.enTel)) {
  329. this.collectResult = '请输入正确的传真'
  330. this.timeoutCount++
  331. return false
  332. }
  333. if (this.storeInfo.enterprise.enPhone && this.storeInfo.enterprise.enPhone !== '' && !/^1[3|4|5|6|7|8|9][0-9]{9}$/.test(this.storeInfo.enterprise.enPhone)) {
  334. this.collectResult = '请输入正确的手机号码'
  335. this.timeoutCount++
  336. return false
  337. }
  338. if (this.storeInfo.enterprise.enWeixin && this.storeInfo.enterprise.enWeixin !== '' && !/^[0-9a-zA-Z]{6,20}$/.test(this.storeInfo.enterprise.enWeixin)) {
  339. this.collectResult = '请输入正确的微信号'
  340. this.timeoutCount++
  341. return false
  342. }
  343. if (this.storeInfo.enterprise.enQQ && this.storeInfo.enterprise.enQQ !== '' && !/^[1-9][0-9]{4,10}$/.test(this.storeInfo.enterprise.enQQ)) {
  344. this.collectResult = '请输入正确的QQ号'
  345. this.timeoutCount++
  346. return false
  347. }
  348. let kay = {
  349. description: this.storeInfo.description,
  350. enterprise: this.storeInfo.enterprise,
  351. storeName: this.storeInfo.storeName,
  352. storeShortName: this.storeInfo.storeShortName,
  353. storeApplication: this.storeInfo.storeApplication,
  354. logoUrl: this.imageUploadUrl
  355. }
  356. this.$http.put(`/store-service/stores/${this.storeInfo.uuid}?kind=BASIC_INFO`, kay).then(res => {
  357. this.collectResult = '保存成功'
  358. this.timeoutCount++
  359. this.storeState = 'look'
  360. }).catch(err => {
  361. this.collectResult = err.response.data
  362. this.timeoutCount++
  363. let str = JSON.stringify(this.$store.state.option.storeStatus.data)
  364. this.storeInfo = JSON.parse(str)
  365. })
  366. },
  367. setTextareaHeight () {
  368. this.$nextTick(() => {
  369. let el = this.$refs.descTextarea
  370. if (el) {
  371. el.style.height = '2rem'
  372. el.style.height = (el.scrollHeight * 2.06 - el.clientHeight + 150) / 100 + 'rem'
  373. }
  374. })
  375. },
  376. setApplicationTextareaHeight () {
  377. this.$nextTick(() => {
  378. let el = this.$refs.applicationTextarea
  379. if (el) {
  380. el.style.height = '2rem'
  381. el.style.height = (el.scrollHeight * 2.06 - el.clientHeight + 150) / 100 + 'rem'
  382. }
  383. })
  384. },
  385. setEnTextareaHeight () {
  386. this.$nextTick(() => {
  387. let el = this.$refs.enTextarea
  388. if (el) {
  389. el.style.height = '2rem'
  390. el.style.height = (el.scrollHeight * 2.06 - el.clientHeight + 150) / 100 + 'rem'
  391. }
  392. })
  393. },
  394. // setAddarea () {
  395. // this.$nextTick(() => {
  396. // let el = this.$refs.addTextarea
  397. // if (el) {
  398. // // console.log(el.scrollHeight - el.clientHeight)
  399. // // console.log(el.clientHeight)
  400. // // console.log('-----------------')
  401. // el.style.height = '.6rem'
  402. // el.style.height = (el.scrollHeight * 2 - el.clientHeight + 25) / 100 + 'rem'
  403. // }
  404. // })
  405. // },
  406. setBS () {
  407. if (this.BScroll) {
  408. this.BScroll.refresh()
  409. } else {
  410. this.BScroll = new BScroll(this.$refs.userContent, {
  411. click: true
  412. })
  413. }
  414. },
  415. cancelBS () {
  416. this.BScroll.destroy()
  417. }
  418. },
  419. computed: {
  420. getRemindText: function () {
  421. return '您的账户暂未开通店铺,请前往pc端申请开通!'
  422. },
  423. storeI() {
  424. let str = JSON.stringify(this.$store.state.option.storeStatus.data)
  425. this.storeInfo = JSON.parse(str)
  426. return ''
  427. },
  428. isAdmin () {
  429. return this.user.data.userUU === this.user.data.enterprise.enAdminuu
  430. }
  431. },
  432. components: {
  433. RemindBox
  434. },
  435. mounted() {
  436. this.$nextTick(() => {
  437. this.setBS()
  438. })
  439. }
  440. }
  441. </script>
  442. <style lang="scss" scoped>
  443. .user-content {
  444. background: #f1f3f6;
  445. .si-wrap {
  446. width: 7.1rem;
  447. margin: .3rem auto;
  448. background: #fff;
  449. border-radius: .05rem;
  450. }
  451. .user-center-content {
  452. height: 100%;
  453. overflow: hidden;
  454. }
  455. .scroll {
  456. padding-bottom: 0.4rem;
  457. }
  458. }
  459. .com-mobile-header {
  460. i {
  461. font-size: .36rem;
  462. position: relative;
  463. top: .04rem;
  464. right: .02rem;
  465. }
  466. }
  467. .topinfo {
  468. padding: 0 0.24rem;
  469. color: #333;
  470. font-size: 0.28rem;
  471. height: 0.8rem;
  472. line-height: 0.8rem;
  473. border-bottom: 0.01rem solid #d9d9d9;
  474. .pull-right {
  475. color: #999;
  476. font-size: 0.26rem;
  477. img {
  478. width: 0.34rem;
  479. height: 0.34rem;
  480. }
  481. }
  482. }
  483. .infoul {
  484. color: #666;
  485. font-size: 0.28rem;
  486. padding: 0 .24rem;
  487. .file_logo{
  488. position:relative;
  489. width:4.4rem;
  490. .file_img{
  491. width:1rem;
  492. display:inline-block;
  493. img{
  494. width:100%;
  495. height: 1rem;
  496. }
  497. }
  498. .file_input{
  499. position:absolute;
  500. top:0;
  501. left:0;
  502. display:inline-block;
  503. vertical-align: top;
  504. width:4.4rem;
  505. input[type=file] {
  506. opacity: 0;
  507. width: 1rem;
  508. height: 1rem;
  509. float: left;
  510. margin-right:.15rem;
  511. }
  512. span{
  513. font-size: .20rem;
  514. }
  515. }
  516. }
  517. .upload {
  518. img {
  519. transform: rotate(180deg);
  520. }
  521. }
  522. li {
  523. border-bottom: .01rem solid #d9d9d9;
  524. min-height: 1.16rem;
  525. line-height: normal;
  526. padding: .4rem .2rem;
  527. &.border {
  528. border-bottom: .01rem solid #d9d9d9;
  529. }
  530. &.noupdate {
  531. background: #fafafa;
  532. color: #999;
  533. }
  534. }
  535. .name {
  536. width: 1.8rem;
  537. text-align: right;
  538. color: #226ce7;
  539. }
  540. &.no-edit {
  541. color: #999;
  542. .name {
  543. color: #226ce7;
  544. }
  545. }
  546. .text {
  547. width: 4.4rem;
  548. word-break: break-all;
  549. line-height: .44rem;
  550. }
  551. /*.pull-left {*/
  552. /*float: none !important;*/
  553. /*display: inline-block;*/
  554. /*word-wrap: break-word;*/
  555. /*vertical-align: top;*/
  556. /*}*/
  557. .update {
  558. padding: 0.06rem 0 0.06rem 0;
  559. }
  560. input {
  561. width: 4.4rem;
  562. border: 0 solid #b4b4b4;
  563. padding: 0.06rem 0 0.06rem 0.12rem;
  564. }
  565. textarea{
  566. width: 4.4rem;
  567. height: 1.36rem;
  568. padding: 0.06rem 0 0.06rem 0.12rem;
  569. overflow-y: visible;
  570. border: none;
  571. }
  572. }
  573. .control {
  574. width: 90%;
  575. margin: 0.15rem auto 0.4rem;
  576. height: .88rem;
  577. line-height: 0.88rem;
  578. }
  579. .save {
  580. border-radius: 3px;
  581. width: 48%;
  582. color: #fff;
  583. text-align: center;
  584. height: .88rem;
  585. line-height: 0.88rem;
  586. background: #3e82f5;
  587. float: right;
  588. }
  589. .cancel {
  590. border-radius: 3px;
  591. width: 48%;
  592. background: #acabab;
  593. color: #fff;
  594. text-align: center;
  595. height: .88rem;
  596. line-height: 0.88rem;
  597. float: left;
  598. }
  599. .none-state{
  600. text-align: center;
  601. padding:1.5rem 0;
  602. background: #fff;
  603. margin-top:.1rem;
  604. width:100%;
  605. img{
  606. margin:0 auto;
  607. width: 4.08rem;
  608. height: 2.62rem;
  609. }
  610. p {
  611. font-size: .32rem;
  612. color: #999;
  613. margin: 1.19rem 0 0 0;
  614. }
  615. a {
  616. display: block;
  617. font-size: .28rem;
  618. color: #fff;
  619. width: 1.88rem;
  620. height: .54rem;
  621. line-height: .54rem;
  622. background: #418bf6;
  623. margin: .7rem auto 0;
  624. border-radius: .05rem;
  625. }
  626. }
  627. </style>