homepage.vue 7.5 KB

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