index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <view id="store" class="store" :style="[isHome?contentStyle:'']">
  3. <view class='pictrue'>
  4. <image :style="[isHome?logoStyleRadius:'']" :src="merchantInfo.avatar" class=""></image>
  5. </view>
  6. <view class="text">
  7. <navigator :url="`/pages/merchant/${type}/index?merId=${merId}`" hover-class="none">
  8. <view class="flex merchantInfo">
  9. <text class="name" :style="!isHome?'color: #FFFFFF;':''">{{merchantInfo.name}}</text>
  10. <text v-if="isShowTypeId" class="iconfont icon-jiantou"></text>
  11. </view>
  12. </navigator>
  13. <view class="score">
  14. <text v-if="merchantInfo.isSelf"
  15. class="font-bg-red bt-color bg-color mr10 self_min merType">自营</text>
  16. <text v-if="isShowTypeId && merchantInfo.typeId"
  17. class="bt-color mr10 merType color-FAAD14">{{merchantInfo.typeId | merchantTypeFilter}}</text>
  18. <view class='starsList'>
  19. <block v-for="(itemn, indexn) in merchantInfo.starLevel" :key="indexn">
  20. <text class='iconfont icon-pingfen font-color'></text>
  21. </block>
  22. <block v-show="Number(merchantInfo.starLevel)<5">
  23. <text v-for="(itemn, indexn) in noStarLevel" :key="indexn"
  24. class='iconfont icon-pingfen noCheck'></text>
  25. </block>
  26. </view>
  27. </view>
  28. </view>
  29. <button v-if="type!=='home'" hover-class="none" class="merCollect"
  30. :class="merchantInfoNew.isCollect ? 'care' : ''" @click="followToggle" :style="[isHome || isHomeComb?followColor:'']">
  31. <text v-if="!merchantInfoNew.isCollect" class="iconfont icon-guanzhu"></text>
  32. {{ merchantInfoNew.isCollect ? '已关注' : '关注' }}
  33. </button>
  34. <navigator v-if="!isShowTypeId" :url="`/pages/merchant/${type}/index?merId=${merId}`" hover-class="none">
  35. <button class="merCollect" hover-class="none">进店</button>
  36. </navigator>
  37. </view>
  38. </template>
  39. <script>
  40. // +----------------------------------------------------------------------
  41. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  42. // +----------------------------------------------------------------------
  43. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  44. // +----------------------------------------------------------------------
  45. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  46. // +----------------------------------------------------------------------
  47. // | Author: CRMEB Team <admin@crmeb.com>
  48. // +----------------------------------------------------------------------
  49. import {
  50. getMerCollectAddApi,
  51. getMerCollectCancelApi
  52. } from '@/api/merchant.js';
  53. import {
  54. followMer
  55. } from '@/libs/follow.js';
  56. import {
  57. mapGetters
  58. } from "vuex";
  59. import {
  60. toLogin
  61. } from '@/libs/login.js';
  62. export default {
  63. computed: {
  64. ...mapGetters(["merchantClassify", "merchantType", 'isLogin', 'uid']),
  65. //头像圆角
  66. logoStyleRadius() {
  67. if(this.dataConfig) {
  68. return {
  69. 'logoStyleRadius': this.dataConfig.logoStyleRadius.val ? this.dataConfig.logoStyleRadius
  70. .val + 'px' : '0'
  71. }
  72. }
  73. },
  74. contentStyle() {
  75. if(this.dataConfig) {
  76. return {
  77. margin: '20rpx 24rpx',
  78. backgroundColor: '#fff',
  79. }
  80. }
  81. },
  82. // 关注颜色
  83. followColor() {
  84. if(this.dataConfig) {
  85. return {
  86. border: '1px solid',
  87. color: this.dataConfig.followColor.color[0].item,
  88. background: '#fff'
  89. }
  90. }
  91. }
  92. },
  93. props: {
  94. // 店铺diy中设置的数据,店铺首页diy中使用
  95. dataConfig: {
  96. type: Object,
  97. default: () => {}
  98. },
  99. merchantInfo: {
  100. type: Object,
  101. default: () => {}
  102. },
  103. merId: {
  104. type: Number,
  105. default: () => 0
  106. },
  107. type: {
  108. type: String,
  109. default: () => 'detail'
  110. },
  111. isShowTypeId: {
  112. type: Boolean,
  113. default: () => true
  114. },
  115. //是否是首页展示,true是,false不是
  116. isHome: {
  117. type: Boolean,
  118. default: () => false
  119. },
  120. //店铺主页是否是头部组件中使用的diy
  121. isHomeComb: {
  122. type: Boolean,
  123. default: () => false
  124. }
  125. },
  126. data() {
  127. return {
  128. skeletonShow: true,
  129. isShow: true,
  130. avatar: '',
  131. merchantInfoNew: {
  132. ...this.merchantInfo
  133. },
  134. noStarLevel: 0
  135. }
  136. },
  137. mounted: function() {
  138. const query = uni.createSelectorQuery().in(this);
  139. query.select('#store').boundingClientRect(data => {
  140. //this.storeHeight = data.height;
  141. this.$emit('merHomeHeight', data.height)
  142. }).exec();
  143. this.getnoStarLevel()
  144. },
  145. methods: {
  146. getnoStarLevel: function(nVal, oVal) {
  147. if (parseInt(this.merchantInfoNew.starLevel) < 5) this.noStarLevel = 5 - parseInt(this.merchantInfoNew
  148. .starLevel);
  149. },
  150. // 设置是否关注
  151. followToggle: function() {
  152. if (this.isLogin === false) {
  153. toLogin();
  154. } else {
  155. followMer(this.merchantInfoNew.isCollect, this.merId).then(() => {
  156. this.$set(this.merchantInfoNew, 'isCollect', !this.merchantInfoNew.isCollect);
  157. this.$store.commit('MERCHANTJINFO', {...this.merchantInfoNew});
  158. });
  159. }
  160. }
  161. }
  162. };
  163. </script>
  164. <style lang="scss" scoped>
  165. .noCheck {
  166. color: #ddd;
  167. }
  168. .care {
  169. border: 1px solid #FFFFFF;
  170. background: inherit !important;
  171. }
  172. .font-color {
  173. @include main_color(theme);
  174. }
  175. .iconfont {
  176. //font-size: 24rpx !important;
  177. }
  178. .icon-pingweifen {
  179. color: #ccc;
  180. }
  181. .merchantInfo {
  182. align-items: center;
  183. margin-bottom: 16rpx;
  184. }
  185. .store {
  186. position: relative;
  187. // z-index: 5;
  188. display: flex;
  189. align-items: center;
  190. padding: 24rpx;
  191. //width: 100%;
  192. // top:12rpx;
  193. .pictrue {
  194. width: 80rpx;
  195. height: 80rpx;
  196. border-radius: 50%;
  197. overflow: hidden;
  198. }
  199. .easy-loadimage,
  200. image,
  201. uni-image {
  202. width: 100%;
  203. height: 100%;
  204. }
  205. .text {
  206. flex: 1;
  207. min-width: 0;
  208. margin-right: 20rpx;
  209. margin-left: 12rpx;
  210. navigator {
  211. // display: inline-flex;
  212. align-items: center;
  213. max-width: 100%;
  214. .name {
  215. min-width: 0;
  216. overflow: hidden;
  217. white-space: nowrap;
  218. text-overflow: ellipsis;
  219. font-weight: bold;
  220. font-size: 30rpx;
  221. line-height: 1;
  222. }
  223. .iconfont {
  224. margin-left: 10rpx;
  225. font-size: 17rpx;
  226. color: #FFFFFF;
  227. }
  228. }
  229. .score {
  230. display: flex;
  231. align-items: center;
  232. margin-top: 8rpx;
  233. font-weight: 500;
  234. font-size: 24rpx;
  235. line-height: 1;
  236. .iconfont {
  237. font-size: 26rpx;
  238. }
  239. }
  240. }
  241. }
  242. .self_min {
  243. min-width: 56rpx;
  244. text-align: center;
  245. }
  246. .starsList{
  247. padding-bottom: 4rpx;
  248. }
  249. .icon-jiantou{
  250. color: #999 !important;
  251. }
  252. </style>