index.vue 6.6 KB

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