storeinfo.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  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. if (!this.isAdmin) {
  234. this.setRemindText('您无该模块的编辑权限,请联系企业管理员进行编辑维护!')
  235. return
  236. }
  237. this.storeState = 'update'
  238. this.Islook = true
  239. this.hidelook = true
  240. this.IsEnlook = true
  241. this.hideEnlook = true
  242. this.setTextareaHeight()
  243. this.setApplicationTextareaHeight()
  244. this.setEnTextareaHeight()
  245. // this.setAddarea()
  246. },
  247. dealWithText2(tp) {
  248. if (tp === 'open') {
  249. this.Islook = false
  250. this.hidelook = false
  251. } else {
  252. this.Islook = true
  253. this.hidelook = true
  254. }
  255. },
  256. dealWithEnText2(tp) {
  257. if (tp === 'open') {
  258. this.IsEnlook = false
  259. this.hideEnlook = false
  260. } else {
  261. this.IsEnlook = true
  262. this.hideEnlook = true
  263. }
  264. },
  265. dealWithText(_T) {
  266. if (_T !== undefined) {
  267. // 文本处理
  268. this.normalText = _T
  269. if (_T.length < 140) {
  270. this.Islook = false
  271. return _T
  272. } else {
  273. this.Islook = true
  274. return _T.substr(0, 140) + '...'
  275. }
  276. } else {
  277. this.Islook = false
  278. return this.normalText && this.normalText.length ? this.normalText : '暂无信息'
  279. }
  280. },
  281. dealWithEnText(_T) {
  282. if (_T !== undefined) {
  283. // 文本处理
  284. this.normalEnText = _T
  285. if (_T.length < 140) {
  286. this.IsEnlook = false
  287. return _T
  288. } else {
  289. this.IsEnlook = true
  290. return _T.substr(0, 140) + '...'
  291. }
  292. } else {
  293. this.IsEnlook = false
  294. return this.normalEnText && this.normalEnText.length ? this.normalEnText : '暂无信息'
  295. }
  296. },
  297. storeInfosave(_tp) {
  298. this.BScroll.refresh()
  299. if (_tp === 'cancel') {
  300. let str = JSON.stringify(this.$store.state.option.storeStatus.data)
  301. this.storeInfo = JSON.parse(str)
  302. this.storeState = 'look'
  303. return false
  304. }
  305. if (!this.storeInfo) {
  306. this.collectResult = '店铺信息不能为空'
  307. this.timeoutCount++
  308. return false
  309. }
  310. // if (!this.storeInfo.description || this.storeInfo.description === '') {
  311. // this.collectResult = '店铺简介信息不能为空'
  312. // this.timeoutCount++
  313. // return false
  314. // }
  315. if (!this.storeInfo.enterprise) {
  316. this.collectResult = '企业信息不能为空'
  317. this.timeoutCount++
  318. return false
  319. }
  320. // if (!this.storeInfo.enterprise.description || this.storeInfo.enterprise.description === '') {
  321. // this.collectResult = '企业介绍不能为空'
  322. // this.timeoutCount++
  323. // return false
  324. // }
  325. if (!this.storeInfo.enterprise.enTel || this.storeInfo.enterprise.enTel === '' || !/^[\d-]{8,20}$/.test(this.storeInfo.enterprise.enTel)) {
  326. this.collectResult = '请输入正确的电话号码'
  327. this.timeoutCount++
  328. return false
  329. }
  330. if (this.storeInfo.enterprise.enFax && this.storeInfo.enterprise.enFax !== '' && !/^[\d-]{8,20}$/.test(this.storeInfo.enterprise.enTel)) {
  331. this.collectResult = '请输入正确的传真'
  332. this.timeoutCount++
  333. return false
  334. }
  335. 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)) {
  336. this.collectResult = '请输入正确的手机号码'
  337. this.timeoutCount++
  338. return false
  339. }
  340. if (this.storeInfo.enterprise.enWeixin && this.storeInfo.enterprise.enWeixin !== '' && !/^[0-9a-zA-Z]{6,20}$/.test(this.storeInfo.enterprise.enWeixin)) {
  341. this.collectResult = '请输入正确的微信号'
  342. this.timeoutCount++
  343. return false
  344. }
  345. if (this.storeInfo.enterprise.enQQ && this.storeInfo.enterprise.enQQ !== '' && !/^[1-9][0-9]{4,10}$/.test(this.storeInfo.enterprise.enQQ)) {
  346. this.collectResult = '请输入正确的QQ号'
  347. this.timeoutCount++
  348. return false
  349. }
  350. let kay = {
  351. description: this.storeInfo.description,
  352. enterprise: this.storeInfo.enterprise,
  353. storeName: this.storeInfo.storeName,
  354. storeShortName: this.storeInfo.storeShortName,
  355. storeApplication: this.storeInfo.storeApplication,
  356. logoUrl: this.imageUploadUrl
  357. }
  358. this.$http.put(`/store-service/stores/${this.storeInfo.uuid}?kind=BASIC_INFO`, kay).then(res => {
  359. this.collectResult = '保存成功'
  360. this.timeoutCount++
  361. this.storeState = 'look'
  362. }).catch(err => {
  363. this.collectResult = err.response.data
  364. this.timeoutCount++
  365. let str = JSON.stringify(this.$store.state.option.storeStatus.data)
  366. this.storeInfo = JSON.parse(str)
  367. })
  368. },
  369. setTextareaHeight () {
  370. this.$nextTick(() => {
  371. let el = this.$refs.descTextarea
  372. if (el) {
  373. el.style.height = '2rem'
  374. el.style.height = (el.scrollHeight * 2.06 - el.clientHeight + 150) / 100 + 'rem'
  375. }
  376. })
  377. },
  378. setApplicationTextareaHeight () {
  379. this.$nextTick(() => {
  380. let el = this.$refs.applicationTextarea
  381. if (el) {
  382. el.style.height = '2rem'
  383. el.style.height = (el.scrollHeight * 2.06 - el.clientHeight + 150) / 100 + 'rem'
  384. }
  385. })
  386. },
  387. setEnTextareaHeight () {
  388. this.$nextTick(() => {
  389. let el = this.$refs.enTextarea
  390. if (el) {
  391. el.style.height = '2rem'
  392. el.style.height = (el.scrollHeight * 2.06 - el.clientHeight + 150) / 100 + 'rem'
  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: #999;
  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: .14rem;
  516. }
  517. }
  518. }
  519. .upload {
  520. img {
  521. transform: rotate(180deg);
  522. }
  523. }
  524. li {
  525. border-bottom: .01rem solid #d9d9d9;
  526. min-height: 1.16rem;
  527. line-height: normal;
  528. padding: .4rem .2rem;
  529. &.border {
  530. border-bottom: .01rem solid #d9d9d9;
  531. }
  532. &.noupdate {
  533. background: #fafafa;
  534. color: #999;
  535. }
  536. }
  537. .name {
  538. width: 1.8rem;
  539. text-align: right;
  540. color: #226ce7;
  541. }
  542. &.no-edit {
  543. color: #999;
  544. .name {
  545. color: #226ce7;
  546. }
  547. }
  548. .text {
  549. width: 4.4rem;
  550. word-break: break-all;
  551. line-height: .44rem;
  552. }
  553. /*.pull-left {*/
  554. /*float: none !important;*/
  555. /*display: inline-block;*/
  556. /*word-wrap: break-word;*/
  557. /*vertical-align: top;*/
  558. /*}*/
  559. .update {
  560. padding: 0.06rem 0 0.06rem 0;
  561. }
  562. input {
  563. width: 4.4rem;
  564. border: 0 solid #b4b4b4;
  565. padding: 0.06rem 0 0.06rem 0.12rem;
  566. }
  567. textarea{
  568. width: 4.4rem;
  569. height: 1.36rem;
  570. padding: 0.06rem 0 0.06rem 0.12rem;
  571. overflow-y: visible;
  572. border: none;
  573. }
  574. }
  575. .control {
  576. width: 90%;
  577. margin: 0.15rem auto 0.4rem;
  578. height: .88rem;
  579. line-height: 0.88rem;
  580. }
  581. .save {
  582. border-radius: 3px;
  583. width: 48%;
  584. color: #fff;
  585. text-align: center;
  586. height: .88rem;
  587. line-height: 0.88rem;
  588. background: #3e82f5;
  589. float: right;
  590. }
  591. .cancel {
  592. border-radius: 3px;
  593. width: 48%;
  594. background: #acabab;
  595. color: #fff;
  596. text-align: center;
  597. height: .88rem;
  598. line-height: 0.88rem;
  599. float: left;
  600. }
  601. .none-state{
  602. text-align: center;
  603. padding:1.5rem 0;
  604. background: #fff;
  605. margin-top:.1rem;
  606. width:100%;
  607. img{
  608. margin:0 auto;
  609. width: 4.08rem;
  610. height: 2.62rem;
  611. }
  612. p {
  613. font-size: .32rem;
  614. color: #999;
  615. margin: 1.19rem 0 0 0;
  616. }
  617. a {
  618. display: block;
  619. font-size: .28rem;
  620. color: #fff;
  621. width: 1.88rem;
  622. height: .54rem;
  623. line-height: .54rem;
  624. background: #418bf6;
  625. margin: .7rem auto 0;
  626. border-radius: .05rem;
  627. }
  628. }
  629. </style>