storeinfo.vue 21 KB

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