金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

230 lines
6.1 KiB

  1. <template>
  2. <view id="coupon-over">
  3. <view class="no-list" v-if="(!list.length || !list[0].length) && init">
  4. <i class="iconfont icon-youhuiquan"></i>
  5. <view>报告主人您暂无优惠券~</view>
  6. </view>
  7. <view v-for="(items, idx) in list" :key="idx">
  8. <view class="coupon" v-for="(item, index) in list[idx]" :key="index">
  9. <view class="coupon-left">
  10. <view class="text-wrap">
  11. <view class="text-box">
  12. <view class="text">
  13. <text class="money" v-if="item.discount.action_type.type == 'cash'"></text>
  14. <sapn>{{ item.discount.action_type.value }}</sapn>
  15. <text class="money" v-if="item.discount.action_type.type == 'discount'"></text>
  16. </view>
  17. <text class="label text">{{ item.discount.label }}</text>
  18. </view>
  19. </view>
  20. <view class="dot-wrap">
  21. <view class="dot-item">
  22. </view>
  23. <view class="dot-item">
  24. </view>
  25. <view class="dot-item">
  26. </view>
  27. <view class="dot-item">
  28. </view>
  29. <view class="dot-item">
  30. </view>
  31. <view class="dot-item">
  32. </view>
  33. </view>
  34. </view>
  35. <view class="coupon-right">
  36. <view class="top">
  37. <span class="type">
  38. <span v-if="item.discount.channel == 'ec'">商城</span>
  39. <span v-else>门店</span>
  40. </span>
  41. <text class="info">{{item.discount.title}}</text>
  42. </view>
  43. <view class="bottom">
  44. <view class="bottom-use">
  45. <view class="tiem-box">
  46. <text>{{item.discount.use_start_time}}{{item.discount.use_end_time}}</text>
  47. </view>
  48. <view v-if="is_coupon == 1">
  49. <!-- <view class="btn use" data-code="{{item.discount.code}}" data-index="{{idx}}" data-findex="{{index}}" wx:if="{{!item.discount.has_get}}" @tap.stop="getCoupon">
  50. 点击领取
  51. </view>
  52. <view class="btn already" data-id="{{item.id}}" @tap.stop="jumpList">
  53. 去使用
  54. </view> -->
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="cover">
  60. <view class="big-circle">
  61. <view class="small-circle">
  62. <view :animation="animationData" v-if="item.used_at">已使用</view>
  63. <view :animation="animationData" v-else>已过期</view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </template>
  71. <script>
  72. import {pageLogin, getUrl,config} from '@/common/js/utils.js';
  73. export default {
  74. data() {
  75. return {
  76. page: 1,
  77. list: [],
  78. meta: '',
  79. show: false,
  80. init: false,
  81. animationDate: {}
  82. };
  83. },
  84. onReachBottom() {
  85. var hasMore = this.meta.pagination.total_pages > this.meta.pagination.current_page;
  86. if (hasMore) {
  87. var page = this.meta.pagination.current_page + 1;
  88. this.setData({
  89. show: true
  90. });
  91. this.queryCouponList(0, page);
  92. } else {
  93. wx.showToast({
  94. image: '../../../static/error.png',
  95. title: '再拉也没有啦'
  96. });
  97. }
  98. },
  99. onShow() {
  100. var animation = wx.createAnimation({
  101. duration: 1000,
  102. timingFunction: 'ease'
  103. });
  104. this.animation = animation;
  105. animation.rotate(-30).step();
  106. // this.setData({
  107. // animationData: animation.export()
  108. // });
  109. this.animationDate=animation.export();
  110. },
  111. onLoad() {
  112. this.queryCouponList(0);
  113. },
  114. components: {},
  115. props: {},
  116. methods: {
  117. jumpOff() {
  118. wx.navigateTo({
  119. url: '/pages/coupon/over/over'
  120. });
  121. },
  122. // 查询优惠券列表
  123. queryCouponList(status, page = 1) {
  124. var token = this.$cookieStorage.get('user_token');
  125. wx.showLoading({
  126. title: "加载中",
  127. mask: true
  128. });
  129. this.$http.get({
  130. api: 'api/coupon',
  131. header: {
  132. Authorization: token
  133. },
  134. data: {
  135. is_active: status,
  136. page
  137. }
  138. }).then(res => {
  139. if (res.statusCode == 200) {
  140. res = res.data;
  141. if (res.status) {
  142. // this.setData({
  143. // [`list[${page - 1}]`]: res.data,
  144. // meta: res.meta
  145. // });
  146. this.$set(this.list, page -1, res.data);
  147. this.meta=res.meta;
  148. } else {
  149. wx.showModal({
  150. content: res.message,
  151. showCancel: false
  152. });
  153. }
  154. } else {
  155. wx.showModal({
  156. content: "请求失败",
  157. showCancel: false
  158. });
  159. }
  160. this.setData({
  161. show: false,
  162. init: true
  163. });
  164. wx.hideLoading();
  165. }).catch(rej => {
  166. wx.hideLoading();
  167. this.setData({
  168. show: false,
  169. init: true
  170. });
  171. });
  172. },
  173. setData: function (obj) {
  174. let that = this;
  175. let keys = [];
  176. let val, data;
  177. Object.keys(obj).forEach(function (key) {
  178. keys = key.split('.');
  179. val = obj[key];
  180. data = that.$data;
  181. keys.forEach(function (key2, index) {
  182. if (index + 1 == keys.length) {
  183. that.$set(data, key2, val);
  184. } else {
  185. if (!data[key2]) {
  186. that.$set(data, key2, {});
  187. }
  188. }
  189. data = data[key2];
  190. });
  191. });
  192. }
  193. },
  194. computed: {},
  195. watch: {}
  196. };
  197. </script>
  198. <style rel="stylesheet/less" lang="less">
  199. @import "over";
  200. </style>