myyhq.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <view class="content">
  3. <view class="navbar">
  4. <view v-for="(itemn, index) in navList" :key="index" class="nav-item"
  5. :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ itemn.text }}</view>
  6. </view>
  7. <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" :style="{ height: height}"
  8. @change="changeTab">
  9. <swiper-item v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  10. <scroll-view scroll-y="true" :style="{ height: height}" style="padding-top: 20rpx;"
  11. @scrolltolower="getMyex()">
  12. <empty v-if="tabItem.loaded && tabItem.list.length === 0"></empty>
  13. <view class="shop-dhq flex" v-for="qitem in tabItem.list">
  14. <view class="dhq-left flex f-d-c f-j-c fg1 f-ai-s">
  15. <view class="dhq-name">
  16. {{qitem.coupon_title}}
  17. </view>
  18. <view class="dhq-price flex">
  19. <view class="j-price">
  20. {{qitem.coupon_price}}
  21. </view>
  22. </view>
  23. </view>
  24. <view class="dhq-right fs0 flex f-d-c f-j-sa">
  25. <view class="right-btn" @click.stop="userNow(qitem)" v-if="tabCurrentIndex == 0">
  26. 立即使用
  27. </view>
  28. <view class="right-btn" @click.stop="shareF(qitem)" v-if="tabCurrentIndex == 0">
  29. 分享好友
  30. </view>
  31. <view class="right-btn ysy" v-if="tabCurrentIndex == 1">
  32. 已使用
  33. </view>
  34. <view class="right-btn ysy" v-if="tabCurrentIndex == 2">
  35. 已过期
  36. </view>
  37. </view>
  38. </view>
  39. </scroll-view>
  40. </swiper-item>
  41. </swiper>
  42. </view>
  43. </template>
  44. <script>
  45. import empty from '@/components/empty';
  46. import {
  47. mapState,
  48. mapMutations
  49. } from 'vuex';
  50. import {
  51. getMyYhq
  52. } from '@/api/user.js'
  53. export default {
  54. components: {
  55. empty
  56. },
  57. data() {
  58. return {
  59. height: '',
  60. tabCurrentIndex: 0,
  61. navList: [{
  62. type: 0,
  63. text: '未使用',
  64. list: [],
  65. page: 1,
  66. limit: 10,
  67. loadingType: 'more',
  68. loaded: false,
  69. },
  70. {
  71. type: 1,
  72. text: '已使用',
  73. list: [],
  74. page: 1,
  75. limit: 10,
  76. loadingType: 'more',
  77. loaded: false,
  78. },
  79. {
  80. type: 2,
  81. text: '已过期',
  82. list: [],
  83. page: 1,
  84. limit: 10,
  85. loadingType: 'more',
  86. loaded: false,
  87. }
  88. ],
  89. }
  90. },
  91. onLoad() {
  92. },
  93. onShow() {
  94. this.getMyex()
  95. },
  96. onReachBottom() {
  97. },
  98. computed: {
  99. ...mapState('user', ['hasLogin', 'userInfo'])
  100. },
  101. onReady() {
  102. var obj = this;
  103. uni.getSystemInfo({
  104. success: resu => {
  105. const query = uni.createSelectorQuery();
  106. query.select('.swiper-box').boundingClientRect();
  107. query.exec(function(res) {
  108. console.log(res, 'ddddddddddddd');
  109. obj.height = resu.windowHeight - res[0].top + 'px';
  110. console.log('打印页面的剩余高度', obj.height);
  111. });
  112. },
  113. fail: res => {}
  114. });
  115. },
  116. methods: {
  117. // 立即使用
  118. userNow(item) {
  119. uni.navigateTo({
  120. url: '/pages/shop/djqQm?code=' + item.code
  121. })
  122. },
  123. // 分享好友
  124. shareF(item) {
  125. uni.navigateTo({
  126. url: '/pages/shop/shareF?code=' + item.code + '&type=1' + '&logo=' + this.userInfo.avatar +
  127. '&nickname=' + encodeURI(this.userInfo.nickname) + '&goodname=' + encodeURI(item
  128. .coupon_title)
  129. })
  130. },
  131. //swiper 切换
  132. changeTab(e) {
  133. this.tabCurrentIndex = e.target.current;
  134. this.getMyex('tab');
  135. },
  136. //顶部tab点击
  137. tabClick(index) {
  138. this.tabCurrentIndex = index;
  139. this.getMyex('tab');
  140. },
  141. getMyex(tab) {
  142. let obj = this
  143. let index = obj.tabCurrentIndex
  144. let navItem = obj.navList[index]
  145. if (navItem.loadingType == 'loading' || navItem.loadingType == 'noMore') {
  146. return
  147. }
  148. if (tab == 'tab' && navItem.loaded) {
  149. return
  150. }
  151. navItem.loadingType = 'loading'
  152. getMyYhq({
  153. page: navItem.page,
  154. limit: navItem.limit,
  155. status: navItem.type
  156. }).then(({
  157. data
  158. }) => {
  159. navItem.list = navItem.list.concat(data)
  160. navItem.page++
  161. if (data.length == navItem.limit) {
  162. navItem.loadingType = 'more'
  163. return
  164. } else {
  165. navItem.loadingType = 'noMore'
  166. }
  167. obj.$set(navItem, 'loaded', true)
  168. })
  169. },
  170. }
  171. }
  172. </script>
  173. <style lang="scss" scoped>
  174. .navbar {
  175. display: flex;
  176. height: 40px;
  177. padding: 0 5px;
  178. background: #fff;
  179. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  180. position: relative;
  181. z-index: 10;
  182. .nav-item {
  183. flex: 1;
  184. display: flex;
  185. justify-content: center;
  186. align-items: center;
  187. height: 100%;
  188. font-size: 15px;
  189. color: $font-color-dark;
  190. position: relative;
  191. &.current {
  192. color: $base-color;
  193. &:after {
  194. content: '';
  195. position: absolute;
  196. left: 50%;
  197. bottom: 0;
  198. transform: translateX(-50%);
  199. width: 44px;
  200. height: 0;
  201. border-bottom: 2px solid $base-color;
  202. }
  203. }
  204. }
  205. }
  206. .shop-dhq {
  207. width: 702rpx;
  208. height: 171rpx;
  209. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.15);
  210. margin: auto;
  211. border-radius: 20rpx;
  212. background-color: #fff;
  213. padding: 0 20rpx 0 26rpx;
  214. margin-bottom: 20rpx;
  215. .dhq-left {
  216. .dhq-name {
  217. font-size: 33rpx;
  218. font-weight: bold;
  219. color: #333333;
  220. }
  221. .dhq-price {
  222. padding-top: 20rpx;
  223. .j-price {
  224. font-size: 38rpx;
  225. font-weight: bold;
  226. color: #FF4C4C;
  227. &::before {
  228. content: '¥';
  229. font-size: 24rpx;
  230. color: #FF4C4C;
  231. }
  232. }
  233. .j-zk {
  234. display: inline-block;
  235. margin-left: 10rpx;
  236. line-height: 32rpx;
  237. height: 32rpx;
  238. border: 1px solid #FF4C4C;
  239. border-radius: 5rpx;
  240. font-size: 22rpx;
  241. font-weight: 500;
  242. color: #FF4C4C;
  243. padding: 0 8rpx;
  244. }
  245. }
  246. }
  247. .dhq-right {
  248. height: 80%;
  249. .right-btn {
  250. // width: 105rpx;
  251. display: inline-block;
  252. padding: 0 10rpx;
  253. line-height: 56rpx;
  254. background: linear-gradient(143.2747deg, #FF6A00, #EE0979);
  255. border: 1rpx solid #FF4C4C;
  256. border-radius: 27rpx;
  257. text-align: center;
  258. color: #fff;
  259. font-size: 28rpx;
  260. font-weight: bold;
  261. }
  262. .ysy {
  263. background: #999;
  264. border: none;
  265. padding: 0 20rpx;
  266. }
  267. }
  268. }
  269. </style>