storeinfo.vue 11 KB

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