myyhq.vue 6.1 KB

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