merchants.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <template>
  2. <Theme>
  3. <view class="wrap">
  4. <view class="nav">
  5. <Navbar
  6. autoBack
  7. leftIconColor="var(--light)"
  8. @leftClick="leftClick"
  9. @rightClick="rightClick"
  10. bgColor="transparent"
  11. >
  12. <template #center>
  13. <view class="nav_center">
  14. <Search
  15. v-model="searchValue"
  16. border="none"
  17. :placeholder="t('商品的链接或名称')"
  18. @confirm="searchConfirm"
  19. >
  20. <template #prefix>
  21. <i class="icon-font icon-search"></i>
  22. </template>
  23. </Search>
  24. </view>
  25. </template>
  26. <template #right>
  27. <navMenu :options="{ icon: 'icon-home', text: '主页' }" blacked />
  28. </template>
  29. </Navbar>
  30. <view class="bg_logo">{{ verConfig.appNames }}</view>
  31. </view>
  32. <view class="tops" id="tabs" :style="{ top: tabTop + 'px' }">
  33. <view class="shop_info">
  34. <view class="shop_img">
  35. <image
  36. :src="`../../static/shop/icon_${defaultParams.channel}.png`"
  37. class="_img"
  38. ></image>
  39. </view>
  40. <view class="shop_name">{{ shopName }}</view>
  41. </view>
  42. <view class="btn_wrapper">
  43. <!-- <i class="icon-font icon-share"></i> -->
  44. <up-icon
  45. :name="isCollect ? 'star-fill' : 'star'"
  46. @click="shopCollect"
  47. size="30"
  48. :color="isCollect ? 'var(--primary)' : 'var(--light)'"
  49. ></up-icon>
  50. </view>
  51. </view>
  52. <view class="content">
  53. <List
  54. url="/shop/seller/goods"
  55. :topHeight="tabHeight"
  56. :defaultParams="defaultParams"
  57. ref="listRef"
  58. @datas="getList"
  59. >
  60. <template #item="{ item, index }">
  61. <shopList
  62. :channel="defaultParams.channel"
  63. :item="item"
  64. @collect="collectClick($event, index)"
  65. />
  66. </template>
  67. </List>
  68. </view>
  69. </view>
  70. <popup title="搜索条款" isClose ref="popupRef">
  71. <template #content>
  72. <view class="pop_cont">
  73. <trans _t="搜索条款内容" />
  74. </view>
  75. <view class="pop_tip">
  76. <trans _t="您已同意搜索条款" />
  77. </view>
  78. <view class="pop_btn" @click="popClose">
  79. <trans _t="关闭" />
  80. </view>
  81. </template>
  82. </popup>
  83. </Theme>
  84. </template>
  85. <script setup>
  86. import { ref, reactive, computed, onMounted, nextTick } from "vue";
  87. import verConfig from "@/ver.config";
  88. import navMenu from "@/components/nav_menu";
  89. import Navbar from "@/components/navbar";
  90. import Search from "@/components/input";
  91. import { t } from "@/locale";
  92. import { onLoad, onReachBottom } from "@dcloudio/uni-app";
  93. import List from "@/components/list";
  94. import { query, systemInfo } from "@/utils";
  95. import shopList from "../index/components/shop_list";
  96. import popup from "@/components/popup";
  97. import { SHOP_USER_COLLECT, SHOP_SELLER_INFO } from "@/api";
  98. const searchValue = ref("");
  99. const listRef = ref(null);
  100. const popupRef = ref(null);
  101. const tabHeight = ref(0);
  102. const tabTop = ref(44);
  103. const dataList = ref([]);
  104. const shopName = ref("");
  105. const isCollect = ref(false);
  106. const defaultParams = reactive({
  107. channel: "",
  108. shop_id: "",
  109. seller_id: "",
  110. });
  111. const sellerInfo = async () => {
  112. try {
  113. const res = await SHOP_SELLER_INFO({
  114. channel: defaultParams.channel,
  115. shop_id: defaultParams.shop_id,
  116. });
  117. isCollect.value = res.data.isCollect;
  118. shopName.value = res.data.nick;
  119. } catch (error) {}
  120. };
  121. const rightClick = () => {
  122. popupRef.value && popupRef.value.open();
  123. };
  124. const getList = (list) => {
  125. dataList.value = list;
  126. };
  127. const searchConfirm = () => {
  128. defaultParams.keyWord = searchValue.value;
  129. nextTick(() => {
  130. listRef.value && listRef.value.handleRefresh();
  131. });
  132. };
  133. const popClose = () => {
  134. popupRef.value && popupRef.value.close();
  135. };
  136. onLoad((options) => {
  137. const { channel, shop_id, seller_id, title } = options;
  138. defaultParams.channel = channel;
  139. defaultParams.shop_id = shop_id;
  140. defaultParams.seller_id = seller_id;
  141. });
  142. const leftClick = () => {
  143. uni.navigateBack();
  144. // uni.switchTab({ url: '/pages/index/index' });
  145. };
  146. const shopCollect = () => {
  147. setCollect({
  148. channel: defaultParams.channel,
  149. type: "shop",
  150. shop_id: defaultParams.shop_id,
  151. seller_id: defaultParams.seller_id,
  152. title: shopName.value,
  153. pic_url: "",
  154. });
  155. };
  156. const collectClick = (item, index) => {
  157. setCollect(
  158. {
  159. channel: defaultParams.channel,
  160. type: "good",
  161. goods_id: item.num_iid,
  162. seller_id: item.seller_id,
  163. title: item.title,
  164. pic_url: item.pic_url,
  165. price: item.price,
  166. },
  167. index
  168. );
  169. };
  170. const setCollect = async (params, index) => {
  171. try {
  172. const res = await SHOP_USER_COLLECT(params);
  173. if (!index && index != 0) {
  174. isCollect.value = res.data.collect;
  175. return;
  176. }
  177. nextTick(() => {
  178. dataList.value[index].isCollect = res.data.collect;
  179. listRef.value && listRef.value.setList(dataList.value);
  180. });
  181. } catch (error) {
  182. Toast(error.msg);
  183. }
  184. };
  185. onMounted(() => {
  186. nextTick(async () => {
  187. const res = await query("#tabs", this);
  188. tabTop.value = res.top + systemInfo().statusBarHeight;
  189. tabHeight.value = res.height;
  190. nextTick(() => {
  191. sellerInfo();
  192. listRef.value && listRef.value.getData();
  193. });
  194. });
  195. });
  196. onReachBottom(() => {
  197. nextTick(() => {
  198. listRef.value && listRef.value.scrolltolower();
  199. });
  200. });
  201. </script>
  202. <style lang="less" scoped>
  203. @import url("@/style.less");
  204. .wrap {
  205. min-height: 100vh;
  206. background-color: var(--light);
  207. .nav {
  208. position: relative;
  209. background-color: var(--black);
  210. :deep(.u-navbar) {
  211. position: relative;
  212. z-index: 1;
  213. }
  214. .nav_center {
  215. width: calc(100% - 46px - 50px);
  216. /deep/ .u-input {
  217. background: rgba(255, 255, 255, 0.6);
  218. backdrop-filter: blur(10px);
  219. .icon-search {
  220. color: var(--light);
  221. }
  222. .uni-input-placeholder,
  223. .uni-input-input {
  224. color: var(--light) !important;
  225. .size(24rpx);
  226. }
  227. }
  228. .icon-camera {
  229. color: var(--light);
  230. font-size: 56rpx;
  231. }
  232. }
  233. .nav_right {
  234. .icon-font {
  235. .size(28px);
  236. color: var(--text);
  237. }
  238. }
  239. .bg_logo {
  240. position: fixed;
  241. .size(128rpx);
  242. color: var(--inputBg);
  243. opacity: 0.06;
  244. top: 0;
  245. left: 50%;
  246. font-weight: bold;
  247. transform: translateX(-50%);
  248. line-height: 88rpx;
  249. text-transform: uppercase;
  250. font-family: "HarmonyOS_Sans";
  251. text-wrap: nowrap;
  252. }
  253. }
  254. .tops {
  255. background-color: var(--black);
  256. .flex_position(space-between);
  257. gap: 24rpx;
  258. padding: 48rpx 48rpx 24rpx;
  259. // margin: 24rpx 24rpx 0;
  260. // border-radius: 16rpx;
  261. .shop_info {
  262. .ver();
  263. .shop_img {
  264. width: 100rpx;
  265. height: 100rpx;
  266. ._img {
  267. width: inherit;
  268. height: inherit;
  269. border-radius: 8rpx;
  270. }
  271. }
  272. .shop_name {
  273. color: var(--light);
  274. .size();
  275. font-weight: 700;
  276. line-height: 60rpx;
  277. margin-left: 24rpx;
  278. }
  279. }
  280. .btn_wrapper {
  281. .ver();
  282. .icon-font {
  283. .size(62rpx);
  284. color: var(--light);
  285. margin-right: 8rpx;
  286. }
  287. }
  288. }
  289. .content {
  290. padding: 24rpx;
  291. /deep/ .wrap_list {
  292. .uni-scroll-view-content {
  293. > uni-view {
  294. .flex();
  295. flex-wrap: wrap;
  296. gap: 16rpx;
  297. .u-list-item {
  298. width: calc((100% - 16rpx) / 2);
  299. }
  300. }
  301. }
  302. }
  303. }
  304. }
  305. .pop_cont {
  306. color: var(--text);
  307. .size(28rpx);
  308. line-height: 60rpx;
  309. }
  310. .pop_tip {
  311. color: var(--text-01);
  312. .size(28rpx);
  313. line-height: 60rpx;
  314. }
  315. .pop_btn {
  316. margin-top: 32rpx;
  317. height: 76rpx;
  318. padding: 16rpx 30rpx;
  319. color: var(--primary);
  320. border: 1px solid var(--primary);
  321. border-radius: 16rpx;
  322. .size(24rpx);
  323. .flex_center();
  324. }
  325. </style>