card.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. <template>
  2. <view class="container">
  3. <view class="member"></view>
  4. <view class="content">
  5. <view class="member_card">
  6. <view class="info">开通美卡平均可省</view>
  7. <view class="text">
  8. 1588
  9. <text>元/年</text>
  10. </view>
  11. </view>
  12. <view class="assets">
  13. <view class="title">
  14. <image class="" src="/static/img/img33.png"></image>
  15. <view class="name">美卡特权</view>
  16. </view>
  17. <view class="privileges flex">
  18. <view class="privileges_list" v-for="(ls, index) in list" @click="clickNav(index)">
  19. <view class="img"><image :src="ls.img"></image></view>
  20. <view class="text">{{ ls.text }}</view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="discount flex" id="block1">
  25. <view class="tpl">
  26. <view class="name">美卡专享价</view>
  27. <view class="text">800+超值低价商品等你来拿</view>
  28. </view>
  29. <view class="tip">
  30. <view class="money">¥172</view>
  31. <view class="money">平均可省</view>
  32. </view>
  33. </view>
  34. <view class="goods" id="block3">
  35. <view class="list flex_item" v-for="ls in goods" @click="ToDetail(ls)">
  36. <view class="list-img"><image :src="ls.image"></image></view>
  37. <view class="list-info">
  38. <view class="name clamp">{{ ls.store_name }}</view>
  39. <view class="describe clamp">{{ ls.store_info }}</view>
  40. <view class="text" v-if="ls.keyword != ''">
  41. <text v-for="lss in ls.keyword">{{ lss }}</text>
  42. </view>
  43. <view class="price-box flex">
  44. <view class="price">
  45. <view class="grey">¥{{ ls.price }}</view>
  46. <view class="red">
  47. ¥{{ ls.ot_price }}
  48. <text>市场价</text>
  49. </view>
  50. </view>
  51. <view class="gocar position-relative" @click.stop="Addcar(ls)">
  52. <image src="/static/img/img21.png"></image>
  53. <view class="corner" v-if="ls.cart_num > 0">
  54. <text>{{ ls.cart_num }}</text>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="submit" id="block2">查看800+美卡专享价商品</view>
  62. <view class="discount flex">
  63. <view class="tpl">
  64. <view class="name">免配送券</view>
  65. <view class="text">每次抵扣4元,价值30元/月</view>
  66. </view>
  67. <view class="tip">
  68. <view class="money">¥172</view>
  69. <view class="money">平均可省</view>
  70. </view>
  71. </view>
  72. <view class="bound">
  73. <view class="text">
  74. 开通美卡美卡享受免配送费
  75. <text>4次/月</text>
  76. </view>
  77. <view class="tpl"><text>配送权仅可当月使用</text></view>
  78. </view>
  79. <view class="Tips">
  80. <uni-icons type="info-filled" color="#999999" size="18" />
  81. <text>下单自动抵扣,无需领取</text>
  82. </view>
  83. <view class="discount flex">
  84. <view class="tpl">
  85. <view class="name">美卡专享卡包</view>
  86. <view class="text">同样的产品,你买就是低价</view>
  87. </view>
  88. <view class="tip">
  89. <view class="money">¥164</view>
  90. <view class="money">平均可省</view>
  91. </view>
  92. </view>
  93. <view class="bound">
  94. <view class="text">
  95. 开通美卡购物领折扣更
  96. <text>实惠</text>
  97. </view>
  98. <view class="tpl"><text>美卡卡购物更实惠</text></view>
  99. </view>
  100. <view class="opening flex">
  101. <view class="more">充值美卡享更多优惠</view>
  102. <view class="confirm" @click="navTo('/pages/user/member')">立即开通</view>
  103. </view>
  104. </view>
  105. </view>
  106. </template>
  107. <script>
  108. import { userinfo } from '@/api/user.js';
  109. import { getProducts } from '@/api/product.js';
  110. import { cartAdd } from '@/api/product.js';
  111. export default {
  112. data() {
  113. return {
  114. userInfo: '',
  115. list: [
  116. {
  117. img: 'https://shicaitest.liuniu946.com/img/img51.png',
  118. text: '美卡专享价'
  119. },
  120. {
  121. img: 'https://shicaitest.liuniu946.com/img/img52.png',
  122. text: '美卡优惠卡包'
  123. },
  124. {
  125. img: 'https://shicaitest.liuniu946.com/img/img53.png',
  126. text: '免配送券'
  127. },
  128. {
  129. img: 'https://shicaitest.liuniu946.com/img/img54.png',
  130. text: '更多'
  131. }
  132. ],
  133. goods: '',
  134. block_1ScrollTop: '',
  135. block_2ScrollTop: '',
  136. pageHeight:''
  137. };
  138. },
  139. onLoad() {},
  140. onShow() {
  141. this.loadDate();
  142. },
  143. mounted() {
  144. var query = uni.createSelectorQuery();
  145. //获取对应模块到顶部的距离
  146. query
  147. .select('#block1')
  148. .boundingClientRect(res => {
  149. this.block_1ScrollTop = res.top;
  150. })
  151. .exec();
  152. query
  153. .select('#block2')
  154. .boundingClientRect(res => {
  155. this.block_2ScrollTop = res.top;
  156. })
  157. .exec();
  158. },
  159. onReady() {
  160. // 初始化获取页面宽度
  161. uni.createSelectorQuery()
  162. .select('.content')
  163. .fields(
  164. {
  165. size: true
  166. },
  167. data => {
  168. // 获取页面百分比
  169. this.pageHeight = data.height * (data.width / 750);
  170. }
  171. )
  172. .exec();
  173. },
  174. methods: {
  175. clickNav(index) {
  176. if (index == 0) {
  177. uni.pageScrollTo({
  178. scrollTop: this.block_1ScrollTop
  179. });
  180. };
  181. if(index == 1){
  182. uni.pageScrollTo({
  183. scrollTop: this.block_2ScrollTop + this.pageHeight + 1000
  184. });
  185. };
  186. if(index == 2){
  187. uni.pageScrollTo({
  188. scrollTop: this.block_2ScrollTop + this.pageHeight + 1000
  189. });
  190. };
  191. },
  192. loadDate() {
  193. let obj = this;
  194. getProducts({
  195. page: 1,
  196. limit: 5,
  197. type: 1,
  198. news: '',
  199. keyword: ''
  200. }).then(e => {
  201. obj.goods = e.data;
  202. });
  203. },
  204. //加入购物车
  205. Addcar(item) {
  206. let obj = this;
  207. cartAdd({
  208. cartNum: '1', //商品数量
  209. uniqueId: '', //商品标签
  210. new: 0, //商品是否新增加到购物车1为不加入0为加入
  211. mer_id: '',
  212. productId: item.id //商品编号
  213. })
  214. .then(function(e) {
  215. let da = e.data;
  216. uni.showToast({
  217. title: '成功加入购物车',
  218. type: 'top',
  219. duration: 500,
  220. icon: 'none'
  221. });
  222. obj.loadDate();
  223. })
  224. .catch(e => {
  225. console.log(e);
  226. });
  227. },
  228. // 商品详情页
  229. ToDetail(item) {
  230. uni.navigateTo({
  231. url: `/pages/product/product?id=` + item.id
  232. });
  233. },
  234. navTo(url) {
  235. uni.navigateTo({
  236. url
  237. });
  238. }
  239. }
  240. };
  241. </script>
  242. <style lang="scss">
  243. page {
  244. height: 100%;
  245. background-color: $page-color-base;
  246. .container {
  247. height: 100%;
  248. }
  249. }
  250. .member {
  251. background: #1c2532;
  252. height: 250rpx;
  253. width: 100%;
  254. border-bottom-left-radius: 20%;
  255. border-bottom-right-radius: 20%;
  256. }
  257. .content {
  258. width: 100%;
  259. margin-top: -120rpx;
  260. .member_card {
  261. width: 90%;
  262. margin: 0rpx auto;
  263. height: 300rpx;
  264. padding: 45rpx 45rpx;
  265. background: #2dbd59;
  266. border: 2rpx solid #ffe487;
  267. border-radius: 25rpx;
  268. text-align: center;
  269. .info {
  270. color: #ffffff;
  271. font-size: 29rpx;
  272. padding-top: 50rpx;
  273. }
  274. .text {
  275. color: #feeda1;
  276. font-size: 65rpx;
  277. padding-top: 40rpx;
  278. text {
  279. font-size: 41rpx;
  280. }
  281. }
  282. }
  283. }
  284. .assets {
  285. background: #ffffff;
  286. width: 100%;
  287. margin-top: 25rpx;
  288. padding: 25rpx 0rpx;
  289. text-align: center;
  290. .title {
  291. width: 85%;
  292. height: 3rpx;
  293. margin: 0rpx auto;
  294. image {
  295. width: 100%;
  296. height: 100%;
  297. }
  298. .name {
  299. position: relative;
  300. bottom: 40rpx;
  301. font-weight: bold;
  302. }
  303. }
  304. .privileges {
  305. margin-top: 100rpx;
  306. font-size: 24rpx;
  307. margin-bottom: 40rpx;
  308. .privileges_list {
  309. text-align: center;
  310. width: 200rpx !important;
  311. .img {
  312. height: 80rpx;
  313. text-align: center;
  314. image {
  315. width: 80rpx;
  316. height: 100%;
  317. }
  318. }
  319. .text {
  320. padding-top: 15rpx;
  321. }
  322. }
  323. }
  324. }
  325. .discount {
  326. width: 100%;
  327. padding: 50rpx 25rpx;
  328. .tpl {
  329. .name {
  330. font-size: 36rpx;
  331. color: #333333;
  332. font-weight: bold;
  333. }
  334. .text {
  335. color: #999999;
  336. font-size: 24rpx;
  337. padding-top: 15rpx;
  338. }
  339. }
  340. .tip {
  341. text-align: right;
  342. background: #1c2532;
  343. border-radius: 40rpx;
  344. padding: 18rpx 24rpx;
  345. border-bottom-right-radius: 10rpx !important;
  346. .money {
  347. background: linear-gradient(270deg, rgba(204, 178, 121, 1) 0%, rgba(245, 234, 197, 1) 100%);
  348. -webkit-background-clip: text;
  349. -webkit-text-fill-color: transparent;
  350. font-weight: bold;
  351. font-size: 26rpx;
  352. }
  353. }
  354. }
  355. .goods {
  356. padding: 0rpx 25rpx;
  357. width: 92%;
  358. margin: 0rpx auto;
  359. background: #ffffff;
  360. border-radius: 15rpx;
  361. margin-bottom: 50rpx;
  362. .list {
  363. border-bottom: 2rpx solid #f0f0f0;
  364. padding: 25rpx 0rpx;
  365. .list-img {
  366. width: 225rpx;
  367. height: 225rpx;
  368. image {
  369. width: 100%;
  370. height: 100%;
  371. }
  372. }
  373. .list-info {
  374. padding-left: 25rpx;
  375. width: 60%;
  376. .name {
  377. color: #333333;
  378. font-size: 30rpx;
  379. font-weight: 500;
  380. }
  381. .describe {
  382. color: #999999;
  383. font-size: 24rpx;
  384. margin: 15rpx 0rpx;
  385. padding-bottom: 15rpx;
  386. }
  387. .text {
  388. color: #ff383e;
  389. padding: 15rpx 0rpx;
  390. text {
  391. border-radius: 10rpx;
  392. border: 2rpx solid #ff383e;
  393. font-size: 20rpx;
  394. padding: 2rpx 15rpx;
  395. }
  396. }
  397. .price-box {
  398. .price {
  399. font-size: 26rpx;
  400. .grey {
  401. color: #666666;
  402. text-decoration: line-through;
  403. }
  404. .red {
  405. color: #2dbd59;
  406. text {
  407. margin-left: 15rpx;
  408. background: #2dbd59;
  409. color: #ffffff;
  410. border-radius: 10rpx;
  411. padding: 3rpx 15rpx;
  412. }
  413. }
  414. }
  415. .gocar {
  416. width: 50rpx;
  417. height: 50rpx;
  418. image {
  419. width: 100%;
  420. height: 100%;
  421. }
  422. }
  423. }
  424. }
  425. }
  426. }
  427. .submit {
  428. background: #ffe487;
  429. width: 92%;
  430. margin: 0rpx auto;
  431. padding: 25rpx 0rpx;
  432. text-align: center;
  433. margin-bottom: 20rpx;
  434. border-radius: 15rpx;
  435. font-weight: bold;
  436. color: rgba(51, 51, 51, 1);
  437. font-size: 30rpx;
  438. }
  439. .bound {
  440. width: 92%;
  441. margin: 0rpx auto;
  442. height: 100px;
  443. display: flex;
  444. flex-direction: column;
  445. align-items: center;
  446. position: relative; //设置定位
  447. background: linear-gradient(-21deg, rgba(0, 184, 72, 1) 0%, rgba(40, 218, 116, 1) 100%);
  448. border-radius: 20rpx;
  449. padding: 30rpx 20rpx;
  450. color: #ffffff;
  451. .text {
  452. font-size: 36rpx;
  453. text {
  454. color: #feeda1;
  455. font-size: 48rpx;
  456. }
  457. }
  458. .tpl {
  459. margin-top: 25rpx;
  460. text {
  461. background: #ffffff;
  462. padding: 14rpx 103rpx;
  463. border-radius: 20rpx;
  464. color: #333333;
  465. font-size: 32rpx;
  466. }
  467. }
  468. }
  469. .bound::before {
  470. content: '';
  471. width: 35px;
  472. height: 30px;
  473. border-radius: 50%;
  474. display: block;
  475. background: #f8f6f6;
  476. position: absolute;
  477. top: 50%;
  478. left: -20px;
  479. transform: translateY(-50%);
  480. }
  481. .bound::after {
  482. content: '';
  483. width: 35px;
  484. height: 30px;
  485. border-radius: 50%;
  486. display: block;
  487. background: #f8f6f6;
  488. position: absolute;
  489. top: 50%;
  490. right: -20px;
  491. transform: translateY(-50%);
  492. }
  493. .opening {
  494. width: 100%;
  495. font-size: 30rpx;
  496. padding-top: 90rpx;
  497. text-align: center;
  498. .more {
  499. background: #1e2531;
  500. color: #feeda1;
  501. width: 60%;
  502. padding: 30rpx 0rpx;
  503. }
  504. .confirm {
  505. background: #2dbd59;
  506. color: #ffffff;
  507. width: 40%;
  508. padding: 30rpx 0rpx;
  509. }
  510. }
  511. .Tips {
  512. width: 100%;
  513. padding-left: 25rpx;
  514. font-size: 24rpx;
  515. color: #999999;
  516. padding-top: 20rpx;
  517. text {
  518. padding-left: 10rpx;
  519. }
  520. }
  521. </style>