exchange.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <app-layout>
  3. <app-tab-nav :tabList="tabList" :activeItem="activeTab" @click="tabStatus" :theme="getTheme"></app-tab-nav>
  4. <view class='coupon' v-if="activeTab == 1" v-for="item in list" :key="item.id">
  5. <view class='coupon-name' v-if="item.integralCoupon.coupon.type == 2">{{item.integralCoupon.coupon.sub_price}}元优惠券 满{{item.integralCoupon.coupon.min_price}}元可用</view>
  6. <view class='coupon-name' v-else>{{item.integralCoupon.coupon.discount}}折优惠券 满{{item.integralCoupon.coupon.min_price}}元可用</view>
  7. <view class='coupon-price' :style="{'color': getTheme.color}">{{item.integralCoupon.integral_num}}积分
  8. <text v-if="item.integralCoupon.price > 0">+{{item.integralCoupon.price}}元</text>
  9. </view>
  10. <view @click="toList" class="card-list">
  11. <button class='to-card' :style="{'color': getTheme.color}">去卡券包查看</button>
  12. </view>
  13. </view>
  14. <view class='goods' v-if="activeTab == 2" v-for="item in list" :key="item.id">
  15. <image class='goods-img' mode="aspectFill" :src='item.detail[0].goods_info.goods_attr.pic_url ? item.detail[0].goods_info.goods_attr.pic_url : item.detail[0].goods.goodsWarehouse.cover_pic'></image>
  16. <view class='goods-info'>
  17. <view class='coupon-name t-omit-two'>{{item.detail[0].goods_info.name}}</view>
  18. <view class='coupon-price' :style="{'color': getTheme.color}">{{item.detail[0].goods_info.goods_attr.extra.integral_num}}积分+{{item.detail[0].goods_info.goods_attr.price}}元</view>
  19. </view>
  20. <view @click="toOrder(item.id)" class="order-detail">
  21. <button class='to-card' :style="{'color': getTheme.color}">订单详情</button>
  22. </view>
  23. </view>
  24. </app-layout>
  25. </template>
  26. <script>
  27. import appTabNav from "../../../components/basic-component/app-tab-nav/app-tab-nav.vue";
  28. import {mapGetters, mapState} from "vuex";
  29. export default {
  30. name: "about",
  31. components: {
  32. "app-tab-nav": appTabNav
  33. },
  34. data() {
  35. return {
  36. list: [],
  37. tabList: [
  38. {id:1, name: '优惠券'},
  39. {id:2, name: '商品'}
  40. ],
  41. page: 2,
  42. activeTab: 1,
  43. };
  44. },
  45. computed: {
  46. ...mapState({
  47. mall: state => state.mallConfig.mall
  48. }),
  49. ...mapGetters('mallConfig', {
  50. getTheme: 'getTheme',
  51. })
  52. },
  53. onLoad() { this.$commonLoad.onload();
  54. this.$showLoading({
  55. type: 'global',
  56. text: '加载中...'
  57. });
  58. this.getList();
  59. },
  60. methods: {
  61. tabStatus(e) {
  62. this.list = [];
  63. this.page = 2;
  64. this.activeTab = +e.currentTarget.dataset.id;
  65. uni.showLoading({
  66. mask: true,
  67. title: '加载中...'
  68. });
  69. this.getList();
  70. },
  71. toOrder(id) {
  72. uni.navigateTo({
  73. url: '/pages/order/order-detail/order-detail?id=' + id
  74. });
  75. },
  76. toList() {
  77. uni.navigateTo({
  78. url: '/pages/coupon/index/index'
  79. });
  80. },
  81. getList() {
  82. let that = this;
  83. let url = that.$api.integral_mall.coupon_order;
  84. if(that.activeTab == 2) {
  85. url = that.$api.integral_mall.order
  86. }
  87. that.$request({
  88. url: url,
  89. }).then(response=>{
  90. that.$hideLoading();
  91. uni.hideLoading();
  92. if(response.code == 0) {
  93. that.list = response.data.list;
  94. }else {
  95. uni.showToast({
  96. title: response.msg,
  97. icon: 'none',
  98. duration: 1000
  99. });
  100. }
  101. }).catch(response => {
  102. that.$hideLoading();
  103. uni.hideLoading();
  104. });
  105. },
  106. },
  107. onReachBottom() {
  108. let that = this;
  109. let url = that.$api.integral_mall.coupon_order;
  110. if(that.activeTab == 2) {
  111. url = that.$api.integral_mall.order
  112. }
  113. that.$request({
  114. url: url,
  115. data: {
  116. page: that.page
  117. }
  118. }).then(response=>{
  119. that.$hideLoading();
  120. if(response.code == 0) {
  121. let more = false;
  122. that.list.forEach(function(row,index){
  123. if(row.id == response.data.list[0].id) {
  124. more = true;
  125. return false
  126. }
  127. })
  128. if(!more) {
  129. that.list = that.list.concat(response.data.list);
  130. }
  131. page++;
  132. }else {
  133. uni.showToast({
  134. title: response.msg,
  135. icon: 'none',
  136. duration: 1000
  137. });
  138. }
  139. }).catch(response => {
  140. that.$hideLoading();
  141. });
  142. }
  143. }
  144. </script>
  145. <style scoped lang="scss">
  146. .coupon {
  147. height: #{156rpx};
  148. border-bottom: #{1rpx} solid #e2e2e2;
  149. position: relative;
  150. padding: #{30rpx} #{24rpx} 0;
  151. font-size: 15px;
  152. background-color: #fff;
  153. }
  154. .coupon-name {
  155. color: #353535;
  156. }
  157. .coupon-price {
  158. margin-top: #{12rpx};
  159. }
  160. .to-card {
  161. height: #{56rpx};
  162. line-height: #{56rpx};
  163. padding: 0 #{16rpx};
  164. background-color: #fff;
  165. border-radius: #{28rpx};
  166. border: #{1rpx} solid;
  167. font-size: #{28rpx};
  168. width: auto;
  169. }
  170. .to-card::after {
  171. border: 0;
  172. }
  173. .goods {
  174. height: #{200rpx};
  175. border-bottom: #{1rpx} solid #e2e2e2;
  176. position: relative;
  177. padding: #{32rpx} #{24rpx};
  178. font-size: 15px;
  179. background-color: #fff;
  180. }
  181. .goods-img {
  182. height: #{136rpx};
  183. width: #{180rpx};
  184. float: left;
  185. margin-right: #{16rpx};
  186. }
  187. .goods-info {
  188. width: 72%;
  189. }
  190. .order-detail {
  191. position: absolute;
  192. top: #{72rpx};
  193. right:#{24rpx};
  194. }
  195. .card-list {
  196. position: absolute;
  197. top: #{50rpx};
  198. right:#{24rpx};
  199. }
  200. </style>