storeinfo.vue 15 KB

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