myyhq.vue 6.5 KB

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