index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  1. <template>
  2. <app-layout :overflow="false">
  3. <view class="nav">
  4. <image load-lazy="true" class="nav-bg" src="/static/image/index_BG.png"></image>
  5. <view class="nav-title">我的积分</view>
  6. <view class="nav-num">{{userInfo ? userInfo.integral : 0}}</view>
  7. <view @click="toAbout" class="about">
  8. <image load-lazy="true" src="/static/image/about.png"></image>
  9. </view>
  10. <view @click="router('/plugins/integral_mall/exchange/exchange')" class="exchange">
  11. <image load-lazy="true" src="/static/image/icon/exchange.png"></image>
  12. <text>我的兑换</text>
  13. </view>
  14. <view @click="router('/pages/user-center/integral-detail/integral-detail')" class="log">
  15. <image load-lazy="true" src="/static/image/log.png"></image>
  16. <text>积分收支</text>
  17. </view>
  18. </view>
  19. <view class="banner" indicator-dots="true" autoplay="true" v-if="banners && banners.length">
  20. <swiper class="swiper" indicator-dots="true" autoplay="true">
  21. <swiper-item v-for="(item,index) in banners" :key="index">
  22. <app-jump-button :open_type="item.open_type" :url="item.page_url" :params="item.params">
  23. <image mode="aspectFill" :src="item.pic_url"></image>
  24. </app-jump-button>
  25. </swiper-item>
  26. </swiper>
  27. </view>
  28. <view class="coupon" v-if="coupon.length > 0">
  29. <view class="coupon-title">兑换优惠券</view>
  30. <scroll-view scroll-x class="coupon-list">
  31. <view class="coupon-item" @click="router('/plugins/integral_mall/coupon/coupon?id=' + item.id)" v-for="item in coupon" :key="item.id">
  32. <image load-lazy="true" src="/static/image/coupon-bg.png"></image>
  33. <view class="coupon-name t-omit" v-if="item.coupon.type == 2">¥
  34. <text>{{item.coupon.sub_price}}</text>优惠券</view>
  35. <view class="coupon-name discount" v-else>
  36. <text>{{item.coupon.discount}}</text>优惠券</view>
  37. <view class="coupon-user t-omit">
  38. {{item.integral_num}}积分<span v-if="item.price > 0">+{{item.price}}元</span>兑换
  39. <!-- 满{{item.coupon.min_price}}元可用 -->
  40. </view>
  41. <view class="coupon-exchange">
  42. <view>立即兑换</view>
  43. </view>
  44. </view>
  45. </scroll-view>
  46. </view>
  47. <view class="goods">
  48. <view class="goods-title">
  49. <view class="coupon-title">优惠购专区</view>
  50. </view>
  51. <scroll-view scroll-x class="cat-list">
  52. <view @click="tab(0)" :style="{'background-color': _num == 0 ? getTheme.background : ''}" :class="[`cat-item`,`t-omit`,`${_num == 0 ?'active':''}`]">全部</view>
  53. <view @click="tab(item.id)" :style="{'background-color': _num == item.id ? getTheme.background : ''}" :class="[`cat-item`,`t-omit`,`${_num == item.id ?'active':''}`]" v-for="item in cats" :key="item.id">{{item.name}}
  54. </view>
  55. </scroll-view>
  56. <view class="goods-list dir-left-wrap">
  57. <view open-type="navigate" @click="toGoods(item)" class="goods-item" v-for="item in goods" :key="item.id">
  58. <image load-lazy="true" mode="aspectFill" class="goods-img" :src="item.cover_pic"></image>
  59. <view class="out-dialog" v-if="item.goods_stock == 0 && appSetting.is_show_stock == '1'">
  60. <image :src="appSetting.is_use_stock == '1' ? appImg.plugins_out : appSetting.sell_out_pic"></image>
  61. </view>
  62. <view class="goods-name t-omit">{{item.name}}</view>
  63. <view class="goods-price" :style="{'color': getTheme.color}">{{item.integralMallGoods.integral_num}}积分<text v-if="item.price > 0">+¥{{item.price}}</text></view>
  64. <view class="goods-old">¥{{item.original_price}}</view>
  65. <view class="goods-num">仅剩{{item.goods_stock}}件</view>
  66. <button v-if="item.goods_stock > 0" class="goods-exchange" :style="{'background-color': item.buy_goods_auth ? getTheme.background : '#999999'}">立即兑换</button>
  67. <button v-else class="goods-exchange" style="background: #CDCDCD;color: #fff;">已售罄</button>
  68. </view>
  69. </view>
  70. </view>
  71. <view class="dialog-bg" v-if="lose || success">
  72. <view class="dialog">
  73. <view @click="close">
  74. <image load-lazy="true" class="close" src="/static/image/icon/icon-close.png"></image>
  75. </view>
  76. <view class="lose" v-if="lose">
  77. <image load-lazy="true" class="lose-img" src="/static/image/lose.png"></image>
  78. <view class="lose-title">兑换失败!</view>
  79. <view>当前积分不足</view>
  80. </view>
  81. <view class="success" v-if="success">
  82. <image load-lazy="true" class="success-head" :src="integralImg.app_image.success"></image>
  83. <view>恭喜您,兑换成功!</view>
  84. <view class="main-between success-btn">
  85. <view @click="toList">
  86. <button class="to-card">去卡券包</button>
  87. </view>
  88. <view @click="toList">
  89. <button class="to-use">立即使用</button>
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. <!-- <view class="dialog-bg" v-if="choose.id > 0">
  96. <view class="dialog-tip">
  97. <view class="dialog-title">提示</view>
  98. <view class="dialog-msg">
  99. 确定使用
  100. <text v-if="choose.integral_num > 0"><text style="color: #ff4544">{{choose.integral_num}}</text>积分</text>
  101. <text v-if="choose.price > 0"><text v-if="choose.integral_num > 0">与</text>
  102. <text style="color: #ff4544">{{choose.price}}</text>元</text>
  103. 兑换此优惠券?
  104. </view>
  105. <view class="dialog-btn main-center">
  106. <view @click="chooseItem({})" class="dialog-close">取消</view>
  107. <view class="line"></view>
  108. <view class="dialog-submit" @click="submit">确认</view>
  109. </view>
  110. </view>
  111. </view> -->
  112. </app-layout>
  113. </template>
  114. <script>
  115. import { mapState, mapGetters } from "vuex";
  116. export default {
  117. data() {
  118. return {
  119. success: false,
  120. lose: false,
  121. _num: 0,
  122. more: false,
  123. setting: {},
  124. coupon: [],
  125. userInfo: {
  126. integral: 0
  127. },
  128. choose: {
  129. integral: 0
  130. },
  131. banners: [],
  132. cats: [],
  133. id: 0,
  134. exchangeCoupon: false,
  135. current: 'wechat',
  136. goods: [],
  137. args: false,
  138. page: 1,
  139. disable: 'disable'
  140. }
  141. },
  142. computed: {
  143. ...mapState({
  144. integralImg: state => state.mallConfig.plugin.integral_mall,
  145. appSetting: state => state.mallConfig.mall.setting,
  146. appImg: state => state.mallConfig.__wxapp_img.mall,
  147. platform: function(state) {
  148. return state.gConfig.systemInfo.platform;
  149. }
  150. }),
  151. ...mapGetters('mallConfig', {
  152. getVideo: 'getVideo',
  153. getTheme: 'getTheme'
  154. }),
  155. },
  156. methods: {
  157. close() {
  158. this.success = false;
  159. this.lose = false;
  160. },
  161. tab(id) {
  162. this._num = id;
  163. this.page = 1;
  164. this.goods = [];
  165. this.getGoods();
  166. },
  167. toList() {
  168. this.success = false;
  169. uni.navigateTo({
  170. url: '/pages/coupon/index/index'
  171. });
  172. },
  173. toGoods(data) {
  174. // #ifndef MP-BAIDU
  175. if (data.goodsWarehouse.video_url && this.getVideo == 1) {
  176. // #ifdef MP
  177. uni.navigateTo({
  178. url: `/pages/goods/video?goods_id=${data.id}&sign=${data.sign}`
  179. });
  180. // #endif
  181. // #ifdef H5
  182. uni.navigateTo({
  183. url: '/plugins/integral_mall/goods/goods?goods_id=' + data.id
  184. });
  185. // #endif
  186. } else {
  187. uni.navigateTo({
  188. url: '/plugins/integral_mall/goods/goods?goods_id=' + data.id
  189. });
  190. }
  191. // #endif
  192. // #ifdef MP-BAIDU
  193. uni.navigateTo({
  194. url: '/plugins/integral_mall/goods/goods?goods_id=' + data.id
  195. });
  196. // #endif
  197. },
  198. toAbout() {
  199. uni.navigateTo({
  200. url: `/pages/rules/index?url=${encodeURIComponent(this.$api.integral_mall.index)}&keys=${JSON.stringify(['setting', 'rule'])}`,
  201. });
  202. },
  203. router(url) {
  204. uni.navigateTo({
  205. url: url
  206. });
  207. },
  208. getList() {
  209. let that = this;
  210. that.$request({
  211. url: that.$api.integral_mall.index,
  212. }).then(response=>{
  213. that.$hideLoading();
  214. if(response.code === 0) {
  215. let { banners, setting, userInfo } = response.data;
  216. that.banners = banners;
  217. that.setting = setting;
  218. that.userInfo = userInfo;
  219. }else {
  220. uni.showToast({
  221. title: response.msg,
  222. icon: 'none',
  223. duration: 1000
  224. });
  225. }
  226. }).catch(() => {
  227. that.$hideLoading();
  228. });
  229. },
  230. getCoupon() {
  231. let that = this;
  232. that.$request({
  233. url: that.$api.integral_mall.coupon,
  234. }).then(response=>{
  235. that.$hideLoading();
  236. if(response.code === 0) {
  237. that.coupon = response.data.list;
  238. }else {
  239. uni.showToast({
  240. title: response.msg,
  241. icon: 'none',
  242. duration: 1000
  243. });
  244. }
  245. }).catch(() => {
  246. that.$hideLoading();
  247. });
  248. },
  249. getCat() {
  250. let that = this;
  251. that.$request({
  252. url: that.$api.integral_mall.cats,
  253. }).then(response=>{
  254. that.$hideLoading();
  255. if(response.code === 0) {
  256. that.cats = response.data.list;
  257. }else {
  258. uni.showToast({
  259. title: response.msg,
  260. icon: 'none',
  261. duration: 1000
  262. });
  263. }
  264. }).catch(() => {
  265. that.$hideLoading();
  266. });
  267. },
  268. getGoods() {
  269. let that = this;
  270. that.$request({
  271. url: that.$api.integral_mall.goods,
  272. data: {
  273. cat_id: that._num,
  274. page: that.page
  275. }
  276. }).then(response=>{
  277. that.$hideLoading();
  278. if(response.code === 0) {
  279. that.more = false;
  280. if(response.data.list.length == response.data.pagination.pageSize) {
  281. that.page++;
  282. that.more = true;
  283. }
  284. if(that.page > 1) {
  285. that.goods = that.goods.concat(response.data.list);
  286. }else {
  287. that.goods = response.data.list;
  288. }
  289. }else {
  290. uni.showToast({
  291. title: response.msg,
  292. icon: 'none',
  293. duration: 1000
  294. });
  295. }
  296. }).catch(() => {
  297. that.$hideLoading();
  298. });
  299. },
  300. },
  301. onReachBottom() {
  302. if(this.more) {
  303. this.getGoods();
  304. }
  305. },
  306. // #ifdef MP
  307. onShareAppMessage() {
  308. return this.$shareAppMessage({
  309. title: this.$children[0].navigationBarTitle,
  310. path: "/plugins/integral_mall/index/index",
  311. });
  312. },
  313. // #endif
  314. // #ifdef MP-WEIXIN
  315. onShareTimeline() {
  316. // 分享朋友圈beta
  317. return this.$shareTimeline({
  318. title: this.$children[0].navigationBarTitle,
  319. query: {} // 此处填写页面的参数
  320. });
  321. },
  322. // #endif
  323. onLoad() { this.$commonLoad.onload();
  324. let that = this;
  325. that._num = 0;
  326. // #ifdef MP-WEIXIN
  327. wx.showShareMenu({
  328. menus: ['shareAppMessage', 'shareTimeline']
  329. })
  330. // #endif
  331. that.$showLoading({
  332. type: 'global',
  333. text: '加载中...'
  334. });
  335. that.getList();
  336. that.getCoupon();
  337. that.getCat();
  338. that.getGoods();
  339. }
  340. }
  341. </script>
  342. <style scoped lang="scss">
  343. .nav {
  344. height: #{220rpx};
  345. width: 100%;
  346. position: relative;
  347. }
  348. .nav-bg {
  349. height: #{220rpx};
  350. width: 100%;
  351. }
  352. .nav-title {
  353. text-align: center;
  354. width: 100%;
  355. position: absolute;
  356. top: #{25rpx};
  357. color: #999;
  358. font-size: 12px;
  359. }
  360. .nav-num {
  361. text-align: center;
  362. width: 100%;
  363. position: absolute;
  364. top: #{60rpx};
  365. color: #ecb786;
  366. font-size: 24px;
  367. }
  368. .exchange, .log {
  369. position: absolute;
  370. bottom: #{40rpx};
  371. color: #fff;
  372. font-size: 15px;
  373. height: #{34rpx};
  374. line-height: #{34rpx};
  375. }
  376. .exchange image, .log image {
  377. height: #{34rpx};
  378. width: #{34rpx};
  379. margin-right: #{16rpx};
  380. display: block;
  381. float: left;
  382. }
  383. .exchange {
  384. left: #{120rpx};
  385. }
  386. .log {
  387. right: #{120rpx};
  388. }
  389. .about {
  390. height: #{30rpx};
  391. width: #{30rpx};
  392. position: absolute;
  393. top: #{25rpx};
  394. right: 38%;
  395. }
  396. .about image {
  397. height: #{30rpx};
  398. width: #{30rpx};
  399. display: block;
  400. }
  401. .banner {
  402. margin: #{20rpx} 0;
  403. height: #{190rpx};
  404. }
  405. .banner swiper {
  406. height: #{190rpx};
  407. }
  408. .banner image {
  409. height: #{190rpx};
  410. width: 100%;
  411. }
  412. .coupon {
  413. background-color: #fff;
  414. padding: #{30rpx} 0 #{40rpx} #{25rpx};
  415. }
  416. .coupon-title {
  417. font-size: 15px;
  418. color: #353535;
  419. border-left: #{4rpx} solid #ff6f28;
  420. padding-left: #{16rpx};
  421. height: #{35rpx};
  422. line-height: #{35rpx};
  423. margin-bottom: #{38rpx};
  424. }
  425. .coupon-list {
  426. height: #{220rpx};
  427. white-space: nowrap;
  428. overflow: hidden;
  429. width: auto;
  430. }
  431. .coupon-item {
  432. width: #{330rpx};
  433. height: #{220rpx};
  434. position: relative;
  435. display: inline-block;
  436. font-size: 13px;
  437. color: #353535;
  438. margin-right: #{20rpx};
  439. }
  440. .coupon-item image {
  441. width: #{330rpx};
  442. height: #{220rpx};
  443. }
  444. .coupon-name {
  445. position: absolute;
  446. left: #{24rpx};
  447. top: #{10rpx};
  448. width: #{300rpx};
  449. font-weight: bold;
  450. &.discount text:after {
  451. content: '折';
  452. font-size: 50%;
  453. }
  454. }
  455. .coupon-name text {
  456. font-size: 20px;
  457. margin-right: #{12rpx};
  458. }
  459. .coupon-user {
  460. position: absolute;
  461. width: #{280rpx};
  462. left: #{24rpx};
  463. top: #{70rpx};
  464. }
  465. .coupon-exchange {
  466. position: absolute;
  467. bottom: #{22rpx};
  468. left: 0;
  469. right: 0;
  470. text-align: center;
  471. }
  472. .coupon-exchange view {
  473. display: inline-block;
  474. padding: 0 #{28rpx};
  475. text-align: center;
  476. height: #{48rpx};
  477. line-height: #{48rpx};
  478. border-radius: #{24rpx};
  479. border: #{2rpx} solid #353535;
  480. margin: 0 auto;
  481. }
  482. .goods-title {
  483. padding-left: #{20rpx};
  484. height: #{96rpx};
  485. line-height: #{96rpx};
  486. padding-top: #{30.5rpx};
  487. background-color: #fff;
  488. margin-top: #{24rpx};
  489. border-bottom: #{1rpx} solid #e2e2e2;
  490. }
  491. .cat-list {
  492. height: #{100rpx};
  493. background-color: #fff;
  494. border-bottom: #{1rpx} solid #e2e2e2;
  495. white-space: nowrap;
  496. overflow: hidden;
  497. width: auto;
  498. position: sticky;
  499. top: 0;
  500. z-index: 10;
  501. }
  502. .cat-item {
  503. display: inline-block;
  504. margin: #{23rpx};
  505. text-align: center;
  506. width: auto;
  507. color: #353535;
  508. font-size: 12px;
  509. height: #{54rpx};
  510. line-height: #{54rpx};
  511. padding: 0 #{20rpx};
  512. }
  513. .cat-item.active {
  514. border-radius: #{27rpx};
  515. color: #fff;
  516. }
  517. .goods-list {
  518. padding-left: #{24rpx};
  519. }
  520. .goods-item {
  521. width: #{344rpx};
  522. background-color: #fff;
  523. font-size: 14px;
  524. color: #353535;
  525. margin: #{14rpx} #{14rpx} 0 0;
  526. position: relative;
  527. display: block;
  528. border-radius: #{16rpx};
  529. }
  530. .goods-name {
  531. margin-top: #{16rpx};
  532. padding-left: #{24rpx};
  533. font-size: 26upx;
  534. height: 30upx;
  535. line-height: 30upx;
  536. }
  537. .goods-img {
  538. height: #{344rpx};
  539. width: #{344rpx};
  540. display: block;
  541. border-top-left-radius: #{16rpx};
  542. border-top-right-radius: #{16rpx};
  543. }
  544. .out-dialog {
  545. width: #{344rpx};
  546. height: #{344rpx};
  547. position: absolute;
  548. top: 0;
  549. left: 0;
  550. background-color: rgba(0,0,0,.5);
  551. image {
  552. width: #{344rpx};
  553. height: #{344rpx};
  554. }
  555. }
  556. .goods-price {
  557. margin-top: #{10rpx};
  558. margin-left: #{24rpx};
  559. padding-bottom: #{125rpx};
  560. }
  561. .goods-old {
  562. font-size: 13px;
  563. color: #999;
  564. text-decoration: line-through;
  565. position: absolute;
  566. left: #{24rpx};
  567. bottom: #{88rpx};
  568. }
  569. .goods-num {
  570. position: absolute;
  571. right: #{24rpx};
  572. bottom: #{88rpx};
  573. font-size: 13px;
  574. }
  575. .goods-exchange {
  576. height: #{48rpx};
  577. line-height: #{48rpx};
  578. border-radius: #{24rpx};
  579. position: absolute;
  580. bottom: #{24rpx};
  581. left: #{24rpx};
  582. right: #{24rpx};
  583. color: #fff;
  584. font-size: 13px;
  585. }
  586. .goods-exchange::after {
  587. border: 0;
  588. }
  589. .dialog-bg {
  590. position: fixed;
  591. left: 0;
  592. top: 0;
  593. height: 100%;
  594. width: 100%;
  595. background-color: rgba(0, 0, 0, 0.3);
  596. }
  597. .dialog {
  598. width: #{574rpx};
  599. margin: 0 auto;
  600. background-color: #fff;
  601. position: fixed;
  602. top: 25%;
  603. left: 0;
  604. right: 0;
  605. border-radius: #{16rpx};
  606. }
  607. .close {
  608. height: #{30rpx};
  609. width: #{30rpx};
  610. position: absolute;
  611. right: #{22rpx};
  612. top: #{22rpx};
  613. z-index: 10;
  614. }
  615. .lose {
  616. padding: #{88rpx} 0 #{88rpx} #{90rpx};
  617. height: #{310rpx};
  618. font-size: 15px;
  619. color: #353535;
  620. }
  621. .lose-img {
  622. height: #{134rpx};
  623. width: #{124rpx};
  624. margin-right: #{48rpx};
  625. display: block;
  626. float: left;
  627. }
  628. .lose-title {
  629. font-size: 23px;
  630. font-weight: 500;
  631. margin: #{15rpx} 0;
  632. }
  633. .success {
  634. height: #{350rpx};
  635. background-color: #fff;
  636. text-align: center;
  637. padding-top: #{150rpx};
  638. font-size: 18px;
  639. color: #353535;
  640. border-radius: #{16rpx};
  641. }
  642. .success-head {
  643. height: #{332rpx};
  644. width: #{574rpx};
  645. position: absolute;
  646. top: #{-215rpx};
  647. left: 0;
  648. }
  649. .to-card, .to-use {
  650. margin-top: #{44rpx};
  651. height: #{64rpx};
  652. border-radius: #{32rpx};
  653. line-height: #{64rpx};
  654. width: #{228rpx};
  655. font-size: 16px;
  656. }
  657. .to-card::after, .to-use::after {
  658. border: 0;
  659. }
  660. .to-card {
  661. background-color: #fff;
  662. color: #353535;
  663. border: #{1rpx} solid #999;
  664. }
  665. .to-use {
  666. background-color: #ff4544;
  667. color: #fff;
  668. }
  669. .dialog-tip {
  670. position: fixed;
  671. top: #{400rpx};
  672. left: 0;
  673. right: 0;
  674. padding-bottom: #{88rpx};
  675. width: #{640rpx};
  676. margin: 0 auto;
  677. z-index: 21;
  678. background-color: #fff;
  679. border-radius: 10px;
  680. text-align: center;
  681. font-size: #{30rpx};
  682. }
  683. .dialog-msg {
  684. margin: 0 #{50rpx} #{50rpx};
  685. }
  686. .dialog-title {
  687. margin: #{40rpx} auto #{35rpx};
  688. }
  689. .dialog-btn {
  690. height: #{88rpx};
  691. width: #{640rpx};
  692. border-top: #{1rpx} solid #e2e2e2;
  693. line-height: #{88rpx};
  694. position: absolute;
  695. bottom: 0;
  696. left: 0;
  697. }
  698. .dialog-close,.dialog-submit {
  699. width: 50%;
  700. }
  701. .line {
  702. height: #{44rpx};
  703. margin-top: #{22rpx};
  704. width: #{1rpx};
  705. background-color: #e2e2e2;
  706. }
  707. .dialog-submit {
  708. color: #ff4544;
  709. }
  710. .success-btn {
  711. padding:0 #{39rpx};
  712. }
  713. </style>