storeinfo.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  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="isAdmin && 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">
  38. </textarea>
  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" v-if="storeState === 'look'">
  44. {{storeInfo.enterprise.address || '暂无信息'}}
  45. </div>
  46. <div v-else class="text pull-left">
  47. <input v-model="storeInfo.enterprise.address" type="text"/>
  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 v-else class="text pull-left">
  56. <input v-model="storeInfo.enterprise.enTel" type="text"/>
  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 v-else class="text pull-left">
  65. <input v-model="storeInfo.enterprise.enFax" type="text"/>
  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 v-else class="text pull-left">
  74. <input v-model="storeInfo.enterprise.enPhone" type="text"/>
  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 v-else class="text pull-left">
  83. <input v-model="storeInfo.enterprise.enWeixin" type="text"/>
  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 v-else class="text pull-left">
  92. <input v-model="storeInfo.enterprise.enQQ" type="text"/>
  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. methods: {
  141. updateInfo() {
  142. this.storeState = 'update'
  143. this.Islook = true
  144. this.hidelook = true
  145. },
  146. dealWithText2(tp) {
  147. if (tp === 'open') {
  148. this.Islook = false
  149. this.hidelook = false
  150. } else {
  151. this.Islook = true
  152. this.hidelook = true
  153. }
  154. },
  155. dealWithText(_T) {
  156. if (_T !== undefined) {
  157. // 文本处理
  158. this.normalText = _T
  159. if (_T.length < 140) {
  160. this.Islook = false
  161. return _T
  162. } else {
  163. this.Islook = true
  164. return _T.substr(0, 140) + '...'
  165. }
  166. } else {
  167. this.Islook = false
  168. return this.normalText
  169. }
  170. },
  171. storeInfosave(_tp) {
  172. if (_tp === 'cancel') {
  173. let str = JSON.stringify(this.$store.state.option.storeStatus.data)
  174. this.storeInfo = JSON.parse(str)
  175. this.storeState = 'look'
  176. return false
  177. }
  178. if (!this.storeInfo) {
  179. this.collectResult = '店铺信息不能为空'
  180. this.timeoutCount++
  181. return false
  182. }
  183. if (!this.storeInfo.description || this.storeInfo.description === '') {
  184. this.collectResult = '店铺简介信息不能为空'
  185. this.timeoutCount++
  186. return false
  187. }
  188. if (!this.storeInfo.enterprise) {
  189. this.collectResult = '企业信息不能为空'
  190. this.timeoutCount++
  191. return false
  192. }
  193. if (!this.storeInfo.enterprise.address || this.storeInfo.enterprise.address === '') {
  194. this.collectResult = '企业地址不能为空'
  195. this.timeoutCount++
  196. return false
  197. }
  198. if (!this.storeInfo.enterprise.enTel || this.storeInfo.enterprise.enTel === '') {
  199. this.collectResult = '请输入正确的电话号码'
  200. this.timeoutCount++
  201. return false
  202. }
  203. if (!/^1[3|4|5|6|7|8|9][0-9]{9}$/.test(this.storeInfo.enterprise.enPhone) && this.storeInfo.enterprise.enPhone) {
  204. this.collectResult = '请输入正确的手机号码'
  205. this.timeoutCount++
  206. return false
  207. }
  208. if (!/^[a-zA-Z]{1}[-_a-zA-Z0-9]{5,19}$/.test(this.storeInfo.enterprise.enWeixin) && this.storeInfo.enterprise.enWeixin) {
  209. this.collectResult = '请输入正确的微信号'
  210. this.timeoutCount++
  211. return false
  212. }
  213. if (!/^[1-9][0-9]{4,10}$/.test(this.storeInfo.enterprise.enQQ) && this.storeInfo.enterprise.enQQ) {
  214. this.collectResult = '请输入正确的QQ号'
  215. this.timeoutCount++
  216. return false
  217. }
  218. let kay = {
  219. description: this.storeInfo.description,
  220. enterprise: this.storeInfo.enterprise,
  221. storeName: this.storeInfo.storeName,
  222. storeShortName: this.storeInfo.storeShortName
  223. }
  224. this.$http.put(`/store-service/stores/${this.storeInfo.uuid}?kind=BASIC_INFO`, kay).then(res => {
  225. this.collectResult = '保存成功'
  226. this.timeoutCount++
  227. this.storeState = 'look'
  228. }).catch(err => {
  229. this.collectResult = err.response.data
  230. this.timeoutCount++
  231. let str = JSON.stringify(this.$store.state.option.storeStatus.data)
  232. this.storeInfo = JSON.parse(str)
  233. })
  234. }
  235. },
  236. computed: {
  237. getRemindText: function () {
  238. return '您的账户暂未开通店铺,请前往pc端申请开通!'
  239. },
  240. storeI() {
  241. let str = JSON.stringify(this.$store.state.option.storeStatus.data)
  242. this.storeInfo = JSON.parse(str)
  243. return ''
  244. },
  245. isAdmin () {
  246. return this.user.data.userUU === this.user.data.enterprise.enAdminuu
  247. }
  248. },
  249. components: {
  250. RemindBox
  251. },
  252. mounted() {
  253. this.$nextTick(() => {
  254. if (this.BScroll) {
  255. this.BScroll.refresh()
  256. } else {
  257. this.BScroll = new BScroll(this.$refs.userContent, {
  258. click: true
  259. })
  260. }
  261. })
  262. }
  263. }
  264. </script>
  265. <style lang="scss" scoped>
  266. .user-content {
  267. background: #f1f3f6;
  268. .si-wrap {
  269. width: 7.1rem;
  270. margin: .3rem auto;
  271. background: #fff;
  272. }
  273. .user-center-content {
  274. height: 100%;
  275. overflow: hidden;
  276. }
  277. .scroll {
  278. padding-bottom: 0.4rem;
  279. }
  280. }
  281. .com-mobile-header {
  282. i {
  283. font-size: .36rem;
  284. position: relative;
  285. top: .04rem;
  286. right: .02rem;
  287. }
  288. }
  289. .topinfo {
  290. padding: 0 0.24rem;
  291. color: #333;
  292. font-size: 0.28rem;
  293. height: 0.8rem;
  294. line-height: 0.8rem;
  295. border-bottom: 0.01rem solid #d9d9d9;
  296. .pull-right {
  297. color: #999;
  298. font-size: 0.26rem;
  299. img {
  300. width: 0.34rem;
  301. height: 0.34rem;
  302. }
  303. }
  304. }
  305. .infoul {
  306. color: #666;
  307. font-size: 0.28rem;
  308. padding: 0 .24rem;
  309. .upload {
  310. img {
  311. transform: rotate(180deg);
  312. }
  313. }
  314. li {
  315. border-bottom: .01rem solid #d9d9d9;
  316. min-height: 1.16rem;
  317. line-height: normal;
  318. padding: .4rem .28rem;
  319. &.border {
  320. border-bottom: .01rem solid #d9d9d9;
  321. }
  322. &.noupdate {
  323. background: #fafafa;
  324. color: #999;
  325. }
  326. }
  327. .name {
  328. width: 1.6rem;
  329. text-align: right;
  330. color: #226ce7;
  331. }
  332. &.no-edit {
  333. color: #999;
  334. .name {
  335. color: #999;
  336. }
  337. }
  338. .text {
  339. width: 4.4rem;
  340. }
  341. .update {
  342. padding: 0.06rem 0 0.06rem 0;
  343. }
  344. input {
  345. width: 4.4rem;
  346. border: 0px solid #b4b4b4;
  347. padding: 0.06rem 0 0.06rem 0.12rem;
  348. }
  349. textarea{
  350. width: 4.4rem;
  351. padding: 0.06rem 0 0.06rem 0.12rem;
  352. /*min-height: 5rem;*/
  353. resize: none;
  354. border: 0 solid #b4b4b4;
  355. }
  356. }
  357. .control {
  358. width: 90%;
  359. margin: 0.15rem auto 0.4rem;
  360. height: .88rem;
  361. line-height: 0.88rem;
  362. }
  363. .save {
  364. border-radius: 3px;
  365. width: 48%;
  366. color: #fff;
  367. text-align: center;
  368. height: .88rem;
  369. line-height: 0.88rem;
  370. background: #3e82f5;
  371. float: right;
  372. }
  373. .cancel {
  374. border-radius: 3px;
  375. width: 48%;
  376. background: #acabab;
  377. color: #fff;
  378. text-align: center;
  379. height: .88rem;
  380. line-height: 0.88rem;
  381. float: left;
  382. }
  383. .none-state{
  384. text-align: center;
  385. padding:1.5rem 0;
  386. background: #fff;
  387. margin-top:.1rem;
  388. width:100%;
  389. img{
  390. margin:0 auto;
  391. width: 4.08rem;
  392. height: 2.62rem;
  393. }
  394. p {
  395. font-size: .32rem;
  396. color: #999;
  397. margin: 1.19rem 0 0 0;
  398. }
  399. a {
  400. display: block;
  401. font-size: .28rem;
  402. color: #fff;
  403. width: 1.88rem;
  404. height: .54rem;
  405. line-height: .54rem;
  406. background: #418bf6;
  407. margin: .7rem auto 0;
  408. border-radius: .05rem;
  409. }
  410. }
  411. </style>