list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <template>
  2. <view class="wrapper">
  3. <!-- 筛选弹出层 -->
  4. <u-popup width="90%" v-model="popup" mode="right">
  5. <view class="screen-title">商品筛选</view>
  6. <view class="screen-view">
  7. <view class="screen-item">
  8. <h4>价格区间</h4>
  9. <view class="flex">
  10. <u-input class="u-bg" placeholder-style="font-size:22rpx;" type="number" input-align="center" placeholder="最低价"></u-input>
  11. <view class="line"></view>
  12. <u-input class="u-bg" placeholder-style="font-size:22rpx;" type="number" input-align="center" placeholder="最高价"></u-input>
  13. </view>
  14. </view>
  15. <view class="screen-item">
  16. <h4>销量</h4>
  17. <view class="flex">
  18. <u-input class="u-bg w200 flex1" placeholder-style="font-size:22rpx;" type="number" input-align="center" placeholder="销量"></u-input>
  19. <view class="flex1">笔以上</view>
  20. </view>
  21. </view>
  22. <view class="screen-item">
  23. <h4>收入比率</h4>
  24. <view class="flex">
  25. <u-input class="u-bg" placeholder-style="font-size:22rpx;" type="number" input-align="center" placeholder="最低%"></u-input>
  26. <view class="line"></view>
  27. <u-input class="u-bg" placeholder-style="font-size:22rpx;" type="number" input-align="center" placeholder="最高%"></u-input>
  28. </view>
  29. </view>
  30. <view class="screen-item">
  31. <h4>包邮</h4>
  32. <view class="flex">
  33. <u-tag class="u-tag" shape="circle" text="包邮" mode="plain" type="info" />
  34. </view>
  35. </view>
  36. <view class="screen-item">
  37. <h4>促销活动</h4>
  38. <view class="flex">
  39. <u-tag class="u-tag" shape="circle" text="限时抢购" mode="plain" type="info" />
  40. <u-tag class="u-tag" shape="circle" text="拼团秒杀" mode="plain" type="info" />
  41. </view>
  42. </view>
  43. <view class="screen-item">
  44. <h4>经营类型</h4>
  45. <view class="flex">
  46. <u-tag class="u-tag" shape="circle" text="平台自营" mode="plain" type="info" />
  47. <u-tag class="u-tag" shape="circle" text="三方店铺" mode="plain" type="info" />
  48. </view>
  49. </view>
  50. </view>
  51. <view class="screen-btn">
  52. <view class="screen-clear"> 重置 </view>
  53. <view class="screen-submit"> 确定 </view>
  54. </view>
  55. </u-popup>
  56. <!-- 导航栏 -->
  57. <view class="nav">
  58. <view class="nav-item" @click="handleMyGoods(true)" :class="{ checked: params.checked }">已选择</view>
  59. <view class="nav-item" @click="handleMyGoods(false)" :class="{ checked: !params.checked }">未选择</view>
  60. <!-- <view class="nav-item" @click="popup = !popup">筛选</view> -->
  61. </view>
  62. <!-- 商品列表 -->
  63. <view class="goods-list">
  64. <view class="goods-item" v-for="(item, index) in goodsList" :key="index">
  65. <view class="goods-item-img" @click="handleNavgationGoods(item)">
  66. <u-image width="176rpx" height="176rpx" :src="item.thumbnail"></u-image>
  67. </view>
  68. <view class="goods-item-desc">
  69. <!-- 商品描述 -->
  70. <view class="-item-title" @click="handleNavgationGoods(item)">
  71. {{ item.goodsName }}
  72. </view>
  73. <!-- 商品金额 -->
  74. <view class="-item-price" @click="handleNavgationGoods(item)">
  75. 佣金:
  76. <span> ¥{{ item.commission | unitPrice }}</span>
  77. </view>
  78. <!-- 比率佣金 -->
  79. <view class="-item-bottom">
  80. <view class="-item-bootom-money" @click="handleNavgationGoods(item)">
  81. <!-- <view class="-item-bl">
  82. 比率:
  83. <span>{{ "5.00%" }}</span>
  84. </view> -->
  85. <view class="-item-yj">
  86. <span>¥{{ item.price | unitPrice }}</span>
  87. </view>
  88. </view>
  89. <view>
  90. <view class="click" v-if="!params.checked" @click="handleClickGoods(item)">立即选取</view>
  91. <view class="click" v-if="params.checked" @click="handleLink(item)">分销商品</view>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. <view class="empty">
  97. <!-- <u-empty v-if="empty" text="没有分销商品了" mode="list"></u-empty> -->
  98. </view>
  99. </view>
  100. <canvas class="canvas-hide" canvas-id="qrcode" />
  101. <drawCanvas ref="drawCanvas" v-if="showFlag" :res="res" />
  102. </view>
  103. </template>
  104. <script>
  105. import {
  106. distributionGoods,
  107. checkedDistributionGoods,
  108. getMpCode,
  109. } from "@/api/goods";
  110. import drawCanvas from "@/components/m-canvas";
  111. export default {
  112. data() {
  113. return {
  114. showFlag: false, //分销分享开关
  115. empty: false,
  116. popup: false, //弹出层开关
  117. active_color: this.$mainColor,
  118. current: 0,
  119. params: {
  120. pageNumber: 1,
  121. pageSize: 10,
  122. checked: true,
  123. },
  124. goodsList: [],
  125. // 分销分享 实例
  126. res: {
  127. container: {
  128. width: 600,
  129. height: 960,
  130. background: "#fff",
  131. title: "分享背景",
  132. },
  133. // 分销分享
  134. bottom: {
  135. img: "",
  136. code: "",
  137. price: 0,
  138. },
  139. },
  140. routers: "",
  141. };
  142. },
  143. components: {
  144. drawCanvas,
  145. },
  146. onLoad(options) {
  147. this.routers = options;
  148. },
  149. watch: {
  150. showFlag(val) {},
  151. },
  152. onShow() {
  153. this.goodsList = [];
  154. this.init();
  155. },
  156. methods: {
  157. handleNavgationGoods(val) {
  158. uni.navigateTo({
  159. url: `/pages/product/goods?id=${val.skuId}&goodsId=${val.id}`,
  160. });
  161. },
  162. async handleLink(goods) {
  163. uni.showToast({
  164. title: "请请按住保存图片",
  165. duration: 2000,
  166. icon: "none",
  167. });
  168. let page = `pages/product/goods`;
  169. let scene = `${goods.skuId},${goods.goodsId},${this.routers.id}`;
  170. let result = await getMpCode({ page, scene });
  171. if (result.data.success) {
  172. let callback = result.data.result;
  173. this.res.container.title = `${goods.goodsName}`;
  174. this.res.bottom.code = `data:image/png;base64,${callback}`;
  175. this.res.bottom.price = this.$options.filters.unitPrice(
  176. goods.price,
  177. "¥"
  178. );
  179. this.res.bottom.desc = `${goods.goodsName}`;
  180. this.res.bottom.img = `${goods.thumbnail}`;
  181. if (this.showFlag) {
  182. this.$refs.drawCanvas.init();
  183. }
  184. this.showFlag = true;
  185. } else {
  186. uni.showToast({
  187. title: `制作二维码失败!请稍后重试`,
  188. duration: 2000,
  189. icon: "none",
  190. });
  191. }
  192. },
  193. change(index) {
  194. this.current = index;
  195. },
  196. // 点击我的选品库
  197. handleMyGoods(flag) {
  198. this.goodsList = [];
  199. this.params.checked = flag;
  200. this.init();
  201. },
  202. // 选择商品
  203. handleClickGoods(val) {
  204. uni.showLoading({
  205. title: "加载中",
  206. mask: true,
  207. });
  208. checkedDistributionGoods(val.id).then((res) => {
  209. uni.hideLoading();
  210. if (res.data.success) {
  211. uni.showToast({
  212. title: "已添加到我的选品库",
  213. duration: 2000,
  214. icon: "none",
  215. });
  216. setTimeout(() => {
  217. this.goodsList = [];
  218. this.init();
  219. }, 500);
  220. }
  221. });
  222. },
  223. init() {
  224. uni.showLoading({
  225. title: "加载中",
  226. });
  227. distributionGoods(this.params).then((res) => {
  228. uni.hideLoading();
  229. if (res.data.success && res.data.result.records.length >= 1) {
  230. this.goodsList.push(...res.data.result.records);
  231. }
  232. if (this.goodsList.length == 0) {
  233. this.empty = true;
  234. }
  235. });
  236. },
  237. },
  238. };
  239. </script>
  240. <style lang="scss" scoped>
  241. .canvas-hide {
  242. /* 1 */
  243. position: fixed;
  244. right: 100vw;
  245. bottom: 100vh;
  246. /* 2 */
  247. z-index: -9999;
  248. /* 3 */
  249. opacity: 0;
  250. }
  251. .empty {
  252. margin: 40rpx 0;
  253. }
  254. .checked {
  255. color: $main-color;
  256. font-weight: bold;
  257. }
  258. .screen-btn {
  259. display: flex;
  260. width: 100%;
  261. height: 88rpx;
  262. line-height: 88rpx;
  263. position: fixed;
  264. bottom: 0;
  265. > .screen-clear,
  266. .screen-submit {
  267. width: 50%;
  268. text-align: center;
  269. }
  270. .screen-submit {
  271. background: $main-color;
  272. color: #fff;
  273. }
  274. }
  275. .screen-item {
  276. margin-bottom: 40rpx;
  277. }
  278. .flex1 {
  279. padding-left: 10rpx;
  280. }
  281. .u-tag {
  282. margin-right: 20rpx;
  283. }
  284. .line {
  285. width: 40rpx;
  286. height: 2rpx;
  287. background: #999;
  288. margin: 0 10rpx;
  289. }
  290. .u-bg {
  291. background: #eff1f4;
  292. border-radius: 0.4em;
  293. font-size: 22rpx;
  294. }
  295. .screen-title {
  296. height: 88rpx;
  297. text-align: center;
  298. font-size: 28upz;
  299. line-height: 88rpx;
  300. border-bottom: 1px solid #ededed;
  301. }
  302. .flex {
  303. display: flex;
  304. margin: 20rpx 0;
  305. align-items: center;
  306. }
  307. .screen-view {
  308. padding: 32rpx;
  309. }
  310. .bar {
  311. padding: 0 20rpx;
  312. display: flex;
  313. justify-content: space-between;
  314. align-items: center;
  315. height: 88rpx;
  316. width: 100%;
  317. background: #fff;
  318. z-index: 8;
  319. > .bar-btn {
  320. display: flex;
  321. }
  322. }
  323. .nav {
  324. background: #fff;
  325. width: 100%;
  326. display: flex;
  327. height: 88rpx;
  328. box-sizing: border-box;
  329. border-top: 1px solid #ededed;
  330. border-bottom: 1px solid #ededed;
  331. > .nav-item {
  332. line-height: 88rpx;
  333. height: 88rpx;
  334. flex: 1;
  335. text-align: center;
  336. }
  337. }
  338. .click {
  339. background: $main-color;
  340. color: #fff;
  341. margin: 0 4rpx;
  342. font-size: 22rpx;
  343. padding: 10rpx 20rpx;
  344. border-radius: 100px;
  345. }
  346. .goods-list {
  347. // #ifdef H5
  348. height: calc(100vh - 176rpx);
  349. // #endif
  350. // #ifndef H5
  351. height: calc(100vh - 88rpx);
  352. // #endif
  353. overflow: auto;
  354. }
  355. .goods-item {
  356. border-radius: 20rpx;
  357. background: #fff;
  358. display: flex;
  359. padding: 22rpx;
  360. margin: 20rpx;
  361. justify-content: space-between;
  362. > .goods-item-desc {
  363. flex: 2;
  364. padding: 0 16rpx;
  365. line-height: 1.7;
  366. > .-item-bottom {
  367. display: flex;
  368. justify-content: space-between;
  369. align-items: center;
  370. padding-bottom: 20rpx;
  371. > .-item-bootom-money {
  372. > .-item-bl,
  373. .-item-yj {
  374. margin-right: 10rpx;
  375. font-size: 24rpx;
  376. color: $font-color-base;
  377. }
  378. }
  379. }
  380. > .-item-title {
  381. display: -webkit-box;
  382. -webkit-box-orient: vertical;
  383. -webkit-line-clamp: 1;
  384. overflow: hidden;
  385. }
  386. > .-item-price {
  387. color: $jd-color;
  388. > span {
  389. font-size: 36rpx;
  390. }
  391. }
  392. }
  393. }
  394. .wrapper {
  395. width: 100%;
  396. }
  397. </style>