homepage.vue 7.0 KB

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