homepage.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <view class="page">
  3. <!-- 页面渐变色背景 -->
  4. <view class="shadow"> </view>
  5. <!-- 页面渐变色背景 -->
  6. <view class="content">
  7. <view class="top-information">
  8. <image class="user-header" :src="userInfo.image" mode=""> </image>
  9. <view class="btn-list">
  10. <button class="btn-1">
  11. <u-icon color="#f83224" size="14" name="kefu-ermai"></u-icon>客服
  12. </button>
  13. <button v-if="isShow != '1'" class="btn-1">
  14. <u-icon color="#f83224" size="14" name="plus"></u-icon>关注
  15. </button>
  16. </view>
  17. <view class="name"> {{ userInfo.merchant_name }} </view>
  18. <view class="score">
  19. <u-rate
  20. count="5"
  21. disabled
  22. :allowHalf="true"
  23. :gutter="1"
  24. inactiveColor="#ffacab"
  25. activeColor="#FF1515"
  26. v-model="userInfo.score"
  27. :size="12"
  28. ></u-rate>
  29. <text class="num">{{ userInfo.score }}</text>
  30. </view>
  31. <view class="sale">
  32. <view class="">
  33. 销售量
  34. <text space="nbsp">{{ "&nbsp;" }} {{ userInfo.sales_num }}</text>
  35. </view>
  36. <text space="nbsp" class="shu"
  37. >{{ "&nbsp;&nbsp;" }} | {{ "&nbsp;&nbsp;" }}</text
  38. >
  39. <view class="">
  40. 评价总数
  41. <text space="nbsp">{{ "&nbsp;" }} {{ userInfo.comment_num }}</text>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="goods-list">
  46. <view class="tab-list">
  47. <view :class="{ tab: selectTab == 1 }" @click="switchTab(1)">
  48. 默认
  49. </view>
  50. <view :class="{ tab: selectTab == 2 }" @click="switchTab(2)"
  51. >新品</view
  52. >
  53. <view :class="{ tab: selectTab == 3 }" @click="switchTab(3)"
  54. >销量</view
  55. >
  56. <view
  57. class="price"
  58. :class="{ tab: selectTab == 4 }"
  59. @click="switchTab(4)"
  60. >价格
  61. <view
  62. style="
  63. display: flex;
  64. flex-direction: column;
  65. justify-content: center;
  66. margin-left: 6rpx;
  67. margin-top: 4rpx;
  68. "
  69. >
  70. <u-icon
  71. name="arrow-up-fill"
  72. size="6"
  73. :color="iconUp == 1 ? '#f83224' : '#303133'"
  74. ></u-icon
  75. ><u-icon
  76. :color="iconUp == 2 ? '#f83224' : '#303133'"
  77. size="6"
  78. name="arrow-down-fill"
  79. ></u-icon>
  80. </view>
  81. </view>
  82. </view>
  83. <view class="goods">
  84. <GoodsCard
  85. v-for="item in goodsList"
  86. :key="item.id"
  87. :itemInfo="item"
  88. @toDetail="toDetail"
  89. />
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. </template>
  95. <script>
  96. import GoodsCard from "./component/goodsCard.vue";
  97. export default {
  98. components: {
  99. GoodsCard,
  100. },
  101. data() {
  102. return {
  103. value: 4,
  104. selectTab: 0,
  105. iconUp: 0,
  106. isShow: "2", //是否可关注
  107. userId: "",
  108. userInfo: {}, //用户信息
  109. goodsList: [],
  110. };
  111. },
  112. onLoad(option) {
  113. if (option.page) {
  114. this.isShow = option.page;
  115. }
  116. this.userId = option.merchant_id;
  117. },
  118. methods: {
  119. switchTab(num) {
  120. this.selectTab = num;
  121. if (num == 4) {
  122. // this.iconUp = this.iconUp == 0 ? 1:2
  123. // if(this.iconUp == 2){
  124. // this.iconUp =1
  125. // }
  126. switch (this.iconUp) {
  127. case 1:
  128. this.iconUp = 2;
  129. break;
  130. case 0:
  131. this.iconUp = 1;
  132. break;
  133. case 2:
  134. this.iconUp = 1;
  135. break;
  136. }
  137. } else {
  138. this.iconUp = 0;
  139. }
  140. },
  141. toDetail(item) {
  142. console.log(item);
  143. // return;
  144. uni.navigateTo({
  145. url: `/pageA/productdetails?id=${item.id}`,
  146. });
  147. },
  148. getCommodityList(status = "") {
  149. //获取用户信息
  150. uni.$u.http
  151. .get(`/api/merchant/info?merchant_id=${this.userId}`)
  152. .then((res) => {
  153. this.userInfo = res;
  154. });
  155. //获取店铺商品
  156. uni.$u.http
  157. .post(`/api/goods/merchant_goods`, {
  158. page: 1,
  159. limit: 10,
  160. merchant_id: this.userId,
  161. status: status,
  162. keywords: this.keywords,
  163. source: this.source,
  164. })
  165. .then((res) => {
  166. this.goodsList = res.data;
  167. });
  168. },
  169. },
  170. mounted() {
  171. this.getCommodityList();
  172. //设置顶部导航栏颜色
  173. uni.setNavigationBarColor({
  174. frontColor: "#ffffff",
  175. backgroundColor: "#f74639",
  176. });
  177. },
  178. };
  179. </script>
  180. <style lang="scss" scoped>
  181. .page {
  182. .shadow {
  183. position: absolute;
  184. top: 0;
  185. height: 300px;
  186. width: 100%;
  187. background: linear-gradient(#f74639, #f4f4f4);
  188. z-index: -1;
  189. }
  190. .content {
  191. padding: 20rpx 24rpx;
  192. margin-top: 76rpx;
  193. .top-information {
  194. position: relative;
  195. border-radius: 20rpx;
  196. background-color: #fff;
  197. padding: 28rpx 24rpx;
  198. ::v-deep .u-icon__icon {
  199. color: #f83224 !important;
  200. }
  201. .user-header {
  202. width: 164rpx;
  203. height: 164rpx;
  204. border-radius: 50%;
  205. border: 2rpx solid #fff;
  206. position: absolute;
  207. top: -80rpx;
  208. left: 28rpx;
  209. }
  210. .btn-list {
  211. display: flex;
  212. align-items: center;
  213. justify-content: flex-end;
  214. .btn-1 {
  215. border: 2rpx solid #f83224;
  216. background-color: #fff;
  217. color: #f83224;
  218. padding: 0;
  219. margin: 0;
  220. display: flex;
  221. justify-content: space-around;
  222. align-items: center;
  223. height: 52rpx;
  224. border-radius: 24rpx;
  225. line-height: 52rpx;
  226. font-size: 26rpx;
  227. padding: 0 28rpx;
  228. margin-left: 20rpx;
  229. }
  230. }
  231. .name {
  232. margin-top: 28rpx;
  233. font-weight: 600;
  234. font-size: 32rpx;
  235. color: #333333;
  236. }
  237. .score {
  238. width: 30%;
  239. height: 28rpx;
  240. background-color: rgba(255, 27, 0, 0.1);
  241. display: flex;
  242. border-radius: 12rpx;
  243. margin-top: 16rpx;
  244. justify-content: space-around;
  245. .num {
  246. font-size: 22rpx;
  247. color: #ff1515;
  248. font-weight: 600;
  249. }
  250. }
  251. .sale {
  252. display: flex;
  253. align-items: center;
  254. font-size: 24rpx;
  255. color: #777;
  256. margin-top: 20rpx;
  257. .shu {
  258. font-size: 16rpx;
  259. color: #979797;
  260. opacity: 0.2;
  261. }
  262. }
  263. }
  264. }
  265. .goods-list {
  266. border-radius: 20rpx;
  267. background-color: #fff;
  268. padding: 0 20rpx;
  269. margin-top: 20rpx;
  270. .tab-list {
  271. height: 96rpx;
  272. display: flex;
  273. justify-content: space-around;
  274. align-items: center;
  275. font-size: 26rpx;
  276. color: #333333;
  277. border-bottom: 2rpx solid rgba(151, 151, 151, 0.1);
  278. margin-bottom: 20rpx;
  279. .tab {
  280. color: #000;
  281. font-weight: 600;
  282. }
  283. .price {
  284. display: flex;
  285. align-items: center;
  286. }
  287. }
  288. .goods {
  289. display: flex;
  290. flex-wrap: wrap;
  291. justify-content: space-between;
  292. }
  293. }
  294. }
  295. </style>