storeinfo.vue 14 KB

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