CommonStoreHeader.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <view>
  3. <title-header />
  4. <view class="header" :style="{backgroundImage:'url('+store.mb_title_img+')'}">
  5. <view class="content-wrapper">
  6. <view class="avatar" @click="goStoreabout">
  7. <image class="img" mode="aspectFit" :src="store.store_avatar">
  8. </view>
  9. <view class="content">
  10. <view class="store_name">{{store.store_name}}<text class="ml-5"
  11. v-if="(store.is_platform_store && config.business_licence) || store.business_licence_number_electronic"
  12. @click="showPopup('imageVisible')"><text class="iconfont">&#xe621;</text></text></view>
  13. <view>
  14. <uni-rate :size="14" :readonly="true" :value="parseInt(store.store_credit_percent/100*5)" />
  15. </view>
  16. <view class="follow_number">
  17. {{store.store_collect}}人收藏
  18. </view>
  19. <view class="store_address" v-if="store.store_address" @click="goMap()">
  20. <text class="iconfont">&#xe6d3;</text>
  21. <text class="span" v-if="store.store_address">{{store.store_address}}</text>
  22. </view>
  23. </view>
  24. <view class="follow_panel" :class="{'active':store.is_favorate}">
  25. <view class="follow_button" @click="toggleFavorite">
  26. <text class="iconfont" v-if="!store.is_favorate">&#xe64e;</text>
  27. {{favoriteName}}
  28. </view>
  29. </view>
  30. </view>
  31. <view class="background">
  32. <image mode="aspectFit" v-if="store.store_logo" :src="store.store_logo" width="100%" height="100%">
  33. <image mode="aspectFit" v-else :src="store.store_logo" width="100%" height="100%">
  34. </view>
  35. <uni-popup ref="imageVisible" class="middle-popup">
  36. <image class="img" mode="aspectFit" v-if="store.business_licence_number_electronic"
  37. :src="store.business_licence_number_electronic">
  38. <image class="img" mode="aspectFit" v-if="store.is_platform_store && config.business_licence"
  39. :src="config.business_licence">
  40. </uni-popup>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import TitleHeader from '../../TitleHeader'
  46. import {
  47. mapState,
  48. mapActions
  49. } from 'vuex'
  50. import {
  51. addFavoriteStore,
  52. delFavoriteStore
  53. } from '../../../api/memberFavorite'
  54. export default {
  55. name: 'CommonStoreHeader',
  56. data() {
  57. return {}
  58. },
  59. props: ['store'],
  60. computed: {
  61. ...mapState({
  62. config: state => state.config.config,
  63. }),
  64. favoriteName() {
  65. return this.store.is_favorate ? '已收藏' : '收藏'
  66. }
  67. },
  68. components: {
  69. TitleHeader,
  70. },
  71. created: function() {
  72. },
  73. methods: {
  74. showPopup(id) {
  75. this.$refs[id].open()
  76. },
  77. hidePopup(id) {
  78. this.$refs[id].close()
  79. },
  80. goStoreabout: function() {
  81. uni.navigateTo({
  82. url: '/pages/home/storeabout/Storeabout?id=' + this.store.store_id
  83. })
  84. },
  85. goMap() {
  86. uni.navigateTo({
  87. url: '/pages/home/storedetail/Storemap?id=' + this.store.store_id
  88. })
  89. },
  90. toggleFavorite() {
  91. if (!this.store.is_favorate) {
  92. addFavoriteStore(this.store.store_id).then(
  93. response => {
  94. uni.showToast({
  95. icon: 'none',
  96. title: response.message
  97. })
  98. this.store.is_favorate = 1
  99. this.store.store_collect++
  100. this.$forceUpdate()
  101. },
  102. error => {
  103. uni.showToast({
  104. icon: 'none',
  105. title: error.message
  106. })
  107. }
  108. )
  109. } else {
  110. delFavoriteStore(this.store.store_id).then(
  111. response => {
  112. uni.showToast({
  113. icon: 'none',
  114. title: response.message
  115. })
  116. this.store.is_favorate = 0
  117. this.store.store_collect--
  118. this.$forceUpdate()
  119. },
  120. error => {
  121. uni.showToast({
  122. icon: 'none',
  123. title: error.message
  124. })
  125. }
  126. )
  127. }
  128. }
  129. }
  130. }
  131. </script>
  132. <style lang="scss" scoped>
  133. .dot {
  134. position: absolute;
  135. width: .5rem;
  136. height: .5rem;
  137. background: red;
  138. border-radius: 50%;
  139. top: .2rem;
  140. right: 0;
  141. }
  142. .header {
  143. background: $primaryColor;
  144. color: #fff;
  145. overflow: hidden;
  146. position: relative;
  147. background-position: center;
  148. background-size: auto 100%;
  149. }
  150. .header .content-wrapper {
  151. -ms-flex-align: center;
  152. -webkit-box-align: center;
  153. align-items: center;
  154. display: -webkit-box;
  155. display: -ms-flexbox;
  156. display: flex;
  157. padding: 0.8rem $pageSpace;
  158. position: relative;
  159. }
  160. .header .content-wrapper .avatar {
  161. -ms-flex: 0 0 3rem;
  162. -webkit-box-flex: 0;
  163. flex: 0 0 3rem;
  164. margin-right: 0.4rem;
  165. width: 3rem;
  166. }
  167. .header .content-wrapper .avatar .img {
  168. border-radius: 0.2rem;
  169. width: 3rem;
  170. height: 3rem;
  171. }
  172. .header .content-wrapper .content {
  173. position: relative;
  174. width: 8rem;
  175. }
  176. .header .content-wrapper .content .store_name {
  177. font-size: $h2;
  178. font-weight: 700;
  179. }
  180. .header .content-wrapper .content .store_address .span {
  181. font-size: $h6
  182. }
  183. .follow_number {
  184. line-height: 0.7rem;
  185. font-size: $h6;
  186. color: #fff;
  187. margin-top: 0.1rem;
  188. }
  189. .follow_panel {
  190. position: absolute;
  191. top: 1rem;
  192. right: $pageSpace;
  193. }
  194. .follow_panel .follow_button {
  195. display: block;
  196. background: #fff;
  197. border: 1px solid #fff;
  198. border-radius: 2.5rem;
  199. padding: 0 0.4rem;
  200. line-height: 1.2rem;
  201. font-size: $fontSize;
  202. color: $primaryColor;
  203. width: 2.4rem;
  204. text-align: center
  205. }
  206. .follow_panel.active .follow_button {
  207. background: $primaryColor;
  208. border-color: #fff;
  209. color: #fff;
  210. }
  211. .follow_panel .follow_button i {
  212. line-height: 1.2rem;
  213. }
  214. .header-more {
  215. width: 2rem;
  216. height: 2rem;
  217. line-height: 2rem;
  218. position: absolute;
  219. top: 0.5rem;
  220. right: 0;
  221. color: #fff;
  222. text-align: center;
  223. font-size: $h1;
  224. }
  225. .header .background {
  226. background: #2c3b53;
  227. -webkit-filter: blur(0.5rem);
  228. filter: blur(0.5rem);
  229. height: 100%;
  230. left: 0;
  231. position: absolute;
  232. top: 0;
  233. width: 100%;
  234. z-index: -1;
  235. }
  236. .middle-popup {
  237. width: 80%
  238. }
  239. .middle-popup .img {
  240. max-width: 100%
  241. }
  242. </style>