homepage.vue 9.4 KB

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