storeinfo.vue 12 KB

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