coupon.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <template>
  2. <view class="container">
  3. <view class="tui-coupon-list">
  4. <view class="tui-coupon-item tui-top20" v-for="(item,index) in couponList" :key="index">
  5. <image src="/static/images/mall/coupon/bg_coupon_3x.png" class="tui-coupon-bg"
  6. mode="widthFix"></image>
  7. <image v-if="item.fetch==1" src="/static/images/mall/coupon/img_couponcentre_received_3x.png" class="tui-coupon-sign"></image>
  8. <view class="tui-coupon-item-left">
  9. <view class="tui-coupon-price-box">
  10. <view class="tui-coupon-price-sign" v-if="item.coupon_type==10">¥</view>
  11. <view class="tui-coupon-price" v-if="item.coupon_type==10">{{item.reduce_price}}</view>
  12. <view class="tui-coupon-price" v-if="item.coupon_type==20">{{item.discount}}</view>
  13. <view class="tui-coupon-price-sign" v-if="item.coupon_type==20">折</view>
  14. </view>
  15. <view class="tui-coupon-intro">满{{item.min_price}}元可用</view>
  16. </view>
  17. <view class="tui-coupon-item-right">
  18. <view class="tui-coupon-content">
  19. <view class="tui-coupon-title-box">
  20. <view v-if="item.sid==0" class="tui-coupon-btn" :class="{'tui-bg-grey':i>0}">全场券</view>
  21. <view v-if="item.use_goods==0" class="tui-coupon-title">全部商品可用</view>
  22. <view v-if="item.use_goods==1" class="tui-coupon-title">{{item.cat_ids_name}}类目可用</view>
  23. <view v-if="item.use_goods==2" class="tui-coupon-title">{{item.goods_ids_name}}可用</view>
  24. </view>
  25. <view class="tui-coupon-rule">
  26. <view class="tui-rule-box tui-padding-btm">
  27. <view class="tui-coupon-circle"></view>
  28. <view class="tui-coupon-text">不可叠加使用</view>
  29. </view>
  30. <view class="tui-rule-box">
  31. <view class="tui-coupon-circle"></view>
  32. <view v-if="item.expire_type==10" class="tui-coupon-text">自领取之日起{{item.expire_day}}天有效
  33. </view>
  34. <view v-if="item.expire_type==20" class="tui-coupon-text">
  35. {{item.start_time}}至{{item.end_time}}
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view v-if="item.fetch!=1" class="tui-btn-box">
  42. <tui-button @click="toCounpon(item.id)" type="danger" width="152rpx" height="52rpx" :size="24"
  43. shape="circle">立即领取</tui-button>
  44. </view>
  45. </view>
  46. </view>
  47. <!--加载loadding-->
  48. <tui-loadmore v-if="loadding" :index="3" type="red"></tui-loadmore>
  49. <tui-nomore v-if="!pullUpOn" backgroundColor="#f5f5f5"></tui-nomore>
  50. <!--加载loadding-->
  51. </view>
  52. </template>
  53. <script>
  54. export default {
  55. data() {
  56. return {
  57. lang:{},
  58. loadding: false,
  59. pullUpOn: true,
  60. couponList: []
  61. }
  62. },
  63. onLoad: function(e) {
  64. let _this = this;
  65. _this.$request.get('Lang.getlang').then(res => {
  66. if (res.errno == 0) {
  67. _this.lang = res.data;
  68. }
  69. });
  70. this.getCoupons();
  71. },
  72. methods: {
  73. getCoupons: function() { // 读取可领取券列表
  74. var _this = this;
  75. _this.$request.get('couponreceive.couponlist',{samkey: (new Date()).valueOf(),showLoading:true}).then(res => {
  76. if (res.errno == 0) {
  77. _this.couponList = res.data;
  78. }
  79. })
  80. },
  81. toCounpon: function(id) {
  82. const _this = this
  83. _this.$request.post('Couponreceive.fetch', {
  84. id: id
  85. }).then(res => {
  86. if (res.errno == 20001 || res.errno == 20002) {
  87. wx.showModal({
  88. title: '错误',
  89. content: '来晚了',
  90. showCancel: false
  91. })
  92. return;
  93. }
  94. if (res.errno == 20003) {
  95. wx.showModal({
  96. title: '错误',
  97. content: '你领过了,别贪心哦~',
  98. showCancel: false
  99. })
  100. return;
  101. }
  102. if (res.errno == 30001) {
  103. wx.showModal({
  104. title: '错误',
  105. content: '您的'+lang.points+'不足',
  106. showCancel: false
  107. })
  108. return;
  109. }
  110. if (res.errno == 20004) {
  111. wx.showModal({
  112. title: '错误',
  113. content: '已过期~',
  114. showCancel: false
  115. })
  116. return;
  117. }
  118. if (res.errno == 0) {
  119. wx.showToast({
  120. title: '领取成功',
  121. icon: 'success',
  122. duration: 2000
  123. })
  124. _this.getCoupons();
  125. } else {
  126. wx.showModal({
  127. title: '错误',
  128. content: res.msg,
  129. showCancel: false
  130. })
  131. }
  132. })
  133. }
  134. },
  135. onPullDownRefresh() {
  136. setTimeout(() => {
  137. this.pullUpOn = true
  138. uni.stopPullDownRefresh()
  139. }, 200);
  140. },
  141. onReachBottom() {
  142. //只是测试效果,逻辑以实际数据为准
  143. if (!this.pullUpOn) return;
  144. this.loadding = true
  145. setTimeout(() => {
  146. this.loadding = false
  147. this.pullUpOn = false
  148. }, 1000)
  149. }
  150. }
  151. </script>
  152. <style>
  153. page {
  154. background-color: #F5F5F5;
  155. }
  156. .container {
  157. padding-bottom: env(safe-area-inset-bottom);
  158. }
  159. .tui-coupon-list {
  160. width: 100%;
  161. padding: 0 25rpx;
  162. box-sizing: border-box;
  163. }
  164. .tui-coupon-banner {
  165. width: 100%;
  166. }
  167. .tui-coupon-item {
  168. width: 100%;
  169. height: 210rpx;
  170. position: relative;
  171. display: flex;
  172. align-items: center;
  173. padding-right: 30rpx;
  174. box-sizing: border-box;
  175. overflow: hidden;
  176. }
  177. .tui-coupon-bg {
  178. width: 100%;
  179. height: 210rpx;
  180. position: absolute;
  181. left: 0;
  182. top: 0;
  183. z-index: 1;
  184. }
  185. .tui-coupon-sign {
  186. height: 110rpx;
  187. width: 110rpx;
  188. position: absolute;
  189. z-index: 9;
  190. top: -30rpx;
  191. right: 40rpx;
  192. }
  193. .tui-coupon-item-left {
  194. width: 218rpx;
  195. height: 210rpx;
  196. position: relative;
  197. z-index: 2;
  198. display: flex;
  199. align-items: center;
  200. justify-content: center;
  201. flex-direction: column;
  202. flex-shrink: 0;
  203. }
  204. .tui-coupon-price-box {
  205. display: flex;
  206. color: #e41f19;
  207. align-items: flex-end;
  208. }
  209. .tui-coupon-price-sign {
  210. font-size: 30rpx;
  211. }
  212. .tui-coupon-price {
  213. font-size: 70rpx;
  214. line-height: 68rpx;
  215. font-weight: bold;
  216. }
  217. .tui-price-small {
  218. font-size: 58rpx !important;
  219. line-height: 56rpx !important;
  220. }
  221. .tui-coupon-intro {
  222. background: #F7F7F7;
  223. padding: 8rpx 10rpx;
  224. font-size: 26rpx;
  225. line-height: 26rpx;
  226. font-weight: 400;
  227. color: #666;
  228. margin-top: 18rpx;
  229. }
  230. .tui-coupon-item-right {
  231. flex: 1;
  232. height: 210rpx;
  233. position: relative;
  234. z-index: 2;
  235. display: flex;
  236. align-items: center;
  237. justify-content: space-between;
  238. padding-left: 24rpx;
  239. box-sizing: border-box;
  240. overflow: hidden;
  241. }
  242. .tui-coupon-content {
  243. width: 82%;
  244. display: flex;
  245. flex-direction: column;
  246. justify-content: center;
  247. }
  248. .tui-coupon-title-box {
  249. display: flex;
  250. align-items: center;
  251. font-size: 28rpx;
  252. }
  253. .tui-coupon-title {
  254. width: 100%;
  255. font-size: 26rpx;
  256. color: #333;
  257. }
  258. .tui-coupon-btn {
  259. padding: 6rpx;
  260. background: #FFEBEB;
  261. color: #e41f19;
  262. font-size: 25rpx;
  263. line-height: 25rpx;
  264. display: flex;
  265. align-items: center;
  266. justify-content: center;
  267. transform: scale(0.9);
  268. transform-origin: 0 center;
  269. border-radius: 4rpx;
  270. flex-shrink: 0;
  271. }
  272. .tui-color-grey {
  273. color: #888 !important;
  274. }
  275. .tui-bg-grey {
  276. background: #F0F0F0 !important;
  277. color: #888 !important;
  278. }
  279. .tui-coupon-rule {
  280. padding-top: 22rpx;
  281. }
  282. .tui-rule-box {
  283. display: flex;
  284. align-items: center;
  285. transform: scale(0.8);
  286. transform-origin: 0 100%;
  287. }
  288. .tui-padding-btm {
  289. padding-bottom: 6rpx;
  290. }
  291. .tui-coupon-circle {
  292. width: 8rpx;
  293. height: 8rpx;
  294. background: rgb(160, 160, 160);
  295. border-radius: 50%;
  296. }
  297. .tui-coupon-text {
  298. font-size: 28rpx;
  299. line-height: 28rpx;
  300. font-weight: 400;
  301. color: #666;
  302. padding-left: 8rpx;
  303. white-space: nowrap;
  304. }
  305. .tui-top20 {
  306. margin-top: 20rpx;
  307. }
  308. .tui-coupon-radio {
  309. transform: scale(0.7);
  310. transform-origin: 100% center;
  311. }
  312. .tui-btn-box {
  313. position: absolute;
  314. width: 146rpx;
  315. height: 52rpx;
  316. right: 20rpx;
  317. bottom: 40rpx;
  318. z-index: 10;
  319. }
  320. /* #ifdef APP-PLUS || MP */
  321. .wx-radio-input {
  322. margin-right: 0 !important;
  323. }
  324. /* #endif */
  325. /* #ifdef H5 */
  326. >>>uni-radio .uni-radio-input {
  327. margin-right: 0 !important;
  328. }
  329. /* #endif */
  330. </style>