storeinfo.vue 19 KB

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