storeinfo.vue 17 KB

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